@cmpsr/analytics
Advanced tools
Comparing version 0.5.0-canary-20241009182444 to 0.5.0-canary-20241009200356
@@ -25,15 +25,2 @@ /* eslint-disable prefer-rest-params */ "use strict"; | ||
var _amplitude = require("./integrations/amplitude/index"); | ||
function _define_property(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function _interop_require_default(obj) { | ||
@@ -83,41 +70,2 @@ return obj && obj.__esModule ? obj : { | ||
} | ||
function _object_spread(target) { | ||
for(var i = 1; i < arguments.length; i++){ | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
})); | ||
} | ||
ownKeys.forEach(function(key) { | ||
_define_property(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) { | ||
symbols = symbols.filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
} | ||
keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _object_spread_props(target, source) { | ||
source = source != null ? source : {}; | ||
if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function(key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _object_without_properties(source, excluded) { | ||
@@ -159,10 +107,6 @@ if (source == null) return {}; | ||
var proxyToIntegrations = function(integrations, func, args) { | ||
var mappedResult = integrations.map(function(integration) { | ||
// eslint-disable-next-line prefer-spread | ||
var wat = integration[func].apply(integration, args); | ||
console.log(wat, "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); | ||
return wat; | ||
integrations.forEach(function(integration) { | ||
return(// eslint-disable-next-line prefer-spread | ||
integration[func].apply(integration, args)); | ||
}); | ||
console.log(mappedResult, "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"); | ||
return mappedResult; | ||
}; | ||
@@ -188,3 +132,3 @@ var _AnalyticsProvider = function(_param) { | ||
return enabledIntegrations.map(function(integration) { | ||
return new supportedIntegrations[integration](props[integration]); | ||
return new supportedIntegrations[integration](props[integration], anonymousId); | ||
}); | ||
@@ -206,10 +150,6 @@ }, []); | ||
}, | ||
user: function user() { | ||
var userObjects = proxyToIntegrations(integrations, "user", Array.from(arguments)); | ||
console.log(userObjects, "DDDDDDDDDDDDDDDDDDDDDDDDDDD"); | ||
var user = Object.assign.apply(null, userObjects); | ||
console.log(user, "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); | ||
return _object_spread_props(_object_spread({}, user), { | ||
user: function() { | ||
return { | ||
anonymousId: anonymousId | ||
}); | ||
}; | ||
}, | ||
@@ -216,0 +156,0 @@ reset: function reset() { |
@@ -5,3 +5,3 @@ import { Identify, Group, Page, Track } from 'types'; | ||
export declare class Amplitude implements IIntegration { | ||
constructor(config: AmplitudeConfig); | ||
constructor(config: AmplitudeConfig, anonymousId?: string | null); | ||
identify: Identify; | ||
@@ -13,5 +13,2 @@ group: Group; | ||
revenue: (price: any, quantity: any, type: any) => void; | ||
user: () => { | ||
deviceId: any; | ||
}; | ||
} |
@@ -91,3 +91,3 @@ "use strict"; | ||
} | ||
var Amplitude = function Amplitude(config) { | ||
var Amplitude = function Amplitude(config, anonymousId) { | ||
"use strict"; | ||
@@ -135,12 +135,6 @@ _class_call_check(this, Amplitude); | ||
}); | ||
_define_property(this, "user", function() { | ||
var amplitude = window.amplitude; | ||
var deviceId = amplitude.getDeviceId(); | ||
console.log(deviceId, "AAAAAAAAAAAAAAAAAAAAAA"); | ||
return { | ||
deviceId: deviceId | ||
}; | ||
}); | ||
var amplitude = (0, _loadAmplitude.loadAmplitude)(); | ||
amplitude.init(config.apiKey); | ||
var params = {}; | ||
if (anonymousId) params["deviceId"] = anonymousId; | ||
amplitude.init(config.apiKey, params); | ||
}; |
@@ -12,3 +12,2 @@ import { IIntegration } from '../types'; | ||
revenue: () => void; | ||
user: () => {}; | ||
} |
@@ -60,5 +60,2 @@ "use strict"; | ||
_define_property(this, "revenue", function() {}); | ||
_define_property(this, "user", function() { | ||
return {}; | ||
}); | ||
if (!config.trackingId) { | ||
@@ -65,0 +62,0 @@ throw new Error("Google Analytics trackingId is required for analytics"); |
@@ -12,3 +12,2 @@ import { IIntegration } from '../types'; | ||
revenue: () => void; | ||
user: () => {}; | ||
} |
@@ -112,5 +112,2 @@ "use strict"; | ||
_define_property(this, "revenue", function() {}); | ||
_define_property(this, "user", function() { | ||
return {}; | ||
}); | ||
if (!config.trackingId) { | ||
@@ -117,0 +114,0 @@ throw new Error("TAG ID is required for gTag"); |
@@ -12,3 +12,2 @@ import { IIntegration } from '../types'; | ||
revenue: () => void; | ||
user: () => {}; | ||
} |
@@ -86,5 +86,2 @@ "use strict"; | ||
_define_property(this, "revenue", function() {}); | ||
_define_property(this, "user", function() { | ||
return {}; | ||
}); | ||
if (!config.writeKey) { | ||
@@ -91,0 +88,0 @@ throw new Error("Segment writeKey is required for analytics"); |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "0.5.0-canary-20241009182444", | ||
"version": "0.5.0-canary-20241009200356", | ||
"author": "Steve Cox <stevejcox@me.com>", | ||
@@ -13,0 +13,0 @@ "license": "MIT", |
41244
1173