@amplitude/analytics-browser 2.21.1 → 2.22.1

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 (75) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/browser-client.d.ts +2 -1
  3. package/lib/cjs/browser-client.d.ts.map +1 -1
  4. package/lib/cjs/browser-client.js +68 -50
  5. package/lib/cjs/browser-client.js.map +1 -1
  6. package/lib/cjs/config/joined-config.d.ts +37 -15
  7. package/lib/cjs/config/joined-config.d.ts.map +1 -1
  8. package/lib/cjs/config/joined-config.js +155 -123
  9. package/lib/cjs/config/joined-config.js.map +1 -1
  10. package/lib/cjs/config.d.ts +1 -1
  11. package/lib/cjs/storage/local-storage.d.ts +1 -2
  12. package/lib/cjs/storage/local-storage.d.ts.map +1 -1
  13. package/lib/cjs/storage/local-storage.js +1 -2
  14. package/lib/cjs/storage/local-storage.js.map +1 -1
  15. package/lib/cjs/storage/session-storage.d.ts +1 -1
  16. package/lib/cjs/storage/session-storage.d.ts.map +1 -1
  17. package/lib/cjs/storage/session-storage.js +1 -2
  18. package/lib/cjs/storage/session-storage.js.map +1 -1
  19. package/lib/cjs/version.d.ts +1 -1
  20. package/lib/cjs/version.js +1 -1
  21. package/lib/cjs/version.js.map +1 -1
  22. package/lib/esm/browser-client.d.ts +2 -1
  23. package/lib/esm/browser-client.d.ts.map +1 -1
  24. package/lib/esm/browser-client.js +70 -52
  25. package/lib/esm/browser-client.js.map +1 -1
  26. package/lib/esm/config/joined-config.d.ts +37 -15
  27. package/lib/esm/config/joined-config.d.ts.map +1 -1
  28. package/lib/esm/config/joined-config.js +153 -122
  29. package/lib/esm/config/joined-config.js.map +1 -1
  30. package/lib/esm/config.d.ts +1 -1
  31. package/lib/esm/storage/local-storage.d.ts +1 -2
  32. package/lib/esm/storage/local-storage.d.ts.map +1 -1
  33. package/lib/esm/storage/local-storage.js +1 -2
  34. package/lib/esm/storage/local-storage.js.map +1 -1
  35. package/lib/esm/storage/session-storage.d.ts +1 -1
  36. package/lib/esm/storage/session-storage.d.ts.map +1 -1
  37. package/lib/esm/storage/session-storage.js +1 -2
  38. package/lib/esm/storage/session-storage.js.map +1 -1
  39. package/lib/esm/version.d.ts +1 -1
  40. package/lib/esm/version.js +1 -1
  41. package/lib/esm/version.js.map +1 -1
  42. package/lib/scripts/amplitude-bookmarklet-snippet-min.js +1 -1
  43. package/lib/scripts/amplitude-bookmarklet.html +1 -1
  44. package/lib/scripts/amplitude-gtm-min.js +1 -1
  45. package/lib/scripts/amplitude-gtm-min.js.gz +0 -0
  46. package/lib/scripts/amplitude-gtm-min.js.map +1 -1
  47. package/lib/scripts/amplitude-gtm-snippet-min.js +1 -1
  48. package/lib/scripts/amplitude-min.js +1 -1
  49. package/lib/scripts/amplitude-min.js.gz +0 -0
  50. package/lib/scripts/amplitude-min.js.map +1 -1
  51. package/lib/scripts/amplitude-min.umd.js +1 -1
  52. package/lib/scripts/amplitude-min.umd.js.gz +0 -0
  53. package/lib/scripts/amplitude-snippet-instructions.html +1 -1
  54. package/lib/scripts/amplitude-snippet-min.js +1 -1
  55. package/lib/scripts/browser-client.d.ts +2 -1
  56. package/lib/scripts/browser-client.d.ts.map +1 -1
  57. package/lib/scripts/config/joined-config.d.ts +37 -15
  58. package/lib/scripts/config/joined-config.d.ts.map +1 -1
  59. package/lib/scripts/config.d.ts +1 -1
  60. package/lib/scripts/storage/local-storage.d.ts +1 -2
  61. package/lib/scripts/storage/local-storage.d.ts.map +1 -1
  62. package/lib/scripts/storage/session-storage.d.ts +1 -1
  63. package/lib/scripts/storage/session-storage.d.ts.map +1 -1
  64. package/lib/scripts/version.d.ts +1 -1
  65. package/package.json +7 -7
  66. package/lib/cjs/storage/browser-storage.d.ts +0 -12
  67. package/lib/cjs/storage/browser-storage.d.ts.map +0 -1
  68. package/lib/cjs/storage/browser-storage.js +0 -122
  69. package/lib/cjs/storage/browser-storage.js.map +0 -1
  70. package/lib/esm/storage/browser-storage.d.ts +0 -12
  71. package/lib/esm/storage/browser-storage.d.ts.map +0 -1
  72. package/lib/esm/storage/browser-storage.js +0 -119
  73. package/lib/esm/storage/browser-storage.js.map +0 -1
  74. package/lib/scripts/storage/browser-storage.d.ts +0 -12
  75. package/lib/scripts/storage/browser-storage.d.ts.map +0 -1
@@ -1,131 +1,162 @@
1
- import { __assign, __awaiter, __generator, __values } from "tslib";
2
- import { createRemoteConfigFetch } from '@amplitude/analytics-remote-config';
3
- import { RequestMetadata, } from '@amplitude/analytics-core';
4
- var BrowserJoinedConfigGenerator = /** @class */ (function () {
5
- function BrowserJoinedConfigGenerator(localConfig) {
6
- this.config = localConfig;
7
- this.config.loggerProvider.debug('Local configuration before merging with remote config', JSON.stringify(this.config, null, 2));
1
+ import { __assign, __values } from "tslib";
2
+ /**
3
+ * Performs a deep transformation of a remote config object so that
4
+ * it matches the expected schema of the local config.
5
+ *
6
+ * Specifically, it normalizes nested `enabled` flags into concise union types.
7
+ *
8
+ * ### Transformation Rules:
9
+ * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.
10
+ * - If it has only `enabled: true`, it is replaced with `true`.
11
+ * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.
12
+ *
13
+ * ### Examples:
14
+ * Input: { prop: { enabled: true, hello: 'world' }}
15
+ * Output: { prop: { hello: 'world' } }
16
+ *
17
+ * Input: { prop: { enabled: true }}
18
+ * Output: { prop: true }
19
+ *
20
+ * Input: { prop: { enabled: false, hello: 'world' }}
21
+ * Output: { prop: false }
22
+ *
23
+ * Input: { prop: { hello: 'world' }}
24
+ * Output: { prop: { hello: 'world' } } // No change
25
+ *
26
+ * @param config Remote config object to be transformed
27
+ * @returns Transformed config object compatible with local schema
28
+ */
29
+ export function translateRemoteConfigToLocal(config) {
30
+ var e_1, _a;
31
+ // Disabling type checking rules because remote config comes from a remote source
32
+ // and this function needs to handle any unexpected values
33
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access,
34
+ @typescript-eslint/no-unsafe-assignment,
35
+ @typescript-eslint/no-unsafe-argument
36
+ */
37
+ if (typeof config !== 'object' || config === null) {
38
+ return;
8
39
  }
9
- BrowserJoinedConfigGenerator.prototype.initialize = function () {
10
- return __awaiter(this, void 0, void 0, function () {
11
- var _a;
12
- return __generator(this, function (_b) {
13
- switch (_b.label) {
14
- case 0:
15
- _a = this;
16
- return [4 /*yield*/, createRemoteConfigFetch({
17
- localConfig: this.config,
18
- configKeys: ['analyticsSDK'],
19
- })];
20
- case 1:
21
- _a.remoteConfigFetch = _b.sent();
22
- return [2 /*return*/];
40
+ // translations are not applied on array properties
41
+ if (Array.isArray(config)) {
42
+ return;
43
+ }
44
+ var propertyNames = Object.keys(config);
45
+ try {
46
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
47
+ var propertyName = propertyNames_1_1.value;
48
+ try {
49
+ var value = config[propertyName];
50
+ // transform objects with { enabled } property to boolean | object
51
+ if (typeof (value === null || value === void 0 ? void 0 : value.enabled) === 'boolean') {
52
+ if (value.enabled) {
53
+ // if enabled is true, set the value to the rest of the object
54
+ // or true if the object has no other properties
55
+ delete value.enabled;
56
+ if (Object.keys(value).length === 0) {
57
+ config[propertyName] = true;
58
+ }
59
+ }
60
+ else {
61
+ // If enabled is false, set the value to false
62
+ config[propertyName] = false;
63
+ }
23
64
  }
24
- });
25
- });
26
- };
27
- BrowserJoinedConfigGenerator.prototype.generateJoinedConfig = function () {
28
- var _a, _b, _c, _d, _e;
29
- var _f;
30
- return __awaiter(this, void 0, void 0, function () {
31
- var remoteConfig, _g, transformedAutocaptureRemoteConfig, transformedRcElementInteractions, exactAllowList, regexList, _h, _j, pattern, combinedPageUrlAllowlist, e_1;
32
- var e_2, _k;
33
- return __generator(this, function (_l) {
34
- switch (_l.label) {
35
- case 0:
36
- _l.trys.push([0, 3, , 4]);
37
- _g = this.remoteConfigFetch;
38
- if (!_g) return [3 /*break*/, 2];
39
- return [4 /*yield*/, this.remoteConfigFetch.getRemoteConfig('analyticsSDK', 'browserSDK', this.config.sessionId)];
40
- case 1:
41
- _g = (_l.sent());
42
- _l.label = 2;
43
- case 2:
44
- remoteConfig = _g;
45
- this.config.loggerProvider.debug('Remote configuration:', JSON.stringify(remoteConfig, null, 2));
46
- // merge remoteConfig.autocapture and this.config.autocapture
47
- // if a field is in remoteConfig.autocapture, use that value
48
- // if a field is not in remoteConfig.autocapture, use the value from this.config.autocapture
49
- if (remoteConfig && 'autocapture' in remoteConfig) {
50
- if (typeof remoteConfig.autocapture === 'boolean') {
51
- this.config.autocapture = remoteConfig.autocapture;
65
+ // recursively translate properties of the value
66
+ translateRemoteConfigToLocal(value);
67
+ }
68
+ catch (e) {
69
+ // a failure here means that an accessor threw an error
70
+ // so don't translate it
71
+ // TODO(diagnostics): add a diagnostic event for this
72
+ }
73
+ }
74
+ }
75
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
76
+ finally {
77
+ try {
78
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
79
+ }
80
+ finally { if (e_1) throw e_1.error; }
81
+ }
82
+ }
83
+ /**
84
+ * Updates the browser config in place by applying remote configuration settings.
85
+ * Primarily merges autocapture settings from the remote config into the browser config.
86
+ *
87
+ * @param remoteConfig - The remote configuration to apply, or null if none available
88
+ * @param browserConfig - The browser config object to update (modified in place)
89
+ */
90
+ export function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig) {
91
+ var e_2, _a;
92
+ var _b, _c;
93
+ if (!remoteConfig) {
94
+ return;
95
+ }
96
+ // translate remote config to local compatible format
97
+ translateRemoteConfigToLocal(remoteConfig);
98
+ try {
99
+ browserConfig.loggerProvider.debug('Update browser config with remote configuration:', JSON.stringify(remoteConfig));
100
+ // type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK
101
+ // and it will be caught by the try-catch block
102
+ var typedRemoteConfig = remoteConfig;
103
+ // merge remoteConfig.autocapture and browserConfig.autocapture
104
+ // if a field is in remoteConfig.autocapture, use that value
105
+ // if a field is not in remoteConfig.autocapture, use the value from browserConfig.autocapture
106
+ if (typedRemoteConfig && 'autocapture' in typedRemoteConfig) {
107
+ if (typeof typedRemoteConfig.autocapture === 'boolean') {
108
+ browserConfig.autocapture = typedRemoteConfig.autocapture;
109
+ }
110
+ if (typeof typedRemoteConfig.autocapture === 'object' && typedRemoteConfig.autocapture !== null) {
111
+ var transformedAutocaptureRemoteConfig = __assign({}, typedRemoteConfig.autocapture);
112
+ if (browserConfig.autocapture === undefined) {
113
+ browserConfig.autocapture = typedRemoteConfig.autocapture;
114
+ }
115
+ // Handle Element Interactions config initialization
116
+ if (typeof typedRemoteConfig.autocapture.elementInteractions === 'object' &&
117
+ typedRemoteConfig.autocapture.elementInteractions !== null &&
118
+ ((_b = typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex) === null || _b === void 0 ? void 0 : _b.length)) {
119
+ transformedAutocaptureRemoteConfig.elementInteractions = __assign({}, typedRemoteConfig.autocapture.elementInteractions);
120
+ var transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;
121
+ var exactAllowList = (_c = transformedRcElementInteractions.pageUrlAllowlist) !== null && _c !== void 0 ? _c : [];
122
+ // Convert string patterns to RegExp objects, warn on invalid patterns and skip them
123
+ var regexList = [];
124
+ try {
125
+ for (var _d = __values(typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex), _e = _d.next(); !_e.done; _e = _d.next()) {
126
+ var pattern = _e.value;
127
+ try {
128
+ regexList.push(new RegExp(pattern));
52
129
  }
53
- if (typeof remoteConfig.autocapture === 'object') {
54
- transformedAutocaptureRemoteConfig = __assign({}, remoteConfig.autocapture);
55
- if (this.config.autocapture === undefined) {
56
- this.config.autocapture = remoteConfig.autocapture;
57
- }
58
- // Handle Element Interactions config initialization
59
- if (typeof remoteConfig.autocapture.elementInteractions === 'object' &&
60
- ((_a = remoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex) === null || _a === void 0 ? void 0 : _a.length)) {
61
- transformedAutocaptureRemoteConfig.elementInteractions = __assign({}, remoteConfig.autocapture.elementInteractions);
62
- transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;
63
- exactAllowList = (_b = transformedRcElementInteractions.pageUrlAllowlist) !== null && _b !== void 0 ? _b : [];
64
- regexList = [];
65
- try {
66
- for (_h = __values(remoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex), _j = _h.next(); !_j.done; _j = _h.next()) {
67
- pattern = _j.value;
68
- try {
69
- regexList.push(new RegExp(pattern));
70
- }
71
- catch (regexError) {
72
- this.config.loggerProvider.warn("Invalid regex pattern: ".concat(pattern), regexError);
73
- }
74
- }
75
- }
76
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
77
- finally {
78
- try {
79
- if (_j && !_j.done && (_k = _h.return)) _k.call(_h);
80
- }
81
- finally { if (e_2) throw e_2.error; }
82
- }
83
- combinedPageUrlAllowlist = exactAllowList.concat(regexList);
84
- transformedRcElementInteractions.pageUrlAllowlist = combinedPageUrlAllowlist;
85
- delete transformedRcElementInteractions.pageUrlAllowlistRegex;
86
- }
87
- if (typeof this.config.autocapture === 'boolean') {
88
- this.config.autocapture = __assign({ attribution: this.config.autocapture, fileDownloads: this.config.autocapture, formInteractions: this.config.autocapture, pageViews: this.config.autocapture, sessions: this.config.autocapture, elementInteractions: this.config.autocapture, webVitals: this.config.autocapture, frustrationInteractions: this.config.autocapture }, transformedAutocaptureRemoteConfig);
89
- }
90
- if (typeof this.config.autocapture === 'object') {
91
- this.config.autocapture = __assign(__assign({}, this.config.autocapture), transformedAutocaptureRemoteConfig);
92
- }
130
+ catch (regexError) {
131
+ browserConfig.loggerProvider.warn("Invalid regex pattern: ".concat(pattern), regexError);
93
132
  }
94
- // Override default tracking options if autocapture is updated by remote config
95
- this.config.defaultTracking = this.config.autocapture;
96
- }
97
- this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));
98
- (_c = (_f = this.config).requestMetadata) !== null && _c !== void 0 ? _c : (_f.requestMetadata = new RequestMetadata());
99
- if ((_d = this.remoteConfigFetch) === null || _d === void 0 ? void 0 : _d.metrics.fetchTimeAPISuccess) {
100
- this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_success', this.remoteConfigFetch.metrics.fetchTimeAPISuccess);
101
133
  }
102
- if ((_e = this.remoteConfigFetch) === null || _e === void 0 ? void 0 : _e.metrics.fetchTimeAPIFail) {
103
- this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_fail', this.remoteConfigFetch.metrics.fetchTimeAPIFail);
134
+ }
135
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
136
+ finally {
137
+ try {
138
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
104
139
  }
105
- return [3 /*break*/, 4];
106
- case 3:
107
- e_1 = _l.sent();
108
- this.config.loggerProvider.error('Failed to fetch remote configuration because of error: ', e_1);
109
- return [3 /*break*/, 4];
110
- case 4: return [2 /*return*/, this.config];
140
+ finally { if (e_2) throw e_2.error; }
141
+ }
142
+ var combinedPageUrlAllowlist = exactAllowList.concat(regexList);
143
+ transformedRcElementInteractions.pageUrlAllowlist = combinedPageUrlAllowlist;
144
+ delete transformedRcElementInteractions.pageUrlAllowlistRegex;
145
+ }
146
+ if (typeof browserConfig.autocapture === 'boolean') {
147
+ browserConfig.autocapture = __assign({ attribution: browserConfig.autocapture, fileDownloads: browserConfig.autocapture, formInteractions: browserConfig.autocapture, pageViews: browserConfig.autocapture, sessions: browserConfig.autocapture, elementInteractions: browserConfig.autocapture, webVitals: browserConfig.autocapture, frustrationInteractions: browserConfig.autocapture }, transformedAutocaptureRemoteConfig);
111
148
  }
112
- });
113
- });
114
- };
115
- return BrowserJoinedConfigGenerator;
116
- }());
117
- export { BrowserJoinedConfigGenerator };
118
- export var createBrowserJoinedConfigGenerator = function (localConfig) { return __awaiter(void 0, void 0, void 0, function () {
119
- var joinedConfigGenerator;
120
- return __generator(this, function (_a) {
121
- switch (_a.label) {
122
- case 0:
123
- joinedConfigGenerator = new BrowserJoinedConfigGenerator(localConfig);
124
- return [4 /*yield*/, joinedConfigGenerator.initialize()];
125
- case 1:
126
- _a.sent();
127
- return [2 /*return*/, joinedConfigGenerator];
149
+ if (typeof browserConfig.autocapture === 'object') {
150
+ browserConfig.autocapture = __assign(__assign({}, browserConfig.autocapture), transformedAutocaptureRemoteConfig);
151
+ }
152
+ }
153
+ // Override default tracking options if autocapture is updated by remote config
154
+ browserConfig.defaultTracking = browserConfig.autocapture;
128
155
  }
129
- });
130
- }); };
156
+ browserConfig.loggerProvider.debug('Browser config after remote config update:', JSON.stringify(browserConfig));
157
+ }
158
+ catch (e) {
159
+ browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);
160
+ }
161
+ }
131
162
  //# sourceMappingURL=joined-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAqB,MAAM,oCAAoC,CAAC;AAChG,OAAO,EACL,eAAe,GAIhB,MAAM,2BAA2B,CAAC;AAkBnC;IAME,sCAAY,WAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAC9B,uDAAuD,EACvD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,CAAC;IACJ,CAAC;IAEK,iDAAU,GAAhB;;;;;;wBACE,KAAA,IAAI,CAAA;wBAAqB,qBAAM,uBAAuB,CAAsB;gCAC1E,WAAW,EAAE,IAAI,CAAC,MAAM;gCACxB,UAAU,EAAE,CAAC,cAAc,CAAC;6BAC7B,CAAC,EAAA;;wBAHF,GAAK,iBAAiB,GAAG,SAGvB,CAAC;;;;;KACJ;IAEK,2DAAoB,GAA1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Fetch } from '@amplitude/analytics-remote-config';\nimport {\n RequestMetadata,\n BrowserConfig as IBrowserConfig,\n AutocaptureOptions,\n type ElementInteractionsOptions,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n}\nexport interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n pageUrlAllowlistRegex?: string[];\n}\n\nexport type BrowserRemoteConfig = {\n browserSDK: {\n autocapture?: AutocaptureOptionsRemoteConfig | boolean;\n };\n};\n\nexport class BrowserJoinedConfigGenerator {\n // Local config before generateJoinedConfig is called\n // Joined config after generateJoinedConfig is called\n config: IBrowserConfig;\n remoteConfigFetch: RemoteConfigFetch<BrowserRemoteConfig> | undefined;\n\n constructor(localConfig: IBrowserConfig) {\n this.config = localConfig;\n this.config.loggerProvider.debug(\n 'Local configuration before merging with remote config',\n JSON.stringify(this.config, null, 2),\n );\n }\n\n async initialize() {\n this.remoteConfigFetch = await createRemoteConfigFetch<BrowserRemoteConfig>({\n localConfig: this.config,\n configKeys: ['analyticsSDK'],\n });\n }\n\n async generateJoinedConfig(): Promise<IBrowserConfig> {\n try {\n const remoteConfig =\n this.remoteConfigFetch &&\n (await this.remoteConfigFetch.getRemoteConfig('analyticsSDK', 'browserSDK', this.config.sessionId));\n this.config.loggerProvider.debug('Remote configuration:', JSON.stringify(remoteConfig, null, 2));\n\n // merge remoteConfig.autocapture and this.config.autocapture\n // if a field is in remoteConfig.autocapture, use that value\n // if a field is not in remoteConfig.autocapture, use the value from this.config.autocapture\n if (remoteConfig && 'autocapture' in remoteConfig) {\n if (typeof remoteConfig.autocapture === 'boolean') {\n this.config.autocapture = remoteConfig.autocapture;\n }\n\n if (typeof remoteConfig.autocapture === 'object') {\n const transformedAutocaptureRemoteConfig = { ...remoteConfig.autocapture };\n\n if (this.config.autocapture === undefined) {\n this.config.autocapture = remoteConfig.autocapture;\n }\n\n // Handle Element Interactions config initialization\n if (\n typeof remoteConfig.autocapture.elementInteractions === 'object' &&\n remoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex?.length\n ) {\n transformedAutocaptureRemoteConfig.elementInteractions = {\n ...remoteConfig.autocapture.elementInteractions,\n };\n const transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;\n\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of remoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n this.config.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n const combinedPageUrlAllowlist = exactAllowList.concat(regexList);\n\n transformedRcElementInteractions.pageUrlAllowlist = combinedPageUrlAllowlist;\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n if (typeof this.config.autocapture === 'boolean') {\n this.config.autocapture = {\n attribution: this.config.autocapture,\n fileDownloads: this.config.autocapture,\n formInteractions: this.config.autocapture,\n pageViews: this.config.autocapture,\n sessions: this.config.autocapture,\n elementInteractions: this.config.autocapture,\n webVitals: this.config.autocapture,\n frustrationInteractions: this.config.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n\n if (typeof this.config.autocapture === 'object') {\n this.config.autocapture = {\n ...this.config.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n }\n\n // Override default tracking options if autocapture is updated by remote config\n this.config.defaultTracking = this.config.autocapture;\n }\n\n this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));\n this.config.requestMetadata ??= new RequestMetadata();\n if (this.remoteConfigFetch?.metrics.fetchTimeAPISuccess) {\n this.config.requestMetadata.recordHistogram(\n 'remote_config_fetch_time_API_success',\n this.remoteConfigFetch.metrics.fetchTimeAPISuccess,\n );\n }\n if (this.remoteConfigFetch?.metrics.fetchTimeAPIFail) {\n this.config.requestMetadata.recordHistogram(\n 'remote_config_fetch_time_API_fail',\n this.remoteConfigFetch.metrics.fetchTimeAPIFail,\n );\n }\n } catch (e) {\n this.config.loggerProvider.error('Failed to fetch remote configuration because of error: ', e);\n }\n\n return this.config;\n }\n}\n\nexport const createBrowserJoinedConfigGenerator = async (localConfig: IBrowserConfig) => {\n const joinedConfigGenerator = new BrowserJoinedConfigGenerator(localConfig);\n await joinedConfigGenerator.initialize();\n return joinedConfigGenerator;\n};\n"]}
1
+ {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAA4B;;IACvE,iFAAiF;IACjF,0DAA0D;IAC1D;;;KAGC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;QACjD,OAAO;KACR;IAED,mDAAmD;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO;KACR;IAED,IAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;QAC1C,KAA2B,IAAA,kBAAA,SAAA,aAAa,CAAA,4CAAA,uEAAE;YAArC,IAAM,YAAY,0BAAA;YACrB,IAAI;gBACF,IAAM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;gBACnC,kEAAkE;gBAClE,IAAI,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAA,KAAK,SAAS,EAAE;oBACvC,IAAI,KAAK,CAAC,OAAO,EAAE;wBACjB,8DAA8D;wBAC9D,gDAAgD;wBAChD,OAAO,KAAK,CAAC,OAAO,CAAC;wBACrB,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAA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,WAAW,EACnC,mBAAmB,EAAE,aAAa,CAAC,WAAW,EAC9C,SAAS,EAAE,aAAa,CAAC,WAAW,EACpC,uBAAuB,EAAE,aAAa,CAAC,WAAW,IAC/C,kCAAkC,CACtC,CAAC;iBACH;gBAED,IAAI,OAAO,aAAa,CAAC,WAAW,KAAK,QAAQ,EAAE;oBACjD,aAAa,CAAC,WAAW,yBACpB,aAAa,CAAC,WAAW,GACzB,kCAAkC,CACtC,CAAC;iBACH;aACF;YAED,+EAA+E;YAC/E,aAAa,CAAC,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;SAC3D;QAED,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,4CAA4C,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;KACjH;IAAC,OAAO,CAAC,EAAE;QACV,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,CAAC,CAAC,CAAC;KAClG;AACH,CAAC","sourcesContent":["import {\n AutocaptureOptions,\n type ElementInteractionsOptions,\n BrowserConfig,\n RemoteConfig,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n}\nexport interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n pageUrlAllowlistRegex?: string[];\n}\n\n// Type alias for the remote config structure we expect (this is what comes from the filtered browserSDK config)\ntype RemoteConfigBrowserSDK = {\n autocapture?: AutocaptureOptionsRemoteConfig | boolean;\n};\n\n/**\n * Performs a deep transformation of a remote config object so that\n * it matches the expected schema of the local config.\n *\n * Specifically, it normalizes nested `enabled` flags into concise union types.\n *\n * ### Transformation Rules:\n * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.\n * - If it has only `enabled: true`, it is replaced with `true`.\n * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.\n *\n * ### Examples:\n * Input: { prop: { enabled: true, hello: 'world' }}\n * Output: { prop: { hello: 'world' } }\n *\n * Input: { prop: { enabled: true }}\n * Output: { prop: true }\n *\n * Input: { prop: { enabled: false, hello: 'world' }}\n * Output: { prop: false }\n *\n * Input: { prop: { hello: 'world' }}\n * Output: { prop: { hello: 'world' } } // No change\n *\n * @param config Remote config object to be transformed\n * @returns Transformed config object compatible with local schema\n */\nexport function translateRemoteConfigToLocal(config?: Record<string, any>) {\n // Disabling type checking rules because remote config comes from a remote source\n // and this function needs to handle any unexpected values\n /* eslint-disable @typescript-eslint/no-unsafe-member-access,\n @typescript-eslint/no-unsafe-assignment,\n @typescript-eslint/no-unsafe-argument\n */\n if (typeof config !== 'object' || config === null) {\n return;\n }\n\n // translations are not applied on array properties\n if (Array.isArray(config)) {\n return;\n }\n\n const propertyNames = Object.keys(config);\n for (const propertyName of propertyNames) {\n try {\n const value = config[propertyName];\n // transform objects with { enabled } property to boolean | object\n if (typeof value?.enabled === 'boolean') {\n if (value.enabled) {\n // if enabled is true, set the value to the rest of the object\n // or true if the object has no other properties\n delete value.enabled;\n if (Object.keys(value).length === 0) {\n (config as any)[propertyName] = true;\n }\n } else {\n // If enabled is false, set the value to false\n (config as any)[propertyName] = false;\n }\n }\n\n // recursively translate properties of the value\n translateRemoteConfigToLocal(value as Record<string, any>);\n } catch (e) {\n // a failure here means that an accessor threw an error\n // so don't translate it\n // TODO(diagnostics): add a diagnostic event for this\n }\n }\n}\n\n/**\n * Updates the browser config in place by applying remote configuration settings.\n * Primarily merges autocapture settings from the remote config into the browser config.\n *\n * @param remoteConfig - The remote configuration to apply, or null if none available\n * @param browserConfig - The browser config object to update (modified in place)\n */\nexport function updateBrowserConfigWithRemoteConfig(\n remoteConfig: RemoteConfig | null,\n browserConfig: BrowserConfig,\n): void {\n if (!remoteConfig) {\n return;\n }\n\n // translate remote config to local compatible format\n translateRemoteConfigToLocal(remoteConfig);\n\n try {\n browserConfig.loggerProvider.debug(\n 'Update browser config with remote configuration:',\n JSON.stringify(remoteConfig),\n );\n\n // type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK\n // and it will be caught by the try-catch block\n const typedRemoteConfig = remoteConfig as RemoteConfigBrowserSDK;\n\n // merge remoteConfig.autocapture and browserConfig.autocapture\n // if a field is in remoteConfig.autocapture, use that value\n // if a field is not in remoteConfig.autocapture, use the value from browserConfig.autocapture\n if (typedRemoteConfig && 'autocapture' in typedRemoteConfig) {\n if (typeof typedRemoteConfig.autocapture === 'boolean') {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n if (typeof typedRemoteConfig.autocapture === 'object' && typedRemoteConfig.autocapture !== null) {\n const transformedAutocaptureRemoteConfig = { ...typedRemoteConfig.autocapture };\n\n if (browserConfig.autocapture === undefined) {\n browserConfig.autocapture = typedRemoteConfig.autocapture;\n }\n\n // Handle Element Interactions config initialization\n if (\n typeof typedRemoteConfig.autocapture.elementInteractions === 'object' &&\n typedRemoteConfig.autocapture.elementInteractions !== null &&\n typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex?.length\n ) {\n transformedAutocaptureRemoteConfig.elementInteractions = {\n ...typedRemoteConfig.autocapture.elementInteractions,\n };\n const transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;\n\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n browserConfig.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n const combinedPageUrlAllowlist = exactAllowList.concat(regexList);\n\n transformedRcElementInteractions.pageUrlAllowlist = combinedPageUrlAllowlist;\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n if (typeof browserConfig.autocapture === 'boolean') {\n browserConfig.autocapture = {\n attribution: browserConfig.autocapture,\n fileDownloads: browserConfig.autocapture,\n formInteractions: browserConfig.autocapture,\n pageViews: browserConfig.autocapture,\n sessions: browserConfig.autocapture,\n elementInteractions: browserConfig.autocapture,\n webVitals: browserConfig.autocapture,\n frustrationInteractions: browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n\n if (typeof browserConfig.autocapture === 'object') {\n browserConfig.autocapture = {\n ...browserConfig.autocapture,\n ...transformedAutocaptureRemoteConfig,\n };\n }\n }\n\n // Override default tracking options if autocapture is updated by remote config\n browserConfig.defaultTracking = browserConfig.autocapture;\n }\n\n browserConfig.loggerProvider.debug('Browser config after remote config update:', JSON.stringify(browserConfig));\n } catch (e) {\n browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);\n }\n}\n"]}
@@ -31,7 +31,7 @@ export declare class BrowserConfig extends Config implements IBrowserConfig {
31
31
  useBatch: boolean;
32
32
  fetchRemoteConfig: boolean;
33
33
  networkTrackingOptions?: NetworkTrackingOptions | undefined;
34
- readonly version = "2.21.1";
34
+ readonly version = "2.22.1";
35
35
  protected _cookieStorage: Storage<UserSession>;
36
36
  protected _deviceId?: string;
37
37
  protected _lastEventId?: number;
@@ -1,5 +1,4 @@
1
- import { ILogger } from '@amplitude/analytics-core';
2
- import { BrowserStorage } from './browser-storage';
1
+ import { ILogger, BrowserStorage } from '@amplitude/analytics-core';
3
2
  interface LocalStorageOptions {
4
3
  loggerProvider?: ILogger;
5
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,UAAU,mBAAmB;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AACD,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACpD,cAAc,CAAC,EAAE,OAAO,CAAC;gBAEb,MAAM,CAAC,EAAE,mBAAmB;IAalC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAWhD"}
1
+ {"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/local-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIpF,UAAU,mBAAmB;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AACD,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACpD,cAAc,CAAC,EAAE,OAAO,CAAC;gBAEb,MAAM,CAAC,EAAE,mBAAmB;IAalC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAWhD"}
@@ -1,6 +1,5 @@
1
1
  import { __awaiter, __extends, __generator } from "tslib";
2
- import { getGlobalScope } from '@amplitude/analytics-core';
3
- import { BrowserStorage } from './browser-storage';
2
+ import { getGlobalScope, BrowserStorage } from '@amplitude/analytics-core';
4
3
  var MAX_ARRAY_LENGTH = 1000;
5
4
  var LocalStorage = /** @class */ (function (_super) {
6
5
  __extends(LocalStorage, _super);
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../../src/storage/local-storage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAW,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,IAAM,gBAAgB,GAAG,IAAI,CAAC;AAK9B;IAAqC,gCAAiB;IAGpD,sBAAY,MAA4B;QAAxC,iBAWC;;QAVC,IAAI,YAAY,CAAC;QAEjB,IAAI;YACF,YAAY,GAAG,MAAA,cAAc,EAAE,0CAAE,YAAY,CAAC;SAC/C;QAAC,OAAO,CAAC,EAAE;YACV,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,0CAAE,KAAK,CAAC,+CAAwC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;YAC3F,YAAY,GAAG,SAAS,CAAC;SAC1B;gBACD,kBAAM,YAAY,CAAC;QACnB,KAAI,CAAC,cAAc,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC;;IAC/C,CAAC;IAEK,0BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;;;;;6BACzB,CAAA,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAA,EAAvD,wBAAuD;wBACnD,kBAAkB,GAAG,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC;wBAC3D,qBAAM,iBAAM,GAAG,YAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAM,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;wBAC5D,MAAA,IAAI,CAAC,cAAc,0CAAE,KAAK,CACxB,yBAAkB,kBAAkB,uDAA6C,gBAAgB,MAAG,CACrG,CAAC;;4BAEF,qBAAM,iBAAM,GAAG,YAAC,GAAG,EAAE,KAAK,CAAC,EAAA;;wBAA3B,SAA2B,CAAC;;;;;;KAE/B;IACH,mBAAC;AAAD,CAAC,AA3BD,CAAqC,cAAc,GA2BlD","sourcesContent":["import { getGlobalScope, ILogger } from '@amplitude/analytics-core';\nimport { BrowserStorage } from './browser-storage';\n\nconst MAX_ARRAY_LENGTH = 1000;\n\ninterface LocalStorageOptions {\n loggerProvider?: ILogger;\n}\nexport class LocalStorage<T> extends BrowserStorage<T> {\n loggerProvider?: ILogger;\n\n constructor(config?: LocalStorageOptions) {\n let localStorage;\n\n try {\n localStorage = getGlobalScope()?.localStorage;\n } catch (e) {\n config?.loggerProvider?.debug(`Failed to access localStorage. error=${JSON.stringify(e)}`);\n localStorage = undefined;\n }\n super(localStorage);\n this.loggerProvider = config?.loggerProvider;\n }\n\n async set(key: string, value: T): Promise<void> {\n if (Array.isArray(value) && value.length > MAX_ARRAY_LENGTH) {\n const droppedEventsCount = value.length - MAX_ARRAY_LENGTH;\n await super.set(key, value.slice(0, MAX_ARRAY_LENGTH) as T);\n this.loggerProvider?.error(\n `Failed to save ${droppedEventsCount} events because the queue length exceeded ${MAX_ARRAY_LENGTH}.`,\n );\n } else {\n await super.set(key, value);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"local-storage.js","sourceRoot":"","sources":["../../../src/storage/local-storage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAW,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEpF,IAAM,gBAAgB,GAAG,IAAI,CAAC;AAK9B;IAAqC,gCAAiB;IAGpD,sBAAY,MAA4B;QAAxC,iBAWC;;QAVC,IAAI,YAAY,CAAC;QAEjB,IAAI;YACF,YAAY,GAAG,MAAA,cAAc,EAAE,0CAAE,YAAY,CAAC;SAC/C;QAAC,OAAO,CAAC,EAAE;YACV,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,0CAAE,KAAK,CAAC,+CAAwC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;YAC3F,YAAY,GAAG,SAAS,CAAC;SAC1B;gBACD,kBAAM,YAAY,CAAC;QACnB,KAAI,CAAC,cAAc,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC;;IAC/C,CAAC;IAEK,0BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;;;;;6BACzB,CAAA,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAA,EAAvD,wBAAuD;wBACnD,kBAAkB,GAAG,KAAK,CAAC,MAAM,GAAG,gBAAgB,CAAC;wBAC3D,qBAAM,iBAAM,GAAG,YAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAM,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;wBAC5D,MAAA,IAAI,CAAC,cAAc,0CAAE,KAAK,CACxB,yBAAkB,kBAAkB,uDAA6C,gBAAgB,MAAG,CACrG,CAAC;;4BAEF,qBAAM,iBAAM,GAAG,YAAC,GAAG,EAAE,KAAK,CAAC,EAAA;;wBAA3B,SAA2B,CAAC;;;;;;KAE/B;IACH,mBAAC;AAAD,CAAC,AA3BD,CAAqC,cAAc,GA2BlD","sourcesContent":["import { getGlobalScope, ILogger, BrowserStorage } from '@amplitude/analytics-core';\n\nconst MAX_ARRAY_LENGTH = 1000;\n\ninterface LocalStorageOptions {\n loggerProvider?: ILogger;\n}\nexport class LocalStorage<T> extends BrowserStorage<T> {\n loggerProvider?: ILogger;\n\n constructor(config?: LocalStorageOptions) {\n let localStorage;\n\n try {\n localStorage = getGlobalScope()?.localStorage;\n } catch (e) {\n config?.loggerProvider?.debug(`Failed to access localStorage. error=${JSON.stringify(e)}`);\n localStorage = undefined;\n }\n super(localStorage);\n this.loggerProvider = config?.loggerProvider;\n }\n\n async set(key: string, value: T): Promise<void> {\n if (Array.isArray(value) && value.length > MAX_ARRAY_LENGTH) {\n const droppedEventsCount = value.length - MAX_ARRAY_LENGTH;\n await super.set(key, value.slice(0, MAX_ARRAY_LENGTH) as T);\n this.loggerProvider?.error(\n `Failed to save ${droppedEventsCount} events because the queue length exceeded ${MAX_ARRAY_LENGTH}.`,\n );\n } else {\n await super.set(key, value);\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { BrowserStorage } from './browser-storage';
1
+ import { BrowserStorage } from '@amplitude/analytics-core';
2
2
  export declare class SessionStorage<T> extends BrowserStorage<T> {
3
3
  constructor();
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/session-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;;CAIvD"}
1
+ {"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/session-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3E,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;;CAIvD"}
@@ -1,6 +1,5 @@
1
1
  import { __extends } from "tslib";
2
- import { getGlobalScope } from '@amplitude/analytics-core';
3
- import { BrowserStorage } from './browser-storage';
2
+ import { getGlobalScope, BrowserStorage } from '@amplitude/analytics-core';
4
3
  var SessionStorage = /** @class */ (function (_super) {
5
4
  __extends(SessionStorage, _super);
6
5
  function SessionStorage() {
@@ -1 +1 @@
1
- {"version":3,"file":"session-storage.js","sourceRoot":"","sources":["../../../src/storage/session-storage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;IAAuC,kCAAiB;IACtD;;eACE,kBAAM,MAAA,cAAc,EAAE,0CAAE,cAAc,CAAC;IACzC,CAAC;IACH,qBAAC;AAAD,CAAC,AAJD,CAAuC,cAAc,GAIpD","sourcesContent":["import { getGlobalScope } from '@amplitude/analytics-core';\nimport { BrowserStorage } from './browser-storage';\n\nexport class SessionStorage<T> extends BrowserStorage<T> {\n constructor() {\n super(getGlobalScope()?.sessionStorage);\n }\n}\n"]}
1
+ {"version":3,"file":"session-storage.js","sourceRoot":"","sources":["../../../src/storage/session-storage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3E;IAAuC,kCAAiB;IACtD;;eACE,kBAAM,MAAA,cAAc,EAAE,0CAAE,cAAc,CAAC;IACzC,CAAC;IACH,qBAAC;AAAD,CAAC,AAJD,CAAuC,cAAc,GAIpD","sourcesContent":["import { getGlobalScope, BrowserStorage } from '@amplitude/analytics-core';\n\nexport class SessionStorage<T> extends BrowserStorage<T> {\n constructor() {\n super(getGlobalScope()?.sessionStorage);\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.21.1";
1
+ export declare const VERSION = "2.22.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export var VERSION = '2.21.1';
1
+ export var VERSION = '2.22.1';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.21.1';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.22.1';\n"]}
@@ -1 +1 @@
1
- !function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},s=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},o=function(e){for(var t=0;t<v.length;t++)s(e,v[t],!1);for(var r=0;r<y.length;r++)s(e,y[r],!0)};r.invoked=!0;var u=t.getElementsByTagName("script")[0],a=t.createElement("script");a.src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz",a.async=!1,u.parentNode.insertBefore(a,u);var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-0YGHXXlwihCXHVsuLY/qwvIp5Cmq5L2iINMXx//A4wCZ0n9TJmQsyr0UtxK2L2FQ",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.21.1-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK"),e.amplitude.init("YOUR_API_KEY","YOUR_USER_ID",{instanceName:"amplitude-bookmarklet",serverZone:"YOUR_SERVER_ZONE",ingestionMetadata:{sourceName:"browser-typescript-bookmarklet",sourceVersion:"1.0.0"},optOut:!1}),amplitudeAutocapturePlugin&&amplitudeAutocapturePlugin.autocapturePlugin&&"function"==typeof amplitudeAutocapturePlugin.autocapturePlugin&&e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin()),alert("Amplitude is now tracking events!")},u.parentNode.insertBefore(c,u);for(var p=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<l.length;d++)n(p,l[d]);r.Identify=p;for(var m=function(){return this._q=[],this},g=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],f=0;f<g.length;f++)n(m,g[f]);r.Revenue=m;var v=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],y=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];o(r),r.createInstance=function(e){return r._iq[e]={_q:[]},o(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
1
+ !function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},s=function(e){for(var t=0;t<v.length;t++)o(e,v[t],!1);for(var r=0;r<y.length;r++)o(e,y[r],!0)};r.invoked=!0;var u=t.getElementsByTagName("script")[0],a=t.createElement("script");a.src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz",a.async=!1,u.parentNode.insertBefore(a,u);var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-VDysG3y8O289yWNGGS5ESEU5j/t67M0RoQzTAd8C0RU6oep9uB64PVjIqHkX7O4N",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.22.1-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK"),e.amplitude.init("YOUR_API_KEY","YOUR_USER_ID",{instanceName:"amplitude-bookmarklet",serverZone:"YOUR_SERVER_ZONE",ingestionMetadata:{sourceName:"browser-typescript-bookmarklet",sourceVersion:"1.0.0"},optOut:!1}),amplitudeAutocapturePlugin&&amplitudeAutocapturePlugin.autocapturePlugin&&"function"==typeof amplitudeAutocapturePlugin.autocapturePlugin&&e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin()),alert("Amplitude is now tracking events!")},u.parentNode.insertBefore(c,u);for(var p=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<l.length;d++)n(p,l[d]);r.Identify=p;for(var m=function(){return this._q=[],this},g=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],f=0;f<g.length;f++)n(m,g[f]);r.Revenue=m;var v=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],y=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];s(r),r.createInstance=function(e){return r._iq[e]={_q:[]},s(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
@@ -1 +1 @@
1
- javascript:!function()%7B%22use%20strict%22%3B!function(e%2Ct)%7Bvar%20r%3De.amplitude%7C%7C%7B_q%3A%5B%5D%2C_iq%3A%7B%7D%7D%3Bif(r.invoked)e.console%26%26console.error%26%26console.error(%22Amplitude%20snippet%20has%20been%20loaded.%22)%3Belse%7Bvar%20n%3Dfunction(e%2Ct)%7Be.prototype%5Bt%5D%3Dfunction()%7Breturn%20this._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(arguments%2C0)%7D)%2Cthis%7D%7D%2Ci%3Dfunction(e%2Ct%2Cr)%7Breturn%20function(n)%7Be._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(r%2C0)%2Cresolve%3An%7D)%7D%7D%2Cs%3Dfunction(e%2Ct%2Cr)%7Be%5Bt%5D%3Dfunction()%7Bif(r)return%7Bpromise%3Anew%20Promise(i(e%2Ct%2CArray.prototype.slice.call(arguments)))%7D%7D%7D%2Co%3Dfunction(e)%7Bfor(var%20t%3D0%3Bt%3Cv.length%3Bt%2B%2B)s(e%2Cv%5Bt%5D%2C!1)%3Bfor(var%20r%3D0%3Br%3Cy.length%3Br%2B%2B)s(e%2Cy%5Br%5D%2C!0)%7D%3Br.invoked%3D!0%3Bvar%20u%3Dt.getElementsByTagName(%22script%22)%5B0%5D%2Ca%3Dt.createElement(%22script%22)%3Ba.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fplugin-autocapture-browser-0.9.0-min.js.gz%22%2Ca.async%3D!1%2Cu.parentNode.insertBefore(a%2Cu)%3Bvar%20c%3Dt.createElement(%22script%22)%3Bc.type%3D%22text%2Fjavascript%22%2Cc.integrity%3D%22sha384-0YGHXXlwihCXHVsuLY%2FqwvIp5Cmq5L2iINMXx%2F%2FA4wCZ0n9TJmQsyr0UtxK2L2FQ%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.21.1-min.js.gz%22%2Cc.onload%3Dfunction()%7Be.amplitude.runQueuedFunctions%7C%7Cconsole.log(%22%5BAmplitude%5D%20Error%3A%20could%20not%20load%20SDK%22)%2Ce.amplitude.init(%22YOUR_API_KEY%22%2C%22YOUR_USER_ID%22%2C%7BinstanceName%3A%22amplitude-bookmarklet%22%2CserverZone%3A%22YOUR_SERVER_ZONE%22%2CingestionMetadata%3A%7BsourceName%3A%22browser-typescript-bookmarklet%22%2CsourceVersion%3A%221.0.0%22%7D%2CoptOut%3A!1%7D)%2CamplitudeAutocapturePlugin%26%26amplitudeAutocapturePlugin.autocapturePlugin%26%26%22function%22%3D%3Dtypeof%20amplitudeAutocapturePlugin.autocapturePlugin%26%26e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin())%2Calert(%22Amplitude%20is%20now%20tracking%20events!%22)%7D%2Cu.parentNode.insertBefore(c%2Cu)%3Bfor(var%20p%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cl%3D%5B%22add%22%2C%22append%22%2C%22clearAll%22%2C%22prepend%22%2C%22set%22%2C%22setOnce%22%2C%22unset%22%2C%22preInsert%22%2C%22postInsert%22%2C%22remove%22%2C%22getUserProperties%22%5D%2Cd%3D0%3Bd%3Cl.length%3Bd%2B%2B)n(p%2Cl%5Bd%5D)%3Br.Identify%3Dp%3Bfor(var%20m%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cg%3D%5B%22getEventProperties%22%2C%22setProductId%22%2C%22setQuantity%22%2C%22setPrice%22%2C%22setRevenue%22%2C%22setRevenueType%22%2C%22setReceipt%22%2C%22setReceiptSig%22%2C%22setCurrency%22%2C%22setEventProperties%22%5D%2Cf%3D0%3Bf%3Cg.length%3Bf%2B%2B)n(m%2Cg%5Bf%5D)%3Br.Revenue%3Dm%3Bvar%20v%3D%5B%22getDeviceId%22%2C%22setDeviceId%22%2C%22getSessionId%22%2C%22setSessionId%22%2C%22getUserId%22%2C%22setUserId%22%2C%22setOptOut%22%2C%22setTransport%22%2C%22reset%22%2C%22extendSession%22%5D%2Cy%3D%5B%22init%22%2C%22add%22%2C%22remove%22%2C%22track%22%2C%22logEvent%22%2C%22identify%22%2C%22groupIdentify%22%2C%22setGroup%22%2C%22revenue%22%2C%22flush%22%5D%3Bo(r)%2Cr.createInstance%3Dfunction(e)%7Breturn%20r._iq%5Be%5D%3D%7B_q%3A%5B%5D%7D%2Co(r._iq%5Be%5D)%2Cr._iq%5Be%5D%7D%2Ce.amplitude%3Dr%7D%7D(window%2Cdocument)%7D()%3B%0A
1
+ javascript:!function()%7B%22use%20strict%22%3B!function(e%2Ct)%7Bvar%20r%3De.amplitude%7C%7C%7B_q%3A%5B%5D%2C_iq%3A%7B%7D%7D%3Bif(r.invoked)e.console%26%26console.error%26%26console.error(%22Amplitude%20snippet%20has%20been%20loaded.%22)%3Belse%7Bvar%20n%3Dfunction(e%2Ct)%7Be.prototype%5Bt%5D%3Dfunction()%7Breturn%20this._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(arguments%2C0)%7D)%2Cthis%7D%7D%2Ci%3Dfunction(e%2Ct%2Cr)%7Breturn%20function(n)%7Be._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(r%2C0)%2Cresolve%3An%7D)%7D%7D%2Co%3Dfunction(e%2Ct%2Cr)%7Be%5Bt%5D%3Dfunction()%7Bif(r)return%7Bpromise%3Anew%20Promise(i(e%2Ct%2CArray.prototype.slice.call(arguments)))%7D%7D%7D%2Cs%3Dfunction(e)%7Bfor(var%20t%3D0%3Bt%3Cv.length%3Bt%2B%2B)o(e%2Cv%5Bt%5D%2C!1)%3Bfor(var%20r%3D0%3Br%3Cy.length%3Br%2B%2B)o(e%2Cy%5Br%5D%2C!0)%7D%3Br.invoked%3D!0%3Bvar%20u%3Dt.getElementsByTagName(%22script%22)%5B0%5D%2Ca%3Dt.createElement(%22script%22)%3Ba.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fplugin-autocapture-browser-0.9.0-min.js.gz%22%2Ca.async%3D!1%2Cu.parentNode.insertBefore(a%2Cu)%3Bvar%20c%3Dt.createElement(%22script%22)%3Bc.type%3D%22text%2Fjavascript%22%2Cc.integrity%3D%22sha384-VDysG3y8O289yWNGGS5ESEU5j%2Ft67M0RoQzTAd8C0RU6oep9uB64PVjIqHkX7O4N%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.22.1-min.js.gz%22%2Cc.onload%3Dfunction()%7Be.amplitude.runQueuedFunctions%7C%7Cconsole.log(%22%5BAmplitude%5D%20Error%3A%20could%20not%20load%20SDK%22)%2Ce.amplitude.init(%22YOUR_API_KEY%22%2C%22YOUR_USER_ID%22%2C%7BinstanceName%3A%22amplitude-bookmarklet%22%2CserverZone%3A%22YOUR_SERVER_ZONE%22%2CingestionMetadata%3A%7BsourceName%3A%22browser-typescript-bookmarklet%22%2CsourceVersion%3A%221.0.0%22%7D%2CoptOut%3A!1%7D)%2CamplitudeAutocapturePlugin%26%26amplitudeAutocapturePlugin.autocapturePlugin%26%26%22function%22%3D%3Dtypeof%20amplitudeAutocapturePlugin.autocapturePlugin%26%26e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin())%2Calert(%22Amplitude%20is%20now%20tracking%20events!%22)%7D%2Cu.parentNode.insertBefore(c%2Cu)%3Bfor(var%20p%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cl%3D%5B%22add%22%2C%22append%22%2C%22clearAll%22%2C%22prepend%22%2C%22set%22%2C%22setOnce%22%2C%22unset%22%2C%22preInsert%22%2C%22postInsert%22%2C%22remove%22%2C%22getUserProperties%22%5D%2Cd%3D0%3Bd%3Cl.length%3Bd%2B%2B)n(p%2Cl%5Bd%5D)%3Br.Identify%3Dp%3Bfor(var%20m%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cg%3D%5B%22getEventProperties%22%2C%22setProductId%22%2C%22setQuantity%22%2C%22setPrice%22%2C%22setRevenue%22%2C%22setRevenueType%22%2C%22setReceipt%22%2C%22setReceiptSig%22%2C%22setCurrency%22%2C%22setEventProperties%22%5D%2Cf%3D0%3Bf%3Cg.length%3Bf%2B%2B)n(m%2Cg%5Bf%5D)%3Br.Revenue%3Dm%3Bvar%20v%3D%5B%22getDeviceId%22%2C%22setDeviceId%22%2C%22getSessionId%22%2C%22setSessionId%22%2C%22getUserId%22%2C%22setUserId%22%2C%22setOptOut%22%2C%22setTransport%22%2C%22reset%22%2C%22extendSession%22%5D%2Cy%3D%5B%22init%22%2C%22add%22%2C%22remove%22%2C%22track%22%2C%22logEvent%22%2C%22identify%22%2C%22groupIdentify%22%2C%22setGroup%22%2C%22revenue%22%2C%22flush%22%5D%3Bs(r)%2Cr.createInstance%3Dfunction(e)%7Breturn%20r._iq%5Be%5D%3D%7B_q%3A%5B%5D%7D%2Cs(r._iq%5Be%5D)%2Cr._iq%5Be%5D%7D%2Ce.amplitude%3Dr%7D%7D(window%2Cdocument)%7D()%3B%0A