@amplitude/analytics-browser
Advanced tools
Comparing version 1.1.5 to 1.2.0
import { AmplitudeCore } from '@amplitude/analytics-core'; | ||
import { AdditionalBrowserOptions, AttributionBrowserOptions, BrowserConfig, BrowserOptions, EventOptions, Identify as IIdentify, Result, Revenue as IRevenue, TransportType } from '@amplitude/analytics-types'; | ||
import { AdditionalBrowserOptions, AttributionBrowserOptions, BrowserClient, BrowserConfig, BrowserOptions, EventOptions, Identify as IIdentify, Result, Revenue as IRevenue, TransportType } from '@amplitude/analytics-types'; | ||
export declare class AmplitudeBrowser extends AmplitudeCore<BrowserConfig> { | ||
@@ -18,206 +18,5 @@ init(apiKey: string, userId?: string, options?: BrowserOptions & AdditionalBrowserOptions): Promise<void>; | ||
} | ||
/** | ||
* Initializes the Amplitude SDK with your apiKey, userId and optional configurations. | ||
* This method must be called before any other operations. | ||
* | ||
* ```typescript | ||
* await init(API_KEY, USER_ID, options).promise; | ||
* ``` | ||
*/ | ||
export declare const init: (apiKey: string, userId?: string | undefined, options?: (BrowserOptions & AdditionalBrowserOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
* Adds a new plugin. | ||
* | ||
* ```typescript | ||
* const plugin = {...}; | ||
* amplitude.add(plugin); | ||
* ``` | ||
*/ | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
* Removes a plugin. | ||
* | ||
* ```typescript | ||
* amplitude.remove('myPlugin'); | ||
* ``` | ||
*/ | ||
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
* Tracks user-defined event, with specified type, optional event properties and optional overwrites. | ||
* | ||
* ```typescript | ||
* // event tracking with event type only | ||
* track('Page Load'); | ||
* | ||
* // event tracking with event type and additional event properties | ||
* track('Page Load', { loadTime: 1000 }); | ||
* | ||
* // event tracking with event type, additional event properties, and overwritten event options | ||
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 }); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await track('Page Load').promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Alias for track() | ||
*/ | ||
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Sends an identify event containing user property operations | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('colors', ['rose', 'gold']); | ||
* identify(id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await identify(id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Sends a group identify event containing group property operations. | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('skills', ['js', 'ts']); | ||
* const groupType = 'org'; | ||
* const groupName = 'engineering'; | ||
* groupIdentify(groupType, groupName, id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await groupIdentify(groupType, groupName, id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
export declare const setGroup: (groupType: string, groupName: string | string[], eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Sends a revenue event containing revenue property operations. | ||
* | ||
* ```typescript | ||
* const rev = new Revenue(); | ||
* rev.setRevenue(100); | ||
* revenue(rev); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await revenue(rev).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Returns current user ID. | ||
* | ||
* ```typescript | ||
* const userId = getUserId(); | ||
* ``` | ||
*/ | ||
export declare const getUserId: () => string | undefined; | ||
/** | ||
* Sets a new user ID. | ||
* | ||
* ```typescript | ||
* setUserId('userId'); | ||
* ``` | ||
*/ | ||
export declare const setUserId: (userId: string | undefined) => void; | ||
/** | ||
* Returns current device ID. | ||
* | ||
* ```typescript | ||
* const deviceId = getDeviceId(); | ||
* ``` | ||
*/ | ||
export declare const getDeviceId: () => string | undefined; | ||
/** | ||
* Sets a new device ID. | ||
* When setting a custom device ID, make sure the value is sufficiently unique. | ||
* A uuid is recommended. | ||
* | ||
* ```typescript | ||
* setDeviceId('deviceId'); | ||
* ``` | ||
*/ | ||
export declare const setDeviceId: (deviceId: string) => void; | ||
/** | ||
* reset is a shortcut to anonymize users after they log out, by: | ||
* - setting userId to `undefined` | ||
* - regenerating a new random deviceId | ||
* | ||
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard. | ||
* | ||
* ```typescript | ||
* reset(); | ||
* ``` | ||
*/ | ||
export declare const reset: () => void; | ||
/** | ||
* Returns current session ID. | ||
* | ||
* ```typescript | ||
* const sessionId = getSessionId(); | ||
* ``` | ||
*/ | ||
export declare const getSessionId: () => number | undefined; | ||
/** | ||
* Sets a new session ID. | ||
* When settign a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp). | ||
* | ||
* ```typescript | ||
* setSessionId(Date.now()); | ||
* ``` | ||
*/ | ||
export declare const setSessionId: (sessionId: number) => void; | ||
/** | ||
* Sets a new optOut config value. This toggles event tracking on/off. | ||
* | ||
*```typescript | ||
* // Stops tracking | ||
* setOptOut(true); | ||
* | ||
* // Starts/resumes tracking | ||
* setOptOut(false); | ||
* ``` | ||
*/ | ||
export declare const setOptOut: (optOut: boolean) => void; | ||
/** | ||
* Sets the network transport type for events. | ||
* | ||
* ```typescript | ||
* // Use Fetch API | ||
* setTransport('fetch'); | ||
* | ||
* // Use XMLHttpRequest API | ||
* setTransport('xhr'); | ||
* | ||
* // Use navigator.sendBeacon API | ||
* setTransport('beacon'); | ||
* ``` | ||
*/ | ||
export declare const setTransport: (transport: TransportType) => void; | ||
/** | ||
* Flush and send all the events which haven't been sent. | ||
* | ||
*```typescript | ||
* // Send all the unsent events | ||
* flush(); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* await flush().promise; | ||
* ``` | ||
*/ | ||
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
export declare const createInstance: () => BrowserClient; | ||
declare const _default: BrowserClient; | ||
export default _default; | ||
//# sourceMappingURL=browser-client.d.ts.map |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
exports.createInstance = exports.AmplitudeBrowser = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -24,3 +24,9 @@ var analytics_core_1 = require("@amplitude/analytics-core"); | ||
switch (_d.label) { | ||
case 0: return [4 /*yield*/, (0, cookie_migration_1.parseOldCookies)(apiKey, options)]; | ||
case 0: | ||
// Step 0: Block concurrent initialization | ||
if (this.initializing) { | ||
return [2 /*return*/]; | ||
} | ||
this.initializing = true; | ||
return [4 /*yield*/, (0, cookie_migration_1.parseOldCookies)(apiKey, options)]; | ||
case 1: | ||
@@ -64,2 +70,3 @@ oldCookies = _d.sent(); | ||
_d.sent(); | ||
this.initializing = false; | ||
// Step 5: Set timeline ready for processing events | ||
@@ -174,207 +181,28 @@ // Send existing events, which might be collected by track before init | ||
exports.AmplitudeBrowser = AmplitudeBrowser; | ||
var client = new AmplitudeBrowser(); | ||
/** | ||
* Initializes the Amplitude SDK with your apiKey, userId and optional configurations. | ||
* This method must be called before any other operations. | ||
* | ||
* ```typescript | ||
* await init(API_KEY, USER_ID, options).promise; | ||
* ``` | ||
*/ | ||
exports.init = (0, analytics_core_1.returnWrapper)(client.init.bind(client)); | ||
/** | ||
* Adds a new plugin. | ||
* | ||
* ```typescript | ||
* const plugin = {...}; | ||
* amplitude.add(plugin); | ||
* ``` | ||
*/ | ||
exports.add = (0, analytics_core_1.returnWrapper)(client.add.bind(client)); | ||
/** | ||
* Removes a plugin. | ||
* | ||
* ```typescript | ||
* amplitude.remove('myPlugin'); | ||
* ``` | ||
*/ | ||
exports.remove = (0, analytics_core_1.returnWrapper)(client.remove.bind(client)); | ||
/** | ||
* Tracks user-defined event, with specified type, optional event properties and optional overwrites. | ||
* | ||
* ```typescript | ||
* // event tracking with event type only | ||
* track('Page Load'); | ||
* | ||
* // event tracking with event type and additional event properties | ||
* track('Page Load', { loadTime: 1000 }); | ||
* | ||
* // event tracking with event type, additional event properties, and overwritten event options | ||
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 }); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await track('Page Load').promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
exports.track = (0, analytics_core_1.returnWrapper)(client.track.bind(client)); | ||
/** | ||
* Alias for track() | ||
*/ | ||
exports.logEvent = (0, analytics_core_1.returnWrapper)(client.logEvent.bind(client)); | ||
/** | ||
* Sends an identify event containing user property operations | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('colors', ['rose', 'gold']); | ||
* identify(id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await identify(id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
exports.identify = (0, analytics_core_1.returnWrapper)(client.identify.bind(client)); | ||
/** | ||
* Sends a group identify event containing group property operations. | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('skills', ['js', 'ts']); | ||
* const groupType = 'org'; | ||
* const groupName = 'engineering'; | ||
* groupIdentify(groupType, groupName, id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await groupIdentify(groupType, groupName, id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
exports.groupIdentify = (0, analytics_core_1.returnWrapper)(client.groupIdentify.bind(client)); | ||
exports.setGroup = (0, analytics_core_1.returnWrapper)(client.setGroup.bind(client)); | ||
/** | ||
* Sends a revenue event containing revenue property operations. | ||
* | ||
* ```typescript | ||
* const rev = new Revenue(); | ||
* rev.setRevenue(100); | ||
* revenue(rev); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await revenue(rev).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
exports.revenue = (0, analytics_core_1.returnWrapper)(client.revenue.bind(client)); | ||
/** | ||
* Returns current user ID. | ||
* | ||
* ```typescript | ||
* const userId = getUserId(); | ||
* ``` | ||
*/ | ||
exports.getUserId = client.getUserId.bind(client); | ||
/** | ||
* Sets a new user ID. | ||
* | ||
* ```typescript | ||
* setUserId('userId'); | ||
* ``` | ||
*/ | ||
exports.setUserId = client.setUserId.bind(client); | ||
/** | ||
* Returns current device ID. | ||
* | ||
* ```typescript | ||
* const deviceId = getDeviceId(); | ||
* ``` | ||
*/ | ||
exports.getDeviceId = client.getDeviceId.bind(client); | ||
/** | ||
* Sets a new device ID. | ||
* When setting a custom device ID, make sure the value is sufficiently unique. | ||
* A uuid is recommended. | ||
* | ||
* ```typescript | ||
* setDeviceId('deviceId'); | ||
* ``` | ||
*/ | ||
exports.setDeviceId = client.setDeviceId.bind(client); | ||
/** | ||
* reset is a shortcut to anonymize users after they log out, by: | ||
* - setting userId to `undefined` | ||
* - regenerating a new random deviceId | ||
* | ||
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard. | ||
* | ||
* ```typescript | ||
* reset(); | ||
* ``` | ||
*/ | ||
exports.reset = client.reset.bind(client); | ||
/** | ||
* Returns current session ID. | ||
* | ||
* ```typescript | ||
* const sessionId = getSessionId(); | ||
* ``` | ||
*/ | ||
exports.getSessionId = client.getSessionId.bind(client); | ||
/** | ||
* Sets a new session ID. | ||
* When settign a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp). | ||
* | ||
* ```typescript | ||
* setSessionId(Date.now()); | ||
* ``` | ||
*/ | ||
exports.setSessionId = client.setSessionId.bind(client); | ||
/** | ||
* Sets a new optOut config value. This toggles event tracking on/off. | ||
* | ||
*```typescript | ||
* // Stops tracking | ||
* setOptOut(true); | ||
* | ||
* // Starts/resumes tracking | ||
* setOptOut(false); | ||
* ``` | ||
*/ | ||
exports.setOptOut = client.setOptOut.bind(client); | ||
/** | ||
* Sets the network transport type for events. | ||
* | ||
* ```typescript | ||
* // Use Fetch API | ||
* setTransport('fetch'); | ||
* | ||
* // Use XMLHttpRequest API | ||
* setTransport('xhr'); | ||
* | ||
* // Use navigator.sendBeacon API | ||
* setTransport('beacon'); | ||
* ``` | ||
*/ | ||
exports.setTransport = client.setTransport.bind(client); | ||
/** | ||
* Flush and send all the events which haven't been sent. | ||
* | ||
*```typescript | ||
* // Send all the unsent events | ||
* flush(); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* await flush().promise; | ||
* ``` | ||
*/ | ||
exports.flush = (0, analytics_core_1.returnWrapper)(client.flush.bind(client)); | ||
var createInstance = function () { | ||
var client = new AmplitudeBrowser(); | ||
return { | ||
init: (0, analytics_core_1.returnWrapper)(client.init.bind(client)), | ||
add: (0, analytics_core_1.returnWrapper)(client.add.bind(client)), | ||
remove: (0, analytics_core_1.returnWrapper)(client.remove.bind(client)), | ||
track: (0, analytics_core_1.returnWrapper)(client.track.bind(client)), | ||
logEvent: (0, analytics_core_1.returnWrapper)(client.logEvent.bind(client)), | ||
identify: (0, analytics_core_1.returnWrapper)(client.identify.bind(client)), | ||
groupIdentify: (0, analytics_core_1.returnWrapper)(client.groupIdentify.bind(client)), | ||
setGroup: (0, analytics_core_1.returnWrapper)(client.setGroup.bind(client)), | ||
revenue: (0, analytics_core_1.returnWrapper)(client.revenue.bind(client)), | ||
flush: (0, analytics_core_1.returnWrapper)(client.flush.bind(client)), | ||
getUserId: client.getUserId.bind(client), | ||
setUserId: client.setUserId.bind(client), | ||
getDeviceId: client.getDeviceId.bind(client), | ||
setDeviceId: client.setDeviceId.bind(client), | ||
reset: client.reset.bind(client), | ||
getSessionId: client.getSessionId.bind(client), | ||
setSessionId: client.setSessionId.bind(client), | ||
setOptOut: client.setOptOut.bind(client), | ||
setTransport: client.setTransport.bind(client), | ||
}; | ||
}; | ||
exports.createInstance = createInstance; | ||
exports.default = (0, exports.createInstance)(); | ||
//# sourceMappingURL=browser-client.js.map |
@@ -17,17 +17,3 @@ import { Event, BrowserOptions, BrowserConfig as IBrowserConfig, Storage, TrackingOptions, TransportType, UserSession, SessionManager as ISessionManager } from '@amplitude/analytics-types'; | ||
storageProvider: MemoryStorage<Event[]>; | ||
trackingOptions: { | ||
city: boolean; | ||
country: boolean; | ||
carrier: boolean; | ||
deviceManufacturer: boolean; | ||
deviceModel: boolean; | ||
dma: boolean; | ||
ipAddress: boolean; | ||
language: boolean; | ||
osName: boolean; | ||
osVersion: boolean; | ||
platform: boolean; | ||
region: boolean; | ||
versionName: boolean; | ||
}; | ||
trackingOptions: Required<TrackingOptions>; | ||
transportProvider: FetchTransport; | ||
@@ -70,17 +56,3 @@ }; | ||
storageProvider: MemoryStorage<Event[]>; | ||
trackingOptions: { | ||
city: boolean; | ||
country: boolean; | ||
carrier: boolean; | ||
deviceManufacturer: boolean; | ||
deviceModel: boolean; | ||
dma: boolean; | ||
ipAddress: boolean; | ||
language: boolean; | ||
osName: boolean; | ||
osVersion: boolean; | ||
platform: boolean; | ||
region: boolean; | ||
versionName: boolean; | ||
}; | ||
trackingOptions: Required<TrackingOptions>; | ||
transportProvider: FetchTransport; | ||
@@ -87,0 +59,0 @@ }) => Promise<Storage<UserSession>>; |
@@ -17,2 +17,11 @@ var _this = this; | ||
var cookieStorage = new analytics_core_1.MemoryStorage(); | ||
var trackingOptions = { | ||
deviceManufacturer: true, | ||
deviceModel: true, | ||
ipAddress: true, | ||
language: true, | ||
osName: true, | ||
osVersion: true, | ||
platform: true, | ||
}; | ||
return { | ||
@@ -28,17 +37,3 @@ cookieExpiration: 365, | ||
storageProvider: new analytics_core_1.MemoryStorage(), | ||
trackingOptions: { | ||
city: true, | ||
country: true, | ||
carrier: true, | ||
deviceManufacturer: true, | ||
deviceModel: true, | ||
dma: true, | ||
ipAddress: true, | ||
language: true, | ||
osName: true, | ||
osVersion: true, | ||
platform: true, | ||
region: true, | ||
versionName: true, | ||
}, | ||
trackingOptions: trackingOptions, | ||
transportProvider: new fetch_1.FetchTransport(), | ||
@@ -45,0 +40,0 @@ }; |
@@ -1,2 +0,3 @@ | ||
export { add, flush, getDeviceId, getSessionId, getUserId, groupIdentify, identify, init, logEvent, remove, reset, revenue, setDeviceId, setGroup, setOptOut, setSessionId, setTransport, setUserId, track, } from './browser-client'; | ||
export { createInstance } from './browser-client'; | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>, flush: () => import("@amplitude/analytics-types").AmplitudeReturn<void>, getDeviceId: () => string | undefined, getSessionId: () => number | undefined, getUserId: () => string | undefined, groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, identify: (identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, init: (apiKey: string, userId?: string | undefined, options?: import("@amplitude/analytics-types").BrowserOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>, logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>, reset: () => void, revenue: (revenue: import("@amplitude/analytics-types").Revenue, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setDeviceId: (deviceId: string) => void, setGroup: (groupType: string, groupName: string | string[], eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setOptOut: (optOut: boolean) => void, setSessionId: (sessionId: number) => void, setTransport: (transport: import("@amplitude/analytics-types").TransportType) => void, setUserId: (userId: string) => void, track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>; | ||
export { runQueuedFunctions } from './utils/snippet-helper'; | ||
@@ -3,0 +4,0 @@ export { Revenue, Identify } from '@amplitude/analytics-core'; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Types = exports.Identify = exports.Revenue = exports.runQueuedFunctions = exports.track = exports.setUserId = exports.setTransport = exports.setSessionId = exports.setOptOut = exports.setGroup = exports.setDeviceId = exports.revenue = exports.reset = exports.remove = exports.logEvent = exports.init = exports.identify = exports.groupIdentify = exports.getUserId = exports.getSessionId = exports.getDeviceId = exports.flush = exports.add = void 0; | ||
exports.Types = exports.Identify = exports.Revenue = exports.runQueuedFunctions = exports.track = exports.setUserId = exports.setTransport = exports.setSessionId = exports.setOptOut = exports.setGroup = exports.setDeviceId = exports.revenue = exports.reset = exports.remove = exports.logEvent = exports.init = exports.identify = exports.groupIdentify = exports.getUserId = exports.getSessionId = exports.getDeviceId = exports.flush = exports.add = exports.createInstance = void 0; | ||
var tslib_1 = require("tslib"); | ||
var browser_client_1 = require("./browser-client"); | ||
Object.defineProperty(exports, "add", { enumerable: true, get: function () { return browser_client_1.add; } }); | ||
Object.defineProperty(exports, "flush", { enumerable: true, get: function () { return browser_client_1.flush; } }); | ||
Object.defineProperty(exports, "getDeviceId", { enumerable: true, get: function () { return browser_client_1.getDeviceId; } }); | ||
Object.defineProperty(exports, "getSessionId", { enumerable: true, get: function () { return browser_client_1.getSessionId; } }); | ||
Object.defineProperty(exports, "getUserId", { enumerable: true, get: function () { return browser_client_1.getUserId; } }); | ||
Object.defineProperty(exports, "groupIdentify", { enumerable: true, get: function () { return browser_client_1.groupIdentify; } }); | ||
Object.defineProperty(exports, "identify", { enumerable: true, get: function () { return browser_client_1.identify; } }); | ||
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return browser_client_1.init; } }); | ||
Object.defineProperty(exports, "logEvent", { enumerable: true, get: function () { return browser_client_1.logEvent; } }); | ||
Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return browser_client_1.remove; } }); | ||
Object.defineProperty(exports, "reset", { enumerable: true, get: function () { return browser_client_1.reset; } }); | ||
Object.defineProperty(exports, "revenue", { enumerable: true, get: function () { return browser_client_1.revenue; } }); | ||
Object.defineProperty(exports, "setDeviceId", { enumerable: true, get: function () { return browser_client_1.setDeviceId; } }); | ||
Object.defineProperty(exports, "setGroup", { enumerable: true, get: function () { return browser_client_1.setGroup; } }); | ||
Object.defineProperty(exports, "setOptOut", { enumerable: true, get: function () { return browser_client_1.setOptOut; } }); | ||
Object.defineProperty(exports, "setSessionId", { enumerable: true, get: function () { return browser_client_1.setSessionId; } }); | ||
Object.defineProperty(exports, "setTransport", { enumerable: true, get: function () { return browser_client_1.setTransport; } }); | ||
Object.defineProperty(exports, "setUserId", { enumerable: true, get: function () { return browser_client_1.setUserId; } }); | ||
Object.defineProperty(exports, "track", { enumerable: true, get: function () { return browser_client_1.track; } }); | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
var browser_client_1 = (0, tslib_1.__importDefault)(require("./browser-client")); | ||
var browser_client_2 = require("./browser-client"); | ||
Object.defineProperty(exports, "createInstance", { enumerable: true, get: function () { return browser_client_2.createInstance; } }); | ||
exports.add = browser_client_1.default.add, exports.flush = browser_client_1.default.flush, exports.getDeviceId = browser_client_1.default.getDeviceId, exports.getSessionId = browser_client_1.default.getSessionId, exports.getUserId = browser_client_1.default.getUserId, exports.groupIdentify = browser_client_1.default.groupIdentify, exports.identify = browser_client_1.default.identify, exports.init = browser_client_1.default.init, exports.logEvent = browser_client_1.default.logEvent, exports.remove = browser_client_1.default.remove, exports.reset = browser_client_1.default.reset, exports.revenue = browser_client_1.default.revenue, exports.setDeviceId = browser_client_1.default.setDeviceId, exports.setGroup = browser_client_1.default.setGroup, exports.setOptOut = browser_client_1.default.setOptOut, exports.setSessionId = browser_client_1.default.setSessionId, exports.setTransport = browser_client_1.default.setTransport, exports.setUserId = browser_client_1.default.setUserId, exports.track = browser_client_1.default.track; | ||
var snippet_helper_1 = require("./utils/snippet-helper"); | ||
@@ -25,0 +10,0 @@ Object.defineProperty(exports, "runQueuedFunctions", { enumerable: true, get: function () { return snippet_helper_1.runQueuedFunctions; } }); |
@@ -10,3 +10,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
(0, snippet_helper_1.runQueuedFunctions)(amplitude, queue); | ||
for (var i = 0; i < globalThis.amplitude._iq.length; i++) { | ||
var instance = Object.assign(globalThis.amplitude._iq[i], amplitude.createInstance()); | ||
var queue_1 = instance._q; | ||
instance._q = []; | ||
(0, snippet_helper_1.runQueuedFunctions)(instance, queue_1); | ||
} | ||
} | ||
//# sourceMappingURL=snippet-index.js.map |
export declare const getQueryParams: () => Record<string, string | undefined>; | ||
export declare const tryDecodeURIComponent: (value?: string) => string; | ||
//# sourceMappingURL=query-params.d.ts.map |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getQueryParams = void 0; | ||
var tslib_1 = require("tslib"); | ||
exports.tryDecodeURIComponent = exports.getQueryParams = void 0; | ||
var getQueryParams = function () { | ||
@@ -11,7 +10,9 @@ /* istanbul ignore if */ | ||
var params = pairs.reduce(function (acc, curr) { | ||
var _a = (0, tslib_1.__read)(curr.split('=', 2), 2), key = _a[0], _b = _a[1], value = _b === void 0 ? '' : _b; | ||
var query = curr.split('=', 2); | ||
var key = (0, exports.tryDecodeURIComponent)(query[0]); | ||
var value = (0, exports.tryDecodeURIComponent)(query[1]); | ||
if (!value) { | ||
return acc; | ||
} | ||
acc[decodeURIComponent(key)] = decodeURIComponent(value); | ||
acc[key] = value; | ||
return acc; | ||
@@ -22,2 +23,12 @@ }, {}); | ||
exports.getQueryParams = getQueryParams; | ||
var tryDecodeURIComponent = function (value) { | ||
if (value === void 0) { value = ''; } | ||
try { | ||
return decodeURIComponent(value); | ||
} | ||
catch (_a) { | ||
return ''; | ||
} | ||
}; | ||
exports.tryDecodeURIComponent = tryDecodeURIComponent; | ||
//# sourceMappingURL=query-params.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.1.5"; | ||
export declare const VERSION = "1.2.0"; | ||
//# sourceMappingURL=version.d.ts.map |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
exports.VERSION = '1.1.5'; | ||
exports.VERSION = '1.2.0'; | ||
//# sourceMappingURL=version.js.map |
import { AmplitudeCore } from '@amplitude/analytics-core'; | ||
import { AdditionalBrowserOptions, AttributionBrowserOptions, BrowserConfig, BrowserOptions, EventOptions, Identify as IIdentify, Result, Revenue as IRevenue, TransportType } from '@amplitude/analytics-types'; | ||
import { AdditionalBrowserOptions, AttributionBrowserOptions, BrowserClient, BrowserConfig, BrowserOptions, EventOptions, Identify as IIdentify, Result, Revenue as IRevenue, TransportType } from '@amplitude/analytics-types'; | ||
export declare class AmplitudeBrowser extends AmplitudeCore<BrowserConfig> { | ||
@@ -18,206 +18,5 @@ init(apiKey: string, userId?: string, options?: BrowserOptions & AdditionalBrowserOptions): Promise<void>; | ||
} | ||
/** | ||
* Initializes the Amplitude SDK with your apiKey, userId and optional configurations. | ||
* This method must be called before any other operations. | ||
* | ||
* ```typescript | ||
* await init(API_KEY, USER_ID, options).promise; | ||
* ``` | ||
*/ | ||
export declare const init: (apiKey: string, userId?: string | undefined, options?: (BrowserOptions & AdditionalBrowserOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
* Adds a new plugin. | ||
* | ||
* ```typescript | ||
* const plugin = {...}; | ||
* amplitude.add(plugin); | ||
* ``` | ||
*/ | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
* Removes a plugin. | ||
* | ||
* ```typescript | ||
* amplitude.remove('myPlugin'); | ||
* ``` | ||
*/ | ||
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
* Tracks user-defined event, with specified type, optional event properties and optional overwrites. | ||
* | ||
* ```typescript | ||
* // event tracking with event type only | ||
* track('Page Load'); | ||
* | ||
* // event tracking with event type and additional event properties | ||
* track('Page Load', { loadTime: 1000 }); | ||
* | ||
* // event tracking with event type, additional event properties, and overwritten event options | ||
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 }); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await track('Page Load').promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Alias for track() | ||
*/ | ||
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Sends an identify event containing user property operations | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('colors', ['rose', 'gold']); | ||
* identify(id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await identify(id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Sends a group identify event containing group property operations. | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('skills', ['js', 'ts']); | ||
* const groupType = 'org'; | ||
* const groupName = 'engineering'; | ||
* groupIdentify(groupType, groupName, id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await groupIdentify(groupType, groupName, id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
export declare const setGroup: (groupType: string, groupName: string | string[], eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Sends a revenue event containing revenue property operations. | ||
* | ||
* ```typescript | ||
* const rev = new Revenue(); | ||
* rev.setRevenue(100); | ||
* revenue(rev); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await revenue(rev).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Returns current user ID. | ||
* | ||
* ```typescript | ||
* const userId = getUserId(); | ||
* ``` | ||
*/ | ||
export declare const getUserId: () => string | undefined; | ||
/** | ||
* Sets a new user ID. | ||
* | ||
* ```typescript | ||
* setUserId('userId'); | ||
* ``` | ||
*/ | ||
export declare const setUserId: (userId: string | undefined) => void; | ||
/** | ||
* Returns current device ID. | ||
* | ||
* ```typescript | ||
* const deviceId = getDeviceId(); | ||
* ``` | ||
*/ | ||
export declare const getDeviceId: () => string | undefined; | ||
/** | ||
* Sets a new device ID. | ||
* When setting a custom device ID, make sure the value is sufficiently unique. | ||
* A uuid is recommended. | ||
* | ||
* ```typescript | ||
* setDeviceId('deviceId'); | ||
* ``` | ||
*/ | ||
export declare const setDeviceId: (deviceId: string) => void; | ||
/** | ||
* reset is a shortcut to anonymize users after they log out, by: | ||
* - setting userId to `undefined` | ||
* - regenerating a new random deviceId | ||
* | ||
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard. | ||
* | ||
* ```typescript | ||
* reset(); | ||
* ``` | ||
*/ | ||
export declare const reset: () => void; | ||
/** | ||
* Returns current session ID. | ||
* | ||
* ```typescript | ||
* const sessionId = getSessionId(); | ||
* ``` | ||
*/ | ||
export declare const getSessionId: () => number | undefined; | ||
/** | ||
* Sets a new session ID. | ||
* When settign a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp). | ||
* | ||
* ```typescript | ||
* setSessionId(Date.now()); | ||
* ``` | ||
*/ | ||
export declare const setSessionId: (sessionId: number) => void; | ||
/** | ||
* Sets a new optOut config value. This toggles event tracking on/off. | ||
* | ||
*```typescript | ||
* // Stops tracking | ||
* setOptOut(true); | ||
* | ||
* // Starts/resumes tracking | ||
* setOptOut(false); | ||
* ``` | ||
*/ | ||
export declare const setOptOut: (optOut: boolean) => void; | ||
/** | ||
* Sets the network transport type for events. | ||
* | ||
* ```typescript | ||
* // Use Fetch API | ||
* setTransport('fetch'); | ||
* | ||
* // Use XMLHttpRequest API | ||
* setTransport('xhr'); | ||
* | ||
* // Use navigator.sendBeacon API | ||
* setTransport('beacon'); | ||
* ``` | ||
*/ | ||
export declare const setTransport: (transport: TransportType) => void; | ||
/** | ||
* Flush and send all the events which haven't been sent. | ||
* | ||
*```typescript | ||
* // Send all the unsent events | ||
* flush(); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* await flush().promise; | ||
* ``` | ||
*/ | ||
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
export declare const createInstance: () => BrowserClient; | ||
declare const _default: BrowserClient; | ||
export default _default; | ||
//# sourceMappingURL=browser-client.d.ts.map |
import { __assign, __awaiter, __extends, __generator } from "tslib"; | ||
import { AmplitudeCore, Destination, Identify, Revenue, returnWrapper, UUID } from '@amplitude/analytics-core'; | ||
import { AmplitudeCore, Destination, Identify, Revenue, UUID, returnWrapper } from '@amplitude/analytics-core'; | ||
import { convertProxyObjectToRealObject, isInstanceProxy } from './utils/snippet-helper'; | ||
@@ -22,3 +22,9 @@ import { Context } from './plugins/context'; | ||
switch (_d.label) { | ||
case 0: return [4 /*yield*/, parseOldCookies(apiKey, options)]; | ||
case 0: | ||
// Step 0: Block concurrent initialization | ||
if (this.initializing) { | ||
return [2 /*return*/]; | ||
} | ||
this.initializing = true; | ||
return [4 /*yield*/, parseOldCookies(apiKey, options)]; | ||
case 1: | ||
@@ -62,2 +68,3 @@ oldCookies = _d.sent(); | ||
_d.sent(); | ||
this.initializing = false; | ||
// Step 5: Set timeline ready for processing events | ||
@@ -172,207 +179,27 @@ // Send existing events, which might be collected by track before init | ||
export { AmplitudeBrowser }; | ||
var client = new AmplitudeBrowser(); | ||
/** | ||
* Initializes the Amplitude SDK with your apiKey, userId and optional configurations. | ||
* This method must be called before any other operations. | ||
* | ||
* ```typescript | ||
* await init(API_KEY, USER_ID, options).promise; | ||
* ``` | ||
*/ | ||
export var init = returnWrapper(client.init.bind(client)); | ||
/** | ||
* Adds a new plugin. | ||
* | ||
* ```typescript | ||
* const plugin = {...}; | ||
* amplitude.add(plugin); | ||
* ``` | ||
*/ | ||
export var add = returnWrapper(client.add.bind(client)); | ||
/** | ||
* Removes a plugin. | ||
* | ||
* ```typescript | ||
* amplitude.remove('myPlugin'); | ||
* ``` | ||
*/ | ||
export var remove = returnWrapper(client.remove.bind(client)); | ||
/** | ||
* Tracks user-defined event, with specified type, optional event properties and optional overwrites. | ||
* | ||
* ```typescript | ||
* // event tracking with event type only | ||
* track('Page Load'); | ||
* | ||
* // event tracking with event type and additional event properties | ||
* track('Page Load', { loadTime: 1000 }); | ||
* | ||
* // event tracking with event type, additional event properties, and overwritten event options | ||
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 }); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await track('Page Load').promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export var track = returnWrapper(client.track.bind(client)); | ||
/** | ||
* Alias for track() | ||
*/ | ||
export var logEvent = returnWrapper(client.logEvent.bind(client)); | ||
/** | ||
* Sends an identify event containing user property operations | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('colors', ['rose', 'gold']); | ||
* identify(id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await identify(id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export var identify = returnWrapper(client.identify.bind(client)); | ||
/** | ||
* Sends a group identify event containing group property operations. | ||
* | ||
* ```typescript | ||
* const id = new Identify(); | ||
* id.set('skills', ['js', 'ts']); | ||
* const groupType = 'org'; | ||
* const groupName = 'engineering'; | ||
* groupIdentify(groupType, groupName, id); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await groupIdentify(groupType, groupName, id).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export var groupIdentify = returnWrapper(client.groupIdentify.bind(client)); | ||
export var setGroup = returnWrapper(client.setGroup.bind(client)); | ||
/** | ||
* Sends a revenue event containing revenue property operations. | ||
* | ||
* ```typescript | ||
* const rev = new Revenue(); | ||
* rev.setRevenue(100); | ||
* revenue(rev); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* const result = await revenue(rev).promise; | ||
* console.log(result.event); // {...} | ||
* console.log(result.code); // 200 | ||
* console.log(result.message); // "Event tracked successfully" | ||
* ``` | ||
*/ | ||
export var revenue = returnWrapper(client.revenue.bind(client)); | ||
/** | ||
* Returns current user ID. | ||
* | ||
* ```typescript | ||
* const userId = getUserId(); | ||
* ``` | ||
*/ | ||
export var getUserId = client.getUserId.bind(client); | ||
/** | ||
* Sets a new user ID. | ||
* | ||
* ```typescript | ||
* setUserId('userId'); | ||
* ``` | ||
*/ | ||
export var setUserId = client.setUserId.bind(client); | ||
/** | ||
* Returns current device ID. | ||
* | ||
* ```typescript | ||
* const deviceId = getDeviceId(); | ||
* ``` | ||
*/ | ||
export var getDeviceId = client.getDeviceId.bind(client); | ||
/** | ||
* Sets a new device ID. | ||
* When setting a custom device ID, make sure the value is sufficiently unique. | ||
* A uuid is recommended. | ||
* | ||
* ```typescript | ||
* setDeviceId('deviceId'); | ||
* ``` | ||
*/ | ||
export var setDeviceId = client.setDeviceId.bind(client); | ||
/** | ||
* reset is a shortcut to anonymize users after they log out, by: | ||
* - setting userId to `undefined` | ||
* - regenerating a new random deviceId | ||
* | ||
* With an `undefined` userId and a completely new deviceId, the current user would appear as a brand new user in dashboard. | ||
* | ||
* ```typescript | ||
* reset(); | ||
* ``` | ||
*/ | ||
export var reset = client.reset.bind(client); | ||
/** | ||
* Returns current session ID. | ||
* | ||
* ```typescript | ||
* const sessionId = getSessionId(); | ||
* ``` | ||
*/ | ||
export var getSessionId = client.getSessionId.bind(client); | ||
/** | ||
* Sets a new session ID. | ||
* When settign a custom session ID, make sure the value is in milliseconds since epoch (Unix Timestamp). | ||
* | ||
* ```typescript | ||
* setSessionId(Date.now()); | ||
* ``` | ||
*/ | ||
export var setSessionId = client.setSessionId.bind(client); | ||
/** | ||
* Sets a new optOut config value. This toggles event tracking on/off. | ||
* | ||
*```typescript | ||
* // Stops tracking | ||
* setOptOut(true); | ||
* | ||
* // Starts/resumes tracking | ||
* setOptOut(false); | ||
* ``` | ||
*/ | ||
export var setOptOut = client.setOptOut.bind(client); | ||
/** | ||
* Sets the network transport type for events. | ||
* | ||
* ```typescript | ||
* // Use Fetch API | ||
* setTransport('fetch'); | ||
* | ||
* // Use XMLHttpRequest API | ||
* setTransport('xhr'); | ||
* | ||
* // Use navigator.sendBeacon API | ||
* setTransport('beacon'); | ||
* ``` | ||
*/ | ||
export var setTransport = client.setTransport.bind(client); | ||
/** | ||
* Flush and send all the events which haven't been sent. | ||
* | ||
*```typescript | ||
* // Send all the unsent events | ||
* flush(); | ||
* | ||
* // alternatively, this tracking method is awaitable | ||
* await flush().promise; | ||
* ``` | ||
*/ | ||
export var flush = returnWrapper(client.flush.bind(client)); | ||
export var createInstance = function () { | ||
var client = new AmplitudeBrowser(); | ||
return { | ||
init: returnWrapper(client.init.bind(client)), | ||
add: returnWrapper(client.add.bind(client)), | ||
remove: returnWrapper(client.remove.bind(client)), | ||
track: returnWrapper(client.track.bind(client)), | ||
logEvent: returnWrapper(client.logEvent.bind(client)), | ||
identify: returnWrapper(client.identify.bind(client)), | ||
groupIdentify: returnWrapper(client.groupIdentify.bind(client)), | ||
setGroup: returnWrapper(client.setGroup.bind(client)), | ||
revenue: returnWrapper(client.revenue.bind(client)), | ||
flush: returnWrapper(client.flush.bind(client)), | ||
getUserId: client.getUserId.bind(client), | ||
setUserId: client.setUserId.bind(client), | ||
getDeviceId: client.getDeviceId.bind(client), | ||
setDeviceId: client.setDeviceId.bind(client), | ||
reset: client.reset.bind(client), | ||
getSessionId: client.getSessionId.bind(client), | ||
setSessionId: client.setSessionId.bind(client), | ||
setOptOut: client.setOptOut.bind(client), | ||
setTransport: client.setTransport.bind(client), | ||
}; | ||
}; | ||
export default createInstance(); | ||
//# sourceMappingURL=browser-client.js.map |
@@ -17,17 +17,3 @@ import { Event, BrowserOptions, BrowserConfig as IBrowserConfig, Storage, TrackingOptions, TransportType, UserSession, SessionManager as ISessionManager } from '@amplitude/analytics-types'; | ||
storageProvider: MemoryStorage<Event[]>; | ||
trackingOptions: { | ||
city: boolean; | ||
country: boolean; | ||
carrier: boolean; | ||
deviceManufacturer: boolean; | ||
deviceModel: boolean; | ||
dma: boolean; | ||
ipAddress: boolean; | ||
language: boolean; | ||
osName: boolean; | ||
osVersion: boolean; | ||
platform: boolean; | ||
region: boolean; | ||
versionName: boolean; | ||
}; | ||
trackingOptions: Required<TrackingOptions>; | ||
transportProvider: FetchTransport; | ||
@@ -70,17 +56,3 @@ }; | ||
storageProvider: MemoryStorage<Event[]>; | ||
trackingOptions: { | ||
city: boolean; | ||
country: boolean; | ||
carrier: boolean; | ||
deviceManufacturer: boolean; | ||
deviceModel: boolean; | ||
dma: boolean; | ||
ipAddress: boolean; | ||
language: boolean; | ||
osName: boolean; | ||
osVersion: boolean; | ||
platform: boolean; | ||
region: boolean; | ||
versionName: boolean; | ||
}; | ||
trackingOptions: Required<TrackingOptions>; | ||
transportProvider: FetchTransport; | ||
@@ -87,0 +59,0 @@ }) => Promise<Storage<UserSession>>; |
@@ -14,2 +14,11 @@ import { __assign, __awaiter, __extends, __generator, __values } from "tslib"; | ||
var cookieStorage = new MemoryStorage(); | ||
var trackingOptions = { | ||
deviceManufacturer: true, | ||
deviceModel: true, | ||
ipAddress: true, | ||
language: true, | ||
osName: true, | ||
osVersion: true, | ||
platform: true, | ||
}; | ||
return { | ||
@@ -25,17 +34,3 @@ cookieExpiration: 365, | ||
storageProvider: new MemoryStorage(), | ||
trackingOptions: { | ||
city: true, | ||
country: true, | ||
carrier: true, | ||
deviceManufacturer: true, | ||
deviceModel: true, | ||
dma: true, | ||
ipAddress: true, | ||
language: true, | ||
osName: true, | ||
osVersion: true, | ||
platform: true, | ||
region: true, | ||
versionName: true, | ||
}, | ||
trackingOptions: trackingOptions, | ||
transportProvider: new FetchTransport(), | ||
@@ -42,0 +37,0 @@ }; |
@@ -1,2 +0,3 @@ | ||
export { add, flush, getDeviceId, getSessionId, getUserId, groupIdentify, identify, init, logEvent, remove, reset, revenue, setDeviceId, setGroup, setOptOut, setSessionId, setTransport, setUserId, track, } from './browser-client'; | ||
export { createInstance } from './browser-client'; | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>, flush: () => import("@amplitude/analytics-types").AmplitudeReturn<void>, getDeviceId: () => string | undefined, getSessionId: () => number | undefined, getUserId: () => string | undefined, groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, identify: (identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, init: (apiKey: string, userId?: string | undefined, options?: import("@amplitude/analytics-types").BrowserOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>, logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>, reset: () => void, revenue: (revenue: import("@amplitude/analytics-types").Revenue, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setDeviceId: (deviceId: string) => void, setGroup: (groupType: string, groupName: string | string[], eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setOptOut: (optOut: boolean) => void, setSessionId: (sessionId: number) => void, setTransport: (transport: import("@amplitude/analytics-types").TransportType) => void, setUserId: (userId: string) => void, track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>; | ||
export { runQueuedFunctions } from './utils/snippet-helper'; | ||
@@ -3,0 +4,0 @@ export { Revenue, Identify } from '@amplitude/analytics-core'; |
@@ -1,2 +0,5 @@ | ||
export { add, flush, getDeviceId, getSessionId, getUserId, groupIdentify, identify, init, logEvent, remove, reset, revenue, setDeviceId, setGroup, setOptOut, setSessionId, setTransport, setUserId, track, } from './browser-client'; | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
import client from './browser-client'; | ||
export { createInstance } from './browser-client'; | ||
export var add = client.add, flush = client.flush, getDeviceId = client.getDeviceId, getSessionId = client.getSessionId, getUserId = client.getUserId, groupIdentify = client.groupIdentify, identify = client.identify, init = client.init, logEvent = client.logEvent, remove = client.remove, reset = client.reset, revenue = client.revenue, setDeviceId = client.setDeviceId, setGroup = client.setGroup, setOptOut = client.setOptOut, setSessionId = client.setSessionId, setTransport = client.setTransport, setUserId = client.setUserId, track = client.track; | ||
export { runQueuedFunctions } from './utils/snippet-helper'; | ||
@@ -3,0 +6,0 @@ export { Revenue, Identify } from '@amplitude/analytics-core'; |
@@ -8,3 +8,9 @@ import * as amplitude from './index'; | ||
runQueuedFunctions(amplitude, queue); | ||
for (var i = 0; i < globalThis.amplitude._iq.length; i++) { | ||
var instance = Object.assign(globalThis.amplitude._iq[i], amplitude.createInstance()); | ||
var queue_1 = instance._q; | ||
instance._q = []; | ||
runQueuedFunctions(instance, queue_1); | ||
} | ||
} | ||
//# sourceMappingURL=snippet-index.js.map |
export declare const getQueryParams: () => Record<string, string | undefined>; | ||
export declare const tryDecodeURIComponent: (value?: string) => string; | ||
//# sourceMappingURL=query-params.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { __read } from "tslib"; | ||
export var getQueryParams = function () { | ||
@@ -9,7 +8,9 @@ /* istanbul ignore if */ | ||
var params = pairs.reduce(function (acc, curr) { | ||
var _a = __read(curr.split('=', 2), 2), key = _a[0], _b = _a[1], value = _b === void 0 ? '' : _b; | ||
var query = curr.split('=', 2); | ||
var key = tryDecodeURIComponent(query[0]); | ||
var value = tryDecodeURIComponent(query[1]); | ||
if (!value) { | ||
return acc; | ||
} | ||
acc[decodeURIComponent(key)] = decodeURIComponent(value); | ||
acc[key] = value; | ||
return acc; | ||
@@ -19,2 +20,11 @@ }, {}); | ||
}; | ||
export var tryDecodeURIComponent = function (value) { | ||
if (value === void 0) { value = ''; } | ||
try { | ||
return decodeURIComponent(value); | ||
} | ||
catch (_a) { | ||
return ''; | ||
} | ||
}; | ||
//# sourceMappingURL=query-params.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "1.1.5"; | ||
export declare const VERSION = "1.2.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export var VERSION = '1.1.5'; | ||
export var VERSION = '1.2.0'; | ||
//# 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-7ApSW/NaTIeN9HSgvraZZ/yPDhGmggsAlm2vNAxPIzh/GJp5kBjcBo1RiPjGeGtR",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-1.1.5-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 g(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)}g(r),e.amplitude=r}}(window,document)}(); | ||
!function(){"use strict";!function(e,t){var n=e.amplitude||{_q:[],_iq:[]};if(n.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{n.invoked=!0;var r=t.createElement("script");r.type="text/javascript",r.integrity="sha384-Y4XyoQjvRukDBVnBbXqJPNh2s443JCBG79sung/JWWUc5u3w5iWdPqUAY1EL461g",r.crossOrigin="anonymous",r.async=!0,r.src="https://cdn.amplitude.com/libs/analytics-browser-1.2.0-min.js.gz",r.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(r,s);for(var o=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],u=0;u<i.length;u++)v(o,i[u]);n.Identify=o;for(var a=function(){return this._q=[],this},c=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<c.length;p++)v(a,c[p]);n.Revenue=a;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,n){e[t]=function(){var r={promise:new Promise((n=>{e._q.push({name:t,args:Array.prototype.slice.call(arguments,0),resolve:n})}))};if(n)return r}}for(var n=0;n<d.length;n++)t(d[n],!1);for(var r=0;r<l.length;r++)t(l[r],!0)}f(n),n.createInstance=function(){var e=n._iq.push({_q:[]})-1;return f(n._iq[e]),n._iq[e]},e.amplitude=n}}(window,document)}(); |
{ | ||
"name": "@amplitude/analytics-browser", | ||
"version": "1.1.5", | ||
"version": "1.2.0", | ||
"description": "Official Amplitude SDK for Web", | ||
@@ -45,4 +45,4 @@ "keywords": [ | ||
"@amplitude/analytics-connector": "^1.4.5", | ||
"@amplitude/analytics-core": "^0.7.0", | ||
"@amplitude/analytics-types": "^0.7.0", | ||
"@amplitude/analytics-core": "^0.8.0", | ||
"@amplitude/analytics-types": "^0.8.0", | ||
"@amplitude/ua-parser-js": "^0.7.31", | ||
@@ -66,3 +66,3 @@ "tslib": "^2.3.1" | ||
], | ||
"gitHead": "d71a39cd63930ee604f0df293767692c09ab54f5" | ||
"gitHead": "c701a2b7ada6c8817bf28894f4d68cfa5dd0c403" | ||
} |
@@ -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-7ApSW/NaTIeN9HSgvraZZ/yPDhGmggsAlm2vNAxPIzh/GJp5kBjcBo1RiPjGeGtR",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-1.1.5-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 g(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)}g(r),e.amplitude=r}}(window,document)}(); | ||
!function(){"use strict";!function(e,t){var n=e.amplitude||{_q:[],_iq:[]};if(n.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{n.invoked=!0;var r=t.createElement("script");r.type="text/javascript",r.integrity="sha384-Y4XyoQjvRukDBVnBbXqJPNh2s443JCBG79sung/JWWUc5u3w5iWdPqUAY1EL461g",r.crossOrigin="anonymous",r.async=!0,r.src="https://cdn.amplitude.com/libs/analytics-browser-1.2.0-min.js.gz",r.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(r,s);for(var o=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],u=0;u<i.length;u++)v(o,i[u]);n.Identify=o;for(var a=function(){return this._q=[],this},c=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<c.length;p++)v(a,c[p]);n.Revenue=a;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,n){e[t]=function(){var r={promise:new Promise((n=>{e._q.push({name:t,args:Array.prototype.slice.call(arguments,0),resolve:n})}))};if(n)return r}}for(var n=0;n<d.length;n++)t(d[n],!1);for(var r=0;r<l.length;r++)t(l[r],!0)}f(n),n.createInstance=function(){var e=n._iq.push({_q:[]})-1;return f(n._iq[e]),n._iq[e]},e.amplitude=n}}(window,document)}(); | ||
@@ -38,0 +38,0 @@ amplitude.init("YOUR_API_KEY_HERE"); |
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 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 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 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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
569630
4249
10
+ Added@amplitude/analytics-core@0.8.1(transitive)
+ Added@amplitude/analytics-types@0.8.1(transitive)
- Removed@amplitude/analytics-core@0.7.0(transitive)
- Removed@amplitude/analytics-types@0.7.0(transitive)