Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

analytics-client

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-client - npm Package Compare versions

Comparing version 1.8.3 to 2.0.0-feature-use-ts-client-92dbefedcaa6c9b515cda6eeaf5b7743907f5629

1

dist/index.d.ts
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';

4

dist/index.js
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc