@amplitude/analytics-core 2.38.0 → 2.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/core-client.d.ts +9 -1
- package/lib/cjs/core-client.d.ts.map +1 -1
- package/lib/cjs/core-client.js +15 -5
- package/lib/cjs/core-client.js.map +1 -1
- package/lib/cjs/diagnostics/uncaught-sdk-errors.d.ts.map +1 -1
- package/lib/cjs/diagnostics/uncaught-sdk-errors.js +42 -12
- package/lib/cjs/diagnostics/uncaught-sdk-errors.js.map +1 -1
- package/lib/cjs/index.d.ts +5 -0
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +13 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/messenger/background-capture.d.ts +13 -0
- package/lib/cjs/messenger/background-capture.d.ts.map +1 -0
- package/lib/cjs/messenger/background-capture.js +64 -0
- package/lib/cjs/messenger/background-capture.js.map +1 -0
- package/lib/cjs/messenger/base-window-messenger.d.ts +100 -0
- package/lib/cjs/messenger/base-window-messenger.d.ts.map +1 -0
- package/lib/cjs/messenger/base-window-messenger.js +261 -0
- package/lib/cjs/messenger/base-window-messenger.js.map +1 -0
- package/lib/cjs/messenger/constants.d.ts +6 -0
- package/lib/cjs/messenger/constants.d.ts.map +1 -0
- package/lib/cjs/messenger/constants.js +15 -0
- package/lib/cjs/messenger/constants.js.map +1 -0
- package/lib/cjs/messenger/utils.d.ts +12 -0
- package/lib/cjs/messenger/utils.d.ts.map +1 -0
- package/lib/cjs/messenger/utils.js +48 -0
- package/lib/cjs/messenger/utils.js.map +1 -0
- package/lib/cjs/observers/network.d.ts.map +1 -1
- package/lib/cjs/observers/network.js +58 -39
- package/lib/cjs/observers/network.js.map +1 -1
- package/lib/cjs/storage/cookie.d.ts +0 -1
- package/lib/cjs/storage/cookie.d.ts.map +1 -1
- package/lib/cjs/storage/cookie.js +4 -4
- package/lib/cjs/storage/cookie.js.map +1 -1
- package/lib/cjs/types/client/browser-client.d.ts +33 -0
- package/lib/cjs/types/client/browser-client.d.ts.map +1 -1
- package/lib/cjs/types/client/browser-client.js.map +1 -1
- package/lib/cjs/types/element-interactions.d.ts +0 -1
- package/lib/cjs/types/element-interactions.d.ts.map +1 -1
- package/lib/cjs/types/element-interactions.js.map +1 -1
- package/lib/cjs/utils/safe-stringify.d.ts +4 -0
- package/lib/cjs/utils/safe-stringify.d.ts.map +1 -0
- package/lib/cjs/utils/safe-stringify.js +9 -0
- package/lib/cjs/utils/safe-stringify.js.map +1 -0
- package/lib/esm/core-client.d.ts +9 -1
- package/lib/esm/core-client.d.ts.map +1 -1
- package/lib/esm/core-client.js +16 -6
- package/lib/esm/core-client.js.map +1 -1
- package/lib/esm/diagnostics/uncaught-sdk-errors.d.ts.map +1 -1
- package/lib/esm/diagnostics/uncaught-sdk-errors.js +43 -13
- package/lib/esm/diagnostics/uncaught-sdk-errors.js.map +1 -1
- package/lib/esm/index.d.ts +5 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/messenger/background-capture.d.ts +13 -0
- package/lib/esm/messenger/background-capture.d.ts.map +1 -0
- package/lib/esm/messenger/background-capture.js +60 -0
- package/lib/esm/messenger/background-capture.js.map +1 -0
- package/lib/esm/messenger/base-window-messenger.d.ts +100 -0
- package/lib/esm/messenger/base-window-messenger.d.ts.map +1 -0
- package/lib/esm/messenger/base-window-messenger.js +257 -0
- package/lib/esm/messenger/base-window-messenger.js.map +1 -0
- package/lib/esm/messenger/constants.d.ts +6 -0
- package/lib/esm/messenger/constants.d.ts.map +1 -0
- package/lib/esm/messenger/constants.js +12 -0
- package/lib/esm/messenger/constants.js.map +1 -0
- package/lib/esm/messenger/utils.d.ts +12 -0
- package/lib/esm/messenger/utils.d.ts.map +1 -0
- package/lib/esm/messenger/utils.js +43 -0
- package/lib/esm/messenger/utils.js.map +1 -0
- package/lib/esm/observers/network.d.ts.map +1 -1
- package/lib/esm/observers/network.js +58 -39
- package/lib/esm/observers/network.js.map +1 -1
- package/lib/esm/storage/cookie.d.ts +0 -1
- package/lib/esm/storage/cookie.d.ts.map +1 -1
- package/lib/esm/storage/cookie.js +4 -4
- package/lib/esm/storage/cookie.js.map +1 -1
- package/lib/esm/types/client/browser-client.d.ts +33 -0
- package/lib/esm/types/client/browser-client.d.ts.map +1 -1
- package/lib/esm/types/client/browser-client.js.map +1 -1
- package/lib/esm/types/element-interactions.d.ts +0 -1
- package/lib/esm/types/element-interactions.d.ts.map +1 -1
- package/lib/esm/types/element-interactions.js.map +1 -1
- package/lib/esm/utils/safe-stringify.d.ts +4 -0
- package/lib/esm/utils/safe-stringify.d.ts.map +1 -0
- package/lib/esm/utils/safe-stringify.js +6 -0
- package/lib/esm/utils/safe-stringify.js.map +1 -0
- package/package.json +5 -1
package/lib/cjs/core-client.d.ts
CHANGED
|
@@ -16,6 +16,13 @@ export declare class AmplitudeCore implements CoreClient, PluginHost {
|
|
|
16
16
|
isReady: boolean;
|
|
17
17
|
protected q: Array<CallableFunction | typeof returnWrapper>;
|
|
18
18
|
protected dispatchQ: Array<CallableFunction>;
|
|
19
|
+
/**
|
|
20
|
+
* Current user properties (operation-applied, flat key-value).
|
|
21
|
+
* Only used by client-side SDKs; server SDKs may leave this undefined.
|
|
22
|
+
*/
|
|
23
|
+
userProperties: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
} | undefined;
|
|
19
26
|
constructor(name?: string);
|
|
20
27
|
protected _init(config: IConfig): Promise<void>;
|
|
21
28
|
runQueuedFunctions(queueName: 'q' | 'dispatchQ'): Promise<void>;
|
|
@@ -39,8 +46,9 @@ export declare class AmplitudeCore implements CoreClient, PluginHost {
|
|
|
39
46
|
* This is a best-effort api that only supports $set, $clearAll, and $unset.
|
|
40
47
|
* Other operations are not supported and are ignored.
|
|
41
48
|
*
|
|
49
|
+
* Operations are applied on top of current client state (this.userProperties).
|
|
42
50
|
*
|
|
43
|
-
* @param userProperties The
|
|
51
|
+
* @param userProperties The new user properties object from identify() or setIdentity().
|
|
44
52
|
* @returns A key-value object user properties without operations.
|
|
45
53
|
*
|
|
46
54
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-client.d.ts","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EACL,KAAK,EAIL,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAA6B,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACpE,qBAAa,aAAc,YAAW,UAAU,EAAE,UAAU;IAC1D,SAAS,CAAC,YAAY,UAAS;IAC/B,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;IAGvB,MAAM,EAAE,OAAO,CAAC;IAGhB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,UAAS;IAChB,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,gBAAgB,GAAG,OAAO,aAAa,CAAC,CAAM;IACjE,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAM;
|
|
1
|
+
{"version":3,"file":"core-client.d.ts","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,O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,CAAA;KAAE,GAAG,CAAC,EAAE;CAGzE"}
|
package/lib/cjs/core-client.js
CHANGED
|
@@ -91,10 +91,14 @@ var AmplitudeCore = /** @class */ (function () {
|
|
|
91
91
|
};
|
|
92
92
|
AmplitudeCore.prototype.track = function (eventInput, eventProperties, eventOptions) {
|
|
93
93
|
var event = (0, event_builder_1.createTrackEvent)(eventInput, eventProperties, eventOptions);
|
|
94
|
+
// Update client user properties immediately and synchronously
|
|
95
|
+
this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);
|
|
94
96
|
return (0, return_wrapper_1.returnWrapper)(this.dispatch(event));
|
|
95
97
|
};
|
|
96
98
|
AmplitudeCore.prototype.identify = function (identify, eventOptions) {
|
|
97
99
|
var event = (0, event_builder_1.createIdentifyEvent)(identify, eventOptions);
|
|
100
|
+
// Update client user properties immediately and synchronously
|
|
101
|
+
this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);
|
|
98
102
|
return (0, return_wrapper_1.returnWrapper)(this.dispatch(event));
|
|
99
103
|
};
|
|
100
104
|
AmplitudeCore.prototype.groupIdentify = function (groupType, groupName, identify, eventOptions) {
|
|
@@ -103,6 +107,8 @@ var AmplitudeCore = /** @class */ (function () {
|
|
|
103
107
|
};
|
|
104
108
|
AmplitudeCore.prototype.setGroup = function (groupType, groupName, eventOptions) {
|
|
105
109
|
var event = (0, event_builder_1.createGroupEvent)(groupType, groupName, eventOptions);
|
|
110
|
+
// Update client user properties immediately and synchronously
|
|
111
|
+
this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);
|
|
106
112
|
return (0, return_wrapper_1.returnWrapper)(this.dispatch(event));
|
|
107
113
|
};
|
|
108
114
|
AmplitudeCore.prototype.revenue = function (revenue, eventOptions) {
|
|
@@ -156,8 +162,9 @@ var AmplitudeCore = /** @class */ (function () {
|
|
|
156
162
|
* This is a best-effort api that only supports $set, $clearAll, and $unset.
|
|
157
163
|
* Other operations are not supported and are ignored.
|
|
158
164
|
*
|
|
165
|
+
* Operations are applied on top of current client state (this.userProperties).
|
|
159
166
|
*
|
|
160
|
-
* @param userProperties The
|
|
167
|
+
* @param userProperties The new user properties object from identify() or setIdentity().
|
|
161
168
|
* @returns A key-value object user properties without operations.
|
|
162
169
|
*
|
|
163
170
|
* @example
|
|
@@ -174,7 +181,9 @@ var AmplitudeCore = /** @class */ (function () {
|
|
|
174
181
|
* }
|
|
175
182
|
*/
|
|
176
183
|
AmplitudeCore.prototype.getOperationAppliedUserProperties = function (userProperties) {
|
|
177
|
-
var
|
|
184
|
+
var _a;
|
|
185
|
+
var base = (_a = this.userProperties) !== null && _a !== void 0 ? _a : {};
|
|
186
|
+
var updatedProperties = tslib_1.__assign({}, base);
|
|
178
187
|
if (userProperties === undefined) {
|
|
179
188
|
return updatedProperties;
|
|
180
189
|
}
|
|
@@ -220,7 +229,7 @@ var AmplitudeCore = /** @class */ (function () {
|
|
|
220
229
|
};
|
|
221
230
|
AmplitudeCore.prototype.process = function (event) {
|
|
222
231
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
223
|
-
var
|
|
232
|
+
var result, e_2, message, result;
|
|
224
233
|
return tslib_1.__generator(this, function (_a) {
|
|
225
234
|
switch (_a.label) {
|
|
226
235
|
case 0:
|
|
@@ -230,8 +239,9 @@ var AmplitudeCore = /** @class */ (function () {
|
|
|
230
239
|
return [2 /*return*/, (0, result_builder_1.buildResult)(event, 0, messages_1.OPT_OUT_MESSAGE)];
|
|
231
240
|
}
|
|
232
241
|
if (event.event_type === event_1.SpecialEventType.IDENTIFY) {
|
|
233
|
-
|
|
234
|
-
|
|
242
|
+
// Do not update this.userProperties here.
|
|
243
|
+
// It is only set synchronously in identify() or setIdentity()
|
|
244
|
+
this.timeline.onIdentityChanged({ userProperties: this.userProperties });
|
|
235
245
|
}
|
|
236
246
|
return [4 /*yield*/, this.timeline.push(event)];
|
|
237
247
|
case 1:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-client.js","sourceRoot":"","sources":["../../src/core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,GAAL;QACE,OAAO,IAAA,8BAAa,EAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,8BAAM,GAAN,UAAO,IAAY;QACjB,IAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,CAAC,IAAI,KAAK,IAAI,EAApB,CAAoB,CAAC,CAAC;QAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,uCAAgC,IAAI,CAAE,CAAC,CAAC;YACzE,OAAO,SAAS,CAAC;SAClB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,+BAAO,GAAP,UAA0B,WAAwC;QAChE,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,YAAY,WAAW,EAA7B,CAA6B,CAAQ,CAAC;IACxF,CAAC;IACH,oBAAC;AAAD,CAAC,AA/PD,IA+PC;AA/PY,sCAAa","sourcesContent":["import { Plugin } from './types/plugin';\nimport { IConfig } from './types/config/core-config';\nimport { BaseEvent, EventOptions } from './types/event/base-event';\nimport { Result } from './types/result';\nimport {\n Event,\n IdentifyOperation,\n IdentifyUserProperties,\n SpecialEventType,\n UserProperties,\n} from './types/event/event';\nimport { IIdentify, OrderedIdentifyOperations } from './identify';\nimport { IRevenue } from './revenue';\nimport { CLIENT_NOT_INITIALIZED, OPT_OUT_MESSAGE } from './types/messages';\nimport { Timeline } from './timeline';\nimport {\n createGroupEvent,\n createGroupIdentifyEvent,\n createIdentifyEvent,\n createRevenueEvent,\n createTrackEvent,\n} from './utils/event-builder';\nimport { buildResult } from './utils/result-builder';\nimport { returnWrapper } from './utils/return-wrapper';\nimport { CoreClient, PluginHost } from './types/client/core-client';\nexport class AmplitudeCore implements CoreClient, PluginHost {\n protected initializing = false;\n protected name: string;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: IConfig;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n timeline: Timeline;\n isReady = false;\n protected q: Array<CallableFunction | typeof returnWrapper> = [];\n protected dispatchQ: Array<CallableFunction> = [];\n\n constructor(name = '$default') {\n this.timeline = new Timeline(this);\n this.name = name;\n }\n\n protected async _init(config: IConfig) {\n this.config = config;\n this.timeline.reset(this);\n this.timeline.loggerProvider = this.config.loggerProvider;\n await this.runQueuedFunctions('q');\n this.isReady = true;\n }\n\n async runQueuedFunctions(queueName: 'q' | 'dispatchQ') {\n const queuedFunctions = this[queueName];\n this[queueName] = [];\n for (const queuedFunction of queuedFunctions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const val: ReturnType<typeof returnWrapper> | Promise<any> = queuedFunction();\n if (val && 'promise' in val) {\n await val.promise;\n } else {\n await val;\n }\n }\n // Rerun queued functions if the queue has accrued more while awaiting promises\n if (this[queueName].length) {\n await this.runQueuedFunctions(queueName);\n }\n }\n\n track(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions) {\n const event = createTrackEvent(eventInput, eventProperties, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n logEvent = this.track.bind(this);\n\n identify(identify: IIdentify, eventOptions?: EventOptions) {\n const event = createIdentifyEvent(identify, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions) {\n const event = createGroupIdentifyEvent(groupType, groupName, identify, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions) {\n const event = createGroupEvent(groupType, groupName, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n revenue(revenue: IRevenue, eventOptions?: EventOptions) {\n const event = createRevenueEvent(revenue, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n add(plugin: Plugin) {\n if (!this.isReady) {\n this.q.push(this._addPlugin.bind(this, plugin));\n return returnWrapper();\n }\n return this._addPlugin(plugin);\n }\n\n _addPlugin(plugin: Plugin) {\n return returnWrapper(this.timeline.register(plugin, this.config));\n }\n\n remove(pluginName: string) {\n if (!this.isReady) {\n this.q.push(this._removePlugin.bind(this, pluginName));\n return returnWrapper();\n }\n return this._removePlugin(pluginName);\n }\n\n _removePlugin(pluginName: string) {\n return returnWrapper(this.timeline.deregister(pluginName, this.config));\n }\n\n dispatchWithCallback(event: Event, callback: (result: Result) => void): void {\n if (!this.isReady) {\n return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED));\n }\n void this.process(event).then(callback);\n }\n\n async dispatch(event: Event): Promise<Result> {\n if (!this.isReady) {\n return new Promise<Result>((resolve) => {\n this.dispatchQ.push(this.dispatchWithCallback.bind(this, event, resolve));\n });\n }\n\n return this.process(event);\n }\n\n /**\n *\n * This method applies identify operations to user properties and\n * returns a single object representing the final user property state.\n *\n * This is a best-effort api that only supports $set, $clearAll, and $unset.\n * Other operations are not supported and are ignored.\n *\n *\n * @param userProperties The `event.userProperties` object from an Identify event.\n * @returns A key-value object user properties without operations.\n *\n * @example\n * Input:\n * {\n * $set: { plan: 'premium' },\n * custom_flag: true\n * }\n *\n * Output:\n * {\n * plan: 'premium',\n * custom_flag: true\n * }\n */\n getOperationAppliedUserProperties(userProperties: UserProperties | undefined): { [key: string]: any } {\n const updatedProperties: { [key: string]: any } = {};\n\n if (userProperties === undefined) {\n return updatedProperties;\n }\n\n // Keep non-operation keys for later merge\n const nonOpProperties: {\n [key in Exclude<string, IdentifyOperation>]: any;\n } = {};\n Object.keys(userProperties).forEach((key) => {\n if (!Object.values(IdentifyOperation).includes(key as IdentifyOperation)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n nonOpProperties[key] = userProperties[key];\n }\n });\n\n OrderedIdentifyOperations.forEach((operation) => {\n // Skip when key is an operation.\n if (!Object.keys(userProperties).includes(operation)) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const opProperties: IdentifyUserProperties = userProperties[operation];\n\n switch (operation) {\n case IdentifyOperation.CLEAR_ALL:\n // Due to operation order, the following line will never execute.\n /* istanbul ignore next */\n Object.keys(updatedProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.UNSET:\n Object.keys(opProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.SET:\n Object.assign(updatedProperties, opProperties);\n break;\n }\n });\n\n // Merge non-operation properties.\n // Custom properties should not be affected by operations.\n // https://github.com/amplitude/nova/blob/343f678ded83c032e83b189796b3c2be161b48f5/src/main/java/com/amplitude/userproperty/model/ModifyUserPropertiesIdent.java#L79-L83\n Object.assign(updatedProperties, nonOpProperties);\n\n return updatedProperties;\n }\n\n async process(event: Event): Promise<Result> {\n try {\n // skip event processing if opt out\n if (this.config.optOut) {\n return buildResult(event, 0, OPT_OUT_MESSAGE);\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY) {\n const userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n this.timeline.onIdentityChanged({ userProperties: userProperties });\n }\n\n const result = await this.timeline.push(event);\n\n result.code === 200\n ? this.config.loggerProvider.log(result.message)\n : result.code === 100\n ? this.config.loggerProvider.warn(result.message)\n : this.config.loggerProvider.error(result.message);\n\n return result;\n } catch (e) {\n const message = String(e);\n this.config.loggerProvider.error(message);\n const result = buildResult(event, 0, message);\n\n return result;\n }\n }\n\n setOptOut(optOut: boolean) {\n if (!this.isReady) {\n this.q.push(this._setOptOut.bind(this, Boolean(optOut)));\n return;\n }\n this._setOptOut(optOut);\n }\n\n _setOptOut(optOut: boolean) {\n if (this.config.optOut !== optOut) {\n this.config.optOut = Boolean(optOut);\n this.timeline.onOptOutChanged(optOut);\n }\n }\n\n flush() {\n return returnWrapper(this.timeline.flush());\n }\n\n plugin(name: string): Plugin | undefined {\n const plugin = this.timeline.plugins.find((plugin) => plugin.name === name);\n if (plugin === undefined) {\n this.config.loggerProvider.debug(`Cannot find plugin with name ${name}`);\n return undefined;\n }\n\n return plugin;\n }\n\n plugins<T extends Plugin>(pluginClass: { new (...args: any[]): T }): T[] {\n return this.timeline.plugins.filter((plugin) => plugin instanceof pluginClass) as T[];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"core-client.js","sourceRoot":"","sources":["../../src/core-client.ts"],"names":[],"mappings":";;;;AAIA,6CAM6B;AAC7B,uCAAkE;AAElE,6CAA2E;AAC3E,uCAAsC;AACtC,uDAM+B;AAC/B,yDAAqD;AACrD,yDAAuD;AAEvD;IAmBE,uBAAY,IAAiB;QAAjB,qBAAA,EAAA,iBAAiB;QAlBnB,iBAAY,GAAG,KAAK,CAAC;QAQ/B,YAAO,GAAG,KAAK,CAAC;QACN,MAAC,GAAmD,EAAE,CAAC;QACvD,cAAS,GAA4B,EAAE,CAAC;QAgDlD,aAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAvC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEe,6BAAK,GAArB,UAAsB,MAAe;;;;;wBACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;wBACrB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;wBAC1B,IAAI,CAAC,QAAQ,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;wBAC1D,qBAAM,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAA;;wBAAlC,SAAkC,CAAC;wBACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;;;;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AO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAC,MAAM,IAAK,OAAA,MAAM,YAAY,WAAW,EAA7B,CAA6B,CAAQ,CAAC;IACxF,CAAC;IACH,oBAAC;AAAD,CAAC,AA9QD,IA8QC;AA9QY,sCAAa","sourcesContent":["import { Plugin } from './types/plugin';\nimport { IConfig } from './types/config/core-config';\nimport { BaseEvent, EventOptions } from './types/event/base-event';\nimport { Result } from './types/result';\nimport {\n Event,\n IdentifyOperation,\n IdentifyUserProperties,\n SpecialEventType,\n UserProperties,\n} from './types/event/event';\nimport { IIdentify, OrderedIdentifyOperations } from './identify';\nimport { IRevenue } from './revenue';\nimport { CLIENT_NOT_INITIALIZED, OPT_OUT_MESSAGE } from './types/messages';\nimport { Timeline } from './timeline';\nimport {\n createGroupEvent,\n createGroupIdentifyEvent,\n createIdentifyEvent,\n createRevenueEvent,\n createTrackEvent,\n} from './utils/event-builder';\nimport { buildResult } from './utils/result-builder';\nimport { returnWrapper } from './utils/return-wrapper';\nimport { CoreClient, PluginHost } from './types/client/core-client';\nexport class AmplitudeCore implements CoreClient, PluginHost {\n protected initializing = false;\n protected name: string;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: IConfig;\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n timeline: Timeline;\n isReady = false;\n protected q: Array<CallableFunction | typeof returnWrapper> = [];\n protected dispatchQ: Array<CallableFunction> = [];\n\n /**\n * Current user properties (operation-applied, flat key-value).\n * Only used by client-side SDKs; server SDKs may leave this undefined.\n */\n userProperties: { [key: string]: any } | undefined;\n\n constructor(name = '$default') {\n this.timeline = new Timeline(this);\n this.name = name;\n }\n\n protected async _init(config: IConfig) {\n this.config = config;\n this.timeline.reset(this);\n this.timeline.loggerProvider = this.config.loggerProvider;\n await this.runQueuedFunctions('q');\n this.isReady = true;\n }\n\n async runQueuedFunctions(queueName: 'q' | 'dispatchQ') {\n const queuedFunctions = this[queueName];\n this[queueName] = [];\n for (const queuedFunction of queuedFunctions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const val: ReturnType<typeof returnWrapper> | Promise<any> = queuedFunction();\n if (val && 'promise' in val) {\n await val.promise;\n } else {\n await val;\n }\n }\n // Rerun queued functions if the queue has accrued more while awaiting promises\n if (this[queueName].length) {\n await this.runQueuedFunctions(queueName);\n }\n }\n\n track(eventInput: BaseEvent | string, eventProperties?: Record<string, any>, eventOptions?: EventOptions) {\n const event = createTrackEvent(eventInput, eventProperties, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n logEvent = this.track.bind(this);\n\n identify(identify: IIdentify, eventOptions?: EventOptions) {\n const event = createIdentifyEvent(identify, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions) {\n const event = createGroupIdentifyEvent(groupType, groupName, identify, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n setGroup(groupType: string, groupName: string | string[], eventOptions?: EventOptions) {\n const event = createGroupEvent(groupType, groupName, eventOptions);\n // Update client user properties immediately and synchronously\n this.userProperties = this.getOperationAppliedUserProperties(event.user_properties);\n return returnWrapper(this.dispatch(event));\n }\n\n revenue(revenue: IRevenue, eventOptions?: EventOptions) {\n const event = createRevenueEvent(revenue, eventOptions);\n return returnWrapper(this.dispatch(event));\n }\n\n add(plugin: Plugin) {\n if (!this.isReady) {\n this.q.push(this._addPlugin.bind(this, plugin));\n return returnWrapper();\n }\n return this._addPlugin(plugin);\n }\n\n _addPlugin(plugin: Plugin) {\n return returnWrapper(this.timeline.register(plugin, this.config));\n }\n\n remove(pluginName: string) {\n if (!this.isReady) {\n this.q.push(this._removePlugin.bind(this, pluginName));\n return returnWrapper();\n }\n return this._removePlugin(pluginName);\n }\n\n _removePlugin(pluginName: string) {\n return returnWrapper(this.timeline.deregister(pluginName, this.config));\n }\n\n dispatchWithCallback(event: Event, callback: (result: Result) => void): void {\n if (!this.isReady) {\n return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED));\n }\n void this.process(event).then(callback);\n }\n\n async dispatch(event: Event): Promise<Result> {\n if (!this.isReady) {\n return new Promise<Result>((resolve) => {\n this.dispatchQ.push(this.dispatchWithCallback.bind(this, event, resolve));\n });\n }\n\n return this.process(event);\n }\n\n /**\n *\n * This method applies identify operations to user properties and\n * returns a single object representing the final user property state.\n *\n * This is a best-effort api that only supports $set, $clearAll, and $unset.\n * Other operations are not supported and are ignored.\n *\n * Operations are applied on top of current client state (this.userProperties).\n *\n * @param userProperties The new user properties object from identify() or setIdentity().\n * @returns A key-value object user properties without operations.\n *\n * @example\n * Input:\n * {\n * $set: { plan: 'premium' },\n * custom_flag: true\n * }\n *\n * Output:\n * {\n * plan: 'premium',\n * custom_flag: true\n * }\n */\n getOperationAppliedUserProperties(userProperties: UserProperties | undefined): { [key: string]: any } {\n const base = this.userProperties ?? {};\n const updatedProperties: { [key: string]: any } = { ...base };\n\n if (userProperties === undefined) {\n return updatedProperties;\n }\n\n // Keep non-operation keys for later merge\n const nonOpProperties: {\n [key in Exclude<string, IdentifyOperation>]: any;\n } = {};\n Object.keys(userProperties).forEach((key) => {\n if (!Object.values(IdentifyOperation).includes(key as IdentifyOperation)) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n nonOpProperties[key] = userProperties[key];\n }\n });\n\n OrderedIdentifyOperations.forEach((operation) => {\n // Skip when key is an operation.\n if (!Object.keys(userProperties).includes(operation)) return;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const opProperties: IdentifyUserProperties = userProperties[operation];\n\n switch (operation) {\n case IdentifyOperation.CLEAR_ALL:\n // Due to operation order, the following line will never execute.\n /* istanbul ignore next */\n Object.keys(updatedProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.UNSET:\n Object.keys(opProperties).forEach((prop) => {\n delete updatedProperties[prop];\n });\n break;\n case IdentifyOperation.SET:\n Object.assign(updatedProperties, opProperties);\n break;\n }\n });\n\n // Merge non-operation properties.\n // Custom properties should not be affected by operations.\n // https://github.com/amplitude/nova/blob/343f678ded83c032e83b189796b3c2be161b48f5/src/main/java/com/amplitude/userproperty/model/ModifyUserPropertiesIdent.java#L79-L83\n Object.assign(updatedProperties, nonOpProperties);\n\n return updatedProperties;\n }\n\n async process(event: Event): Promise<Result> {\n try {\n // skip event processing if opt out\n if (this.config.optOut) {\n return buildResult(event, 0, OPT_OUT_MESSAGE);\n }\n\n if (event.event_type === SpecialEventType.IDENTIFY) {\n // Do not update this.userProperties here.\n // It is only set synchronously in identify() or setIdentity()\n this.timeline.onIdentityChanged({ userProperties: this.userProperties });\n }\n\n const result = await this.timeline.push(event);\n\n result.code === 200\n ? this.config.loggerProvider.log(result.message)\n : result.code === 100\n ? this.config.loggerProvider.warn(result.message)\n : this.config.loggerProvider.error(result.message);\n\n return result;\n } catch (e) {\n const message = String(e);\n this.config.loggerProvider.error(message);\n const result = buildResult(event, 0, message);\n\n return result;\n }\n }\n\n setOptOut(optOut: boolean) {\n if (!this.isReady) {\n this.q.push(this._setOptOut.bind(this, Boolean(optOut)));\n return;\n }\n this._setOptOut(optOut);\n }\n\n _setOptOut(optOut: boolean) {\n if (this.config.optOut !== optOut) {\n this.config.optOut = Boolean(optOut);\n this.timeline.onOptOutChanged(optOut);\n }\n }\n\n flush() {\n return returnWrapper(this.timeline.flush());\n }\n\n plugin(name: string): Plugin | undefined {\n const plugin = this.timeline.plugins.find((plugin) => plugin.name === name);\n if (plugin === undefined) {\n this.config.loggerProvider.debug(`Cannot find plugin with name ${name}`);\n return undefined;\n }\n\n return plugin;\n }\n\n plugins<T extends Plugin>(pluginClass: { new (...args: any[]): T }): T[] {\n return this.timeline.plugins.filter((plugin) => plugin instanceof pluginClass) as T[];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uncaught-sdk-errors.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/uncaught-sdk-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAa1D,eAAO,MAAM,UAAU,6BAA6B,CAAC;AACrD,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"uncaught-sdk-errors.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/uncaught-sdk-errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAa1D,eAAO,MAAM,UAAU,6BAA6B,CAAC;AACrD,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAgC9D,eAAO,MAAM,yBAAyB,aAAc;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,SAOzE,CAAC;AAEF,eAAO,MAAM,uBAAuB,WAAY,kBAAkB,SAmEjE,CAAC"}
|
|
@@ -5,22 +5,39 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var global_scope_1 = require("../global-scope");
|
|
6
6
|
exports.GLOBAL_KEY = '__AMPLITUDE_SCRIPT_URL__';
|
|
7
7
|
exports.EVENT_NAME_ERROR_UNCAUGHT = 'sdk.error.uncaught';
|
|
8
|
-
var
|
|
8
|
+
var getNormalizedScriptUrls = function () {
|
|
9
9
|
var scope = (0, global_scope_1.getGlobalScope)();
|
|
10
10
|
/* istanbul ignore next */
|
|
11
|
-
|
|
11
|
+
if (!scope) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
var value = scope[exports.GLOBAL_KEY];
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
/* istanbul ignore next - legacy single URL stored as string */
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
return [value];
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
12
23
|
};
|
|
13
|
-
var
|
|
24
|
+
var addNormalizedScriptUrl = function (url) {
|
|
14
25
|
var scope = (0, global_scope_1.getGlobalScope)();
|
|
15
|
-
|
|
16
|
-
|
|
26
|
+
/* istanbul ignore next */
|
|
27
|
+
if (!scope) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
var urls = getNormalizedScriptUrls();
|
|
31
|
+
if (!urls.includes(url)) {
|
|
32
|
+
urls.push(url);
|
|
33
|
+
scope[exports.GLOBAL_KEY] = urls;
|
|
17
34
|
}
|
|
18
35
|
};
|
|
19
36
|
var registerSdkLoaderMetadata = function (metadata) {
|
|
20
37
|
if (metadata.scriptUrl) {
|
|
21
38
|
var normalized = normalizeUrl(metadata.scriptUrl);
|
|
22
39
|
if (normalized) {
|
|
23
|
-
|
|
40
|
+
addNormalizedScriptUrl(normalized);
|
|
24
41
|
}
|
|
25
42
|
}
|
|
26
43
|
};
|
|
@@ -81,15 +98,28 @@ var enableSdkErrorListeners = function (client) {
|
|
|
81
98
|
};
|
|
82
99
|
exports.enableSdkErrorListeners = enableSdkErrorListeners;
|
|
83
100
|
var detectSdkOrigin = function (payload) {
|
|
84
|
-
var
|
|
85
|
-
|
|
101
|
+
var e_1, _a;
|
|
102
|
+
var normalizedScriptUrls = getNormalizedScriptUrls();
|
|
103
|
+
if (normalizedScriptUrls.length === 0) {
|
|
86
104
|
return undefined;
|
|
87
105
|
}
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
try {
|
|
107
|
+
for (var normalizedScriptUrls_1 = tslib_1.__values(normalizedScriptUrls), normalizedScriptUrls_1_1 = normalizedScriptUrls_1.next(); !normalizedScriptUrls_1_1.done; normalizedScriptUrls_1_1 = normalizedScriptUrls_1.next()) {
|
|
108
|
+
var normalizedScriptUrl = normalizedScriptUrls_1_1.value;
|
|
109
|
+
if (payload.filename && payload.filename.includes(normalizedScriptUrl)) {
|
|
110
|
+
return 'filename';
|
|
111
|
+
}
|
|
112
|
+
if (payload.stack && payload.stack.includes(normalizedScriptUrl)) {
|
|
113
|
+
return 'stack';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
90
116
|
}
|
|
91
|
-
|
|
92
|
-
|
|
117
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
118
|
+
finally {
|
|
119
|
+
try {
|
|
120
|
+
if (normalizedScriptUrls_1_1 && !normalizedScriptUrls_1_1.done && (_a = normalizedScriptUrls_1.return)) _a.call(normalizedScriptUrls_1);
|
|
121
|
+
}
|
|
122
|
+
finally { if (e_1) throw e_1.error; }
|
|
93
123
|
}
|
|
94
124
|
return undefined;
|
|
95
125
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uncaught-sdk-errors.js","sourceRoot":"","sources":["../../../src/diagnostics/uncaught-sdk-errors.ts"],"names":[],"mappings":";;;;AAAA,gDAAiD;AAcpC,QAAA,UAAU,GAAG,0BAA0B,CAAC;AACxC,QAAA,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D,IAAM,
|
|
1
|
+
{"version":3,"file":"uncaught-sdk-errors.js","sourceRoot":"","sources":["../../../src/diagnostics/uncaught-sdk-errors.ts"],"names":[],"mappings":";;;;AAAA,gDAAiD;AAcpC,QAAA,UAAU,GAAG,0BAA0B,CAAC;AACxC,QAAA,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D,IAAM,uBAAuB,GAAG;IAC9B,IAAM,KAAK,GAAG,IAAA,6BAAc,GAAoC,CAAC;IACjE,0BAA0B;IAC1B,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IACD,IAAM,KAAK,GAAG,KAAK,CAAC,kBAAU,CAAC,CAAC;IAChC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;Q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AC,KAAa;;IACjC,IAAI;QACF,0BAA0B;QAC1B,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,MAAA,MAAA,IAAA,6BAAc,GAAE,0CAAE,QAAQ,0CAAE,MAAM,CAAC,CAAC;QAC/D,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC;KAClC;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC;AAEF,IAAM,wBAAwB,GAAG,UAAC,KAAc;IAC9C,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,SAAS,CAAC;KAClB;IAED,IAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC1D,0BAA0B;IAC1B,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC,CAAC;AAEF,0BAA0B;AAC1B,IAAM,eAAe,GAAG,UAAC,MAAe;IACtC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;QAC9B,OAAO,MAAM,CAAC;KACf;IAED,IAAI;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAC/B;IAAC,WAAM;QACN,OAAO,iBAAiB,CAAC;KAC1B;AACH,CAAC,CAAC","sourcesContent":["import { getGlobalScope } from '../global-scope';\nimport { IDiagnosticsClient } from './diagnostics-client';\n\ntype ErrorEventType = 'error' | 'unhandledrejection';\n\ninterface CapturedErrorContext {\n readonly type: ErrorEventType;\n readonly message: string;\n readonly stack?: string;\n readonly filename?: string;\n readonly errorName?: string;\n readonly metadata?: Record<string, unknown>;\n}\n\nexport const GLOBAL_KEY = '__AMPLITUDE_SCRIPT_URL__';\nexport const EVENT_NAME_ERROR_UNCAUGHT = 'sdk.error.uncaught';\n\nconst getNormalizedScriptUrls = (): string[] => {\n const scope = getGlobalScope() as Record<string, unknown> | null;\n /* istanbul ignore next */\n if (!scope) {\n return [];\n }\n const value = scope[GLOBAL_KEY];\n if (Array.isArray(value)) {\n return value as string[];\n }\n /* istanbul ignore next - legacy single URL stored as string */\n if (typeof value === 'string') {\n return [value];\n }\n return [];\n};\n\nconst addNormalizedScriptUrl = (url: string) => {\n const scope = getGlobalScope() as Record<string, unknown> | null;\n /* istanbul ignore next */\n if (!scope) {\n return;\n }\n const urls = getNormalizedScriptUrls();\n if (!urls.includes(url)) {\n urls.push(url);\n scope[GLOBAL_KEY] = urls;\n }\n};\n\nexport const registerSdkLoaderMetadata = (metadata: { scriptUrl?: string }) => {\n if (metadata.scriptUrl) {\n const normalized = normalizeUrl(metadata.scriptUrl);\n if (normalized) {\n addNormalizedScriptUrl(normalized);\n }\n }\n};\n\nexport const enableSdkErrorListeners = (client: IDiagnosticsClient) => {\n const scope = getGlobalScope();\n\n if (!scope || typeof scope.addEventListener !== 'function') {\n return;\n }\n\n const handleError = (event: ErrorEvent) => {\n const error = event.error instanceof Error ? event.error : undefined;\n const stack = error?.stack;\n const match = detectSdkOrigin({ filename: event.filename, stack });\n if (!match) {\n return;\n }\n\n capture({\n type: 'error',\n message: event.message,\n stack,\n filename: event.filename,\n errorName: error?.name,\n metadata: {\n colno: event.colno,\n lineno: event.lineno,\n isTrusted: event.isTrusted,\n matchReason: match,\n },\n });\n };\n\n const handleRejection = (event: PromiseRejectionEvent) => {\n const error = event.reason instanceof Error ? event.reason : undefined;\n const stack = error?.stack;\n const filename = extractFilenameFromStack(stack);\n const match = detectSdkOrigin({ filename, stack });\n\n if (!match) {\n return;\n }\n\n /* istanbul ignore next */\n capture({\n type: 'unhandledrejection',\n message: error?.message ?? stringifyReason(event.reason),\n stack,\n filename,\n errorName: error?.name,\n metadata: {\n isTrusted: event.isTrusted,\n matchReason: match,\n },\n });\n };\n\n const capture = (context: CapturedErrorContext) => {\n client.recordEvent(EVENT_NAME_ERROR_UNCAUGHT, {\n type: context.type,\n message: context.message,\n filename: context.filename,\n error_name: context.errorName,\n stack: context.stack,\n ...context.metadata,\n });\n };\n\n scope.addEventListener('error', handleError, true);\n scope.addEventListener('unhandledrejection', handleRejection, true);\n};\n\nconst detectSdkOrigin = (payload: { filename?: string; stack?: string }): 'filename' | 'stack' | undefined => {\n const normalizedScriptUrls = getNormalizedScriptUrls();\n if (normalizedScriptUrls.length === 0) {\n return undefined;\n }\n\n for (const normalizedScriptUrl of normalizedScriptUrls) {\n if (payload.filename && payload.filename.includes(normalizedScriptUrl)) {\n return 'filename';\n }\n if (payload.stack && payload.stack.includes(normalizedScriptUrl)) {\n return 'stack';\n }\n }\n\n return undefined;\n};\n\nconst normalizeUrl = (value: string) => {\n try {\n /* istanbul ignore next */\n const url = new URL(value, getGlobalScope()?.location?.origin);\n return url.origin + url.pathname;\n } catch {\n return undefined;\n }\n};\n\nconst extractFilenameFromStack = (stack?: string) => {\n if (!stack) {\n return undefined;\n }\n\n const match = stack.match(/(https?:\\/\\/\\S+?)(?=[)\\s]|$)/);\n /* istanbul ignore next */\n return match ? match[1] : undefined;\n};\n\n/* istanbul ignore next */\nconst stringifyReason = (reason: unknown) => {\n if (typeof reason === 'string') {\n return reason;\n }\n\n try {\n return JSON.stringify(reason);\n } catch {\n return '[object Object]';\n }\n};\n"]}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -68,4 +68,9 @@ export { ReactNativeConfig, ReactNativeTrackingOptions, ReactNativeOptions, Reac
|
|
|
68
68
|
export { ReactNativeClient } from './types/client/react-native-client';
|
|
69
69
|
export { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';
|
|
70
70
|
export { InstanceProxy } from './types/proxy';
|
|
71
|
+
export { safeJsonStringify } from './utils/safe-stringify';
|
|
72
|
+
export type { BaseWindowMessenger, ActionHandler } from './messenger/base-window-messenger';
|
|
73
|
+
export { getOrCreateWindowMessenger } from './messenger/base-window-messenger';
|
|
74
|
+
export { enableBackgroundCapture } from './messenger/background-capture';
|
|
75
|
+
export { AMPLITUDE_ORIGIN, AMPLITUDE_ORIGIN_EU, AMPLITUDE_ORIGIN_STAGING, AMPLITUDE_ORIGINS_MAP, AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL, } from './messenger/constants';
|
|
71
76
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,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SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,qBAAqB,EACrB,uCAAuC,GACxC,MAAM,uBAAuB,CAAC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_ACTION_CLICK_ALLOWLIST = exports.DEFAULT_DATA_ATTRIBUTE_PREFIX = exports.DEFAULT_CSS_SELECTOR_ALLOWLIST = exports.OfflineDisabled = exports.ServerZone = exports.SpecialEventType = exports.IdentifyOperation = exports.consoleObserver = exports.STORAGE_PREFIX = exports.AMPLITUDE_PREFIX = exports.LogLevel = exports.RemoteConfigClient = exports.FetchTransport = exports.BaseTransport = exports.registerSdkLoaderMetadata = exports.DiagnosticsClient = exports.BrowserStorage = exports.getStorageKey = exports.decodeCookieValue = exports.isDomainEqual = exports.CookieStorage = exports.MemoryStorage = exports.isTimestampInSample = exports.generateHashCode = exports.getDecodeURI = exports.isUrlMatchAllowlist = exports.createIdentifyEvent = exports.UUID = exports.getClientStates = exports.getClientLogConfig = exports.debugWrapper = exports.returnWrapper = exports.getQueryParams = exports.getLanguage = exports.getOldCookieName = exports.getCookieName = exports.isNewSession = exports.setConnectorUserId = exports.setConnectorDeviceId = exports.getAnalyticsConnector = exports.getGlobalScope = exports.Logger = exports.RequestMetadata = exports.Config = exports.IdentityEventSender = exports.Destination = exports.RevenueProperty = exports.Revenue = exports.Identify = exports.AmplitudeCore = void 0;
|
|
4
|
-
exports.multicast = exports.merge = exports.asyncMap = exports.Observable = exports.EMAIL_REGEX = exports.SSN_REGEX = exports.CC_REGEX = exports.replaceSensitiveString = exports.MASKED_TEXT_VALUE = exports.TEXT_MASK_ATTRIBUTE = exports.getPageTitle = exports.CampaignParser = exports.MKTG = exports.BASE_CAMPAIGN = exports.EMPTY_VALUE = exports.FORBIDDEN_HEADERS = exports.SAFE_HEADERS = exports.NetworkRequestEvent = exports.networkObserver = exports.NetworkEventCallback = exports.Status = exports.DEFAULT_DEAD_CLICK_WINDOW_MS = exports.DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD = exports.DEFAULT_RAGE_CLICK_WINDOW_MS = exports.DEFAULT_RAGE_CLICK_THRESHOLD = exports.DEFAULT_ERROR_CLICK_ALLOWLIST = exports.DEFAULT_RAGE_CLICK_ALLOWLIST = exports.DEFAULT_DEAD_CLICK_ALLOWLIST = void 0;
|
|
4
|
+
exports.AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL = exports.AMPLITUDE_ORIGINS_MAP = exports.AMPLITUDE_ORIGIN_STAGING = exports.AMPLITUDE_ORIGIN_EU = exports.AMPLITUDE_ORIGIN = exports.enableBackgroundCapture = exports.getOrCreateWindowMessenger = exports.safeJsonStringify = exports.multicast = exports.merge = exports.asyncMap = exports.Observable = exports.EMAIL_REGEX = exports.SSN_REGEX = exports.CC_REGEX = exports.replaceSensitiveString = exports.MASKED_TEXT_VALUE = exports.TEXT_MASK_ATTRIBUTE = exports.getPageTitle = exports.CampaignParser = exports.MKTG = exports.BASE_CAMPAIGN = exports.EMPTY_VALUE = exports.FORBIDDEN_HEADERS = exports.SAFE_HEADERS = exports.NetworkRequestEvent = exports.networkObserver = exports.NetworkEventCallback = exports.Status = exports.DEFAULT_DEAD_CLICK_WINDOW_MS = exports.DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD = exports.DEFAULT_RAGE_CLICK_WINDOW_MS = exports.DEFAULT_RAGE_CLICK_THRESHOLD = exports.DEFAULT_ERROR_CLICK_ALLOWLIST = exports.DEFAULT_RAGE_CLICK_ALLOWLIST = exports.DEFAULT_DEAD_CLICK_ALLOWLIST = void 0;
|
|
5
5
|
var core_client_1 = require("./core-client");
|
|
6
6
|
Object.defineProperty(exports, "AmplitudeCore", { enumerable: true, get: function () { return core_client_1.AmplitudeCore; } });
|
|
7
7
|
var identify_1 = require("./identify");
|
|
@@ -124,4 +124,16 @@ Object.defineProperty(exports, "Observable", { enumerable: true, get: function (
|
|
|
124
124
|
Object.defineProperty(exports, "asyncMap", { enumerable: true, get: function () { return observable_1.asyncMap; } });
|
|
125
125
|
Object.defineProperty(exports, "merge", { enumerable: true, get: function () { return observable_1.merge; } });
|
|
126
126
|
Object.defineProperty(exports, "multicast", { enumerable: true, get: function () { return observable_1.multicast; } });
|
|
127
|
+
var safe_stringify_1 = require("./utils/safe-stringify");
|
|
128
|
+
Object.defineProperty(exports, "safeJsonStringify", { enumerable: true, get: function () { return safe_stringify_1.safeJsonStringify; } });
|
|
129
|
+
var base_window_messenger_1 = require("./messenger/base-window-messenger");
|
|
130
|
+
Object.defineProperty(exports, "getOrCreateWindowMessenger", { enumerable: true, get: function () { return base_window_messenger_1.getOrCreateWindowMessenger; } });
|
|
131
|
+
var background_capture_1 = require("./messenger/background-capture");
|
|
132
|
+
Object.defineProperty(exports, "enableBackgroundCapture", { enumerable: true, get: function () { return background_capture_1.enableBackgroundCapture; } });
|
|
133
|
+
var constants_4 = require("./messenger/constants");
|
|
134
|
+
Object.defineProperty(exports, "AMPLITUDE_ORIGIN", { enumerable: true, get: function () { return constants_4.AMPLITUDE_ORIGIN; } });
|
|
135
|
+
Object.defineProperty(exports, "AMPLITUDE_ORIGIN_EU", { enumerable: true, get: function () { return constants_4.AMPLITUDE_ORIGIN_EU; } });
|
|
136
|
+
Object.defineProperty(exports, "AMPLITUDE_ORIGIN_STAGING", { enumerable: true, get: function () { return constants_4.AMPLITUDE_ORIGIN_STAGING; } });
|
|
137
|
+
Object.defineProperty(exports, "AMPLITUDE_ORIGINS_MAP", { enumerable: true, get: function () { return constants_4.AMPLITUDE_ORIGINS_MAP; } });
|
|
138
|
+
Object.defineProperty(exports, "AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL", { enumerable: true, get: function () { return constants_4.AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL; } });
|
|
127
139
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AAItB,uCAAoE;AAA3D,oGAAA,QAAQ,OAAA;AACjB,qCAA+D;AAAtD,kGAAA,OAAO,OAAA;AAAY,0GAAA,eAAe,OAAA;AAC3C,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,+CAAyD;AAAhD,+GAAA,mBAAmB,OAAA;AAC5B,mCAAmD;AAA1C,gGAAA,MAAM,OAAA;AAAE,yGAAA,eAAe,OAAA;AAEhC,mCAAsD;AAA7C,gGAAA,MAAM,OAAA;AACf,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AACvB,6DAAwG;AAA/F,4HAAA,qBAAqB,OAAA;AAAE,2HAAA,oBAAoB,OAAA;AAAE,yHAAA,kBAAkB,OAAA;AACxE,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,6CAAgE;AAAvD,4GAAA,aAAa,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AACxC,uCAAyC;AAAhC,uGAAA,WAAW,OAAA;AACpB,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AAEvB,yDAAwE;AAA/D,+GAAA,aAAa,OAAA;AACtB,uCAAkF;AAAzE,qGAAA,YAAY,OAAA;AAAE,2GAAA,kBAAkB,OAAA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IAAA,4BAA4B,OAAA;AAC5B,sJAAA,0CAA0C,OAAA;AAC1C,wIAAA,4BAA4B,OAAA;AAI9B,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AAEf,+CAA4E;AAAnE,+GAAA,oBAAoB,OAAA;AAAE,0GAAA,eAAe,OAAA;AAC9C,iEAAiH;AAAxG,4HAAA,mBAAmB,OAAA;AAE5B,+CAAoE;AAA3D,yGAAA,YAAY,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAMxC,+CAAqE;AAA5D,wGAAA,WAAW,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,iGAAA,IAAI,OAAA;AACzC,8DAA4D;AAAnD,iHAAA,cAAc,OAAA;AACvB,6CAQ2B;AAPzB,uGAAA,YAAY,OAAA;AACZ,8GAAA,mBAAmB,OAAA;AACnB,4GAAA,iBAAiB,OAAA;AACjB,iHAAA,sBAAsB,OAAA;AACtB,mGAAA,QAAQ,OAAA;AACR,oGAAA,SAAS,OAAA;AACT,sGAAA,WAAW,OAAA;AA6Bb,iDAA4F;AAAnF,wGAAA,UAAU,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,uGAAA,SAAS,OAAA","sourcesContent":["export { AmplitudeCore } from './core-client';\nexport { CoreClient, PluginHost } from './types/client/core-client';\nexport { AnalyticsClient } from './types/client/analytics-client';\nexport { AmplitudeContext } from './types/amplitude-context';\nexport { Identify, IIdentify, ValidPropertyType } from './identify';\nexport { Revenue, IRevenue, RevenueProperty } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { IdentityEventSender } from './plugins/identity';\nexport { Config, RequestMetadata } from './config';\nexport { IConfig } from './types/config/core-config';\nexport { Logger, ILogger, LogConfig } from './logger';\nexport { getGlobalScope } from './global-scope';\nexport { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';\nexport { isNewSession } from './session';\nexport { getCookieName, getOldCookieName } from './cookie-name';\nexport { getLanguage } from './language';\nexport { getQueryParams } from './query-params';\n\nexport { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { createIdentifyEvent } from './utils/event-builder';\nexport { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';\nexport { generateHashCode, isTimestampInSample } from './utils/sampling';\n\nexport { MemoryStorage } from './storage/memory';\nexport { CookieStorage, isDomainEqual, decodeCookieValue } from './storage/cookie';\nexport { getStorageKey } from './storage/helpers';\n\nexport { BrowserStorage } from './storage/browser-storage';\n\nexport { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';\nexport { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';\n\nexport { BaseTransport } from './transports/base';\nexport { FetchTransport } from './transports/fetch';\n\nexport { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';\n\nexport { LogLevel } from './types/loglevel';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';\nexport { Storage, IdentityStorageType, CookieStorageConfig } from './types/storage';\nexport { consoleObserver } from './observers/console';\nexport {\n Event,\n IdentifyOperation,\n SpecialEventType,\n IdentifyEvent,\n GroupIdentifyEvent,\n IdentifyUserProperties,\n} from './types/event/event';\nexport { EventOptions, BaseEvent } from './types/event/base-event';\nexport { IngestionMetadata } from './types/event/ingestion-metadata';\nexport { ServerZoneType, ServerZone } from './types/server-zone';\nexport { OfflineDisabled } from './types/offline';\nexport { Plan } from './types/event/plan';\nexport { TransportType, Transport, TransportOptions, TransportTypeOrOptions } from './types/transport';\nexport { Payload } from './types/payload';\nexport { Response } from './types/response';\nexport { UserSession } from './types/user-session';\nexport {\n Plugin,\n BeforePlugin,\n DestinationPlugin,\n EnrichmentPlugin,\n PluginType,\n AnalyticsIdentity,\n} from './types/plugin';\nexport { Result } from './types/result';\nexport {\n ElementInteractionsOptions,\n Messenger,\n ActionType,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n LabeledEvent,\n Trigger,\n DataSource,\n} from './types/element-interactions';\n\nexport {\n FrustrationInteractionsOptions,\n DEFAULT_DEAD_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_ALLOWLIST,\n DEFAULT_ERROR_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_THRESHOLD,\n DEFAULT_RAGE_CLICK_WINDOW_MS,\n DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD,\n DEFAULT_DEAD_CLICK_WINDOW_MS,\n} from './types/frustration-interactions';\nexport { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';\nexport { FormInteractionsOptions } from './types/form-interactions';\nexport { Status } from './types/status';\n\nexport { NetworkEventCallback, networkObserver } from './observers/network';\nexport { NetworkRequestEvent, IRequestWrapper, JsonObject, JsonValue, JsonArray } from './network-request-event';\nexport { NetworkTrackingOptions, NetworkCaptureRule } from './types/network-tracking';\nexport { SAFE_HEADERS, FORBIDDEN_HEADERS } from './types/constants';\n\nexport { PageUrlEnrichmentOptions } from './types/page-url-enrichment';\n\n// Campaign\nexport { Campaign, UTMParameters, ReferrerParameters, ClickIdParameters, ICampaignParser } from './types/campaign';\nexport { EMPTY_VALUE, BASE_CAMPAIGN, MKTG } from './types/constants';\nexport { CampaignParser } from './campaign/campaign-parser';\nexport {\n getPageTitle,\n TEXT_MASK_ATTRIBUTE,\n MASKED_TEXT_VALUE,\n replaceSensitiveString,\n CC_REGEX,\n SSN_REGEX,\n EMAIL_REGEX,\n} from './plugins/helpers';\n\n// Browser\nexport {\n BrowserConfig,\n BrowserOptions,\n DefaultTrackingOptions,\n TrackingOptions,\n AutocaptureOptions,\n CookieOptions,\n AttributionOptions,\n RemoteConfigOptions,\n} from './types/config/browser-config';\nexport { BrowserClient } from './types/client/browser-client';\n\n// Node\nexport { NodeClient } from './types/client/node-client';\nexport { NodeConfig, NodeOptions } from './types/config/node-config';\n\n// React Native\nexport {\n ReactNativeConfig,\n ReactNativeTrackingOptions,\n ReactNativeOptions,\n ReactNativeAttributionOptions,\n} from './types/config/react-native-config';\nexport { ReactNativeClient } from './types/client/react-native-client';\n\nexport { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';\n\nexport { InstanceProxy } from './types/proxy';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AAItB,uCAAoE;AAA3D,oGAAA,QAAQ,OAAA;AACjB,qCAA+D;AAAtD,kGAAA,OAAO,OAAA;AAAY,0GAAA,eAAe,OAAA;AAC3C,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,+CAAyD;AAAhD,+GAAA,mBAAmB,OAAA;AAC5B,mCAAmD;AAA1C,gGAAA,MAAM,OAAA;AAAE,yGAAA,eAAe,OAAA;AAEhC,mCAAsD;AAA7C,gGAAA,MAAM,OAAA;AACf,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AACvB,6DAAwG;AAA/F,4HAAA,qBAAqB,OAAA;AAAE,2HAAA,oBAAoB,OAAA;AAAE,yHAAA,kBAAkB,OAAA;AACxE,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,6CAAgE;AAAvD,4GAAA,aAAa,OAAA;AAAE,+GAAA,gBAAgB,OAAA;AACxC,uCAAyC;AAAhC,uGAAA,WAAW,OAAA;AACpB,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AAEvB,yDAAwE;AAA/D,+GAAA,aAAa,OAAA;AACtB,uCAAkF;AAAzE,qGAAA,YAAY,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAAE,wGAAA,eAAe,OAAA;AAC1D,qCAAoC;AAA3B,4FAAA,IAAI,OAAA;AACb,uDAA4D;AAAnD,oHAAA,mBAAmB,O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A,MAAM,OAAA;AAEf,+CAA4E;AAAnE,+GAAA,oBAAoB,OAAA;AAAE,0GAAA,eAAe,OAAA;AAC9C,iEAAiH;AAAxG,4HAAA,mBAAmB,OAAA;AAE5B,+CAAoE;AAA3D,yGAAA,YAAY,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAMxC,+CAAqE;AAA5D,wGAAA,WAAW,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,iGAAA,IAAI,OAAA;AACzC,8DAA4D;AAAnD,iHAAA,cAAc,OAAA;AACvB,6CAQ2B;AAPzB,uGAAA,YAAY,OAAA;AACZ,8GAAA,mBAAmB,OAAA;AACnB,4GAAA,iBAAiB,OAAA;AACjB,iHAAA,sBAAsB,OAAA;AACtB,mGAAA,QAAQ,OAAA;AACR,oGAAA,SAAS,OAAA;AACT,sGAAA,WAAW,OAAA;AA6Bb,iDAA4F;AAAnF,wGAAA,UAAU,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,uGAAA,SAAS,OAAA;AAG/C,yDAA2D;AAAlD,mHAAA,iBAAiB,OAAA;AAI1B,2EAA+E;AAAtE,mIAAA,0BAA0B,OAAA;AACnC,qEAAyE;AAAhE,6HAAA,uBAAuB,OAAA;AAChC,mDAM+B;AAL7B,6GAAA,gBAAgB,OAAA;AAChB,gHAAA,mBAAmB,OAAA;AACnB,qHAAA,wBAAwB,OAAA;AACxB,kHAAA,qBAAqB,OAAA;AACrB,oIAAA,uCAAuC,OAAA","sourcesContent":["export { AmplitudeCore } from './core-client';\nexport { CoreClient, PluginHost } from './types/client/core-client';\nexport { AnalyticsClient } from './types/client/analytics-client';\nexport { AmplitudeContext } from './types/amplitude-context';\nexport { Identify, IIdentify, ValidPropertyType } from './identify';\nexport { Revenue, IRevenue, RevenueProperty } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { IdentityEventSender } from './plugins/identity';\nexport { Config, RequestMetadata } from './config';\nexport { IConfig } from './types/config/core-config';\nexport { Logger, ILogger, LogConfig } from './logger';\nexport { getGlobalScope } from './global-scope';\nexport { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';\nexport { isNewSession } from './session';\nexport { getCookieName, getOldCookieName } from './cookie-name';\nexport { getLanguage } from './language';\nexport { getQueryParams } from './query-params';\n\nexport { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { createIdentifyEvent } from './utils/event-builder';\nexport { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';\nexport { generateHashCode, isTimestampInSample } from './utils/sampling';\n\nexport { MemoryStorage } from './storage/memory';\nexport { CookieStorage, isDomainEqual, decodeCookieValue } from './storage/cookie';\nexport { getStorageKey } from './storage/helpers';\n\nexport { BrowserStorage } from './storage/browser-storage';\n\nexport { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';\nexport { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';\n\nexport { BaseTransport } from './transports/base';\nexport { FetchTransport } from './transports/fetch';\n\nexport { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';\n\nexport { LogLevel } from './types/loglevel';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';\nexport { Storage, IdentityStorageType, CookieStorageConfig } from './types/storage';\nexport { consoleObserver } from './observers/console';\nexport {\n Event,\n IdentifyOperation,\n SpecialEventType,\n IdentifyEvent,\n GroupIdentifyEvent,\n IdentifyUserProperties,\n} from './types/event/event';\nexport { EventOptions, BaseEvent } from './types/event/base-event';\nexport { IngestionMetadata } from './types/event/ingestion-metadata';\nexport { ServerZoneType, ServerZone } from './types/server-zone';\nexport { OfflineDisabled } from './types/offline';\nexport { Plan } from './types/event/plan';\nexport { TransportType, Transport, TransportOptions, TransportTypeOrOptions } from './types/transport';\nexport { Payload } from './types/payload';\nexport { Response } from './types/response';\nexport { UserSession } from './types/user-session';\nexport {\n Plugin,\n BeforePlugin,\n DestinationPlugin,\n EnrichmentPlugin,\n PluginType,\n AnalyticsIdentity,\n} from './types/plugin';\nexport { Result } from './types/result';\nexport {\n ElementInteractionsOptions,\n Messenger,\n ActionType,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n LabeledEvent,\n Trigger,\n DataSource,\n} from './types/element-interactions';\n\nexport {\n FrustrationInteractionsOptions,\n DEFAULT_DEAD_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_ALLOWLIST,\n DEFAULT_ERROR_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_THRESHOLD,\n DEFAULT_RAGE_CLICK_WINDOW_MS,\n DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD,\n DEFAULT_DEAD_CLICK_WINDOW_MS,\n} from './types/frustration-interactions';\nexport { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';\nexport { FormInteractionsOptions } from './types/form-interactions';\nexport { Status } from './types/status';\n\nexport { NetworkEventCallback, networkObserver } from './observers/network';\nexport { NetworkRequestEvent, IRequestWrapper, JsonObject, JsonValue, JsonArray } from './network-request-event';\nexport { NetworkTrackingOptions, NetworkCaptureRule } from './types/network-tracking';\nexport { SAFE_HEADERS, FORBIDDEN_HEADERS } from './types/constants';\n\nexport { PageUrlEnrichmentOptions } from './types/page-url-enrichment';\n\n// Campaign\nexport { Campaign, UTMParameters, ReferrerParameters, ClickIdParameters, ICampaignParser } from './types/campaign';\nexport { EMPTY_VALUE, BASE_CAMPAIGN, MKTG } from './types/constants';\nexport { CampaignParser } from './campaign/campaign-parser';\nexport {\n getPageTitle,\n TEXT_MASK_ATTRIBUTE,\n MASKED_TEXT_VALUE,\n replaceSensitiveString,\n CC_REGEX,\n SSN_REGEX,\n EMAIL_REGEX,\n} from './plugins/helpers';\n\n// Browser\nexport {\n BrowserConfig,\n BrowserOptions,\n DefaultTrackingOptions,\n TrackingOptions,\n AutocaptureOptions,\n CookieOptions,\n AttributionOptions,\n RemoteConfigOptions,\n} from './types/config/browser-config';\nexport { BrowserClient } from './types/client/browser-client';\n\n// Node\nexport { NodeClient } from './types/client/node-client';\nexport { NodeConfig, NodeOptions } from './types/config/node-config';\n\n// React Native\nexport {\n ReactNativeConfig,\n ReactNativeTrackingOptions,\n ReactNativeOptions,\n ReactNativeAttributionOptions,\n} from './types/config/react-native-config';\nexport { ReactNativeClient } from './types/client/react-native-client';\n\nexport { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';\n\nexport { InstanceProxy } from './types/proxy';\nexport { safeJsonStringify } from './utils/safe-stringify';\n\n// Messenger (cross-window communication)\nexport type { BaseWindowMessenger, ActionHandler } from './messenger/base-window-messenger';\nexport { getOrCreateWindowMessenger } from './messenger/base-window-messenger';\nexport { enableBackgroundCapture } from './messenger/background-capture';\nexport {\n AMPLITUDE_ORIGIN,\n AMPLITUDE_ORIGIN_EU,\n AMPLITUDE_ORIGIN_STAGING,\n AMPLITUDE_ORIGINS_MAP,\n AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL,\n} from './messenger/constants';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BaseWindowMessenger } from './base-window-messenger';
|
|
2
|
+
/**
|
|
3
|
+
* Enable background capture on a messenger instance.
|
|
4
|
+
* Plugins can call this on a shared messenger instance.
|
|
5
|
+
* The first call registers the handlers; subsequent calls are no-ops.
|
|
6
|
+
*
|
|
7
|
+
* @param messenger - The messenger to enable background capture on
|
|
8
|
+
* @param options.scriptUrl - Override the background capture script URL (optional)
|
|
9
|
+
*/
|
|
10
|
+
export declare function enableBackgroundCapture(messenger: BaseWindowMessenger, options?: {
|
|
11
|
+
scriptUrl?: string;
|
|
12
|
+
}): void;
|
|
13
|
+
//# sourceMappingURL=background-capture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-capture.d.ts","sourceRoot":"","sources":["../../../src/messenger/background-capture.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AASnE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CA6C9G"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableBackgroundCapture = void 0;
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
/**
|
|
6
|
+
* Brand key set on the messenger instance to track whether background capture
|
|
7
|
+
* has been enabled.
|
|
8
|
+
*/
|
|
9
|
+
var BG_CAPTURE_BRAND = '__AMPLITUDE_BACKGROUND_CAPTURE__';
|
|
10
|
+
/**
|
|
11
|
+
* Enable background capture on a messenger instance.
|
|
12
|
+
* Plugins can call this on a shared messenger instance.
|
|
13
|
+
* The first call registers the handlers; subsequent calls are no-ops.
|
|
14
|
+
*
|
|
15
|
+
* @param messenger - The messenger to enable background capture on
|
|
16
|
+
* @param options.scriptUrl - Override the background capture script URL (optional)
|
|
17
|
+
*/
|
|
18
|
+
function enableBackgroundCapture(messenger, options) {
|
|
19
|
+
var _a;
|
|
20
|
+
// Check the brand on the messenger object itself — works across bundle boundaries
|
|
21
|
+
var branded = messenger;
|
|
22
|
+
if (branded[BG_CAPTURE_BRAND] === true) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
branded[BG_CAPTURE_BRAND] = true;
|
|
26
|
+
var scriptUrl = (_a = options === null || options === void 0 ? void 0 : options.scriptUrl) !== null && _a !== void 0 ? _a : constants_1.AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL;
|
|
27
|
+
var backgroundCaptureInstance = null;
|
|
28
|
+
var onBackgroundCapture = function (type, backgroundCaptureData) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
if (type === 'background-capture-complete') {
|
|
31
|
+
(_b = (_a = messenger.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'Background capture complete');
|
|
32
|
+
messenger.notify({ action: 'background-capture-complete', data: backgroundCaptureData });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
messenger.registerActionHandler('initialize-background-capture', function () {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
(_b = (_a = messenger.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'Initializing background capture (external script)');
|
|
38
|
+
var resolvedUrl = new URL(scriptUrl, messenger.endpoint).toString();
|
|
39
|
+
messenger
|
|
40
|
+
.loadScriptOnce(resolvedUrl)
|
|
41
|
+
.then(function () {
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
(_b = (_a = messenger.logger) === null || _a === void 0 ? void 0 : _a.debug) === null || _b === void 0 ? void 0 : _b.call(_a, 'Background capture script loaded (external)');
|
|
44
|
+
// eslint-disable-next-line
|
|
45
|
+
backgroundCaptureInstance = /* istanbul ignore next -- window is always defined in browser */ (_c = window === null || window === void 0 ? void 0 : window.amplitudeBackgroundCapture) === null || _c === void 0 ? void 0 : _c.call(window, {
|
|
46
|
+
messenger: messenger,
|
|
47
|
+
onBackgroundCapture: onBackgroundCapture,
|
|
48
|
+
});
|
|
49
|
+
messenger.notify({ action: 'background-capture-loaded' });
|
|
50
|
+
})
|
|
51
|
+
.catch(function () {
|
|
52
|
+
var _a;
|
|
53
|
+
(_a = messenger.logger) === null || _a === void 0 ? void 0 : _a.warn('Failed to initialize background capture');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
messenger.registerActionHandler('close-background-capture', function () {
|
|
57
|
+
var _a;
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
59
|
+
(_a = backgroundCaptureInstance === null || backgroundCaptureInstance === void 0 ? void 0 : backgroundCaptureInstance.close) === null || _a === void 0 ? void 0 : _a.call(backgroundCaptureInstance);
|
|
60
|
+
backgroundCaptureInstance = null;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.enableBackgroundCapture = enableBackgroundCapture;
|
|
64
|
+
//# sourceMappingURL=background-capture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-capture.js","sourceRoot":"","sources":["../../../src/messenger/background-capture.ts"],"names":[],"mappings":";;;AAEA,yCAAsE;AAEtE;;;GAGG;AACH,IAAM,gBAAgB,GAAG,kCAA2C,CAAC;AAErE;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,SAA8B,EAAE,OAAgC;;IACtG,kFAAkF;IAClF,IAAM,OAAO,GAAG,SAA+C,CAAC;IAChE,IAAI,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,EAAE;QACtC,OAAO;KACR;IACD,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;IAEjC,IAAM,SAAS,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,mDAAuC,CAAC;IAChF,IAAI,yBAAyB,GAAQ,IAAI,CAAC;IAE1C,IAAM,mBAAmB,GAAG,UAAC,IAAY,EAAE,qBAAgE;;QACzG,IAAI,IAAI,KAAK,6BAA6B,EAAE;YAC1C,MAAA,MAAA,SAAS,CAAC,MAAM,0CAAE,KAAK,mDAAG,6BAA6B,CAAC,CAAC;YACzD,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,6BAA6B,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,CAAC;SAC1F;IACH,CAAC,CAAC;IAEF,SAAS,CAAC,qBAAqB,CAAC,+BAA+B,EAAE;;QAC/D,MAAA,MAAA,SAAS,CAAC,MAAM,0CAAE,KAAK,mDAAG,mDAAmD,CAAC,CAAC;QAC/E,IAAM,WAAW,GAAG,IAAI,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;QAEtE,SAAS;aACN,cAAc,CAAC,WAAW,CAAC;aAC3B,IAAI,CAAC;;YACJ,MAAA,MAAA,SAAS,CAAC,MAAM,0CAAE,KAAK,mDAAG,6CAA6C,CAAC,CAAC;YACzE,2BAA2B;YAC3B,yBAAyB,GAAG,iEAAiE,CAAC,MAC5F,MACD,aADC,MAAM,uBAAN,MAAM,CACL,0BAA0B,uDAAG;gBAC9B,SAAS,WAAA;gBACT,mBAAmB,qBAAA;aACpB,CAAC,CAAC;YACH,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,2BAA2B,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC;aACD,KAAK,CAAC;;YACL,MAAA,SAAS,CAAC,MAAM,0CAAE,IAAI,CAAC,yCAAyC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,qBAAqB,CAAC,0BAA0B,EAAE;;QAC1D,yGAAyG;QACzG,MAAA,yBAAyB,aAAzB,yBAAyB,uBAAzB,yBAAyB,CAAE,KAAK,yEAAI,CAAC;QACrC,yBAAyB,GAAG,IAAI,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC;AA7CD,0DA6CC","sourcesContent":["/* eslint-disable no-restricted-globals */\nimport type { BaseWindowMessenger } from './base-window-messenger';\nimport { AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL } from './constants';\n\n/**\n * Brand key set on the messenger instance to track whether background capture\n * has been enabled.\n */\nconst BG_CAPTURE_BRAND = '__AMPLITUDE_BACKGROUND_CAPTURE__' as const;\n\n/**\n * Enable background capture on a messenger instance.\n * Plugins can call this on a shared messenger instance.\n * The first call registers the handlers; subsequent calls are no-ops.\n *\n * @param messenger - The messenger to enable background capture on\n * @param options.scriptUrl - Override the background capture script URL (optional)\n */\nexport function enableBackgroundCapture(messenger: BaseWindowMessenger, options?: { scriptUrl?: string }): void {\n // Check the brand on the messenger object itself — works across bundle boundaries\n const branded = messenger as unknown as Record<string, unknown>;\n if (branded[BG_CAPTURE_BRAND] === true) {\n return;\n }\n branded[BG_CAPTURE_BRAND] = true;\n\n const scriptUrl = options?.scriptUrl ?? AMPLITUDE_BACKGROUND_CAPTURE_SCRIPT_URL;\n let backgroundCaptureInstance: any = null;\n\n const onBackgroundCapture = (type: string, backgroundCaptureData: { [key: string]: string | number | null }) => {\n if (type === 'background-capture-complete') {\n messenger.logger?.debug?.('Background capture complete');\n messenger.notify({ action: 'background-capture-complete', data: backgroundCaptureData });\n }\n };\n\n messenger.registerActionHandler('initialize-background-capture', () => {\n messenger.logger?.debug?.('Initializing background capture (external script)');\n const resolvedUrl = new URL(scriptUrl, messenger.endpoint).toString();\n\n messenger\n .loadScriptOnce(resolvedUrl)\n .then(() => {\n messenger.logger?.debug?.('Background capture script loaded (external)');\n // eslint-disable-next-line\n backgroundCaptureInstance = /* istanbul ignore next -- window is always defined in browser */ (\n window as any\n )?.amplitudeBackgroundCapture?.({\n messenger,\n onBackgroundCapture,\n });\n messenger.notify({ action: 'background-capture-loaded' });\n })\n .catch(() => {\n messenger.logger?.warn('Failed to initialize background capture');\n });\n });\n\n messenger.registerActionHandler('close-background-capture', () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n backgroundCaptureInstance?.close?.();\n backgroundCaptureInstance = null;\n });\n}\n"]}
|