@amplitude/analytics-browser 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/config/joined-config.d.ts +11 -2
  3. package/lib/cjs/config/joined-config.d.ts.map +1 -1
  4. package/lib/cjs/config/joined-config.js +48 -17
  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 +11 -2
  11. package/lib/esm/config/joined-config.d.ts.map +1 -1
  12. package/lib/esm/config/joined-config.js +50 -19
  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 +11 -2
  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 +5 -5
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._q.push({name:t,args:Array.prototype.slice.call(r,0)})},i=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};o(e,t,Array.prototype.slice.call(arguments))}},c=function(e){for(var t=0;t<g.length;t++)i(e,g[t],!1);for(var r=0;r<m.length;r++)i(e,m[r],!0)};r.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-R6xB8AP011xAi0Ojyms3sF5AoJ1EF5G9neUccNc+YhbF7V20u0f84sqJ1U2zAZf9",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/analytics-browser-2.15.0-min.js.gz",a.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(a,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 f=function(){return this._q=[],this},v=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],y=0;y<v.length;y++)n(f,v[y]);r.Revenue=f;var g=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],m=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];c(r),r.createInstance=function(e){return r._iq[e]={_q:[]},c(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})}},i=function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};i(e,t,Array.prototype.slice.call(arguments))}},c=function(e){for(var t=0;t<g.length;t++)o(e,g[t],!1);for(var r=0;r<m.length;r++)o(e,m[r],!0)};r.invoked=!0;var a=t.createElement("script");a.type="text/javascript",a.integrity="sha384-F/rGJX6HCLcJeAnU/vPbEznBI51fwo2iiXwQphdQ3ryIalw2uByx53Bi7OIwJdvJ",a.crossOrigin="anonymous",a.async=!0,a.src="https://cdn.amplitude.com/libs/analytics-browser-2.16.0-min.js.gz",a.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(a,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 f=function(){return this._q=[],this},v=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setReceipt","setReceiptSig","setCurrency","setEventProperties"],y=0;y<v.length;y++)n(f,v[y]);r.Revenue=f;var g=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],m=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];c(r),r.createInstance=function(e){return r._iq[e]={_q:[]},c(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
57
57
 
58
58
  amplitude.init("<YOUR_API_KEY>");
59
59
  </script>
@@ -1,8 +1,17 @@
1
1
  import { RemoteConfigFetch } from '@amplitude/analytics-remote-config';
2
- import { BrowserConfig as IBrowserConfig, AutocaptureOptions } from '@amplitude/analytics-core';
2
+ import { BrowserConfig as IBrowserConfig, AutocaptureOptions, type ElementInteractionsOptions } from '@amplitude/analytics-core';
3
+ export interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {
4
+ elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;
5
+ }
6
+ export interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {
7
+ /**
8
+ * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist
9
+ */
10
+ pageUrlAllowlistRegex?: string[];
11
+ }
3
12
  export type BrowserRemoteConfig = {
4
13
  browserSDK: {
5
- autocapture?: AutocaptureOptions | boolean;
14
+ autocapture?: AutocaptureOptionsRemoteConfig | boolean;
6
15
  };
7
16
  };
8
17
  export declare class BrowserJoinedConfigGenerator {
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAmB,aAAa,IAAI,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjH,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE;QACV,WAAW,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC;KAC5C,CAAC;CACH,CAAC;AAEF,qBAAa,4BAA4B;IAGvC,MAAM,EAAE,cAAc,CAAC;IACvB,iBAAiB,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;gBAE1D,WAAW,EAAE,cAAc;IAQjC,UAAU;IAOV,oBAAoB,IAAI,OAAO,CAAC,cAAc,CAAC;CAgEtD;AAED,eAAO,MAAM,kCAAkC,gBAAuB,cAAc,0CAInF,CAAC"}
1
+ {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAEL,aAAa,IAAI,cAAc,EAC/B,kBAAkB,EAClB,KAAK,0BAA0B,EAChC,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,mBAAmB,CAAC,EAAE,OAAO,GAAG,sCAAsC,CAAC;CACxE;AACD,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE;QACV,WAAW,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC;KACxD,CAAC;CACH,CAAC;AAEF,qBAAa,4BAA4B;IAGvC,MAAM,EAAE,cAAc,CAAC;IACvB,iBAAiB,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;gBAE1D,WAAW,EAAE,cAAc;IAQjC,UAAU;IAOV,oBAAoB,IAAI,OAAO,CAAC,cAAc,CAAC;CA6FtD;AAED,eAAO,MAAM,kCAAkC,gBAAuB,cAAc,0CAInF,CAAC"}
@@ -28,22 +28,23 @@ var BrowserJoinedConfigGenerator = /** @class */ (function () {
28
28
  });
29
29
  };
30
30
  BrowserJoinedConfigGenerator.prototype.generateJoinedConfig = function () {
31
- var _a, _b, _c;
32
- var _d;
31
+ var _a, _b, _c, _d, _e;
32
+ var _f;
33
33
  return tslib_1.__awaiter(this, void 0, void 0, function () {
34
- var remoteConfig, _e, e_1;
35
- return tslib_1.__generator(this, function (_f) {
36
- switch (_f.label) {
34
+ var remoteConfig, _g, transformedAutocaptureRemoteConfig, transformedRcElementInteractions, exactAllowList, regexList, _h, _j, pattern, combinedPageUrlAllowlist, e_1;
35
+ var e_2, _k;
36
+ return tslib_1.__generator(this, function (_l) {
37
+ switch (_l.label) {
37
38
  case 0:
38
- _f.trys.push([0, 3, , 4]);
39
- _e = this.remoteConfigFetch;
40
- if (!_e) return [3 /*break*/, 2];
39
+ _l.trys.push([0, 3, , 4]);
40
+ _g = this.remoteConfigFetch;
41
+ if (!_g) return [3 /*break*/, 2];
41
42
  return [4 /*yield*/, this.remoteConfigFetch.getRemoteConfig('analyticsSDK', 'browserSDK', this.config.sessionId)];
42
43
  case 1:
43
- _e = (_f.sent());
44
- _f.label = 2;
44
+ _g = (_l.sent());
45
+ _l.label = 2;
45
46
  case 2:
46
- remoteConfig = _e;
47
+ remoteConfig = _g;
47
48
  this.config.loggerProvider.debug('Remote configuration:', JSON.stringify(remoteConfig, null, 2));
48
49
  // merge remoteConfig.autocapture and this.config.autocapture
49
50
  // if a field is in remoteConfig.autocapture, use that value
@@ -53,30 +54,60 @@ var BrowserJoinedConfigGenerator = /** @class */ (function () {
53
54
  this.config.autocapture = remoteConfig.autocapture;
54
55
  }
55
56
  if (typeof remoteConfig.autocapture === 'object') {
57
+ transformedAutocaptureRemoteConfig = tslib_1.__assign({}, remoteConfig.autocapture);
56
58
  if (this.config.autocapture === undefined) {
57
59
  this.config.autocapture = remoteConfig.autocapture;
58
60
  }
61
+ // Handle Element Interactions config initialization
62
+ if (typeof remoteConfig.autocapture.elementInteractions === 'object' &&
63
+ ((_a = remoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex) === null || _a === void 0 ? void 0 : _a.length)) {
64
+ transformedAutocaptureRemoteConfig.elementInteractions = tslib_1.__assign({}, remoteConfig.autocapture.elementInteractions);
65
+ transformedRcElementInteractions = transformedAutocaptureRemoteConfig.elementInteractions;
66
+ exactAllowList = (_b = transformedRcElementInteractions.pageUrlAllowlist) !== null && _b !== void 0 ? _b : [];
67
+ regexList = [];
68
+ try {
69
+ for (_h = tslib_1.__values(remoteConfig.autocapture.elementInteractions.pageUrlAllowlistRegex), _j = _h.next(); !_j.done; _j = _h.next()) {
70
+ pattern = _j.value;
71
+ try {
72
+ regexList.push(new RegExp(pattern));
73
+ }
74
+ catch (regexError) {
75
+ this.config.loggerProvider.warn("Invalid regex pattern: ".concat(pattern), regexError);
76
+ }
77
+ }
78
+ }
79
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
80
+ finally {
81
+ try {
82
+ if (_j && !_j.done && (_k = _h.return)) _k.call(_h);
83
+ }
84
+ finally { if (e_2) throw e_2.error; }
85
+ }
86
+ combinedPageUrlAllowlist = exactAllowList.concat(regexList);
87
+ transformedRcElementInteractions.pageUrlAllowlist = combinedPageUrlAllowlist;
88
+ delete transformedRcElementInteractions.pageUrlAllowlistRegex;
89
+ }
59
90
  if (typeof this.config.autocapture === 'boolean') {
60
- this.config.autocapture = tslib_1.__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 }, remoteConfig.autocapture);
91
+ this.config.autocapture = tslib_1.__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 }, transformedAutocaptureRemoteConfig);
61
92
  }
62
93
  if (typeof this.config.autocapture === 'object') {
63
- this.config.autocapture = tslib_1.__assign(tslib_1.__assign({}, this.config.autocapture), remoteConfig.autocapture);
94
+ this.config.autocapture = tslib_1.__assign(tslib_1.__assign({}, this.config.autocapture), transformedAutocaptureRemoteConfig);
64
95
  }
65
96
  }
66
97
  // Override default tracking options if autocapture is updated by remote config
67
98
  this.config.defaultTracking = this.config.autocapture;
68
99
  }
69
100
  this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));
70
- (_a = (_d = this.config).requestMetadata) !== null && _a !== void 0 ? _a : (_d.requestMetadata = new analytics_core_1.RequestMetadata());
71
- if ((_b = this.remoteConfigFetch) === null || _b === void 0 ? void 0 : _b.metrics.fetchTimeAPISuccess) {
101
+ (_c = (_f = this.config).requestMetadata) !== null && _c !== void 0 ? _c : (_f.requestMetadata = new analytics_core_1.RequestMetadata());
102
+ if ((_d = this.remoteConfigFetch) === null || _d === void 0 ? void 0 : _d.metrics.fetchTimeAPISuccess) {
72
103
  this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_success', this.remoteConfigFetch.metrics.fetchTimeAPISuccess);
73
104
  }
74
- if ((_c = this.remoteConfigFetch) === null || _c === void 0 ? void 0 : _c.metrics.fetchTimeAPIFail) {
105
+ if ((_e = this.remoteConfigFetch) === null || _e === void 0 ? void 0 : _e.metrics.fetchTimeAPIFail) {
75
106
  this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_fail', this.remoteConfigFetch.metrics.fetchTimeAPIFail);
76
107
  }
77
108
  return [3 /*break*/, 4];
78
109
  case 3:
79
- e_1 = _f.sent();
110
+ e_1 = _l.sent();
80
111
  this.config.loggerProvider.error('Failed to fetch remote configuration because of error: ', e_1);
81
112
  return [3 /*break*/, 4];
82
113
  case 4: return [2 /*return*/, this.config];
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.js","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":";;;;AAAA,8EAAgG;AAChG,4DAAiH;AAQjH;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,IAAA,iDAAuB,EAAsB;gCAC1E,WAAW,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sBAAO,IAAI,CAAC,MAAM,EAAC;;;;KACpB;IACH,mCAAC;AAAD,CAAC,AArFD,IAqFC;AArFY,oEAA4B;AAuFlC,IAAM,kCAAkC,GAAG,UAAO,WAA2B;;;;;gBAC5E,qBAAqB,GAAG,IAAI,4BAA4B,CAAC,WAAW,CAAC,CAAC;gBAC5E,qBAAM,qBAAqB,CAAC,UAAU,EAAE,EAAA;;gBAAxC,SAAwC,CAAC;gBACzC,sBAAO,qBAAqB,EAAC;;;KAC9B,CAAC;AAJW,QAAA,kCAAkC,sCAI7C","sourcesContent":["import { createRemoteConfigFetch, RemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { RequestMetadata, BrowserConfig as IBrowserConfig, AutocaptureOptions } from '@amplitude/analytics-core';\n\nexport type BrowserRemoteConfig = {\n browserSDK: {\n autocapture?: AutocaptureOptions | 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 if (this.config.autocapture === undefined) {\n this.config.autocapture = remoteConfig.autocapture;\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 ...remoteConfig.autocapture,\n };\n }\n\n if (typeof this.config.autocapture === 'object') {\n this.config.autocapture = {\n ...this.config.autocapture,\n ...remoteConfig.autocapture,\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":";;;;AAAA,8EAAgG;AAChG,4DAKmC;AAkBnC;IAME,sCAAY,WAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,cAA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AD,CAAC,AAlHD,IAkHC;AAlHY,oEAA4B;AAoHlC,IAAM,kCAAkC,GAAG,UAAO,WAA2B;;;;;gBAC5E,qBAAqB,GAAG,IAAI,4BAA4B,CAAC,WAAW,CAAC,CAAC;gBAC5E,qBAAM,qBAAqB,CAAC,UAAU,EAAE,EAAA;;gBAAxC,SAAwC,CAAC;gBACzC,sBAAO,qBAAqB,EAAC;;;KAC9B,CAAC;AAJW,QAAA,kCAAkC,sCAI7C","sourcesContent":["import { createRemoteConfigFetch, RemoteConfigFetch } 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 ...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"]}
@@ -30,7 +30,7 @@ export declare class BrowserConfig extends Config implements IBrowserConfig {
30
30
  transport: 'fetch' | 'xhr' | 'beacon';
31
31
  useBatch: boolean;
32
32
  fetchRemoteConfig: boolean;
33
- readonly version = "2.15.0";
33
+ readonly version = "2.16.0";
34
34
  protected _cookieStorage: Storage<UserSession>;
35
35
  protected _deviceId?: string;
36
36
  protected _lastEventId?: number;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.15.0";
1
+ export declare const VERSION = "2.16.0";
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.15.0';
4
+ exports.VERSION = '2.16.0';
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.15.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.16.0';\n"]}
@@ -1,8 +1,17 @@
1
1
  import { RemoteConfigFetch } from '@amplitude/analytics-remote-config';
2
- import { BrowserConfig as IBrowserConfig, AutocaptureOptions } from '@amplitude/analytics-core';
2
+ import { BrowserConfig as IBrowserConfig, AutocaptureOptions, type ElementInteractionsOptions } from '@amplitude/analytics-core';
3
+ export interface AutocaptureOptionsRemoteConfig extends AutocaptureOptions {
4
+ elementInteractions?: boolean | ElementInteractionsOptionsRemoteConfig;
5
+ }
6
+ export interface ElementInteractionsOptionsRemoteConfig extends ElementInteractionsOptions {
7
+ /**
8
+ * Related to pageUrlAllowlist but holds regex strings which will be initialized and appended to pageUrlAllowlist
9
+ */
10
+ pageUrlAllowlistRegex?: string[];
11
+ }
3
12
  export type BrowserRemoteConfig = {
4
13
  browserSDK: {
5
- autocapture?: AutocaptureOptions | boolean;
14
+ autocapture?: AutocaptureOptionsRemoteConfig | boolean;
6
15
  };
7
16
  };
8
17
  export declare class BrowserJoinedConfigGenerator {
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAmB,aAAa,IAAI,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjH,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE;QACV,WAAW,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC;KAC5C,CAAC;CACH,CAAC;AAEF,qBAAa,4BAA4B;IAGvC,MAAM,EAAE,cAAc,CAAC;IACvB,iBAAiB,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;gBAE1D,WAAW,EAAE,cAAc;IAQjC,UAAU;IAOV,oBAAoB,IAAI,OAAO,CAAC,cAAc,CAAC;CAgEtD;AAED,eAAO,MAAM,kCAAkC,gBAAuB,cAAc,0CAInF,CAAC"}
1
+ {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAEL,aAAa,IAAI,cAAc,EAC/B,kBAAkB,EAClB,KAAK,0BAA0B,EAChC,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,8BAA+B,SAAQ,kBAAkB;IACxE,mBAAmB,CAAC,EAAE,OAAO,GAAG,sCAAsC,CAAC;CACxE;AACD,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE;QACV,WAAW,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC;KACxD,CAAC;CACH,CAAC;AAEF,qBAAa,4BAA4B;IAGvC,MAAM,EAAE,cAAc,CAAC;IACvB,iBAAiB,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;gBAE1D,WAAW,EAAE,cAAc;IAQjC,UAAU;IAOV,oBAAoB,IAAI,OAAO,CAAC,cAAc,CAAC;CA6FtD;AAED,eAAO,MAAM,kCAAkC,gBAAuB,cAAc,0CAInF,CAAC"}
@@ -1,6 +1,6 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
1
+ import { __assign, __awaiter, __generator, __values } from "tslib";
2
2
  import { createRemoteConfigFetch } from '@amplitude/analytics-remote-config';
3
- import { RequestMetadata } from '@amplitude/analytics-core';
3
+ import { RequestMetadata, } from '@amplitude/analytics-core';
4
4
  var BrowserJoinedConfigGenerator = /** @class */ (function () {
5
5
  function BrowserJoinedConfigGenerator(localConfig) {
6
6
  this.config = localConfig;
@@ -25,22 +25,23 @@ var BrowserJoinedConfigGenerator = /** @class */ (function () {
25
25
  });
26
26
  };
27
27
  BrowserJoinedConfigGenerator.prototype.generateJoinedConfig = function () {
28
- var _a, _b, _c;
29
- var _d;
28
+ var _a, _b, _c, _d, _e;
29
+ var _f;
30
30
  return __awaiter(this, void 0, void 0, function () {
31
- var remoteConfig, _e, e_1;
32
- return __generator(this, function (_f) {
33
- switch (_f.label) {
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) {
34
35
  case 0:
35
- _f.trys.push([0, 3, , 4]);
36
- _e = this.remoteConfigFetch;
37
- if (!_e) return [3 /*break*/, 2];
36
+ _l.trys.push([0, 3, , 4]);
37
+ _g = this.remoteConfigFetch;
38
+ if (!_g) return [3 /*break*/, 2];
38
39
  return [4 /*yield*/, this.remoteConfigFetch.getRemoteConfig('analyticsSDK', 'browserSDK', this.config.sessionId)];
39
40
  case 1:
40
- _e = (_f.sent());
41
- _f.label = 2;
41
+ _g = (_l.sent());
42
+ _l.label = 2;
42
43
  case 2:
43
- remoteConfig = _e;
44
+ remoteConfig = _g;
44
45
  this.config.loggerProvider.debug('Remote configuration:', JSON.stringify(remoteConfig, null, 2));
45
46
  // merge remoteConfig.autocapture and this.config.autocapture
46
47
  // if a field is in remoteConfig.autocapture, use that value
@@ -50,30 +51,60 @@ var BrowserJoinedConfigGenerator = /** @class */ (function () {
50
51
  this.config.autocapture = remoteConfig.autocapture;
51
52
  }
52
53
  if (typeof remoteConfig.autocapture === 'object') {
54
+ transformedAutocaptureRemoteConfig = __assign({}, remoteConfig.autocapture);
53
55
  if (this.config.autocapture === undefined) {
54
56
  this.config.autocapture = remoteConfig.autocapture;
55
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
+ }
56
87
  if (typeof this.config.autocapture === 'boolean') {
57
- 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 }, remoteConfig.autocapture);
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 }, transformedAutocaptureRemoteConfig);
58
89
  }
59
90
  if (typeof this.config.autocapture === 'object') {
60
- this.config.autocapture = __assign(__assign({}, this.config.autocapture), remoteConfig.autocapture);
91
+ this.config.autocapture = __assign(__assign({}, this.config.autocapture), transformedAutocaptureRemoteConfig);
61
92
  }
62
93
  }
63
94
  // Override default tracking options if autocapture is updated by remote config
64
95
  this.config.defaultTracking = this.config.autocapture;
65
96
  }
66
97
  this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));
67
- (_a = (_d = this.config).requestMetadata) !== null && _a !== void 0 ? _a : (_d.requestMetadata = new RequestMetadata());
68
- if ((_b = this.remoteConfigFetch) === null || _b === void 0 ? void 0 : _b.metrics.fetchTimeAPISuccess) {
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) {
69
100
  this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_success', this.remoteConfigFetch.metrics.fetchTimeAPISuccess);
70
101
  }
71
- if ((_c = this.remoteConfigFetch) === null || _c === void 0 ? void 0 : _c.metrics.fetchTimeAPIFail) {
102
+ if ((_e = this.remoteConfigFetch) === null || _e === void 0 ? void 0 : _e.metrics.fetchTimeAPIFail) {
72
103
  this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_fail', this.remoteConfigFetch.metrics.fetchTimeAPIFail);
73
104
  }
74
105
  return [3 /*break*/, 4];
75
106
  case 3:
76
- e_1 = _f.sent();
107
+ e_1 = _l.sent();
77
108
  this.config.loggerProvider.error('Failed to fetch remote configuration because of error: ', e_1);
78
109
  return [3 /*break*/, 4];
79
110
  case 4: return [2 /*return*/, this.config];
@@ -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,EAAE,eAAe,EAAuD,MAAM,2BAA2B,CA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mBAAmB,CACnD,CAAC;yBACH;wBACD,IAAI,MAAA,IAAI,CAAC,iBAAiB,0CAAE,OAAO,CAAC,gBAAgB,EAAE;4BACpD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,eAAe,CACzC,mCAAmC,EACnC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,gBAAgB,CAChD,CAAC;yBACH;;;;wBAED,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,GAAC,CAAC,CAAC;;4BAGjG,sBAAO,IAAI,CAAC,MAAM,EAAC;;;;KACpB;IACH,mCAAC;AAAD,CAAC,AArFD,IAqFC;;AAED,MAAM,CAAC,IAAM,kCAAkC,GAAG,UAAO,WAA2B;;;;;gBAC5E,qBAAqB,GAAG,IAAI,4BAA4B,CAAC,WAAW,CAAC,CAAC;gBAC5E,qBAAM,qBAAqB,CAAC,UAAU,EAAE,EAAA;;gBAAxC,SAAwC,CAAC;gBACzC,sBAAO,qBAAqB,EAAC;;;KAC9B,CAAC","sourcesContent":["import { createRemoteConfigFetch, RemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { RequestMetadata, BrowserConfig as IBrowserConfig, AutocaptureOptions } from '@amplitude/analytics-core';\n\nexport type BrowserRemoteConfig = {\n browserSDK: {\n autocapture?: AutocaptureOptions | 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 if (this.config.autocapture === undefined) {\n this.config.autocapture = remoteConfig.autocapture;\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 ...remoteConfig.autocapture,\n };\n }\n\n if (typeof this.config.autocapture === 'object') {\n this.config.autocapture = {\n ...this.config.autocapture,\n ...remoteConfig.autocapture,\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":";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,GAA1B;;;;;;;;;;wBAGM,KAAA,IAAI,CAAC,iBAAiB,CAAA;iCAAtB,wBAAsB;wBACrB,qBAAM,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAA;;wBAAlG,KAAA,CAAC,SAAiG,CAAC,CAAA;;;wBAF/F,YAAY,KAEmF;wBACrG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;wBAEjG,6DAA6D;wBAC7D,4DAA4D;wBAC5D,4FAA4F;wBAC5F,IAAI,YAAY,IAAI,aAAa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wBACD,IAAI,MAAA,IAAI,CAAC,iBAAiB,0CAAE,OAAO,CAAC,gBAAgB,EAAE;4BACpD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,eAAe,CACzC,mCAAmC,EACnC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,gBAAgB,CAChD,CAAC;yBACH;;;;wBAED,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,GAAC,CAAC,CAAC;;4BAGjG,sBAAO,IAAI,CAAC,MAAM,EAAC;;;;KACpB;IACH,mCAAC;AAAD,CAAC,AAlHD,IAkHC;;AAED,MAAM,CAAC,IAAM,kCAAkC,GAAG,UAAO,WAA2B;;;;;gBAC5E,qBAAqB,GAAG,IAAI,4BAA4B,CAAC,WAAW,CAAC,CAAC;gBAC5E,qBAAM,qBAAqB,CAAC,UAAU,EAAE,EAAA;;gBAAxC,SAAwC,CAAC;gBACzC,sBAAO,qBAAqB,EAAC;;;KAC9B,CAAC","sourcesContent":["import { createRemoteConfigFetch, RemoteConfigFetch } 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 ...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"]}
@@ -30,7 +30,7 @@ export declare class BrowserConfig extends Config implements IBrowserConfig {
30
30
  transport: 'fetch' | 'xhr' | 'beacon';
31
31
  useBatch: boolean;
32
32
  fetchRemoteConfig: boolean;
33
- readonly version = "2.15.0";
33
+ readonly version = "2.16.0";
34
34
  protected _cookieStorage: Storage<UserSession>;
35
35
  protected _deviceId?: string;
36
36
  protected _lastEventId?: number;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.15.0";
1
+ export declare const VERSION = "2.16.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export var VERSION = '2.15.0';
1
+ export var VERSION = '2.16.0';
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.15.0';\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.16.0';\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-R6xB8AP011xAi0Ojyms3sF5AoJ1EF5G9neUccNc+YhbF7V20u0f84sqJ1U2zAZf9",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.15.0-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-F/rGJX6HCLcJeAnU/vPbEznBI51fwo2iiXwQphdQ3ryIalw2uByx53Bi7OIwJdvJ",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.16.0-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-R6xB8AP011xAi0Ojyms3sF5AoJ1EF5G9neUccNc%2BYhbF7V20u0f84sqJ1U2zAZf9%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.15.0-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-F%2FrGJX6HCLcJeAnU%2FvPbEznBI51fwo2iiXwQphdQ3ryIalw2uByx53Bi7OIwJdvJ%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.16.0-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