analytics-client
Advanced tools
Comparing version 1.8.3 to 2.0.0-feature-use-ts-client-92dbefedcaa6c9b515cda6eeaf5b7743907f5629
export { AnalyticsUrlParams } from './src/url-params'; | ||
export { Client, Config, createClient, createNoopClient } from './src/client'; | ||
export { Experiment, LocalExperiment } from './src/experiment'; | ||
export { WebTracker, createWebTracker } from './src/web'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createWebTracker = exports.LocalExperiment = exports.createNoopClient = exports.createClient = exports.AnalyticsUrlParams = void 0; | ||
exports.createWebTracker = exports.createNoopClient = exports.createClient = exports.AnalyticsUrlParams = void 0; | ||
var url_params_1 = require("./src/url-params"); | ||
@@ -9,6 +9,4 @@ Object.defineProperty(exports, "AnalyticsUrlParams", { enumerable: true, get: function () { return url_params_1.AnalyticsUrlParams; } }); | ||
Object.defineProperty(exports, "createNoopClient", { enumerable: true, get: function () { return client_1.createNoopClient; } }); | ||
var experiment_1 = require("./src/experiment"); | ||
Object.defineProperty(exports, "LocalExperiment", { enumerable: true, get: function () { return experiment_1.LocalExperiment; } }); | ||
var web_1 = require("./src/web"); | ||
Object.defineProperty(exports, "createWebTracker", { enumerable: true, get: function () { return web_1.createWebTracker; } }); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "analytics-client", | ||
"version": "1.8.3", | ||
"version": "2.0.0", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -16,3 +16,3 @@ "repository": { | ||
"scripts": { | ||
"test": "jest", | ||
"test": "jest --coverage", | ||
"prettify": "balena-lint --typescript --fix src/ test/ index.ts", | ||
@@ -27,6 +27,4 @@ "lint": "balena-lint --typescript src/ test/ index.ts && tsc --noEmit", | ||
"dependencies": { | ||
"@types/amplitude-js": "5.11.0", | ||
"amplitude-js": "5.11.0", | ||
"js-cookie": "^3.0.1", | ||
"mixpanel-browser": "^2.29.0" | ||
"@amplitude/analytics-browser": "^1.5.4", | ||
"js-cookie": "^3.0.1" | ||
}, | ||
@@ -38,3 +36,2 @@ "devDependencies": { | ||
"@types/lodash": "^4.14.182", | ||
"@types/mixpanel-browser": "^2.38.0", | ||
"husky": "^8.0.1", | ||
@@ -65,4 +62,4 @@ "jest": "^28.1.0", | ||
"versionist": { | ||
"publishedAt": "2022-09-27T17:31:41.753Z" | ||
"publishedAt": "2022-10-23T17:58:18.560Z" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import amplitude = require('amplitude-js'); | ||
import * as amplitude from '@amplitude/analytics-browser'; | ||
export interface Properties { | ||
@@ -10,3 +10,2 @@ [key: string]: any; | ||
export interface Client { | ||
amplitude(): amplitude.AmplitudeClient; | ||
deviceId(): string; | ||
@@ -21,2 +20,3 @@ sessionId(): number; | ||
setUserProperties(props: UserProperties): void; | ||
identify(identify: amplitude.Identify): void; | ||
} | ||
@@ -28,11 +28,9 @@ export interface Config { | ||
componentVersion?: string; | ||
amplitude?: Exclude<AmplitudeOverride, amplitude.Config>; | ||
amplitude?: Omit<amplitude.Types.BrowserOptions, keyof AmplitudeOverride>; | ||
deviceId?: string; | ||
} | ||
interface AmplitudeOverride { | ||
apiEndpoint?: string; | ||
endpoint?: string; | ||
deviceId?: string; | ||
cookieExpiration?: number; | ||
includeReferrer?: boolean; | ||
includeUtm?: boolean; | ||
sameSiteCookie?: 'Lax' | 'Strict' | 'None'; | ||
} | ||
@@ -39,0 +37,0 @@ export declare function createClient(config: Config): Client; |
@@ -13,53 +13,31 @@ "use strict"; | ||
exports.createNoopClient = exports.createClient = void 0; | ||
var amplitude = require("amplitude-js"); | ||
var Cookies = require("js-cookie"); | ||
var mixpanel = require("mixpanel-browser"); | ||
var amplitude = require("@amplitude/analytics-browser"); | ||
var package_json_1 = require("../package.json"); | ||
var config_1 = require("./config"); | ||
var identifyObject = function () { | ||
return new amplitude.Identify().set(config_1.USER_PROP_ANALYTICS_CLIENT_VERSION, package_json_1.version); | ||
var getIdentifyObject = function () { | ||
var identifyObject = new amplitude.Identify(); | ||
identifyObject.set(config_1.USER_PROP_ANALYTICS_CLIENT_VERSION, package_json_1.version); | ||
return identifyObject; | ||
}; | ||
var DefaultClient = (function () { | ||
function DefaultClient(config) { | ||
this.config = config; | ||
this.amplitudeInstance = amplitude.getInstance(config.projectName); | ||
this.amplitudeInstance = amplitude.createInstance(); | ||
var amplConfig = Object.assign({}, config.amplitude); | ||
if (config.endpoint) { | ||
amplConfig.apiEndpoint = "".concat(config.endpoint, "/amplitude"); | ||
amplConfig.serverUrl = "https://".concat(config.endpoint, "/amplitude/2/httpapi"); | ||
} | ||
amplConfig.cookieExpiration = config_1.COOKIES_TTL_DAYS; | ||
amplConfig.includeReferrer = true; | ||
amplConfig.includeUtm = true; | ||
amplConfig.sameSiteCookie = 'Lax'; | ||
amplConfig.unsetParamsReferrerOnNewSession = true; | ||
if (config.deviceId) { | ||
amplConfig.deviceId = config.deviceId; | ||
} | ||
this.amplitudeInstance.init(config.projectName, undefined, amplConfig); | ||
this.checkMixpanelUsage(); | ||
this.amplitudeInstance.identify(identifyObject().set(config_1.USER_PROP_COMPONENT_NAME, config.componentName)); | ||
if (config.componentVersion) { | ||
this.amplitudeInstance.setVersionName(config.componentVersion); | ||
amplConfig.appVersion = config.componentVersion; | ||
} | ||
amplConfig.cookieExpiration = config_1.COOKIES_TTL_DAYS; | ||
this.amplitudeInstance.init(config.projectName, undefined, amplConfig); | ||
var identifyObject = getIdentifyObject(); | ||
identifyObject.set(config_1.USER_PROP_COMPONENT_NAME, config.componentName); | ||
this.amplitudeInstance.identify(identifyObject); | ||
} | ||
DefaultClient.prototype.checkMixpanelUsage = function () { | ||
var mixpanelDataPresent = false; | ||
for (var key in Cookies.get()) { | ||
if (key.startsWith('mp_' + this.config.projectName)) { | ||
mixpanelDataPresent = true; | ||
break; | ||
} | ||
} | ||
if (mixpanelDataPresent) { | ||
mixpanel.init(this.config.projectName, { | ||
autotrack: false, | ||
}); | ||
this.amplitudeInstance.setDeviceId(mixpanel.get_distinct_id()); | ||
} | ||
}; | ||
DefaultClient.prototype.amplitude = function () { | ||
return this.amplitudeInstance; | ||
}; | ||
DefaultClient.prototype.deviceId = function () { | ||
return this.amplitudeInstance.options.deviceId; | ||
return this.amplitudeInstance.getDeviceId(); | ||
}; | ||
@@ -76,3 +54,5 @@ DefaultClient.prototype.sessionId = function () { | ||
DefaultClient.prototype.regenerateDeviceId = function () { | ||
this.amplitudeInstance.regenerateDeviceId(); | ||
var userId = this.amplitudeInstance.getUserId(); | ||
this.amplitudeInstance.reset(); | ||
this.amplitudeInstance.setUserId(userId); | ||
}; | ||
@@ -85,3 +65,3 @@ DefaultClient.prototype.linkDevices = function (userId, deviceIds) { | ||
this.setUserId(userId); | ||
var identifyData = identifyObject(); | ||
var identifyData = getIdentifyObject(); | ||
this.amplitudeInstance.identify(identifyData); | ||
@@ -100,7 +80,7 @@ for (var _i = 0, deviceIds_1 = deviceIds; _i < deviceIds_1.length; _i++) { | ||
else { | ||
this.amplitudeInstance.regenerateDeviceId(); | ||
this.regenerateDeviceId(); | ||
} | ||
}; | ||
DefaultClient.prototype.track = function (eventType, props) { | ||
this.amplitudeInstance.logEvent(eventType, props); | ||
this.amplitudeInstance.track(eventType, props); | ||
}; | ||
@@ -124,2 +104,5 @@ DefaultClient.prototype.setUserId = function (userId) { | ||
}; | ||
DefaultClient.prototype.identify = function (identify) { | ||
this.amplitudeInstance.identify(identify); | ||
}; | ||
return DefaultClient; | ||
@@ -140,5 +123,2 @@ }()); | ||
}; | ||
NoopClient.prototype.amplitude = function () { | ||
throw new Error('Not supported'); | ||
}; | ||
NoopClient.prototype.deviceId = function () { | ||
@@ -165,2 +145,4 @@ return ''; | ||
}; | ||
NoopClient.prototype.identify = function () { | ||
}; | ||
return NoopClient; | ||
@@ -167,0 +149,0 @@ }()); |
@@ -34,2 +34,3 @@ "use strict"; | ||
var entry = window.performance.getEntriesByType('navigation'); | ||
console.log(entry); | ||
if (!entry || entry.length < 1) { | ||
@@ -36,0 +37,0 @@ return {}; |
{ | ||
"name": "analytics-client", | ||
"version": "1.8.3", | ||
"version": "2.0.0-feature-use-ts-client-92dbefedcaa6c9b515cda6eeaf5b7743907f5629", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -16,3 +16,3 @@ "repository": { | ||
"scripts": { | ||
"test": "jest", | ||
"test": "jest --coverage", | ||
"prettify": "balena-lint --typescript --fix src/ test/ index.ts", | ||
@@ -27,6 +27,4 @@ "lint": "balena-lint --typescript src/ test/ index.ts && tsc --noEmit", | ||
"dependencies": { | ||
"@types/amplitude-js": "5.11.0", | ||
"amplitude-js": "5.11.0", | ||
"js-cookie": "^3.0.1", | ||
"mixpanel-browser": "^2.29.0" | ||
"@amplitude/analytics-browser": "^1.5.4", | ||
"js-cookie": "^3.0.1" | ||
}, | ||
@@ -38,3 +36,2 @@ "devDependencies": { | ||
"@types/lodash": "^4.14.182", | ||
"@types/mixpanel-browser": "^2.38.0", | ||
"husky": "^8.0.1", | ||
@@ -65,4 +62,4 @@ "jest": "^28.1.0", | ||
"versionist": { | ||
"publishedAt": "2022-09-27T17:31:41.753Z" | ||
"publishedAt": "2022-10-23T17:58:18.560Z" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
2
13
0
100
122354
19
444
2
2
+ Added@amplitude/analytics-browser@1.13.7(transitive)
+ Added@amplitude/analytics-client-common@1.2.3(transitive)
+ Added@amplitude/analytics-connector@1.6.2(transitive)
+ Added@amplitude/analytics-core@1.2.5(transitive)
+ Added@amplitude/analytics-types@1.3.4(transitive)
+ Added@amplitude/experiment-core@0.10.1(transitive)
+ Added@amplitude/plugin-page-view-tracking-browser@1.0.13(transitive)
+ Added@amplitude/plugin-web-attribution-browser@1.0.13(transitive)
+ Added@amplitude/ua-parser-js@0.7.33(transitive)
+ Addedjs-base64@3.7.7(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@types/amplitude-js@5.11.0
- Removedamplitude-js@5.11.0
- Removedmixpanel-browser@^2.29.0
- Removed@amplitude/ua-parser-js@0.7.20(transitive)
- Removed@rrweb/types@2.0.0-alpha.18(transitive)
- Removed@types/amplitude-js@5.11.0(transitive)
- Removed@types/css-font-loading-module@0.0.7(transitive)
- Removed@xstate/fsm@1.6.5(transitive)
- Removedamplitude-js@5.11.0(transitive)
- Removedbase64-arraybuffer@1.0.2(transitive)
- Removedblueimp-md5@2.19.0(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removedfflate@0.4.8(transitive)
- Removedmitt@3.0.1(transitive)
- Removedmixpanel-browser@2.58.0(transitive)
- Removednanoid@3.3.8(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedpostcss@8.5.1(transitive)
- Removedquery-string@5.1.1(transitive)
- Removedrrdom@2.0.0-alpha.18(transitive)
- Removedrrweb@2.0.0-alpha.13(transitive)
- Removedrrweb-snapshot@2.0.0-alpha.18(transitive)
- Removedsource-map-js@1.2.1(transitive)
- Removedstrict-uri-encode@1.1.0(transitive)