@amplitude/analytics-browser 2.45.0 → 2.45.2

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 (35) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/config/joined-config.d.ts +0 -28
  3. package/lib/cjs/config/joined-config.d.ts.map +1 -1
  4. package/lib/cjs/config/joined-config.js +8 -177
  5. package/lib/cjs/config/joined-config.js.map +1 -1
  6. package/lib/cjs/config.d.ts +1 -1
  7. package/lib/cjs/version.d.ts +1 -1
  8. package/lib/cjs/version.js +1 -1
  9. package/lib/cjs/version.js.map +1 -1
  10. package/lib/esm/config/joined-config.d.ts +0 -28
  11. package/lib/esm/config/joined-config.d.ts.map +1 -1
  12. package/lib/esm/config/joined-config.js +8 -176
  13. package/lib/esm/config/joined-config.js.map +1 -1
  14. package/lib/esm/config.d.ts +1 -1
  15. package/lib/esm/version.d.ts +1 -1
  16. package/lib/esm/version.js +1 -1
  17. package/lib/esm/version.js.map +1 -1
  18. package/lib/scripts/amplitude-bookmarklet-snippet-min.js +1 -1
  19. package/lib/scripts/amplitude-bookmarklet.html +1 -1
  20. package/lib/scripts/amplitude-gtm-min.js +1 -1
  21. package/lib/scripts/amplitude-gtm-min.js.gz +0 -0
  22. package/lib/scripts/amplitude-gtm-min.js.map +1 -1
  23. package/lib/scripts/amplitude-gtm-snippet-min.js +1 -1
  24. package/lib/scripts/amplitude-min.js +1 -1
  25. package/lib/scripts/amplitude-min.js.gz +0 -0
  26. package/lib/scripts/amplitude-min.js.map +1 -1
  27. package/lib/scripts/amplitude-min.umd.js +1 -1
  28. package/lib/scripts/amplitude-min.umd.js.gz +0 -0
  29. package/lib/scripts/amplitude-snippet-instructions.html +1 -1
  30. package/lib/scripts/amplitude-snippet-min.js +1 -1
  31. package/lib/scripts/config/joined-config.d.ts +0 -28
  32. package/lib/scripts/config/joined-config.d.ts.map +1 -1
  33. package/lib/scripts/config.d.ts +1 -1
  34. package/lib/scripts/version.d.ts +1 -1
  35. package/package.json +9 -9
package/README.md CHANGED
@@ -53,7 +53,7 @@ This SDK is also available through CDN. Copy the script loader below and paste b
53
53
  <!-- README_SNIPPET_BLOCK -->
54
54
  ```html
55
55
  <script type="text/javascript">
56
- !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}},s=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(s(e,t,Array.prototype.slice.call(arguments)))};!function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})}(e,t,Array.prototype.slice.call(arguments))}},i=function(e){for(var t=0;t<y.length;t++)o(e,y[t],!1);for(var r=0;r<g.length;r++)o(e,g[r],!0)};r.invoked=!0;var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-XQIGro5vKBjeKbCMyWZF4q8Puikh1eIei8tB10PoJuxTrmVKpFnlIWPm7GvsgLcf",c.crossOrigin="anonymous",c.async=!0,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.45.0-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var a=t.getElementsByTagName("script")[0];a.parentNode.insertBefore(c,a);for(var u=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],l=0;l<p.length;l++)n(u,p[l]);r.Identify=u;for(var d=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],v=0;v<f.length;v++)n(d,f[v]);r.Revenue=d;var y=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];i(r),r.createInstance=function(e){return r._iq[e]={_q:[]},i(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
56
+ !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}},s=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(s(e,t,Array.prototype.slice.call(arguments)))};!function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})}(e,t,Array.prototype.slice.call(arguments))}},i=function(e){for(var t=0;t<y.length;t++)o(e,y[t],!1);for(var r=0;r<g.length;r++)o(e,g[r],!0)};r.invoked=!0;var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-Z5hPRB6H+h1KGVzALs6Hd95FRZZQLYuV8cfugNYCNe9M/RIa7MuKIOQ2LHszfCpG",c.crossOrigin="anonymous",c.async=!0,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.45.2-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var a=t.getElementsByTagName("script")[0];a.parentNode.insertBefore(c,a);for(var u=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],l=0;l<p.length;l++)n(u,p[l]);r.Identify=u;for(var d=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],v=0;v<f.length;v++)n(d,f[v]);r.Revenue=d;var y=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];i(r),r.createInstance=function(e){return r._iq[e]={_q:[]},i(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
57
57
 
58
58
  amplitude.init("<YOUR_API_KEY>");
59
59
  </script>
@@ -21,34 +21,6 @@ export interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptio
21
21
  */
22
22
  captureRules?: NetworkCaptureRuleRemoteConfig[];
23
23
  }
24
- /**
25
- * Performs a deep transformation of a remote config object so that
26
- * it matches the expected schema of the local config.
27
- *
28
- * Specifically, it normalizes nested `enabled` flags into concise union types.
29
- *
30
- * ### Transformation Rules:
31
- * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.
32
- * - If it has only `enabled: true`, it is replaced with `true`.
33
- * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.
34
- *
35
- * ### Examples:
36
- * Input: { prop: { enabled: true, hello: 'world' }}
37
- * Output: { prop: { hello: 'world' } }
38
- *
39
- * Input: { prop: { enabled: true }}
40
- * Output: { prop: true }
41
- *
42
- * Input: { prop: { enabled: false, hello: 'world' }}
43
- * Output: { prop: false }
44
- *
45
- * Input: { prop: { hello: 'world' }}
46
- * Output: { prop: { hello: 'world' } } // No change
47
- *
48
- * @param config Remote config object to be transformed
49
- * @returns Transformed config object compatible with local schema
50
- */
51
- export declare function translateRemoteConfigToLocal(config?: Record<string, any>): void;
52
24
  /**
53
25
  * Updates the browser config in place by applying remote configuration settings.
54
26
  * Primarily merges autocapture settings from the remote config into the browser config.
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,aAAa,EAEb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,mBAAmB,CAAC,EAAE,OAAO,GAAG,sCAAsC,CAAC;IACvE,eAAe,C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AY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CACjD;AAsBD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,aAAa,EAAE,aAAa,GAC3B,IAAI,CA6GN"}
@@ -1,179 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateBrowserConfigWithRemoteConfig = exports.translateRemoteConfigToLocal = void 0;
3
+ exports.updateBrowserConfigWithRemoteConfig = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var analytics_core_1 = require("@amplitude/analytics-core");
6
- /**
7
- * Performs a deep transformation of a remote config object so that
8
- * it matches the expected schema of the local config.
9
- *
10
- * Specifically, it normalizes nested `enabled` flags into concise union types.
11
- *
12
- * ### Transformation Rules:
13
- * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.
14
- * - If it has only `enabled: true`, it is replaced with `true`.
15
- * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.
16
- *
17
- * ### Examples:
18
- * Input: { prop: { enabled: true, hello: 'world' }}
19
- * Output: { prop: { hello: 'world' } }
20
- *
21
- * Input: { prop: { enabled: true }}
22
- * Output: { prop: true }
23
- *
24
- * Input: { prop: { enabled: false, hello: 'world' }}
25
- * Output: { prop: false }
26
- *
27
- * Input: { prop: { hello: 'world' }}
28
- * Output: { prop: { hello: 'world' } } // No change
29
- *
30
- * @param config Remote config object to be transformed
31
- * @returns Transformed config object compatible with local schema
32
- */
33
- function translateRemoteConfigToLocal(config) {
34
- var e_1, _a, e_2, _b, e_3, _c;
35
- var _d, _e, _f, _g, _h, _j;
36
- // Disabling type checking rules because remote config comes from a remote source
37
- // and this function needs to handle any unexpected values
38
- /* eslint-disable @typescript-eslint/no-unsafe-member-access,
39
- @typescript-eslint/no-unsafe-assignment,
40
- @typescript-eslint/no-unsafe-argument
41
- */
42
- if (typeof config !== 'object' || config === null) {
43
- return;
44
- }
45
- // translations are not applied on array properties
46
- if (Array.isArray(config)) {
47
- return;
48
- }
49
- var propertyNames = Object.keys(config);
50
- try {
51
- for (var propertyNames_1 = tslib_1.__values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
52
- var propertyName = propertyNames_1_1.value;
53
- try {
54
- var value = config[propertyName];
55
- // transform objects with { enabled } property to boolean | object
56
- if (typeof (value === null || value === void 0 ? void 0 : value.enabled) === 'boolean') {
57
- if (value.enabled) {
58
- // if enabled is true, set the value to the rest of the object
59
- // or true if the object has no other properties
60
- delete value.enabled;
61
- if (Object.keys(value).length === 0) {
62
- config[propertyName] = true;
63
- }
64
- }
65
- else {
66
- // If enabled is false, set the value to false
67
- config[propertyName] = false;
68
- }
69
- }
70
- // recursively translate properties of the value
71
- translateRemoteConfigToLocal(value);
72
- }
73
- catch (e) {
74
- // a failure here means that an accessor threw an error
75
- // so don't translate it
76
- // TODO(diagnostics): add a diagnostic event for this
77
- }
78
- }
79
- }
80
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
81
- finally {
82
- try {
83
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
84
- }
85
- finally { if (e_1) throw e_1.error; }
86
- }
87
- // translate remote responseHeaders and requestHeaders to local responseHeaders and requestHeaders
88
- try {
89
- if ((_f = (_e = (_d = config.autocapture) === null || _d === void 0 ? void 0 : _d.networkTracking) === null || _e === void 0 ? void 0 : _e.captureRules) === null || _f === void 0 ? void 0 : _f.length) {
90
- try {
91
- for (var _k = tslib_1.__values(config.autocapture.networkTracking.captureRules), _l = _k.next(); !_l.done; _l = _k.next()) {
92
- var rule = _l.value;
93
- try {
94
- for (var _m = (e_3 = void 0, tslib_1.__values(['responseHeaders', 'requestHeaders'])), _o = _m.next(); !_o.done; _o = _m.next()) {
95
- var header = _o.value;
96
- var _p = (_g = rule[header]) !== null && _g !== void 0 ? _g : {}, captureSafeHeaders = _p.captureSafeHeaders, allowlist = _p.allowlist;
97
- if (!captureSafeHeaders && !allowlist) {
98
- continue;
99
- }
100
- // if allowlist is not an array, remote config contract is violated, remove it
101
- if (allowlist !== undefined && !Array.isArray(allowlist)) {
102
- delete rule[header];
103
- continue;
104
- }
105
- rule[header] = tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read((captureSafeHeaders ? analytics_core_1.SAFE_HEADERS : [])), false), tslib_1.__read((allowlist !== null && allowlist !== void 0 ? allowlist : [])), false);
106
- }
107
- }
108
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
109
- finally {
110
- try {
111
- if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
112
- }
113
- finally { if (e_3) throw e_3.error; }
114
- }
115
- }
116
- }
117
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
118
- finally {
119
- try {
120
- if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
121
- }
122
- finally { if (e_2) throw e_2.error; }
123
- }
124
- }
125
- }
126
- catch (e) {
127
- /* istanbul ignore next */
128
- // surprise exception, so don't translate it
129
- }
130
- // translate frustrationInteractions pluralization
131
- var frustrationInteractions = (_h = config.autocapture) === null || _h === void 0 ? void 0 : _h.frustrationInteractions;
132
- if (frustrationInteractions) {
133
- if (frustrationInteractions.rageClick) {
134
- frustrationInteractions.rageClicks = frustrationInteractions.rageClick;
135
- delete frustrationInteractions.rageClick;
136
- }
137
- if (frustrationInteractions.deadClick) {
138
- frustrationInteractions.deadClicks = frustrationInteractions.deadClick;
139
- delete frustrationInteractions.deadClick;
140
- }
141
- }
142
- // normalize viewportContentUpdated inside elementInteractions
143
- try {
144
- var elementInteractions = (_j = config.autocapture) === null || _j === void 0 ? void 0 : _j.elementInteractions;
145
- if (elementInteractions && typeof elementInteractions === 'object') {
146
- // { enabled: true } (no other fields) collapses to `true`; convert back to {} for the SDK.
147
- if (elementInteractions.viewportContentUpdated === true) {
148
- elementInteractions.viewportContentUpdated = {};
149
- }
150
- // { enabled: false, ... } collapses to `false`; convert back to { enabled: false } for the SDK.
151
- if (elementInteractions.viewportContentUpdated === false) {
152
- elementInteractions.viewportContentUpdated = { enabled: false };
153
- }
154
- // Migrate deprecated top-level exposureDuration to viewportContentUpdated.exposureDuration
155
- if (elementInteractions.exposureDuration !== undefined) {
156
- var viewportContentUpdated = elementInteractions.viewportContentUpdated;
157
- if (viewportContentUpdated === undefined) {
158
- elementInteractions.viewportContentUpdated = { exposureDuration: elementInteractions.exposureDuration };
159
- }
160
- else if (typeof viewportContentUpdated === 'object' &&
161
- viewportContentUpdated.exposureDuration === undefined &&
162
- viewportContentUpdated.enabled !== false) {
163
- viewportContentUpdated.exposureDuration = elementInteractions.exposureDuration;
164
- }
165
- delete elementInteractions.exposureDuration;
166
- }
167
- }
168
- }
169
- catch (e) {
170
- /* istanbul ignore next */
171
- // surprise exception, so don't translate it
172
- }
173
- }
174
- exports.translateRemoteConfigToLocal = translateRemoteConfigToLocal;
175
6
  function mergeUrls(urlsExact, urlsRegex, browserConfig) {
176
- var e_4, _a;
7
+ var e_1, _a;
177
8
  // Convert string patterns to RegExp objects, warn on invalid patterns and skip them
178
9
  var regexList = [];
179
10
  try {
@@ -187,12 +18,12 @@ function mergeUrls(urlsExact, urlsRegex, browserConfig) {
187
18
  }
188
19
  }
189
20
  }
190
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
21
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
191
22
  finally {
192
23
  try {
193
24
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
194
25
  }
195
- finally { if (e_4) throw e_4.error; }
26
+ finally { if (e_1) throw e_1.error; }
196
27
  }
197
28
  return urlsExact.concat(regexList);
198
29
  }
@@ -204,13 +35,13 @@ function mergeUrls(urlsExact, urlsRegex, browserConfig) {
204
35
  * @param browserConfig - The browser config object to update (modified in place)
205
36
  */
206
37
  function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig) {
207
- var e_5, _a;
38
+ var e_2, _a;
208
39
  var _b, _c, _d, _e, _f;
209
40
  if (!remoteConfig) {
210
41
  return;
211
42
  }
212
43
  // translate remote config to local compatible format
213
- translateRemoteConfigToLocal(remoteConfig);
44
+ (0, analytics_core_1.translateRemoteConfigToLocal)(remoteConfig);
214
45
  try {
215
46
  browserConfig.loggerProvider.debug('Update browser config with remote configuration:', (0, analytics_core_1.safeJsonStringify)(remoteConfig));
216
47
  // type cast error will be thrown if remoteConfig is not a valid RemoteConfigBrowserSDK
@@ -256,12 +87,12 @@ function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig) {
256
87
  delete rule.urlsRegex;
257
88
  }
258
89
  }
259
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
90
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
260
91
  finally {
261
92
  try {
262
93
  if (captureRules_1_1 && !captureRules_1_1.done && (_a = captureRules_1.return)) _a.call(captureRules_1);
263
94
  }
264
- finally { if (e_5) throw e_5.error; }
95
+ finally { if (e_2) throw e_2.error; }
265
96
  }
266
97
  }
267
98
  if (typeof browserConfig.autocapture === 'boolean') {
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,4DAUmC;AAiCnC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,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,iBAAA,aAAa,CAAA,4CAAA,uEAAE;YAArC,IAAM,YAAY,0BAAA;YACrB,IAAI;gBACF,IAAM,KAAK,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AAa,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,yCACpB,aAAa,CAAC,WAAW,GACzB,kCAAkC,CACtC,CAAC;iBACH;aACF;YAED,+EAA+E;YAC/E,aAAa,CAAC,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;SAC3D;QAED,IAAI,kBAAkB,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,gBAAgB,KAAK,IAAI,EAAE;YAC1F,yFAAyF;YACzF,uCAAuC;YACvC,IAAI,aAAa,CAAC,gBAAgB,KAAK,KAAK,EAAE;gBAC5C,aAAa,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;aACrE;SACF;QAED,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,4CAA4C,EAAE,IAAA,kCAAiB,EAAC,aAAa,CAAC,CAAC,CAAC;KACpH;IAAC,OAAO,CAAC,EAAE;QACV,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,CAAC,CAAC,CAAC;KAClG;AACH,CAAC;AAhHD,kFAgHC","sourcesContent":["import {\n AutocaptureOptions,\n type ElementInteractionsOptions,\n BrowserConfig,\n CustomEnrichmentOptions,\n RemoteConfig,\n NetworkTrackingOptions,\n NetworkCaptureRule,\n SAFE_HEADERS,\n safeJsonStringify,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n networkTracking?: boolean | NetworkTrackingOptionsRemoteConfig;\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 interface NetworkCaptureRuleRemoteConfig extends NetworkCaptureRule {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n urlsRegex?: string[];\n}\n\nexport interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\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 customEnrichment?: CustomEnrichmentOptions | 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 // translate remote responseHeaders and requestHeaders to local responseHeaders and requestHeaders\n try {\n if (config.autocapture?.networkTracking?.captureRules?.length) {\n for (const rule of config.autocapture.networkTracking.captureRules) {\n for (const header of ['responseHeaders', 'requestHeaders']) {\n const { captureSafeHeaders, allowlist } = rule[header] ?? {};\n if (!captureSafeHeaders && !allowlist) {\n continue;\n }\n // if allowlist is not an array, remote config contract is violated, remove it\n if (allowlist !== undefined && !Array.isArray(allowlist)) {\n delete rule[header];\n continue;\n }\n rule[header] = [...(captureSafeHeaders ? SAFE_HEADERS : []), ...(allowlist ?? [])];\n }\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n\n // translate frustrationInteractions pluralization\n const frustrationInteractions = config.autocapture?.frustrationInteractions;\n if (frustrationInteractions) {\n if (frustrationInteractions.rageClick) {\n frustrationInteractions.rageClicks = frustrationInteractions.rageClick;\n delete frustrationInteractions.rageClick;\n }\n if (frustrationInteractions.deadClick) {\n frustrationInteractions.deadClicks = frustrationInteractions.deadClick;\n delete frustrationInteractions.deadClick;\n }\n }\n\n // normalize viewportContentUpdated inside elementInteractions\n try {\n const elementInteractions = config.autocapture?.elementInteractions;\n if (elementInteractions && typeof elementInteractions === 'object') {\n // { enabled: true } (no other fields) collapses to `true`; convert back to {} for the SDK.\n if (elementInteractions.viewportContentUpdated === true) {\n elementInteractions.viewportContentUpdated = {};\n }\n // { enabled: false, ... } collapses to `false`; convert back to { enabled: false } for the SDK.\n if (elementInteractions.viewportContentUpdated === false) {\n elementInteractions.viewportContentUpdated = { enabled: false };\n }\n // Migrate deprecated top-level exposureDuration to viewportContentUpdated.exposureDuration\n if (elementInteractions.exposureDuration !== undefined) {\n const viewportContentUpdated = elementInteractions.viewportContentUpdated;\n if (viewportContentUpdated === undefined) {\n elementInteractions.viewportContentUpdated = { exposureDuration: elementInteractions.exposureDuration };\n } else if (\n typeof viewportContentUpdated === 'object' &&\n viewportContentUpdated.exposureDuration === undefined &&\n viewportContentUpdated.enabled !== false\n ) {\n viewportContentUpdated.exposureDuration = elementInteractions.exposureDuration;\n }\n delete elementInteractions.exposureDuration;\n }\n }\n } catch (e) {\n /* istanbul ignore next */\n // surprise exception, so don't translate it\n }\n}\n\nfunction mergeUrls(urlsExact: (string | RegExp)[], urlsRegex: string[] | undefined, browserConfig: BrowserConfig) {\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n browserConfig.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\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 safeJsonStringify(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 // combine exact allow list and regex allow list into just 'pageUrlAllowlist'\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n const urlsRegex = typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex;\n transformedRcElementInteractions.pageUrlAllowlist = mergeUrls(exactAllowList, urlsRegex, browserConfig);\n\n // clean up the regex allow list\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n // Handle Network Tracking config initialization\n if (\n typeof typedRemoteConfig.autocapture.networkTracking === 'object' &&\n typedRemoteConfig.autocapture.networkTracking !== null &&\n typedRemoteConfig.autocapture.networkTracking.captureRules?.length\n ) {\n transformedAutocaptureRemoteConfig.networkTracking = {\n ...typedRemoteConfig.autocapture.networkTracking,\n };\n const transformedRcNetworkTracking = transformedAutocaptureRemoteConfig.networkTracking;\n /* istanbul ignore next */\n const captureRules = transformedRcNetworkTracking.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, browserConfig);\n delete rule.urlsRegex;\n }\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 if ('customEnrichment' in typedRemoteConfig && typedRemoteConfig.customEnrichment !== null) {\n // Respect a locally-explicit false: if the user disabled custom enrichment at init time,\n // remote config must not re-enable it.\n if (browserConfig.customEnrichment !== false) {\n browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;\n }\n }\n\n browserConfig.loggerProvider.debug('Browser config after remote config update:', safeJsonStringify(browserConfig));\n } catch (e) {\n browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);\n }\n}\n"]}
1
+ {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,4DAUmC;AAiCnC,SAAS,SAAS,CAAC,SAA8B,EAAE,SAA+B,EAAE,aAA4B;;IAC9G,oFAAoF;IACpF,IAAM,SAAS,GAAG,EAAE,CAAC;;QACrB,KAAsB,IAAA,KAAA,iBAAA,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAA,gBAAA,4BAAE;YAAlC,IAAM,OAAO,WAAA;YAChB,IAAI;gBACF,SAAS,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;aACrC;YAAC,OAAO,UAAU,EAAE;gBACnB,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,iCAA0B,OAAO,CAAE,EAAE,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AAa,CAAC,WAAW,EACtC,aAAa,EAAE,aAAa,CAAC,WAAW,EACxC,gBAAgB,EAAE,aAAa,CAAC,WAAW,EAC3C,SAAS,EAAE,aAAa,CAAC,WAAW,EACpC,QAAQ,EAAE,aAAa,CAAC,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,yCACpB,aAAa,CAAC,WAAW,GACzB,kCAAkC,CACtC,CAAC;iBACH;aACF;YAED,+EAA+E;YAC/E,aAAa,CAAC,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;SAC3D;QAED,IAAI,kBAAkB,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,gBAAgB,KAAK,IAAI,EAAE;YAC1F,yFAAyF;YACzF,uCAAuC;YACvC,IAAI,aAAa,CAAC,gBAAgB,KAAK,KAAK,EAAE;gBAC5C,aAAa,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,gBAAgB,CAAC;aACrE;SACF;QAED,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,4CAA4C,EAAE,IAAA,kCAAiB,EAAC,aAAa,CAAC,CAAC,CAAC;KACpH;IAAC,OAAO,CAAC,EAAE;QACV,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,CAAC,CAAC,CAAC;KAClG;AACH,CAAC;AAhHD,kFAgHC","sourcesContent":["import {\n AutocaptureOptions,\n type ElementInteractionsOptions,\n BrowserConfig,\n CustomEnrichmentOptions,\n RemoteConfig,\n NetworkTrackingOptions,\n NetworkCaptureRule,\n safeJsonStringify,\n translateRemoteConfigToLocal,\n} from '@amplitude/analytics-core';\n\nexport interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {\n elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;\n networkTracking?: boolean | NetworkTrackingOptionsRemoteConfig;\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 interface NetworkCaptureRuleRemoteConfig extends NetworkCaptureRule {\n /**\n * Related to urls but holds regex strings which will be initialized and appended to urls\n */\n urlsRegex?: string[];\n}\n\nexport interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptions {\n /**\n * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist\n */\n captureRules?: NetworkCaptureRuleRemoteConfig[];\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 customEnrichment?: CustomEnrichmentOptions | boolean;\n};\n\nfunction mergeUrls(urlsExact: (string | RegExp)[], urlsRegex: string[] | undefined, browserConfig: BrowserConfig) {\n // Convert string patterns to RegExp objects, warn on invalid patterns and skip them\n const regexList = [];\n for (const pattern of urlsRegex ?? []) {\n try {\n regexList.push(new RegExp(pattern));\n } catch (regexError) {\n browserConfig.loggerProvider.warn(`Invalid regex pattern: ${pattern}`, regexError);\n }\n }\n\n return urlsExact.concat(regexList);\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 safeJsonStringify(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 // combine exact allow list and regex allow list into just 'pageUrlAllowlist'\n const exactAllowList = transformedRcElementInteractions.pageUrlAllowlist ?? [];\n const urlsRegex = typedRemoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex;\n transformedRcElementInteractions.pageUrlAllowlist = mergeUrls(exactAllowList, urlsRegex, browserConfig);\n\n // clean up the regex allow list\n delete transformedRcElementInteractions.pageUrlAllowlistRegex;\n }\n\n // Handle Network Tracking config initialization\n if (\n typeof typedRemoteConfig.autocapture.networkTracking === 'object' &&\n typedRemoteConfig.autocapture.networkTracking !== null &&\n typedRemoteConfig.autocapture.networkTracking.captureRules?.length\n ) {\n transformedAutocaptureRemoteConfig.networkTracking = {\n ...typedRemoteConfig.autocapture.networkTracking,\n };\n const transformedRcNetworkTracking = transformedAutocaptureRemoteConfig.networkTracking;\n /* istanbul ignore next */\n const captureRules = transformedRcNetworkTracking.captureRules ?? [];\n for (const rule of captureRules) {\n rule.urls = mergeUrls(rule.urls ?? [], rule.urlsRegex, browserConfig);\n delete rule.urlsRegex;\n }\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 if ('customEnrichment' in typedRemoteConfig && typedRemoteConfig.customEnrichment !== null) {\n // Respect a locally-explicit false: if the user disabled custom enrichment at init time,\n // remote config must not re-enable it.\n if (browserConfig.customEnrichment !== false) {\n browserConfig.customEnrichment = typedRemoteConfig.customEnrichment;\n }\n }\n\n browserConfig.loggerProvider.debug('Browser config after remote config update:', safeJsonStringify(browserConfig));\n } catch (e) {\n browserConfig.loggerProvider.error('Failed to apply remote configuration because of error: ', e);\n }\n}\n"]}
@@ -40,7 +40,7 @@ export declare class BrowserConfig extends Config implements IBrowserConfig {
40
40
  topLevelDomain?: string | undefined;
41
41
  enableRequestBodyCompression: boolean;
42
42
  customEnrichment?: boolean | CustomEnrichmentOptions | undefined;
43
- readonly version = "2.45.0";
43
+ readonly version = "2.45.2";
44
44
  protected _cookieStorage: Storage<UserSession>;
45
45
  protected _deviceId?: string;
46
46
  protected _lastEventId?: number;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.45.0";
1
+ export declare const VERSION = "2.45.2";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.45.0';
4
+ exports.VERSION = '2.45.2';
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.45.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.45.2';\n"]}
@@ -21,34 +21,6 @@ export interface NetworkTrackingOptionsRemoteConfig extends NetworkTrackingOptio
21
21
  */
22
22
  captureRules?: NetworkCaptureRuleRemoteConfig[];
23
23
  }
24
- /**
25
- * Performs a deep transformation of a remote config object so that
26
- * it matches the expected schema of the local config.
27
- *
28
- * Specifically, it normalizes nested `enabled` flags into concise union types.
29
- *
30
- * ### Transformation Rules:
31
- * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.
32
- * - If it has only `enabled: true`, it is replaced with `true`.
33
- * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.
34
- *
35
- * ### Examples:
36
- * Input: { prop: { enabled: true, hello: 'world' }}
37
- * Output: { prop: { hello: 'world' } }
38
- *
39
- * Input: { prop: { enabled: true }}
40
- * Output: { prop: true }
41
- *
42
- * Input: { prop: { enabled: false, hello: 'world' }}
43
- * Output: { prop: false }
44
- *
45
- * Input: { prop: { hello: 'world' }}
46
- * Output: { prop: { hello: 'world' } } // No change
47
- *
48
- * @param config Remote config object to be transformed
49
- * @returns Transformed config object compatible with local schema
50
- */
51
- export declare function translateRemoteConfigToLocal(config?: Record<string, any>): void;
52
24
  /**
53
25
  * Updates the browser config in place by applying remote configuration settings.
54
26
  * Primarily merges autocapture settings from the remote config into the browser config.
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,aAAa,EAEb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,mBAAmB,CAAC,EAAE,OAAO,GAAG,sCAAsC,CAAC;IACvE,eAAe,CAAC,EAAE,OAAO,GAAG,kCAAkC,CAAC;CAChE;AACD,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kCAAmC,SAAQ,sBAAsB;IAChF;;OAEG;IACH,YAAY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CACjD;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QA+GxE;AAgBD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,aAAa,EAAE,aAAa,GAC3B,IAAI,CA6GN"}
1
+ {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,aAAa,EAEb,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAGnB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,mBAAmB,CAAC,EAAE,OAAO,GAAG,sCAAsC,CAAC;IACvE,eAAe,CAAC,EAAE,OAAO,GAAG,kCAAkC,CAAC;CAChE;AACD,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kCAAmC,SAAQ,sBAAsB;IAChF;;OAEG;IACH,YAAY,CAAC,EAAE,8BAA8B,EAAE,CAAC;CACjD;AAsBD;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,aAAa,EAAE,aAAa,GAC3B,IAAI,CA6GN"}
@@ -1,175 +1,7 @@
1
- import { __assign, __read, __spreadArray, __values } from "tslib";
2
- import { SAFE_HEADERS, safeJsonStringify, } from '@amplitude/analytics-core';
3
- /**
4
- * Performs a deep transformation of a remote config object so that
5
- * it matches the expected schema of the local config.
6
- *
7
- * Specifically, it normalizes nested `enabled` flags into concise union types.
8
- *
9
- * ### Transformation Rules:
10
- * - If an object has `enabled: true`, it is replaced by the same object without the `enabled` field.
11
- * - If it has only `enabled: true`, it is replaced with `true`.
12
- * - If it has `enabled: false`, it is replaced with `false` regardless of other fields.
13
- *
14
- * ### Examples:
15
- * Input: { prop: { enabled: true, hello: 'world' }}
16
- * Output: { prop: { hello: 'world' } }
17
- *
18
- * Input: { prop: { enabled: true }}
19
- * Output: { prop: true }
20
- *
21
- * Input: { prop: { enabled: false, hello: 'world' }}
22
- * Output: { prop: false }
23
- *
24
- * Input: { prop: { hello: 'world' }}
25
- * Output: { prop: { hello: 'world' } } // No change
26
- *
27
- * @param config Remote config object to be transformed
28
- * @returns Transformed config object compatible with local schema
29
- */
30
- export function translateRemoteConfigToLocal(config) {
31
- var e_1, _a, e_2, _b, e_3, _c;
32
- var _d, _e, _f, _g, _h, _j;
33
- // Disabling type checking rules because remote config comes from a remote source
34
- // and this function needs to handle any unexpected values
35
- /* eslint-disable @typescript-eslint/no-unsafe-member-access,
36
- @typescript-eslint/no-unsafe-assignment,
37
- @typescript-eslint/no-unsafe-argument
38
- */
39
- if (typeof config !== 'object' || config === null) {
40
- return;
41
- }
42
- // translations are not applied on array properties
43
- if (Array.isArray(config)) {
44
- return;
45
- }
46
- var propertyNames = Object.keys(config);
47
- try {
48
- for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
49
- var propertyName = propertyNames_1_1.value;
50
- try {
51
- var value = config[propertyName];
52
- // transform objects with { enabled } property to boolean | object
53
- if (typeof (value === null || value === void 0 ? void 0 : value.enabled) === 'boolean') {
54
- if (value.enabled) {
55
- // if enabled is true, set the value to the rest of the object
56
- // or true if the object has no other properties
57
- delete value.enabled;
58
- if (Object.keys(value).length === 0) {
59
- config[propertyName] = true;
60
- }
61
- }
62
- else {
63
- // If enabled is false, set the value to false
64
- config[propertyName] = false;
65
- }
66
- }
67
- // recursively translate properties of the value
68
- translateRemoteConfigToLocal(value);
69
- }
70
- catch (e) {
71
- // a failure here means that an accessor threw an error
72
- // so don't translate it
73
- // TODO(diagnostics): add a diagnostic event for this
74
- }
75
- }
76
- }
77
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
78
- finally {
79
- try {
80
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
81
- }
82
- finally { if (e_1) throw e_1.error; }
83
- }
84
- // translate remote responseHeaders and requestHeaders to local responseHeaders and requestHeaders
85
- try {
86
- if ((_f = (_e = (_d = config.autocapture) === null || _d === void 0 ? void 0 : _d.networkTracking) === null || _e === void 0 ? void 0 : _e.captureRules) === null || _f === void 0 ? void 0 : _f.length) {
87
- try {
88
- for (var _k = __values(config.autocapture.networkTracking.captureRules), _l = _k.next(); !_l.done; _l = _k.next()) {
89
- var rule = _l.value;
90
- try {
91
- for (var _m = (e_3 = void 0, __values(['responseHeaders', 'requestHeaders'])), _o = _m.next(); !_o.done; _o = _m.next()) {
92
- var header = _o.value;
93
- var _p = (_g = rule[header]) !== null && _g !== void 0 ? _g : {}, captureSafeHeaders = _p.captureSafeHeaders, allowlist = _p.allowlist;
94
- if (!captureSafeHeaders && !allowlist) {
95
- continue;
96
- }
97
- // if allowlist is not an array, remote config contract is violated, remove it
98
- if (allowlist !== undefined && !Array.isArray(allowlist)) {
99
- delete rule[header];
100
- continue;
101
- }
102
- rule[header] = __spreadArray(__spreadArray([], __read((captureSafeHeaders ? SAFE_HEADERS : [])), false), __read((allowlist !== null && allowlist !== void 0 ? allowlist : [])), false);
103
- }
104
- }
105
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
106
- finally {
107
- try {
108
- if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
109
- }
110
- finally { if (e_3) throw e_3.error; }
111
- }
112
- }
113
- }
114
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
115
- finally {
116
- try {
117
- if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
118
- }
119
- finally { if (e_2) throw e_2.error; }
120
- }
121
- }
122
- }
123
- catch (e) {
124
- /* istanbul ignore next */
125
- // surprise exception, so don't translate it
126
- }
127
- // translate frustrationInteractions pluralization
128
- var frustrationInteractions = (_h = config.autocapture) === null || _h === void 0 ? void 0 : _h.frustrationInteractions;
129
- if (frustrationInteractions) {
130
- if (frustrationInteractions.rageClick) {
131
- frustrationInteractions.rageClicks = frustrationInteractions.rageClick;
132
- delete frustrationInteractions.rageClick;
133
- }
134
- if (frustrationInteractions.deadClick) {
135
- frustrationInteractions.deadClicks = frustrationInteractions.deadClick;
136
- delete frustrationInteractions.deadClick;
137
- }
138
- }
139
- // normalize viewportContentUpdated inside elementInteractions
140
- try {
141
- var elementInteractions = (_j = config.autocapture) === null || _j === void 0 ? void 0 : _j.elementInteractions;
142
- if (elementInteractions && typeof elementInteractions === 'object') {
143
- // { enabled: true } (no other fields) collapses to `true`; convert back to {} for the SDK.
144
- if (elementInteractions.viewportContentUpdated === true) {
145
- elementInteractions.viewportContentUpdated = {};
146
- }
147
- // { enabled: false, ... } collapses to `false`; convert back to { enabled: false } for the SDK.
148
- if (elementInteractions.viewportContentUpdated === false) {
149
- elementInteractions.viewportContentUpdated = { enabled: false };
150
- }
151
- // Migrate deprecated top-level exposureDuration to viewportContentUpdated.exposureDuration
152
- if (elementInteractions.exposureDuration !== undefined) {
153
- var viewportContentUpdated = elementInteractions.viewportContentUpdated;
154
- if (viewportContentUpdated === undefined) {
155
- elementInteractions.viewportContentUpdated = { exposureDuration: elementInteractions.exposureDuration };
156
- }
157
- else if (typeof viewportContentUpdated === 'object' &&
158
- viewportContentUpdated.exposureDuration === undefined &&
159
- viewportContentUpdated.enabled !== false) {
160
- viewportContentUpdated.exposureDuration = elementInteractions.exposureDuration;
161
- }
162
- delete elementInteractions.exposureDuration;
163
- }
164
- }
165
- }
166
- catch (e) {
167
- /* istanbul ignore next */
168
- // surprise exception, so don't translate it
169
- }
170
- }
1
+ import { __assign, __values } from "tslib";
2
+ import { safeJsonStringify, translateRemoteConfigToLocal, } from '@amplitude/analytics-core';
171
3
  function mergeUrls(urlsExact, urlsRegex, browserConfig) {
172
- var e_4, _a;
4
+ var e_1, _a;
173
5
  // Convert string patterns to RegExp objects, warn on invalid patterns and skip them
174
6
  var regexList = [];
175
7
  try {
@@ -183,12 +15,12 @@ function mergeUrls(urlsExact, urlsRegex, browserConfig) {
183
15
  }
184
16
  }
185
17
  }
186
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
18
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
187
19
  finally {
188
20
  try {
189
21
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
190
22
  }
191
- finally { if (e_4) throw e_4.error; }
23
+ finally { if (e_1) throw e_1.error; }
192
24
  }
193
25
  return urlsExact.concat(regexList);
194
26
  }
@@ -200,7 +32,7 @@ function mergeUrls(urlsExact, urlsRegex, browserConfig) {
200
32
  * @param browserConfig - The browser config object to update (modified in place)
201
33
  */
202
34
  export function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig) {
203
- var e_5, _a;
35
+ var e_2, _a;
204
36
  var _b, _c, _d, _e, _f;
205
37
  if (!remoteConfig) {
206
38
  return;
@@ -252,12 +84,12 @@ export function updateBrowserConfigWithRemoteConfig(remoteConfig, browserConfig)
252
84
  delete rule.urlsRegex;
253
85
  }
254
86
  }
255
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
87
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
256
88
  finally {
257
89
  try {
258
90
  if (captureRules_1_1 && !captureRules_1_1.done && (_a = captureRules_1.return)) _a.call(captureRules_1);
259
91
  }
260
- finally { if (e_5) throw e_5.error; }
92
+ finally { if (e_2) throw e_2.error; }
261
93
  }
262
94
  }
263
95
  if (typeof browserConfig.autocapture === 'boolean') {