@amplitude/analytics-core 2.32.2 → 2.34.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.
Files changed (43) hide show
  1. package/lib/cjs/config.d.ts +1 -1
  2. package/lib/cjs/config.d.ts.map +1 -1
  3. package/lib/cjs/config.js.map +1 -1
  4. package/lib/cjs/diagnostics/diagnostics-client.d.ts.map +1 -1
  5. package/lib/cjs/diagnostics/diagnostics-client.js +2 -0
  6. package/lib/cjs/diagnostics/diagnostics-client.js.map +1 -1
  7. package/lib/cjs/diagnostics/uncaught-sdk-errors.d.ts +8 -0
  8. package/lib/cjs/diagnostics/uncaught-sdk-errors.d.ts.map +1 -0
  9. package/lib/cjs/diagnostics/uncaught-sdk-errors.js +127 -0
  10. package/lib/cjs/diagnostics/uncaught-sdk-errors.js.map +1 -0
  11. package/lib/cjs/index.d.ts +2 -0
  12. package/lib/cjs/index.d.ts.map +1 -1
  13. package/lib/cjs/index.js +9 -2
  14. package/lib/cjs/index.js.map +1 -1
  15. package/lib/cjs/types/element-interactions.d.ts +6 -2
  16. package/lib/cjs/types/element-interactions.d.ts.map +1 -1
  17. package/lib/cjs/types/element-interactions.js.map +1 -1
  18. package/lib/cjs/utils/observable.d.ts +24 -0
  19. package/lib/cjs/utils/observable.d.ts.map +1 -0
  20. package/lib/cjs/utils/observable.js +183 -0
  21. package/lib/cjs/utils/observable.js.map +1 -0
  22. package/lib/esm/config.d.ts +1 -1
  23. package/lib/esm/config.d.ts.map +1 -1
  24. package/lib/esm/config.js.map +1 -1
  25. package/lib/esm/diagnostics/diagnostics-client.d.ts.map +1 -1
  26. package/lib/esm/diagnostics/diagnostics-client.js +2 -0
  27. package/lib/esm/diagnostics/diagnostics-client.js.map +1 -1
  28. package/lib/esm/diagnostics/uncaught-sdk-errors.d.ts +8 -0
  29. package/lib/esm/diagnostics/uncaught-sdk-errors.d.ts.map +1 -0
  30. package/lib/esm/diagnostics/uncaught-sdk-errors.js +122 -0
  31. package/lib/esm/diagnostics/uncaught-sdk-errors.js.map +1 -0
  32. package/lib/esm/index.d.ts +2 -0
  33. package/lib/esm/index.d.ts.map +1 -1
  34. package/lib/esm/index.js +2 -0
  35. package/lib/esm/index.js.map +1 -1
  36. package/lib/esm/types/element-interactions.d.ts +6 -2
  37. package/lib/esm/types/element-interactions.d.ts.map +1 -1
  38. package/lib/esm/types/element-interactions.js.map +1 -1
  39. package/lib/esm/utils/observable.d.ts +24 -0
  40. package/lib/esm/utils/observable.d.ts.map +1 -0
  41. package/lib/esm/utils/observable.js +177 -0
  42. package/lib/esm/utils/observable.js.map +1 -0
  43. package/package.json +4 -3
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.merge = exports.multicast = exports.asyncMap = exports.Observable = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var zen_observable_ts_1 = require("zen-observable-ts");
6
+ Object.defineProperty(exports, "Observable", { enumerable: true, get: function () { return zen_observable_ts_1.Observable; } });
7
+ var zen_observable_ts_2 = require("zen-observable-ts");
8
+ /**
9
+ * asyncMap operator for Zen Observable
10
+ *
11
+ * Maps each value emitted by the source Observable using an async function,
12
+ * emitting the resolved values in the same order they arrive.
13
+ */
14
+ function asyncMap(observable, fn) {
15
+ return new zen_observable_ts_2.Observable(function (observer) {
16
+ observable.subscribe({
17
+ next: function (value) {
18
+ fn(value)
19
+ .then(function (result) {
20
+ return observer.next(result);
21
+ })
22
+ .catch(function (error) { return observer.error(error); });
23
+ },
24
+ error: function (error) {
25
+ observer.error(error);
26
+ },
27
+ complete: function () {
28
+ observer.complete();
29
+ },
30
+ });
31
+ });
32
+ }
33
+ exports.asyncMap = asyncMap;
34
+ /**
35
+ * merge operator for Zen Observable
36
+ *
37
+ * Merges two observables into a single observable, emitting values from both sources in the order they arrive.
38
+ * @param sourceA Observable to merge
39
+ * @param sourceB Observable to merge
40
+ * @returns Unsubscribable cleanup function
41
+ */
42
+ function merge(sourceA, sourceB) {
43
+ return new zen_observable_ts_2.Observable(function (observer) {
44
+ var closed = false;
45
+ var subscriptions = new Set();
46
+ var cleanup = function () {
47
+ var e_1, _a;
48
+ closed = true;
49
+ try {
50
+ for (var subscriptions_1 = tslib_1.__values(subscriptions), subscriptions_1_1 = subscriptions_1.next(); !subscriptions_1_1.done; subscriptions_1_1 = subscriptions_1.next()) {
51
+ var sub = subscriptions_1_1.value;
52
+ try {
53
+ sub.unsubscribe();
54
+ }
55
+ catch (_b) {
56
+ /* do nothing */
57
+ }
58
+ }
59
+ }
60
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
61
+ finally {
62
+ try {
63
+ if (subscriptions_1_1 && !subscriptions_1_1.done && (_a = subscriptions_1.return)) _a.call(subscriptions_1);
64
+ }
65
+ finally { if (e_1) throw e_1.error; }
66
+ }
67
+ subscriptions.clear();
68
+ };
69
+ var subscribeTo = function (source) {
70
+ var sub = source.subscribe({
71
+ next: function (value) {
72
+ if (!closed)
73
+ observer.next(value);
74
+ },
75
+ error: function (err) {
76
+ if (!closed) {
77
+ closed = true;
78
+ observer.error(err);
79
+ cleanup();
80
+ }
81
+ },
82
+ complete: function () {
83
+ subscriptions.delete(sub);
84
+ if (!closed && subscriptions.size === 0) {
85
+ observer.complete();
86
+ cleanup();
87
+ closed = true;
88
+ }
89
+ },
90
+ });
91
+ subscriptions.add(sub);
92
+ };
93
+ subscribeTo(sourceA);
94
+ subscribeTo(sourceB);
95
+ return cleanup;
96
+ });
97
+ }
98
+ exports.merge = merge;
99
+ // function share() {
100
+ function multicast(source) {
101
+ var observers = new Set();
102
+ var subscription = null;
103
+ function cleanup() {
104
+ /* istanbul ignore next */
105
+ subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
106
+ subscription = null;
107
+ observers.clear();
108
+ }
109
+ return new zen_observable_ts_2.Observable(function (observer) {
110
+ observers.add(observer);
111
+ if (subscription === null) {
112
+ subscription = source.subscribe({
113
+ next: function (value) {
114
+ var e_2, _a;
115
+ var _b;
116
+ try {
117
+ for (var observers_1 = tslib_1.__values(observers), observers_1_1 = observers_1.next(); !observers_1_1.done; observers_1_1 = observers_1.next()) {
118
+ var obs = observers_1_1.value;
119
+ /* istanbul ignore next */
120
+ (_b = obs.next) === null || _b === void 0 ? void 0 : _b.call(obs, value);
121
+ }
122
+ }
123
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
124
+ finally {
125
+ try {
126
+ if (observers_1_1 && !observers_1_1.done && (_a = observers_1.return)) _a.call(observers_1);
127
+ }
128
+ finally { if (e_2) throw e_2.error; }
129
+ }
130
+ },
131
+ error: function (err) {
132
+ var e_3, _a;
133
+ var _b;
134
+ try {
135
+ for (var observers_2 = tslib_1.__values(observers), observers_2_1 = observers_2.next(); !observers_2_1.done; observers_2_1 = observers_2.next()) {
136
+ var obs = observers_2_1.value;
137
+ /* istanbul ignore next */
138
+ (_b = obs.error) === null || _b === void 0 ? void 0 : _b.call(obs, err);
139
+ }
140
+ }
141
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
142
+ finally {
143
+ try {
144
+ if (observers_2_1 && !observers_2_1.done && (_a = observers_2.return)) _a.call(observers_2);
145
+ }
146
+ finally { if (e_3) throw e_3.error; }
147
+ }
148
+ cleanup();
149
+ },
150
+ complete: function () {
151
+ var e_4, _a;
152
+ var _b;
153
+ try {
154
+ for (var observers_3 = tslib_1.__values(observers), observers_3_1 = observers_3.next(); !observers_3_1.done; observers_3_1 = observers_3.next()) {
155
+ var obs = observers_3_1.value;
156
+ /* istanbul ignore next */
157
+ (_b = obs.complete) === null || _b === void 0 ? void 0 : _b.call(obs);
158
+ }
159
+ }
160
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
161
+ finally {
162
+ try {
163
+ if (observers_3_1 && !observers_3_1.done && (_a = observers_3.return)) _a.call(observers_3);
164
+ }
165
+ finally { if (e_4) throw e_4.error; }
166
+ }
167
+ cleanup();
168
+ },
169
+ });
170
+ }
171
+ // Return unsubscribe function for this observer
172
+ return function () {
173
+ observers.delete(observer);
174
+ // If no observers left, unsubscribe from the source
175
+ if (observers.size === 0 && subscription) {
176
+ subscription.unsubscribe();
177
+ subscription = null;
178
+ }
179
+ };
180
+ });
181
+ }
182
+ exports.multicast = multicast;
183
+ //# sourceMappingURL=observable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../src/utils/observable.ts"],"names":[],"mappings":";;;;AAAA,uDAA+C;AAAtC,+GAAA,UAAU,OAAA;AAEnB,uDAAwF;AAExF;;;;;GAKG;AACH,SAAS,QAAQ,CAAO,UAA4B,EAAE,EAA4B;IAChF,OAAO,IAAI,8BAAa,CACtB,UAAC,QAAyF;QACxF,UAAU,CAAC,SAAS,CAAC;YACnB,IAAI,EAAE,UAAC,KAAQ;gBACb,EAAE,CAAC,KAAK,CAAC;qBACN,IAAI,CAAC,UAAC,MAAS;oBACd,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC/B,CAAC,CAAC;qBACD,KAAK,CAAC,UAAC,KAAU,IAAK,OAAA,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAArB,CAAqB,CAAC,CAAC;YAClD,CAAC;YACD,KAAK,EAAE,UAAC,KAAU;gBAChB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;YACD,QAAQ,EAAE;gBACR,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACtB,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC;AAqHQ,4BAAQ;AA/GjB;;;;;;;GAOG;AACH,SAAS,KAAK,CAAO,OAAyB,EAAE,OAAyB;IACvE,OAAO,IAAI,8BAAa,CAAQ,UAAC,QAAQ;QACvC,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAM,aAAa,GAAwB,IAAI,GAAG,EAAE,CAAC;QAErD,IAAM,OAAO,GAAG;;YACd,MAAM,GAAG,IAAI,CAAC;;gBACd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CAAC;gBAC3B,YAAY,GAAG,IAAI,CAAC;aACrB;QACH,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAEkB,8BAAS","sourcesContent":["export { Observable } from 'zen-observable-ts';\n\nimport { Observable as ZenObservable, Observer, Subscription } from 'zen-observable-ts';\n\n/**\n * asyncMap operator for Zen Observable\n *\n * Maps each value emitted by the source Observable using an async function,\n * emitting the resolved values in the same order they arrive.\n */\nfunction asyncMap<T, R>(observable: ZenObservable<T>, fn: (value: T) => Promise<R>): ZenObservable<R> {\n return new ZenObservable(\n (observer: { next: (value: R) => void; error: (error: any) => void; complete: () => void }) => {\n observable.subscribe({\n next: (value: T) => {\n fn(value)\n .then((result: R) => {\n return observer.next(result);\n })\n .catch((error: any) => observer.error(error));\n },\n error: (error: any) => {\n observer.error(error);\n },\n complete: () => {\n observer.complete();\n },\n });\n },\n );\n}\n\ntype Unsubscribable = {\n unsubscribe: () => void;\n};\n\n/**\n * merge operator for Zen Observable\n *\n * Merges two observables into a single observable, emitting values from both sources in the order they arrive.\n * @param sourceA Observable to merge\n * @param sourceB Observable to merge\n * @returns Unsubscribable cleanup function\n */\nfunction merge<A, B>(sourceA: ZenObservable<A>, sourceB: ZenObservable<B>): ZenObservable<A | B> {\n return new ZenObservable<A | B>((observer) => {\n let closed = false;\n\n const subscriptions: Set<Unsubscribable> = new Set();\n\n const cleanup = (): void => {\n closed = true;\n for (const sub of subscriptions) {\n try {\n sub.unsubscribe();\n } catch {\n /* do nothing */\n }\n }\n subscriptions.clear();\n };\n\n const subscribeTo = <T>(source: ZenObservable<T>) => {\n const sub = source.subscribe({\n next(value: T) {\n if (!closed) observer.next(value as A | B);\n },\n error(err) {\n if (!closed) {\n closed = true;\n observer.error(err);\n cleanup();\n }\n },\n complete() {\n subscriptions.delete(sub);\n if (!closed && subscriptions.size === 0) {\n observer.complete();\n cleanup();\n closed = true;\n }\n },\n });\n\n subscriptions.add(sub);\n };\n\n subscribeTo(sourceA);\n subscribeTo(sourceB);\n\n return cleanup;\n });\n}\n\n// function share() {\nfunction multicast<T>(source: ZenObservable<T>): ZenObservable<T> {\n const observers: Set<Observer<T>> = new Set();\n let subscription: Subscription | null = null;\n\n function cleanup() {\n /* istanbul ignore next */\n subscription?.unsubscribe();\n subscription = null;\n observers.clear();\n }\n\n return new ZenObservable<T>((observer) => {\n observers.add(observer);\n\n if (subscription === null) {\n subscription = source.subscribe({\n next(value) {\n for (const obs of observers) {\n /* istanbul ignore next */\n obs.next?.(value);\n }\n },\n error(err) {\n for (const obs of observers) {\n /* istanbul ignore next */\n obs.error?.(err);\n }\n cleanup();\n },\n complete() {\n for (const obs of observers) {\n /* istanbul ignore next */\n obs.complete?.();\n }\n cleanup();\n },\n });\n }\n\n // Return unsubscribe function for this observer\n return () => {\n observers.delete(observer);\n\n // If no observers left, unsubscribe from the source\n if (observers.size === 0 && subscription) {\n subscription.unsubscribe();\n subscription = null;\n }\n };\n });\n}\n\nexport { asyncMap, multicast, merge, Unsubscribable };\n"]}
@@ -7,7 +7,7 @@ import { IngestionMetadata } from './types/event/ingestion-metadata';
7
7
  import { Storage } from './types/storage';
8
8
  import { Logger, ILogger } from './logger';
9
9
  import { LogLevel } from './types/loglevel';
10
- import { IConfig, ConfigOptions, IRequestMetadata, IHistogramOptions, HistogramKey } from './types/config/core-config';
10
+ import { ConfigOptions, IRequestMetadata, IHistogramOptions, HistogramKey, IConfig } from './types/config/core-config';
11
11
  export declare const getDefaultConfig: () => {
12
12
  flushMaxRetries: number;
13
13
  flushQueueSize: number;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,C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AAwC,GAAM,EAAE,KAA0B;QACxE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1C,CAAC;IACH,sBAAC;AAAD,CAAC,AAlBD,IAkBC;;AAED;IAAA;IAIA,CAAC;IAAD,uBAAC;AAAD,CAAC,AAJD,IAIC","sourcesContent":["import { OfflineDisabled } from './types/offline';\nimport { ServerZoneType } from './types/server-zone';\nimport { Transport } from './types/transport';\nimport { Event } from './types/event/event';\nimport { Plan } from './types/event/plan';\nimport { IngestionMetadata } from './types/event/ingestion-metadata';\nimport { Storage } from './types/storage';\nimport {\n AMPLITUDE_SERVER_URL,\n AMPLITUDE_BATCH_SERVER_URL,\n EU_AMPLITUDE_SERVER_URL,\n EU_AMPLITUDE_BATCH_SERVER_URL,\n DEFAULT_INSTANCE_NAME,\n} from './types/constants';\n\nimport { Logger, ILogger } from './logger';\nimport { LogLevel } from './types/loglevel';\nimport { IConfig, ConfigOptions, IRequestMetadata, IHistogramOptions, HistogramKey } from './types/config/core-config';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 12,\n flushQueueSize: 200,\n flushIntervalMillis: 10000,\n instanceName: DEFAULT_INSTANCE_NAME,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n offline: false,\n optOut: false,\n serverUrl: AMPLITUDE_SERVER_URL,\n serverZone: 'US' as ServerZoneType,\n useBatch: false,\n});\nexport class Config implements IConfig {\n apiKey: string;\n flushIntervalMillis: number;\n flushMaxRetries: number;\n flushQueueSize: number;\n instanceName?: string;\n loggerProvider: ILogger;\n logLevel: LogLevel;\n minIdLength?: number;\n offline?: boolean | typeof OfflineDisabled;\n plan?: Plan;\n ingestionMetadata?: IngestionMetadata;\n serverUrl: string | undefined;\n serverZone?: ServerZoneType;\n transportProvider: Transport;\n storageProvider?: Storage<Event[]>;\n useBatch: boolean;\n requestMetadata?: RequestMetadata;\n\n protected _optOut = false;\n get optOut() {\n return this._optOut;\n }\n set optOut(optOut: boolean) {\n this._optOut = optOut;\n }\n\n constructor(options: ConfigOptions) {\n const defaultConfig = getDefaultConfig();\n this.apiKey = options.apiKey;\n this.flushIntervalMillis = options.flushIntervalMillis ?? defaultConfig.flushIntervalMillis;\n this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries;\n this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize;\n this.instanceName = options.instanceName || defaultConfig.instanceName;\n this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider;\n this.logLevel = options.logLevel ?? defaultConfig.logLevel;\n this.minIdLength = options.minIdLength;\n this.plan = options.plan;\n this.ingestionMetadata = options.ingestionMetadata;\n this.offline = options.offline !== undefined ? options.offline : defaultConfig.offline;\n this.optOut = options.optOut ?? defaultConfig.optOut;\n this.serverUrl = options.serverUrl;\n this.serverZone = options.serverZone || defaultConfig.serverZone;\n this.storageProvider = options.storageProvider;\n this.transportProvider = options.transportProvider;\n this.useBatch = options.useBatch ?? defaultConfig.useBatch;\n this.loggerProvider.enable(this.logLevel);\n\n const serverConfig = createServerConfig(options.serverUrl, options.serverZone, options.useBatch);\n this.serverZone = serverConfig.serverZone;\n this.serverUrl = serverConfig.serverUrl;\n }\n}\n\nexport const getServerUrl = (serverZone: ServerZoneType, useBatch: boolean) => {\n if (serverZone === 'EU') {\n return useBatch ? EU_AMPLITUDE_BATCH_SERVER_URL : EU_AMPLITUDE_SERVER_URL;\n }\n return useBatch ? AMPLITUDE_BATCH_SERVER_URL : AMPLITUDE_SERVER_URL;\n};\n\nexport const createServerConfig = (\n serverUrl = '',\n serverZone: ServerZoneType = getDefaultConfig().serverZone,\n useBatch: boolean = getDefaultConfig().useBatch,\n) => {\n if (serverUrl) {\n return { serverUrl, serverZone: undefined };\n }\n const _serverZone = ['US', 'EU'].includes(serverZone) ? serverZone : getDefaultConfig().serverZone;\n return {\n serverZone: _serverZone,\n serverUrl: getServerUrl(_serverZone, useBatch),\n };\n};\n\nexport class RequestMetadata implements IRequestMetadata {\n sdk: {\n metrics: {\n histogram: HistogramOptions;\n };\n };\n\n constructor() {\n this.sdk = {\n metrics: {\n histogram: {},\n },\n };\n }\n\n recordHistogram<T extends HistogramKey>(key: T, value: HistogramOptions[T]) {\n this.sdk.metrics.histogram[key] = value;\n }\n}\n\nclass HistogramOptions implements IHistogramOptions {\n remote_config_fetch_time_IDB?: number;\n remote_config_fetch_time_API_success?: number;\n remote_config_fetch_time_API_fail?: number;\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAW,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,CAAC,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,KAAK;IAC1B,YAAY,EAAE,qBAAqB;IACnC,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,MAAM,EAAE;IAC5B,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,oBAAoB;IAC/B,UAAU,EAAE,IAAsB;IAClC,QAAQ,EAAE,KAAK;CAChB,CAAC,EAZoC,CAYpC,CAAC;AACH;IA2BE,gBAAY,OAAsB;;QARxB,YAAO,GAAG,KAAK,CAAC;QASxB,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,mBAAmB,GAAG,MAAA,OAAO,CAAC,mBAAmB,mCAAI,aAAa,CAAC,mBAAmB,CAAC;QAC5F,IAA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AC;KAC/C,CAAC;AACJ,CAAC,CAAC;AAEF;IAOE;QACE,IAAI,CAAC,GAAG,GAAG;YACT,OAAO,EAAE;gBACP,SAAS,EAAE,EAAE;aACd;SACF,CAAC;IACJ,CAAC;IAED,yCAAe,GAAf,UAAwC,GAAM,EAAE,KAA0B;QACxE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1C,CAAC;IACH,sBAAC;AAAD,CAAC,AAlBD,IAkBC;;AAED;IAAA;IAIA,CAAC;IAAD,uBAAC;AAAD,CAAC,AAJD,IAIC","sourcesContent":["import { OfflineDisabled } from './types/offline';\nimport { ServerZoneType } from './types/server-zone';\nimport { Transport } from './types/transport';\nimport { Event } from './types/event/event';\nimport { Plan } from './types/event/plan';\nimport { IngestionMetadata } from './types/event/ingestion-metadata';\nimport { Storage } from './types/storage';\nimport {\n AMPLITUDE_SERVER_URL,\n AMPLITUDE_BATCH_SERVER_URL,\n EU_AMPLITUDE_SERVER_URL,\n EU_AMPLITUDE_BATCH_SERVER_URL,\n DEFAULT_INSTANCE_NAME,\n} from './types/constants';\n\nimport { Logger, ILogger } from './logger';\nimport { LogLevel } from './types/loglevel';\nimport { ConfigOptions, IRequestMetadata, IHistogramOptions, HistogramKey, IConfig } from './types/config/core-config';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 12,\n flushQueueSize: 200,\n flushIntervalMillis: 10000,\n instanceName: DEFAULT_INSTANCE_NAME,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n offline: false,\n optOut: false,\n serverUrl: AMPLITUDE_SERVER_URL,\n serverZone: 'US' as ServerZoneType,\n useBatch: false,\n});\nexport class Config implements IConfig {\n apiKey: string;\n flushIntervalMillis: number;\n flushMaxRetries: number;\n flushQueueSize: number;\n instanceName?: string;\n loggerProvider: ILogger;\n logLevel: LogLevel;\n minIdLength?: number;\n offline?: boolean | typeof OfflineDisabled;\n plan?: Plan;\n ingestionMetadata?: IngestionMetadata;\n serverUrl: string | undefined;\n serverZone?: ServerZoneType;\n transportProvider: Transport;\n storageProvider?: Storage<Event[]>;\n useBatch: boolean;\n requestMetadata?: RequestMetadata;\n\n protected _optOut = false;\n get optOut() {\n return this._optOut;\n }\n set optOut(optOut: boolean) {\n this._optOut = optOut;\n }\n\n constructor(options: ConfigOptions) {\n const defaultConfig = getDefaultConfig();\n this.apiKey = options.apiKey;\n this.flushIntervalMillis = options.flushIntervalMillis ?? defaultConfig.flushIntervalMillis;\n this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries;\n this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize;\n this.instanceName = options.instanceName || defaultConfig.instanceName;\n this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider;\n this.logLevel = options.logLevel ?? defaultConfig.logLevel;\n this.minIdLength = options.minIdLength;\n this.plan = options.plan;\n this.ingestionMetadata = options.ingestionMetadata;\n this.offline = options.offline !== undefined ? options.offline : defaultConfig.offline;\n this.optOut = options.optOut ?? defaultConfig.optOut;\n this.serverUrl = options.serverUrl;\n this.serverZone = options.serverZone || defaultConfig.serverZone;\n this.storageProvider = options.storageProvider;\n this.transportProvider = options.transportProvider;\n this.useBatch = options.useBatch ?? defaultConfig.useBatch;\n this.loggerProvider.enable(this.logLevel);\n\n const serverConfig = createServerConfig(options.serverUrl, options.serverZone, options.useBatch);\n this.serverZone = serverConfig.serverZone;\n this.serverUrl = serverConfig.serverUrl;\n }\n}\n\nexport const getServerUrl = (serverZone: ServerZoneType, useBatch: boolean) => {\n if (serverZone === 'EU') {\n return useBatch ? EU_AMPLITUDE_BATCH_SERVER_URL : EU_AMPLITUDE_SERVER_URL;\n }\n return useBatch ? AMPLITUDE_BATCH_SERVER_URL : AMPLITUDE_SERVER_URL;\n};\n\nexport const createServerConfig = (\n serverUrl = '',\n serverZone: ServerZoneType = getDefaultConfig().serverZone,\n useBatch: boolean = getDefaultConfig().useBatch,\n) => {\n if (serverUrl) {\n return { serverUrl, serverZone: undefined };\n }\n const _serverZone = ['US', 'EU'].includes(serverZone) ? serverZone : getDefaultConfig().serverZone;\n return {\n serverZone: _serverZone,\n serverUrl: getServerUrl(_serverZone, useBatch),\n };\n};\n\nexport class RequestMetadata implements IRequestMetadata {\n sdk: {\n metrics: {\n histogram: HistogramOptions;\n };\n };\n\n constructor() {\n this.sdk = {\n metrics: {\n histogram: {},\n },\n };\n }\n\n recordHistogram<T extends HistogramKey>(key: T, value: HistogramOptions[T]) {\n this.sdk.metrics.histogram[key] = value;\n }\n}\n\nclass HistogramOptions implements IHistogramOptions {\n remote_config_fetch_time_IDB?: number;\n remote_config_fetch_time_API_success?: number;\n remote_config_fetch_time_API_fail?: number;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics-client.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAsB,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,iBAAiB,QAAgB,CAAC;AAC/C,eAAO,MAAM,yBAAyB,gEAAgE,CAAC;AACvG,eAAO,MAAM,yBAAyB,mEAAmE,CAAC;AAG1G,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAC9C,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAIlD;;GAEG;AACH,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C;;GAEG;AACH,KAAK,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD;;GAEG;AACH,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE3C;;GAEG;AACH,UAAU,gBAA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B;IA2B7B;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;CAMzC"}
@@ -2,6 +2,7 @@ import { __assign, __awaiter, __generator, __read, __spreadArray } from "tslib";
2
2
  import { DiagnosticsStorage } from './diagnostics-storage';
3
3
  import { getGlobalScope } from '../global-scope';
4
4
  import { isTimestampInSampleTemp } from '../utils/sampling';
5
+ import { enableSdkErrorListeners } from './uncaught-sdk-errors';
5
6
  export var SAVE_INTERVAL_MS = 1000; // 1 second
6
7
  export var FLUSH_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
7
8
  export var DIAGNOSTICS_US_SERVER_URL = 'https://diagnostics.prod.us-west-2.amplitude.com/v1/capture';
@@ -39,6 +40,7 @@ var DiagnosticsClient = /** @class */ (function () {
39
40
  // Track internal diagnostics metrics for sampling
40
41
  if (this.shouldTrack) {
41
42
  this.increment('sdk.diagnostics.sampled.in.and.enabled');
43
+ enableSdkErrorListeners(this);
42
44
  }
43
45
  }
44
46
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics-client.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-client.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,CAAC,IAAM,gBAAgB,GAAG,IAAI,CAAC,CAAC,WAAW;AACjD,MAAM,CAAC,IAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAC5D,MAAM,CAAC,IAAM,yBAAyB,GAAG,6DAA6D,CAAC;AACvG,MAAM,CAAC,IAAM,yBAAyB,GAAG,gEAAgE,CAAC;AAE1G,2BAA2B;AAC3B,MAAM,CAAC,IAAM,wBAAwB,GAAG,KAAK,CAAC,CA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AiB,EAAE;4BAC3C,oDAAoD;4BACpD,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;4BACnB,sBAAO;yBACR;6BAAM;4BACL,+BAA+B;4BAC/B,IAAI,CAAC,cAAc,CAAC,iBAAiB,GAAG,kBAAkB,CAAC,CAAC;yBAC7D;;;;;KACF;IAED;;OAEG;IACK,0CAAc,GAAtB,UAAuB,KAAa;QAApC,iBAUC;QATC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;YAC3B,KAAI,CAAC,MAAM,EAAE;iBACV,KAAK,CAAC,UAAC,KAAK;gBACX,KAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;YACjE,CAAC,CAAC;iBACD,OAAO,CAAC;gBACP,KAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACzB,CAAC,CAAC,CAAC;QACP,CAAC,EAAE,KAAK,CAAC,CAAC;IACZ,CAAC;IAED,0CAAc,GAAd,UAAe,UAAkB;QAC/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE,UAAU,CAAC,CAAC;QAC3E,IAAI,CAAC,MAAM,CAAC,UAAU,GAAG,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,uBAAuB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC/G,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;IACH,wBAAC;AAAD,CAAC,AAjVD,IAiVC","sourcesContent":["import { ILogger } from '../logger';\nimport { DiagnosticsStorage, IDiagnosticsStorage } from './diagnostics-storage';\nimport { ServerZoneType } from '../types/server-zone';\nimport { getGlobalScope } from '../global-scope';\nimport { isTimestampInSampleTemp } from '../utils/sampling';\n\nexport const SAVE_INTERVAL_MS = 1000; // 1 second\nexport const FLUSH_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes\nexport const DIAGNOSTICS_US_SERVER_URL = 'https://diagnostics.prod.us-west-2.amplitude.com/v1/capture';\nexport const DIAGNOSTICS_EU_SERVER_URL = 'https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture';\n\n// In-memory storage limits\nexport const MAX_MEMORY_STORAGE_COUNT = 10000; // for tags, counters, histograms separately\nexport const MAX_MEMORY_STORAGE_EVENTS_COUNT = 10;\n\n// === Core Data Types ===\n\n/**\n * Key-value pairs for environment/context information\n */\ntype DiagnosticsTags = Record<string, string>;\n\n/**\n * Numeric counters that can be incremented\n */\ntype DiagnosticsCounters = Record<string, number>;\n\n/**\n * Properties for diagnostic events\n */\ntype EventProperties = Record<string, any>;\n\n/**\n * Individual diagnostic event\n */\ninterface DiagnosticsEvent {\n readonly event_name: string;\n readonly time: number;\n readonly event_properties: EventProperties;\n}\n\n/**\n * Computed histogram statistics for final payload\n */\ninterface HistogramResult {\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly avg: number;\n}\n\n/**\n * Internal histogram statistics with sum for efficient incremental updates\n */\nexport interface HistogramStats {\n count: number;\n min: number;\n max: number;\n sum: number; // Used for avg calculation\n}\n\n/**\n * Collection of histogram results keyed by histogram name\n */\ntype DiagnosticsHistograms = Record<string, HistogramResult>;\n\n/**\n * Collection of histogram stats keyed by histogram name (internal use for memory + persistence storage)\n */\ntype DiagnosticsHistogramStats = Record<string, HistogramStats>;\n\n// === Payload Types ===\n\n/**\n * Complete diagnostics payload sent to backend\n */\ninterface FlushPayload {\n readonly tags: DiagnosticsTags;\n readonly histogram: DiagnosticsHistograms;\n readonly counters: DiagnosticsCounters;\n readonly events: readonly DiagnosticsEvent[];\n}\n\n/**\n * Amplitude Diagnostics Client\n *\n * A client for collecting and managing diagnostics data including tags, counters,\n * histograms, and events. Data is stored persistently using IndexedDB to survive browser restarts and offline scenarios.\n *\n * Key Features:\n * - IndexedDB storage\n * - Time-based persistent storage flush interval (5 minutes since last flush)\n * - 1 second time-based memory storage flush to persistent storage\n * - Histogram statistics calculation (min, max, avg)\n */\nexport interface IDiagnosticsClient {\n /**\n * Set or update a tag\n *\n * @example\n * ```typescript\n * // Set environment tags\n * diagnostics.setTag('library', 'amplitude-typescript/2.0.0');\n * diagnostics.setTag('user_agent', navigator.userAgent);\n * ```\n */\n setTag(name: string, value: string): void;\n\n /**\n * Increment a counter. If doesn't exist, create a counter and set value to 1\n *\n * @example\n * ```typescript\n * // Track counters\n * diagnostics.increment('analytics.fileNotFound');\n * diagnostics.increment('network.retry', 3);\n * ```\n */\n increment(name: string, size?: number): void;\n\n /**\n * Record a histogram value\n *\n * @example\n * ```typescript\n * // Record performance metrics\n * diagnostics.recordHistogram('sr.time', 5.2);\n * diagnostics.recordHistogram('network.latency', 150);\n * ```\n */\n recordHistogram(name: string, value: number): void;\n\n /**\n * Record an event\n *\n * @example\n * ```typescript\n * // Record diagnostic events\n * diagnostics.recordEvent('error', {\n * stack_trace: '...',\n * });\n * ```\n */\n recordEvent(name: string, properties: EventProperties): void;\n\n // Flush storage\n _flush(): void;\n\n /**\n * Sets the sample rate for diagnostics.\n *\n * @example\n * ```typescript\n * diagnostics.setSampleRate(0.5);\n * ```\n */\n _setSampleRate(sampleRate: number): void;\n}\n\nexport class DiagnosticsClient implements IDiagnosticsClient {\n storage?: IDiagnosticsStorage;\n logger: ILogger;\n serverUrl: string;\n apiKey: string;\n // Whether to track diagnostics data based on sample rate and enabled flag\n shouldTrack: boolean;\n config: {\n enabled: boolean;\n sampleRate: number;\n };\n /**\n * The timestamp when the diagnostics client was initialized.\n * Save in memory to keep lifecycle sample rate calculation consistency.\n */\n startTimestamp: number;\n\n // In-memory storages\n inMemoryTags: DiagnosticsTags = {};\n inMemoryCounters: DiagnosticsCounters = {};\n inMemoryHistograms: DiagnosticsHistogramStats = {};\n inMemoryEvents: DiagnosticsEvent[] = [];\n\n // Timer for 1-second persistence\n saveTimer: ReturnType<typeof setTimeout> | null = null;\n // Timer for flush interval\n flushTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(\n apiKey: string,\n logger: ILogger,\n serverZone: ServerZoneType = 'US',\n options?: {\n enabled?: boolean;\n sampleRate?: number;\n },\n ) {\n this.apiKey = apiKey;\n this.logger = logger;\n this.serverUrl = serverZone === 'US' ? DIAGNOSTICS_US_SERVER_URL : DIAGNOSTICS_EU_SERVER_URL;\n\n this.logger.debug('DiagnosticsClient: Initializing with options', JSON.stringify(options, null, 2));\n // Diagnostics is enabled by default with sample rate of 0 (no sampling)\n this.config = { enabled: true, sampleRate: 0, ...options };\n this.startTimestamp = Date.now();\n this.shouldTrack = isTimestampInSampleTemp(this.startTimestamp, this.config.sampleRate) && this.config.enabled;\n\n if (DiagnosticsStorage.isSupported()) {\n this.storage = new DiagnosticsStorage(apiKey, logger);\n } else {\n this.logger.debug('DiagnosticsClient: IndexedDB is not supported');\n }\n\n void this.initializeFlushInterval();\n\n // Track internal diagnostics metrics for sampling\n if (this.shouldTrack) {\n this.increment('sdk.diagnostics.sampled.in.and.enabled');\n }\n }\n\n /**\n * Check if storage is available and tracking is enabled\n */\n isStorageAndTrackEnabled(): boolean {\n return Boolean(this.storage) && Boolean(this.shouldTrack);\n }\n\n setTag(name: string, value: string) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (Object.keys(this.inMemoryTags).length >= MAX_MEMORY_STORAGE_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return setTags as reaching memory limit');\n return;\n }\n\n this.inMemoryTags[name] = value;\n this.startTimersIfNeeded();\n }\n\n increment(name: string, size = 1) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (Object.keys(this.inMemoryCounters).length >= MAX_MEMORY_STORAGE_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return increment as reaching memory limit');\n return;\n }\n\n this.inMemoryCounters[name] = (this.inMemoryCounters[name] || 0) + size;\n this.startTimersIfNeeded();\n }\n\n recordHistogram(name: string, value: number) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (Object.keys(this.inMemoryHistograms).length >= MAX_MEMORY_STORAGE_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return recordHistogram as reaching memory limit');\n return;\n }\n\n const existing = this.inMemoryHistograms[name];\n if (existing) {\n // Update existing stats incrementally\n existing.count += 1;\n existing.min = Math.min(existing.min, value);\n existing.max = Math.max(existing.max, value);\n existing.sum += value;\n } else {\n // Create new stats\n this.inMemoryHistograms[name] = {\n count: 1,\n min: value,\n max: value,\n sum: value,\n };\n }\n this.startTimersIfNeeded();\n }\n\n recordEvent(name: string, properties: EventProperties) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (this.inMemoryEvents.length >= MAX_MEMORY_STORAGE_EVENTS_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return recordEvent as reaching memory limit');\n return;\n }\n\n this.inMemoryEvents.push({\n event_name: name,\n time: Date.now(),\n event_properties: properties,\n });\n this.startTimersIfNeeded();\n }\n\n startTimersIfNeeded() {\n if (!this.saveTimer) {\n this.saveTimer = setTimeout(() => {\n this.saveAllDataToStorage()\n .catch((error) => {\n this.logger.debug('DiagnosticsClient: Failed to save all data to storage', error);\n })\n .finally(() => {\n this.saveTimer = null;\n });\n }, SAVE_INTERVAL_MS);\n }\n\n if (!this.flushTimer) {\n this.flushTimer = setTimeout(() => {\n this._flush()\n .catch((error) => {\n this.logger.debug('DiagnosticsClient: Failed to flush', error);\n })\n .finally(() => {\n this.flushTimer = null;\n });\n }, FLUSH_INTERVAL_MS);\n }\n }\n\n async saveAllDataToStorage() {\n if (!this.storage) {\n return;\n }\n const tagsToSave = { ...this.inMemoryTags };\n const countersToSave = { ...this.inMemoryCounters };\n const histogramsToSave = { ...this.inMemoryHistograms };\n const eventsToSave = [...this.inMemoryEvents];\n\n this.inMemoryEvents = [];\n this.inMemoryTags = {};\n this.inMemoryCounters = {};\n this.inMemoryHistograms = {};\n\n await Promise.all([\n this.storage.setTags(tagsToSave),\n this.storage.incrementCounters(countersToSave),\n this.storage.setHistogramStats(histogramsToSave),\n this.storage.addEventRecords(eventsToSave),\n ]);\n }\n\n async _flush() {\n if (!this.storage) {\n return;\n }\n\n await this.saveAllDataToStorage();\n this.saveTimer = null;\n this.flushTimer = null;\n\n // Get all data from storage and clear it\n const {\n tags: tagRecords,\n counters: counterRecords,\n histogramStats: histogramStatsRecords,\n events: eventRecords,\n } = await this.storage.getAllAndClear();\n\n // Update the last flush timestamp\n void this.storage.setLastFlushTimestamp(Date.now());\n\n // Convert metrics to the expected format\n const tags: DiagnosticsTags = {};\n tagRecords.forEach((record) => {\n tags[record.key] = record.value;\n });\n\n const counters: DiagnosticsCounters = {};\n counterRecords.forEach((record) => {\n counters[record.key] = record.value;\n });\n\n const histogram: DiagnosticsHistograms = {};\n histogramStatsRecords.forEach((stats) => {\n histogram[stats.key] = {\n count: stats.count,\n min: stats.min,\n max: stats.max,\n avg: Math.round((stats.sum / stats.count) * 100) / 100, // round the average to 2 decimal places.\n };\n });\n\n const events: DiagnosticsEvent[] = eventRecords.map((record) => ({\n event_name: record.event_name,\n time: record.time,\n event_properties: record.event_properties,\n }));\n\n // Early return if all data collections are empty\n if (Object.keys(counters).length === 0 && Object.keys(histogram).length === 0 && events.length === 0) {\n return;\n }\n\n // Create flush payload\n const payload: FlushPayload = {\n tags,\n histogram,\n counters,\n events,\n };\n\n // Send payload to diagnostics server\n void this.fetch(payload);\n }\n\n /**\n * Send diagnostics data to the server\n */\n async fetch(payload: FlushPayload) {\n try {\n if (!getGlobalScope()) {\n throw new Error('DiagnosticsClient: Fetch is not supported');\n }\n\n const response = await fetch(this.serverUrl, {\n method: 'POST',\n headers: {\n 'X-ApiKey': this.apiKey,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n this.logger.debug('DiagnosticsClient: Failed to send diagnostics data.');\n return;\n }\n\n this.logger.debug('DiagnosticsClient: Successfully sent diagnostics data');\n } catch (error) {\n this.logger.debug('DiagnosticsClient: Failed to send diagnostics data. ', error);\n }\n }\n\n /**\n * Initialize flush interval logic.\n * Check if 5 minutes has passed since last flush, if so flush immediately.\n * Otherwise set a timer to flush when the interval is reached.\n */\n async initializeFlushInterval() {\n if (!this.storage) {\n return;\n }\n const now = Date.now();\n const lastFlushTimestamp = (await this.storage.getLastFlushTimestamp()) || -1;\n\n // If last flush timestamp is -1, it means this is a new client\n // Save current timestamp as the initial \"last flush timestamp\"\n // and schedule the flush timer\n if (lastFlushTimestamp === -1) {\n void this.storage.setLastFlushTimestamp(now);\n this._setFlushTimer(FLUSH_INTERVAL_MS);\n return;\n }\n\n const timeSinceLastFlush = now - lastFlushTimestamp;\n if (timeSinceLastFlush >= FLUSH_INTERVAL_MS) {\n // More than 5 minutes has passed, flush immediately\n void this._flush();\n return;\n } else {\n // Set timer for remaining time\n this._setFlushTimer(FLUSH_INTERVAL_MS - timeSinceLastFlush);\n }\n }\n\n /**\n * Helper method to set flush timer with consistent error handling\n */\n private _setFlushTimer(delay: number) {\n this.flushTimer = setTimeout(() => {\n this._flush()\n .catch((error) => {\n this.logger.debug('DiagnosticsClient: Failed to flush', error);\n })\n .finally(() => {\n this.flushTimer = null;\n });\n }, delay);\n }\n\n _setSampleRate(sampleRate: number): void {\n this.logger.debug('DiagnosticsClient: Setting sample rate to', sampleRate);\n this.config.sampleRate = sampleRate;\n this.shouldTrack = isTimestampInSampleTemp(this.startTimestamp, this.config.sampleRate) && this.config.enabled;\n this.logger.debug('DiagnosticsClient: Should track is', this.shouldTrack);\n }\n}\n"]}
1
+ {"version":3,"file":"diagnostics-client.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnostics-client.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE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,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAC/G,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;IACH,wBAAC;AAAD,CAAC,AAlVD,IAkVC","sourcesContent":["import { ILogger } from '../logger';\nimport { DiagnosticsStorage, IDiagnosticsStorage } from './diagnostics-storage';\nimport { ServerZoneType } from '../types/server-zone';\nimport { getGlobalScope } from '../global-scope';\nimport { isTimestampInSampleTemp } from '../utils/sampling';\nimport { enableSdkErrorListeners } from './uncaught-sdk-errors';\n\nexport const SAVE_INTERVAL_MS = 1000; // 1 second\nexport const FLUSH_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes\nexport const DIAGNOSTICS_US_SERVER_URL = 'https://diagnostics.prod.us-west-2.amplitude.com/v1/capture';\nexport const DIAGNOSTICS_EU_SERVER_URL = 'https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture';\n\n// In-memory storage limits\nexport const MAX_MEMORY_STORAGE_COUNT = 10000; // for tags, counters, histograms separately\nexport const MAX_MEMORY_STORAGE_EVENTS_COUNT = 10;\n\n// === Core Data Types ===\n\n/**\n * Key-value pairs for environment/context information\n */\ntype DiagnosticsTags = Record<string, string>;\n\n/**\n * Numeric counters that can be incremented\n */\ntype DiagnosticsCounters = Record<string, number>;\n\n/**\n * Properties for diagnostic events\n */\ntype EventProperties = Record<string, any>;\n\n/**\n * Individual diagnostic event\n */\ninterface DiagnosticsEvent {\n readonly event_name: string;\n readonly time: number;\n readonly event_properties: EventProperties;\n}\n\n/**\n * Computed histogram statistics for final payload\n */\ninterface HistogramResult {\n readonly count: number;\n readonly min: number;\n readonly max: number;\n readonly avg: number;\n}\n\n/**\n * Internal histogram statistics with sum for efficient incremental updates\n */\nexport interface HistogramStats {\n count: number;\n min: number;\n max: number;\n sum: number; // Used for avg calculation\n}\n\n/**\n * Collection of histogram results keyed by histogram name\n */\ntype DiagnosticsHistograms = Record<string, HistogramResult>;\n\n/**\n * Collection of histogram stats keyed by histogram name (internal use for memory + persistence storage)\n */\ntype DiagnosticsHistogramStats = Record<string, HistogramStats>;\n\n// === Payload Types ===\n\n/**\n * Complete diagnostics payload sent to backend\n */\ninterface FlushPayload {\n readonly tags: DiagnosticsTags;\n readonly histogram: DiagnosticsHistograms;\n readonly counters: DiagnosticsCounters;\n readonly events: readonly DiagnosticsEvent[];\n}\n\n/**\n * Amplitude Diagnostics Client\n *\n * A client for collecting and managing diagnostics data including tags, counters,\n * histograms, and events. Data is stored persistently using IndexedDB to survive browser restarts and offline scenarios.\n *\n * Key Features:\n * - IndexedDB storage\n * - Time-based persistent storage flush interval (5 minutes since last flush)\n * - 1 second time-based memory storage flush to persistent storage\n * - Histogram statistics calculation (min, max, avg)\n */\nexport interface IDiagnosticsClient {\n /**\n * Set or update a tag\n *\n * @example\n * ```typescript\n * // Set environment tags\n * diagnostics.setTag('library', 'amplitude-typescript/2.0.0');\n * diagnostics.setTag('user_agent', navigator.userAgent);\n * ```\n */\n setTag(name: string, value: string): void;\n\n /**\n * Increment a counter. If doesn't exist, create a counter and set value to 1\n *\n * @example\n * ```typescript\n * // Track counters\n * diagnostics.increment('analytics.fileNotFound');\n * diagnostics.increment('network.retry', 3);\n * ```\n */\n increment(name: string, size?: number): void;\n\n /**\n * Record a histogram value\n *\n * @example\n * ```typescript\n * // Record performance metrics\n * diagnostics.recordHistogram('sr.time', 5.2);\n * diagnostics.recordHistogram('network.latency', 150);\n * ```\n */\n recordHistogram(name: string, value: number): void;\n\n /**\n * Record an event\n *\n * @example\n * ```typescript\n * // Record diagnostic events\n * diagnostics.recordEvent('error', {\n * stack_trace: '...',\n * });\n * ```\n */\n recordEvent(name: string, properties: EventProperties): void;\n\n // Flush storage\n _flush(): void;\n\n /**\n * Sets the sample rate for diagnostics.\n *\n * @example\n * ```typescript\n * diagnostics.setSampleRate(0.5);\n * ```\n */\n _setSampleRate(sampleRate: number): void;\n}\n\nexport class DiagnosticsClient implements IDiagnosticsClient {\n storage?: IDiagnosticsStorage;\n logger: ILogger;\n serverUrl: string;\n apiKey: string;\n // Whether to track diagnostics data based on sample rate and enabled flag\n shouldTrack: boolean;\n config: {\n enabled: boolean;\n sampleRate: number;\n };\n /**\n * The timestamp when the diagnostics client was initialized.\n * Save in memory to keep lifecycle sample rate calculation consistency.\n */\n startTimestamp: number;\n\n // In-memory storages\n inMemoryTags: DiagnosticsTags = {};\n inMemoryCounters: DiagnosticsCounters = {};\n inMemoryHistograms: DiagnosticsHistogramStats = {};\n inMemoryEvents: DiagnosticsEvent[] = [];\n\n // Timer for 1-second persistence\n saveTimer: ReturnType<typeof setTimeout> | null = null;\n // Timer for flush interval\n flushTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(\n apiKey: string,\n logger: ILogger,\n serverZone: ServerZoneType = 'US',\n options?: {\n enabled?: boolean;\n sampleRate?: number;\n },\n ) {\n this.apiKey = apiKey;\n this.logger = logger;\n this.serverUrl = serverZone === 'US' ? DIAGNOSTICS_US_SERVER_URL : DIAGNOSTICS_EU_SERVER_URL;\n\n this.logger.debug('DiagnosticsClient: Initializing with options', JSON.stringify(options, null, 2));\n // Diagnostics is enabled by default with sample rate of 0 (no sampling)\n this.config = { enabled: true, sampleRate: 0, ...options };\n this.startTimestamp = Date.now();\n this.shouldTrack = isTimestampInSampleTemp(this.startTimestamp, this.config.sampleRate) && this.config.enabled;\n\n if (DiagnosticsStorage.isSupported()) {\n this.storage = new DiagnosticsStorage(apiKey, logger);\n } else {\n this.logger.debug('DiagnosticsClient: IndexedDB is not supported');\n }\n\n void this.initializeFlushInterval();\n\n // Track internal diagnostics metrics for sampling\n if (this.shouldTrack) {\n this.increment('sdk.diagnostics.sampled.in.and.enabled');\n enableSdkErrorListeners(this);\n }\n }\n\n /**\n * Check if storage is available and tracking is enabled\n */\n isStorageAndTrackEnabled(): boolean {\n return Boolean(this.storage) && Boolean(this.shouldTrack);\n }\n\n setTag(name: string, value: string) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (Object.keys(this.inMemoryTags).length >= MAX_MEMORY_STORAGE_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return setTags as reaching memory limit');\n return;\n }\n\n this.inMemoryTags[name] = value;\n this.startTimersIfNeeded();\n }\n\n increment(name: string, size = 1) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (Object.keys(this.inMemoryCounters).length >= MAX_MEMORY_STORAGE_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return increment as reaching memory limit');\n return;\n }\n\n this.inMemoryCounters[name] = (this.inMemoryCounters[name] || 0) + size;\n this.startTimersIfNeeded();\n }\n\n recordHistogram(name: string, value: number) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (Object.keys(this.inMemoryHistograms).length >= MAX_MEMORY_STORAGE_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return recordHistogram as reaching memory limit');\n return;\n }\n\n const existing = this.inMemoryHistograms[name];\n if (existing) {\n // Update existing stats incrementally\n existing.count += 1;\n existing.min = Math.min(existing.min, value);\n existing.max = Math.max(existing.max, value);\n existing.sum += value;\n } else {\n // Create new stats\n this.inMemoryHistograms[name] = {\n count: 1,\n min: value,\n max: value,\n sum: value,\n };\n }\n this.startTimersIfNeeded();\n }\n\n recordEvent(name: string, properties: EventProperties) {\n if (!this.isStorageAndTrackEnabled()) {\n return;\n }\n\n if (this.inMemoryEvents.length >= MAX_MEMORY_STORAGE_EVENTS_COUNT) {\n this.logger.debug('DiagnosticsClient: Early return recordEvent as reaching memory limit');\n return;\n }\n\n this.inMemoryEvents.push({\n event_name: name,\n time: Date.now(),\n event_properties: properties,\n });\n this.startTimersIfNeeded();\n }\n\n startTimersIfNeeded() {\n if (!this.saveTimer) {\n this.saveTimer = setTimeout(() => {\n this.saveAllDataToStorage()\n .catch((error) => {\n this.logger.debug('DiagnosticsClient: Failed to save all data to storage', error);\n })\n .finally(() => {\n this.saveTimer = null;\n });\n }, SAVE_INTERVAL_MS);\n }\n\n if (!this.flushTimer) {\n this.flushTimer = setTimeout(() => {\n this._flush()\n .catch((error) => {\n this.logger.debug('DiagnosticsClient: Failed to flush', error);\n })\n .finally(() => {\n this.flushTimer = null;\n });\n }, FLUSH_INTERVAL_MS);\n }\n }\n\n async saveAllDataToStorage() {\n if (!this.storage) {\n return;\n }\n const tagsToSave = { ...this.inMemoryTags };\n const countersToSave = { ...this.inMemoryCounters };\n const histogramsToSave = { ...this.inMemoryHistograms };\n const eventsToSave = [...this.inMemoryEvents];\n\n this.inMemoryEvents = [];\n this.inMemoryTags = {};\n this.inMemoryCounters = {};\n this.inMemoryHistograms = {};\n\n await Promise.all([\n this.storage.setTags(tagsToSave),\n this.storage.incrementCounters(countersToSave),\n this.storage.setHistogramStats(histogramsToSave),\n this.storage.addEventRecords(eventsToSave),\n ]);\n }\n\n async _flush() {\n if (!this.storage) {\n return;\n }\n\n await this.saveAllDataToStorage();\n this.saveTimer = null;\n this.flushTimer = null;\n\n // Get all data from storage and clear it\n const {\n tags: tagRecords,\n counters: counterRecords,\n histogramStats: histogramStatsRecords,\n events: eventRecords,\n } = await this.storage.getAllAndClear();\n\n // Update the last flush timestamp\n void this.storage.setLastFlushTimestamp(Date.now());\n\n // Convert metrics to the expected format\n const tags: DiagnosticsTags = {};\n tagRecords.forEach((record) => {\n tags[record.key] = record.value;\n });\n\n const counters: DiagnosticsCounters = {};\n counterRecords.forEach((record) => {\n counters[record.key] = record.value;\n });\n\n const histogram: DiagnosticsHistograms = {};\n histogramStatsRecords.forEach((stats) => {\n histogram[stats.key] = {\n count: stats.count,\n min: stats.min,\n max: stats.max,\n avg: Math.round((stats.sum / stats.count) * 100) / 100, // round the average to 2 decimal places.\n };\n });\n\n const events: DiagnosticsEvent[] = eventRecords.map((record) => ({\n event_name: record.event_name,\n time: record.time,\n event_properties: record.event_properties,\n }));\n\n // Early return if all data collections are empty\n if (Object.keys(counters).length === 0 && Object.keys(histogram).length === 0 && events.length === 0) {\n return;\n }\n\n // Create flush payload\n const payload: FlushPayload = {\n tags,\n histogram,\n counters,\n events,\n };\n\n // Send payload to diagnostics server\n void this.fetch(payload);\n }\n\n /**\n * Send diagnostics data to the server\n */\n async fetch(payload: FlushPayload) {\n try {\n if (!getGlobalScope()) {\n throw new Error('DiagnosticsClient: Fetch is not supported');\n }\n\n const response = await fetch(this.serverUrl, {\n method: 'POST',\n headers: {\n 'X-ApiKey': this.apiKey,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n this.logger.debug('DiagnosticsClient: Failed to send diagnostics data.');\n return;\n }\n\n this.logger.debug('DiagnosticsClient: Successfully sent diagnostics data');\n } catch (error) {\n this.logger.debug('DiagnosticsClient: Failed to send diagnostics data. ', error);\n }\n }\n\n /**\n * Initialize flush interval logic.\n * Check if 5 minutes has passed since last flush, if so flush immediately.\n * Otherwise set a timer to flush when the interval is reached.\n */\n async initializeFlushInterval() {\n if (!this.storage) {\n return;\n }\n const now = Date.now();\n const lastFlushTimestamp = (await this.storage.getLastFlushTimestamp()) || -1;\n\n // If last flush timestamp is -1, it means this is a new client\n // Save current timestamp as the initial \"last flush timestamp\"\n // and schedule the flush timer\n if (lastFlushTimestamp === -1) {\n void this.storage.setLastFlushTimestamp(now);\n this._setFlushTimer(FLUSH_INTERVAL_MS);\n return;\n }\n\n const timeSinceLastFlush = now - lastFlushTimestamp;\n if (timeSinceLastFlush >= FLUSH_INTERVAL_MS) {\n // More than 5 minutes has passed, flush immediately\n void this._flush();\n return;\n } else {\n // Set timer for remaining time\n this._setFlushTimer(FLUSH_INTERVAL_MS - timeSinceLastFlush);\n }\n }\n\n /**\n * Helper method to set flush timer with consistent error handling\n */\n private _setFlushTimer(delay: number) {\n this.flushTimer = setTimeout(() => {\n this._flush()\n .catch((error) => {\n this.logger.debug('DiagnosticsClient: Failed to flush', error);\n })\n .finally(() => {\n this.flushTimer = null;\n });\n }, delay);\n }\n\n _setSampleRate(sampleRate: number): void {\n this.logger.debug('DiagnosticsClient: Setting sample rate to', sampleRate);\n this.config.sampleRate = sampleRate;\n this.shouldTrack = isTimestampInSampleTemp(this.startTimestamp, this.config.sampleRate) && this.config.enabled;\n this.logger.debug('DiagnosticsClient: Should track is', this.shouldTrack);\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { IDiagnosticsClient } from './diagnostics-client';
2
+ export declare const GLOBAL_KEY = "__AMPLITUDE_SCRIPT_URL__";
3
+ export declare const EVENT_NAME_ERROR_UNCAUGHT = "sdk.error.uncaught";
4
+ export declare const registerSdkLoaderMetadata: (metadata: {
5
+ scriptUrl?: string;
6
+ }) => void;
7
+ export declare const enableSdkErrorListeners: (client: IDiagnosticsClient) => void;
8
+ //# sourceMappingURL=uncaught-sdk-errors.d.ts.map
@@ -0,0 +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;AAe9D,eAAO,MAAM,yBAAyB,aAAc;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,SAOzE,CAAC;AAEF,eAAO,MAAM,uBAAuB,WAAY,kBAAkB,SAmEjE,CAAC"}
@@ -0,0 +1,122 @@
1
+ import { __assign } from "tslib";
2
+ import { getGlobalScope } from '../global-scope';
3
+ export var GLOBAL_KEY = '__AMPLITUDE_SCRIPT_URL__';
4
+ export var EVENT_NAME_ERROR_UNCAUGHT = 'sdk.error.uncaught';
5
+ var getNormalizedScriptUrl = function () {
6
+ var scope = getGlobalScope();
7
+ /* istanbul ignore next */
8
+ return scope === null || scope === void 0 ? void 0 : scope[GLOBAL_KEY];
9
+ };
10
+ var setNormalizedScriptUrl = function (url) {
11
+ var scope = getGlobalScope();
12
+ if (scope) {
13
+ scope[GLOBAL_KEY] = url;
14
+ }
15
+ };
16
+ export var registerSdkLoaderMetadata = function (metadata) {
17
+ if (metadata.scriptUrl) {
18
+ var normalized = normalizeUrl(metadata.scriptUrl);
19
+ if (normalized) {
20
+ setNormalizedScriptUrl(normalized);
21
+ }
22
+ }
23
+ };
24
+ export var enableSdkErrorListeners = function (client) {
25
+ var scope = getGlobalScope();
26
+ if (!scope || typeof scope.addEventListener !== 'function') {
27
+ return;
28
+ }
29
+ var handleError = function (event) {
30
+ var error = event.error instanceof Error ? event.error : undefined;
31
+ var stack = error === null || error === void 0 ? void 0 : error.stack;
32
+ var match = detectSdkOrigin({ filename: event.filename, stack: stack });
33
+ if (!match) {
34
+ return;
35
+ }
36
+ capture({
37
+ type: 'error',
38
+ message: event.message,
39
+ stack: stack,
40
+ filename: event.filename,
41
+ errorName: error === null || error === void 0 ? void 0 : error.name,
42
+ metadata: {
43
+ colno: event.colno,
44
+ lineno: event.lineno,
45
+ isTrusted: event.isTrusted,
46
+ matchReason: match,
47
+ },
48
+ });
49
+ };
50
+ var handleRejection = function (event) {
51
+ var _a;
52
+ var error = event.reason instanceof Error ? event.reason : undefined;
53
+ var stack = error === null || error === void 0 ? void 0 : error.stack;
54
+ var filename = extractFilenameFromStack(stack);
55
+ var match = detectSdkOrigin({ filename: filename, stack: stack });
56
+ if (!match) {
57
+ return;
58
+ }
59
+ /* istanbul ignore next */
60
+ capture({
61
+ type: 'unhandledrejection',
62
+ message: (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : stringifyReason(event.reason),
63
+ stack: stack,
64
+ filename: filename,
65
+ errorName: error === null || error === void 0 ? void 0 : error.name,
66
+ metadata: {
67
+ isTrusted: event.isTrusted,
68
+ matchReason: match,
69
+ },
70
+ });
71
+ };
72
+ var capture = function (context) {
73
+ client.recordEvent(EVENT_NAME_ERROR_UNCAUGHT, __assign({ type: context.type, message: context.message, filename: context.filename, error_name: context.errorName, stack: context.stack }, context.metadata));
74
+ };
75
+ scope.addEventListener('error', handleError, true);
76
+ scope.addEventListener('unhandledrejection', handleRejection, true);
77
+ };
78
+ var detectSdkOrigin = function (payload) {
79
+ var normalizedScriptUrl = getNormalizedScriptUrl();
80
+ if (!normalizedScriptUrl) {
81
+ return undefined;
82
+ }
83
+ if (payload.filename && payload.filename.includes(normalizedScriptUrl)) {
84
+ return 'filename';
85
+ }
86
+ if (payload.stack && payload.stack.includes(normalizedScriptUrl)) {
87
+ return 'stack';
88
+ }
89
+ return undefined;
90
+ };
91
+ var normalizeUrl = function (value) {
92
+ var _a, _b;
93
+ try {
94
+ /* istanbul ignore next */
95
+ var url = new URL(value, (_b = (_a = getGlobalScope()) === null || _a === void 0 ? void 0 : _a.location) === null || _b === void 0 ? void 0 : _b.origin);
96
+ return url.origin + url.pathname;
97
+ }
98
+ catch (_c) {
99
+ return undefined;
100
+ }
101
+ };
102
+ var extractFilenameFromStack = function (stack) {
103
+ if (!stack) {
104
+ return undefined;
105
+ }
106
+ var match = stack.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);
107
+ /* istanbul ignore next */
108
+ return match ? match[1] : undefined;
109
+ };
110
+ /* istanbul ignore next */
111
+ var stringifyReason = function (reason) {
112
+ if (typeof reason === 'string') {
113
+ return reason;
114
+ }
115
+ try {
116
+ return JSON.stringify(reason);
117
+ }
118
+ catch (_a) {
119
+ return '[object Object]';
120
+ }
121
+ };
122
+ //# sourceMappingURL=uncaught-sdk-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uncaught-sdk-errors.js","sourceRoot":"","sources":["../../../src/diagnostics/uncaught-sdk-errors.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAcjD,MAAM,CAAC,IAAM,UAAU,GAAG,0BAA0B,CAAC;AACrD,MAAM,CAAC,IAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D,IAAM,sBAAsB,GAAG;IAC7B,IAA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AAC,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 getNormalizedScriptUrl = (): string | undefined => {\n const scope = getGlobalScope() as Record<string, unknown> | null;\n /* istanbul ignore next */\n return scope?.[GLOBAL_KEY] as string | undefined;\n};\n\nconst setNormalizedScriptUrl = (url: string) => {\n const scope = getGlobalScope() as Record<string, unknown> | null;\n if (scope) {\n scope[GLOBAL_KEY] = url;\n }\n};\n\nexport const registerSdkLoaderMetadata = (metadata: { scriptUrl?: string }) => {\n if (metadata.scriptUrl) {\n const normalized = normalizeUrl(metadata.scriptUrl);\n if (normalized) {\n setNormalizedScriptUrl(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 normalizedScriptUrl = getNormalizedScriptUrl();\n if (!normalizedScriptUrl) {\n return undefined;\n }\n\n if (payload.filename && payload.filename.includes(normalizedScriptUrl)) {\n return 'filename';\n }\n\n if (payload.stack && payload.stack.includes(normalizedScriptUrl)) {\n return 'stack';\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"]}
@@ -26,6 +26,7 @@ export { CookieStorage } from './storage/cookie';
26
26
  export { getStorageKey } from './storage/helpers';
27
27
  export { BrowserStorage } from './storage/browser-storage';
28
28
  export { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';
29
+ export { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';
29
30
  export { BaseTransport } from './transports/base';
30
31
  export { FetchTransport } from './transports/fetch';
31
32
  export { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';
@@ -63,4 +64,5 @@ export { NodeClient } from './types/client/node-client';
63
64
  export { NodeConfig, NodeOptions } from './types/config/node-config';
64
65
  export { ReactNativeConfig, ReactNativeTrackingOptions, ReactNativeOptions, ReactNativeAttributionOptions, } from './types/config/react-native-config';
65
66
  export { ReactNativeClient } from './types/client/react-native-client';
67
+ export { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';
66
68
  //# sourceMappingURL=index.d.ts.map
@@ -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,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,m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22,7 @@ export { CookieStorage } from './storage/cookie';
22
22
  export { getStorageKey } from './storage/helpers';
23
23
  export { BrowserStorage } from './storage/browser-storage';
24
24
  export { DiagnosticsClient } from './diagnostics/diagnostics-client';
25
+ export { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';
25
26
  export { BaseTransport } from './transports/base';
26
27
  export { FetchTransport } from './transports/fetch';
27
28
  export { RemoteConfigClient } from './remote-config/remote-config';
@@ -39,4 +40,5 @@ export { SAFE_HEADERS, FORBIDDEN_HEADERS } from './types/constants';
39
40
  export { EMPTY_VALUE, BASE_CAMPAIGN, MKTG } from './types/constants';
40
41
  export { CampaignParser } from './campaign/campaign-parser';
41
42
  export { getPageTitle, TEXT_MASK_ATTRIBUTE, MASKED_TEXT_VALUE, replaceSensitiveString, CC_REGEX, SSN_REGEX, EMAIL_REGEX, } from './plugins/helpers';
43
+ export { Observable, asyncMap, merge, multicast } from './utils/observable';
42
44
  //# sourceMappingURL=index.js.map