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

@amplitude/analytics-browser

Package Overview
Dependencies
Maintainers
19
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amplitude/analytics-browser - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

12

lib/cjs/browser-client.d.ts

@@ -10,7 +10,5 @@ import { AmplitudeCore } from '@amplitude/analytics-core';

setDeviceId(deviceId: string): void;
regenerateDeviceId(): void;
reset(): void;
getSessionId(): number | undefined;
setSessionId(sessionId: number): void;
setOptOut(optOut: boolean): void;
setTransport(transport: TransportType): void;

@@ -158,12 +156,2 @@ identify(identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;

/**
* Regenerates a new random deviceId for current user. Note: this is not recommended unless you know what you
* are doing. This can be used in conjunction with `setUserId(undefined)` to anonymize users after they log out.
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.
*
* ```typescript
* regenerateDeviceId();
* ```
*/
export declare const regenerateDeviceId: () => void;
/**
* reset is a shortcut to anonymize users after they log out, by:

@@ -170,0 +158,0 @@ * - setting userId to `undefined`

51

lib/cjs/browser-client.js
Object.defineProperty(exports, "__esModule", { value: true });
exports.flush = exports.setTransport = exports.setOptOut = exports.setSessionId = exports.getSessionId = exports.reset = exports.regenerateDeviceId = exports.setDeviceId = exports.getDeviceId = exports.setUserId = exports.getUserId = exports.revenue = exports.setGroup = exports.groupIdentify = exports.identify = exports.logEvent = exports.track = exports.remove = exports.add = exports.init = exports.AmplitudeBrowser = void 0;
exports.flush = exports.setTransport = exports.setOptOut = exports.setSessionId = exports.getSessionId = exports.reset = exports.setDeviceId = exports.getDeviceId = exports.setUserId = exports.getUserId = exports.revenue = exports.setGroup = exports.groupIdentify = exports.identify = exports.logEvent = exports.track = exports.remove = exports.add = exports.init = exports.AmplitudeBrowser = void 0;
var tslib_1 = require("tslib");

@@ -33,3 +33,3 @@ var analytics_core_1 = require("@amplitude/analytics-core");

_d.sent();
isNewSession = false;
isNewSession = !this.config.lastEventTime;
if (!this.config.sessionId ||

@@ -40,3 +40,3 @@ (this.config.lastEventTime && Date.now() - this.config.lastEventTime > this.config.sessionTimeout)) {

// 2) Previous session expired
this.config.sessionId = Date.now();
this.setSessionId(Date.now());
isNewSession = true;

@@ -103,31 +103,44 @@ }

AmplitudeBrowser.prototype.getUserId = function () {
return this.config.userId;
var _a;
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.userId;
};
AmplitudeBrowser.prototype.setUserId = function (userId) {
if (!this.config) {
this.q.push(this.setUserId.bind(this, userId));
return;
}
this.config.userId = userId;
};
AmplitudeBrowser.prototype.getDeviceId = function () {
return this.config.deviceId;
var _a;
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.deviceId;
};
AmplitudeBrowser.prototype.setDeviceId = function (deviceId) {
if (!this.config) {
this.q.push(this.setDeviceId.bind(this, deviceId));
return;
}
this.config.deviceId = deviceId;
};
AmplitudeBrowser.prototype.regenerateDeviceId = function () {
var deviceId = (0, config_1.createDeviceId)();
this.setDeviceId(deviceId);
};
AmplitudeBrowser.prototype.reset = function () {
this.setUserId(undefined);
this.regenerateDeviceId();
this.setDeviceId((0, analytics_core_1.UUID)());
};
AmplitudeBrowser.prototype.getSessionId = function () {
return this.config.sessionId;
var _a;
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.sessionId;
};
AmplitudeBrowser.prototype.setSessionId = function (sessionId) {
if (!this.config) {
this.q.push(this.setSessionId.bind(this, sessionId));
return;
}
this.config.sessionId = sessionId;
this.config.lastEventTime = undefined;
};
AmplitudeBrowser.prototype.setOptOut = function (optOut) {
this.config.optOut = optOut;
};
AmplitudeBrowser.prototype.setTransport = function (transport) {
if (!this.config) {
this.q.push(this.setTransport.bind(this, transport));
return;
}
this.config.transportProvider = (0, config_1.createTransport)(transport);

@@ -300,12 +313,2 @@ };

/**
* Regenerates a new random deviceId for current user. Note: this is not recommended unless you know what you
* are doing. This can be used in conjunction with `setUserId(undefined)` to anonymize users after they log out.
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.
*
* ```typescript
* regenerateDeviceId();
* ```
*/
exports.regenerateDeviceId = client.regenerateDeviceId.bind(client);
/**
* reset is a shortcut to anonymize users after they log out, by:

@@ -312,0 +315,0 @@ * - setting userId to `undefined`

@@ -1,2 +0,2 @@

export declare const VERSION = "1.1.2";
export declare const VERSION = "1.1.3";
//# sourceMappingURL=version.d.ts.map
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.VERSION = '1.1.2';
exports.VERSION = '1.1.3';
//# sourceMappingURL=version.js.map

@@ -10,7 +10,5 @@ import { AmplitudeCore } from '@amplitude/analytics-core';

setDeviceId(deviceId: string): void;
regenerateDeviceId(): void;
reset(): void;
getSessionId(): number | undefined;
setSessionId(sessionId: number): void;
setOptOut(optOut: boolean): void;
setTransport(transport: TransportType): void;

@@ -158,12 +156,2 @@ identify(identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;

/**
* Regenerates a new random deviceId for current user. Note: this is not recommended unless you know what you
* are doing. This can be used in conjunction with `setUserId(undefined)` to anonymize users after they log out.
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.
*
* ```typescript
* regenerateDeviceId();
* ```
*/
export declare const regenerateDeviceId: () => void;
/**
* reset is a shortcut to anonymize users after they log out, by:

@@ -170,0 +158,0 @@ * - setting userId to `undefined`

import { __assign, __awaiter, __extends, __generator } from "tslib";
import { AmplitudeCore, Destination, Identify, Revenue, returnWrapper } from '@amplitude/analytics-core';
import { AmplitudeCore, Destination, Identify, Revenue, returnWrapper, UUID } from '@amplitude/analytics-core';
import { convertProxyObjectToRealObject, isInstanceProxy } from './utils/snippet-helper';
import { Context } from './plugins/context';
import { useBrowserConfig, createTransport, createDeviceId, createFlexibleStorage } from './config';
import { useBrowserConfig, createTransport, createFlexibleStorage } from './config';
import { parseOldCookies } from './cookie-migration';

@@ -31,3 +31,3 @@ import { CampaignTracker } from './attribution/campaign-tracker';

_d.sent();
isNewSession = false;
isNewSession = !this.config.lastEventTime;
if (!this.config.sessionId ||

@@ -38,3 +38,3 @@ (this.config.lastEventTime && Date.now() - this.config.lastEventTime > this.config.sessionTimeout)) {

// 2) Previous session expired
this.config.sessionId = Date.now();
this.setSessionId(Date.now());
isNewSession = true;

@@ -101,31 +101,44 @@ }

AmplitudeBrowser.prototype.getUserId = function () {
return this.config.userId;
var _a;
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.userId;
};
AmplitudeBrowser.prototype.setUserId = function (userId) {
if (!this.config) {
this.q.push(this.setUserId.bind(this, userId));
return;
}
this.config.userId = userId;
};
AmplitudeBrowser.prototype.getDeviceId = function () {
return this.config.deviceId;
var _a;
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.deviceId;
};
AmplitudeBrowser.prototype.setDeviceId = function (deviceId) {
if (!this.config) {
this.q.push(this.setDeviceId.bind(this, deviceId));
return;
}
this.config.deviceId = deviceId;
};
AmplitudeBrowser.prototype.regenerateDeviceId = function () {
var deviceId = createDeviceId();
this.setDeviceId(deviceId);
};
AmplitudeBrowser.prototype.reset = function () {
this.setUserId(undefined);
this.regenerateDeviceId();
this.setDeviceId(UUID());
};
AmplitudeBrowser.prototype.getSessionId = function () {
return this.config.sessionId;
var _a;
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.sessionId;
};
AmplitudeBrowser.prototype.setSessionId = function (sessionId) {
if (!this.config) {
this.q.push(this.setSessionId.bind(this, sessionId));
return;
}
this.config.sessionId = sessionId;
this.config.lastEventTime = undefined;
};
AmplitudeBrowser.prototype.setOptOut = function (optOut) {
this.config.optOut = optOut;
};
AmplitudeBrowser.prototype.setTransport = function (transport) {
if (!this.config) {
this.q.push(this.setTransport.bind(this, transport));
return;
}
this.config.transportProvider = createTransport(transport);

@@ -298,12 +311,2 @@ };

/**
* Regenerates a new random deviceId for current user. Note: this is not recommended unless you know what you
* are doing. This can be used in conjunction with `setUserId(undefined)` to anonymize users after they log out.
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard.
*
* ```typescript
* regenerateDeviceId();
* ```
*/
export var regenerateDeviceId = client.regenerateDeviceId.bind(client);
/**
* reset is a shortcut to anonymize users after they log out, by:

@@ -310,0 +313,0 @@ * - setting userId to `undefined`

@@ -1,2 +0,2 @@

export declare const VERSION = "1.1.2";
export declare const VERSION = "1.1.3";
//# sourceMappingURL=version.d.ts.map

@@ -1,2 +0,2 @@

export var VERSION = '1.1.2';
export var VERSION = '1.1.3';
//# sourceMappingURL=version.js.map

@@ -1,1 +0,1 @@

!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[]};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{r.invoked=!0;var n=t.createElement("script");n.type="text/javascript",n.integrity="sha384-bOgag88cCbUrgxz1PjrCwsqjvX4PBHbKsdFMxw6SpeOKRCXcO1Bctvuacd/mRf3r",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-1.1.2-min.js.gz",n.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var s=t.getElementsByTagName("script")[0];function v(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}}s.parentNode.insertBefore(n,s);for(var o=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],a=0;a<i.length;a++)v(o,i[a]);r.Identify=o;for(var c=function(){return this._q=[],this},u=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<u.length;p++)v(c,u[p]);r.Revenue=c;var d=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset"],l=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];function f(e){function t(t,r){e[t]=function(){var n={promise:new Promise((r=>{e._q.push({name:t,args:Array.prototype.slice.call(arguments,0),resolve:r})}))};if(r)return n}}for(var r=0;r<d.length;r++)t(d[r],!1);for(var n=0;n<l.length;n++)t(l[n],!0)}f(r),e.amplitude=r}}(window,document)}();
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[]};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{r.invoked=!0;var n=t.createElement("script");n.type="text/javascript",n.integrity="sha384-VxpZ51UOXPehRpQdfZ5ubFs8RRA5ctVTPOXhsL1tbjrr2YLF47oerqRUhVjkrZl4",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-1.1.3-min.js.gz",n.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var s=t.getElementsByTagName("script")[0];function v(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}}s.parentNode.insertBefore(n,s);for(var o=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],a=0;a<i.length;a++)v(o,i[a]);r.Identify=o;for(var u=function(){return this._q=[],this},c=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<c.length;p++)v(u,c[p]);r.Revenue=u;var l=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset"],d=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];function f(e){function t(t,r){e[t]=function(){var n={promise:new Promise((r=>{e._q.push({name:t,args:Array.prototype.slice.call(arguments,0),resolve:r})}))};if(r)return n}}for(var r=0;r<l.length;r++)t(l[r],!1);for(var n=0;n<d.length;n++)t(d[n],!0)}f(r),e.amplitude=r}}(window,document)}();
{
"name": "@amplitude/analytics-browser",
"version": "1.1.2",
"version": "1.1.3",
"description": "Official Amplitude SDK for Web",

@@ -45,3 +45,3 @@ "keywords": [

"@amplitude/analytics-connector": "^1.4.5",
"@amplitude/analytics-core": "^0.6.4",
"@amplitude/analytics-core": "^0.6.5",
"@amplitude/analytics-types": "^0.6.1",

@@ -66,3 +66,3 @@ "@amplitude/ua-parser-js": "^0.7.31",

],
"gitHead": "2698f058d93662642fbccd90686aa23dab1995e4"
"gitHead": "196d18de7dd7a3e855073cc01880498e6190b739"
}

@@ -35,3 +35,3 @@ <p align="center">

<script type="text/javascript">
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[]};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{r.invoked=!0;var n=t.createElement("script");n.type="text/javascript",n.integrity="sha384-bOgag88cCbUrgxz1PjrCwsqjvX4PBHbKsdFMxw6SpeOKRCXcO1Bctvuacd/mRf3r",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-1.1.2-min.js.gz",n.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var s=t.getElementsByTagName("script")[0];function v(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}}s.parentNode.insertBefore(n,s);for(var o=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],a=0;a<i.length;a++)v(o,i[a]);r.Identify=o;for(var c=function(){return this._q=[],this},u=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<u.length;p++)v(c,u[p]);r.Revenue=c;var d=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset"],l=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];function f(e){function t(t,r){e[t]=function(){var n={promise:new Promise((r=>{e._q.push({name:t,args:Array.prototype.slice.call(arguments,0),resolve:r})}))};if(r)return n}}for(var r=0;r<d.length;r++)t(d[r],!1);for(var n=0;n<l.length;n++)t(l[n],!0)}f(r),e.amplitude=r}}(window,document)}();
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[]};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{r.invoked=!0;var n=t.createElement("script");n.type="text/javascript",n.integrity="sha384-VxpZ51UOXPehRpQdfZ5ubFs8RRA5ctVTPOXhsL1tbjrr2YLF47oerqRUhVjkrZl4",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-1.1.3-min.js.gz",n.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var s=t.getElementsByTagName("script")[0];function v(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}}s.parentNode.insertBefore(n,s);for(var o=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],a=0;a<i.length;a++)v(o,i[a]);r.Identify=o;for(var u=function(){return this._q=[],this},c=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<c.length;p++)v(u,c[p]);r.Revenue=u;var l=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset"],d=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];function f(e){function t(t,r){e[t]=function(){var n={promise:new Promise((r=>{e._q.push({name:t,args:Array.prototype.slice.call(arguments,0),resolve:r})}))};if(r)return n}}for(var r=0;r<l.length;r++)t(l[r],!1);for(var n=0;n<d.length;n++)t(d[n],!0)}f(r),e.amplitude=r}}(window,document)}();

@@ -168,1 +168,11 @@ amplitude.init("YOUR_API_KEY_HERE");

```
### User Log out
This updates user ID and device ID. After calling `reset()` the succeeding events now belong to a new user identity.
```typescript
import { reset } from '@amplitude/analytics-browser';
reset();
```

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

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

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 too big to display

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