@amplitude/analytics-browser 2.10.0 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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))}},a=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 c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-8fNco6Xiv+HOa+SIVGKVjByyY5LyircydGlHS9mXcHJpapcgF98L6UNOlauMTxJq",c.crossOrigin="anonymous",c.async=!0,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.10.0-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(c,u);for(var l=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<p.length;d++)n(l,p[d]);r.Identify=l;for(var f=function(){return this._q=[],this},y=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],v=0;v<y.length;v++)n(f,y[v]);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"];a(r),r.createInstance=function(e){return r._iq[e]={_q:[]},a(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._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))}},a=function(e){for(var t=0;t<g.length;t++)i(e,g[t],!1);for(var r=0;r<h.length;r++)i(e,h[r],!0)};r.invoked=!0;var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-XxDPxKDB79eXOLF+koPFe4h9iVF6LgQ1J6Do9sdhcohvTlVMK7EJE74b1b0iK3uK",c.crossOrigin="anonymous",c.async=!0,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.11.1-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(c,u);for(var l=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<p.length;d++)n(l,p[d]);r.Identify=l;for(var f=function(){return this._q=[],this},v=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","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"],h=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];a(r),r.createInstance=function(e){return r._iq[e]={_q:[]},a(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
57
57
 
58
58
  amplitude.init("<YOUR_API_KEY>");
59
59
  </script>
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGhG,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;CAmBtD;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,EAAE,aAAa,IAAI,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGhG,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"}
@@ -28,33 +28,55 @@ var BrowserJoinedConfigGenerator = /** @class */ (function () {
28
28
  });
29
29
  };
30
30
  BrowserJoinedConfigGenerator.prototype.generateJoinedConfig = function () {
31
- var _a, _b;
32
- var _c;
31
+ var _a, _b, _c;
32
+ var _d;
33
33
  return tslib_1.__awaiter(this, void 0, void 0, function () {
34
- var remoteConfig, _d, e_1;
35
- return tslib_1.__generator(this, function (_e) {
36
- switch (_e.label) {
34
+ var remoteConfig, _e, e_1;
35
+ return tslib_1.__generator(this, function (_f) {
36
+ switch (_f.label) {
37
37
  case 0:
38
- _e.trys.push([0, 3, , 4]);
39
- _d = this.remoteConfigFetch;
40
- if (!_d) return [3 /*break*/, 2];
38
+ _f.trys.push([0, 3, , 4]);
39
+ _e = this.remoteConfigFetch;
40
+ if (!_e) return [3 /*break*/, 2];
41
41
  return [4 /*yield*/, this.remoteConfigFetch.getRemoteConfig('analyticsSDK', 'browserSDK', this.config.sessionId)];
42
42
  case 1:
43
- _d = (_e.sent());
44
- _e.label = 2;
43
+ _e = (_f.sent());
44
+ _f.label = 2;
45
45
  case 2:
46
- remoteConfig = _d;
46
+ remoteConfig = _e;
47
47
  this.config.loggerProvider.debug('Remote configuration:', JSON.stringify(remoteConfig, null, 2));
48
+ // merge remoteConfig.autocapture and this.config.autocapture
49
+ // if a field is in remoteConfig.autocapture, use that value
50
+ // if a field is not in remoteConfig.autocapture, use the value from this.config.autocapture
48
51
  if (remoteConfig && 'autocapture' in remoteConfig) {
49
- this.config.autocapture = remoteConfig.autocapture;
52
+ if (typeof remoteConfig.autocapture === 'boolean') {
53
+ this.config.autocapture = remoteConfig.autocapture;
54
+ }
55
+ if (typeof remoteConfig.autocapture === 'object') {
56
+ if (this.config.autocapture === undefined) {
57
+ this.config.autocapture = remoteConfig.autocapture;
58
+ }
59
+ 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);
61
+ }
62
+ if (typeof this.config.autocapture === 'object') {
63
+ this.config.autocapture = tslib_1.__assign(tslib_1.__assign({}, this.config.autocapture), remoteConfig.autocapture);
64
+ }
65
+ }
66
+ // Override default tracking options if autocapture is updated by remote config
50
67
  this.config.defaultTracking = this.config.autocapture;
51
68
  }
52
69
  this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));
53
- (_a = (_c = this.config).requestMetadata) !== null && _a !== void 0 ? _a : (_c.requestMetadata = new analytics_core_1.RequestMetadata());
54
- this.config.requestMetadata.recordHistogram('remote_config_fetch_time', (_b = this.remoteConfigFetch) === null || _b === void 0 ? void 0 : _b.fetchTime);
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) {
72
+ this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_success', this.remoteConfigFetch.metrics.fetchTimeAPISuccess);
73
+ }
74
+ if ((_c = this.remoteConfigFetch) === null || _c === void 0 ? void 0 : _c.metrics.fetchTimeAPIFail) {
75
+ this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_fail', this.remoteConfigFetch.metrics.fetchTimeAPIFail);
76
+ }
55
77
  return [3 /*break*/, 4];
56
78
  case 3:
57
- e_1 = _e.sent();
79
+ e_1 = _f.sent();
58
80
  this.config.loggerProvider.error('Failed to fetch remote configuration because of error: ', e_1);
59
81
  return [3 /*break*/, 4];
60
82
  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,iBAmDA;;;;AAlDA,8EAAgG;AAChG,4DAA4D;AAE5D;IAME,sCAAY,WAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAC9B,uDAAuD,EACvD,IAA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AAe,CAAC,0BAA0B,EAAE,MAAA,IAAI,CAAC,iBAAiB,0CAAE,SAAS,CAAC,CAAC;;;;wBAE3G,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,GAAC,CAAC,CAAC;;4BAGjG,sBAAO,IAAI,CAAC,MAAM,EAAC;;;;KACpB;IACH,mCAAC;AAAD,CAAC,AAxCD,IAwCC;AAxCY,oEAA4B;AA0ClC,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 { BrowserConfig as IBrowserConfig, BrowserRemoteConfig } from '@amplitude/analytics-types';\nimport { createRemoteConfigFetch, RemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { RequestMetadata } from '@amplitude/analytics-core';\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 if (remoteConfig && 'autocapture' in remoteConfig) {\n this.config.autocapture = remoteConfig.autocapture;\n this.config.defaultTracking = this.config.autocapture;\n }\n this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));\n this.config.requestMetadata ??= new RequestMetadata();\n this.config.requestMetadata.recordHistogram('remote_config_fetch_time', this.remoteConfigFetch?.fetchTime);\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,iBAgGA;;;;AA/FA,8EAAgG;AAChG,4DAA4D;AAE5D;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,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;;wBA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ourcesContent":["import { BrowserConfig as IBrowserConfig, BrowserRemoteConfig } from '@amplitude/analytics-types';\nimport { createRemoteConfigFetch, RemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { RequestMetadata } from '@amplitude/analytics-core';\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,2 +1,2 @@
1
- export declare const VERSION = "2.10.0";
1
+ export declare const VERSION = "2.11.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
2
  exports.VERSION = void 0;
3
- exports.VERSION = '2.10.0';
3
+ exports.VERSION = '2.11.1';
4
4
  //# 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.10.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.11.1';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"joined-config.d.ts","sourceRoot":"","sources":["../../../src/config/joined-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGhG,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;CAmBtD;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,EAAE,aAAa,IAAI,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAA2B,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGhG,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,4 +1,4 @@
1
- import { __awaiter, __generator } from "tslib";
1
+ import { __assign, __awaiter, __generator } from "tslib";
2
2
  import { createRemoteConfigFetch } from '@amplitude/analytics-remote-config';
3
3
  import { RequestMetadata } from '@amplitude/analytics-core';
4
4
  var BrowserJoinedConfigGenerator = /** @class */ (function () {
@@ -25,33 +25,55 @@ var BrowserJoinedConfigGenerator = /** @class */ (function () {
25
25
  });
26
26
  };
27
27
  BrowserJoinedConfigGenerator.prototype.generateJoinedConfig = function () {
28
- var _a, _b;
29
- var _c;
28
+ var _a, _b, _c;
29
+ var _d;
30
30
  return __awaiter(this, void 0, void 0, function () {
31
- var remoteConfig, _d, e_1;
32
- return __generator(this, function (_e) {
33
- switch (_e.label) {
31
+ var remoteConfig, _e, e_1;
32
+ return __generator(this, function (_f) {
33
+ switch (_f.label) {
34
34
  case 0:
35
- _e.trys.push([0, 3, , 4]);
36
- _d = this.remoteConfigFetch;
37
- if (!_d) return [3 /*break*/, 2];
35
+ _f.trys.push([0, 3, , 4]);
36
+ _e = this.remoteConfigFetch;
37
+ if (!_e) return [3 /*break*/, 2];
38
38
  return [4 /*yield*/, this.remoteConfigFetch.getRemoteConfig('analyticsSDK', 'browserSDK', this.config.sessionId)];
39
39
  case 1:
40
- _d = (_e.sent());
41
- _e.label = 2;
40
+ _e = (_f.sent());
41
+ _f.label = 2;
42
42
  case 2:
43
- remoteConfig = _d;
43
+ remoteConfig = _e;
44
44
  this.config.loggerProvider.debug('Remote configuration:', JSON.stringify(remoteConfig, null, 2));
45
+ // merge remoteConfig.autocapture and this.config.autocapture
46
+ // if a field is in remoteConfig.autocapture, use that value
47
+ // if a field is not in remoteConfig.autocapture, use the value from this.config.autocapture
45
48
  if (remoteConfig && 'autocapture' in remoteConfig) {
46
- this.config.autocapture = remoteConfig.autocapture;
49
+ if (typeof remoteConfig.autocapture === 'boolean') {
50
+ this.config.autocapture = remoteConfig.autocapture;
51
+ }
52
+ if (typeof remoteConfig.autocapture === 'object') {
53
+ if (this.config.autocapture === undefined) {
54
+ this.config.autocapture = remoteConfig.autocapture;
55
+ }
56
+ 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);
58
+ }
59
+ if (typeof this.config.autocapture === 'object') {
60
+ this.config.autocapture = __assign(__assign({}, this.config.autocapture), remoteConfig.autocapture);
61
+ }
62
+ }
63
+ // Override default tracking options if autocapture is updated by remote config
47
64
  this.config.defaultTracking = this.config.autocapture;
48
65
  }
49
66
  this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));
50
- (_a = (_c = this.config).requestMetadata) !== null && _a !== void 0 ? _a : (_c.requestMetadata = new RequestMetadata());
51
- this.config.requestMetadata.recordHistogram('remote_config_fetch_time', (_b = this.remoteConfigFetch) === null || _b === void 0 ? void 0 : _b.fetchTime);
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) {
69
+ this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_success', this.remoteConfigFetch.metrics.fetchTimeAPISuccess);
70
+ }
71
+ if ((_c = this.remoteConfigFetch) === null || _c === void 0 ? void 0 : _c.metrics.fetchTimeAPIFail) {
72
+ this.config.requestMetadata.recordHistogram('remote_config_fetch_time_API_fail', this.remoteConfigFetch.metrics.fetchTimeAPIFail);
73
+ }
52
74
  return [3 /*break*/, 4];
53
75
  case 3:
54
- e_1 = _e.sent();
76
+ e_1 = _f.sent();
55
77
  this.config.loggerProvider.error('Failed to fetch remote configuration because of error: ', e_1);
56
78
  return [3 /*break*/, 4];
57
79
  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":";AACA,OAAO,EAAE,uBAAuB,EAAqB,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;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,MAA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iBAAiB,0CAAE,SAAS,CAAC,CAAC;;;;wBAE3G,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,yDAAyD,EAAE,GAAC,CAAC,CAAC;;4BAGjG,sBAAO,IAAI,CAAC,MAAM,EAAC;;;;KACpB;IACH,mCAAC;AAAD,CAAC,AAxCD,IAwCC;;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 { BrowserConfig as IBrowserConfig, BrowserRemoteConfig } from '@amplitude/analytics-types';\nimport { createRemoteConfigFetch, RemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { RequestMetadata } from '@amplitude/analytics-core';\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 if (remoteConfig && 'autocapture' in remoteConfig) {\n this.config.autocapture = remoteConfig.autocapture;\n this.config.defaultTracking = this.config.autocapture;\n }\n this.config.loggerProvider.debug('Joined configuration: ', JSON.stringify(this.config, null, 2));\n this.config.requestMetadata ??= new RequestMetadata();\n this.config.requestMetadata.recordHistogram('remote_config_fetch_time', this.remoteConfigFetch?.fetchTime);\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":";AACA,OAAO,EAAE,uBAAuB,EAAqB,MAAM,oCAAoC,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;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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import { createRemoteConfigFetch, RemoteConfigFetch } from '@amplitude/analytics-remote-config';\nimport { RequestMetadata } from '@amplitude/analytics-core';\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,2 +1,2 @@
1
- export declare const VERSION = "2.10.0";
1
+ export declare const VERSION = "2.11.1";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export var VERSION = '2.10.0';
1
+ export var VERSION = '2.11.1';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["export const VERSION = '2.10.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.11.1';\n"]}
@@ -1 +1 @@
1
- !function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},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 a=t.getElementsByTagName("script")[0],u=t.createElement("script");u.src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz",u.async=!1,a.parentNode.insertBefore(u,a);var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-8fNco6Xiv+HOa+SIVGKVjByyY5LyircydGlHS9mXcHJpapcgF98L6UNOlauMTxJq",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.10.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!")},a.parentNode.insertBefore(c,a);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","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
+ !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-XxDPxKDB79eXOLF+koPFe4h9iVF6LgQ1J6Do9sdhcohvTlVMK7EJE74b1b0iK3uK",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.11.1-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK"),e.amplitude.init("YOUR_API_KEY","YOUR_USER_ID",{instanceName:"amplitude-bookmarklet",serverZone:"YOUR_SERVER_ZONE",ingestionMetadata:{sourceName:"browser-typescript-bookmarklet",sourceVersion:"1.0.0"},optOut:!1}),amplitudeAutocapturePlugin&&amplitudeAutocapturePlugin.autocapturePlugin&&"function"==typeof amplitudeAutocapturePlugin.autocapturePlugin&&e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin()),alert("Amplitude is now tracking events!")},u.parentNode.insertBefore(c,u);for(var p=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<l.length;d++)n(p,l[d]);r.Identify=p;for(var m=function(){return this._q=[],this},g=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","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%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%20a%3Dt.getElementsByTagName(%22script%22)%5B0%5D%2Cu%3Dt.createElement(%22script%22)%3Bu.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fplugin-autocapture-browser-0.9.0-min.js.gz%22%2Cu.async%3D!1%2Ca.parentNode.insertBefore(u%2Ca)%3Bvar%20c%3Dt.createElement(%22script%22)%3Bc.type%3D%22text%2Fjavascript%22%2Cc.integrity%3D%22sha384-8fNco6Xiv%2BHOa%2BSIVGKVjByyY5LyircydGlHS9mXcHJpapcgF98L6UNOlauMTxJq%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.10.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%2Ca.parentNode.insertBefore(c%2Ca)%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%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
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-XxDPxKDB79eXOLF%2BkoPFe4h9iVF6LgQ1J6Do9sdhcohvTlVMK7EJE74b1b0iK3uK%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.11.1-min.js.gz%22%2Cc.onload%3Dfunction()%7Be.amplitude.runQueuedFunctions%7C%7Cconsole.log(%22%5BAmplitude%5D%20Error%3A%20could%20not%20load%20SDK%22)%2Ce.amplitude.init(%22YOUR_API_KEY%22%2C%22YOUR_USER_ID%22%2C%7BinstanceName%3A%22amplitude-bookmarklet%22%2CserverZone%3A%22YOUR_SERVER_ZONE%22%2CingestionMetadata%3A%7BsourceName%3A%22browser-typescript-bookmarklet%22%2CsourceVersion%3A%221.0.0%22%7D%2CoptOut%3A!1%7D)%2CamplitudeAutocapturePlugin%26%26amplitudeAutocapturePlugin.autocapturePlugin%26%26%22function%22%3D%3Dtypeof%20amplitudeAutocapturePlugin.autocapturePlugin%26%26e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin())%2Calert(%22Amplitude%20is%20now%20tracking%20events!%22)%7D%2Cu.parentNode.insertBefore(c%2Cu)%3Bfor(var%20p%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cl%3D%5B%22add%22%2C%22append%22%2C%22clearAll%22%2C%22prepend%22%2C%22set%22%2C%22setOnce%22%2C%22unset%22%2C%22preInsert%22%2C%22postInsert%22%2C%22remove%22%2C%22getUserProperties%22%5D%2Cd%3D0%3Bd%3Cl.length%3Bd%2B%2B)n(p%2Cl%5Bd%5D)%3Br.Identify%3Dp%3Bfor(var%20m%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cg%3D%5B%22getEventProperties%22%2C%22setProductId%22%2C%22setQuantity%22%2C%22setPrice%22%2C%22setRevenue%22%2C%22setRevenueType%22%2C%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