@esri/telemetry-amazon 5.1.4 → 6.0.0-beta.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 +24 -7
- package/dist/esm/create-page-view-log.js +1 -1
- package/dist/esm/create-page-view-log.js.map +1 -1
- package/dist/esm/index.js +28 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.test.js +43 -171
- package/dist/esm/index.test.js.map +1 -1
- package/dist/esm/plugins/esri.js +138 -0
- package/dist/esm/plugins/esri.js.map +1 -0
- package/dist/esm/plugins/esri.test.js +94 -0
- package/dist/esm/plugins/esri.test.js.map +1 -0
- package/dist/esm/plugins/pinpoint.js +163 -0
- package/dist/esm/plugins/pinpoint.js.map +1 -0
- package/dist/esm/plugins/shared.js +74 -0
- package/dist/esm/plugins/shared.js.map +1 -0
- package/dist/node/create-page-view-log.js +1 -1
- package/dist/node/create-page-view-log.js.map +1 -1
- package/dist/node/index.js +28 -21
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.test.js +43 -172
- package/dist/node/index.test.js.map +1 -1
- package/dist/node/plugins/esri.js +142 -0
- package/dist/node/plugins/esri.js.map +1 -0
- package/dist/node/plugins/esri.test.js +96 -0
- package/dist/node/plugins/esri.test.js.map +1 -0
- package/dist/node/plugins/pinpoint.js +167 -0
- package/dist/node/plugins/pinpoint.js.map +1 -0
- package/dist/node/plugins/shared.js +82 -0
- package/dist/node/plugins/shared.js.map +1 -0
- package/dist/types/create-page-view-log.d.ts +1 -1
- package/dist/types/index.d.ts +10 -7
- package/dist/types/plugins/esri.d.ts +10 -0
- package/dist/types/plugins/esri.test.d.ts +1 -0
- package/dist/types/plugins/pinpoint.d.ts +11 -0
- package/dist/types/plugins/shared.d.ts +11 -0
- package/dist/types/types.d.ts +14 -9
- package/dist/umd/telemetry-amazon.js +766 -201
- package/dist/umd/telemetry-amazon.js.map +1 -1
- package/dist/umd/telemetry-amazon.min.js +766 -201
- package/dist/umd/telemetry-amazon.min.js.map +1 -1
- package/package.json +3 -4
- package/LICENSE +0 -13
|
@@ -1,111 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisTelemetry = global.arcgisTelemetry || {}
|
|
5
|
-
})(this, (function (exports
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var awsPinpointPlugin__default = /*#__PURE__*/_interopDefaultLegacy(awsPinpointPlugin);
|
|
10
|
-
|
|
11
|
-
const storage = {
|
|
12
|
-
storage: {},
|
|
13
|
-
memory: true,
|
|
14
|
-
get(key) {
|
|
15
|
-
let stored;
|
|
16
|
-
try {
|
|
17
|
-
stored =
|
|
18
|
-
(window.localStorage && window.localStorage.getItem(key)) ||
|
|
19
|
-
this.storage[key];
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
stored = this.storage[key];
|
|
23
|
-
}
|
|
24
|
-
if (stored) {
|
|
25
|
-
try {
|
|
26
|
-
return JSON.parse(stored);
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
set(key, value) {
|
|
37
|
-
// handle Safari private mode (setItem is not allowed)
|
|
38
|
-
const valueToString = JSON.stringify(value);
|
|
39
|
-
try {
|
|
40
|
-
window.localStorage.setItem(key, valueToString);
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
if (!this.memory) {
|
|
44
|
-
console.error('setting local storage failed, falling back to in-memory storage');
|
|
45
|
-
this.memory = true;
|
|
46
|
-
}
|
|
47
|
-
this.storage[key] = value;
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
delete(key) {
|
|
51
|
-
try {
|
|
52
|
-
window.localStorage.removeItem(key);
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
if (!this.memory) {
|
|
56
|
-
console.error('setting local storage failed, falling back to in-memory storage');
|
|
57
|
-
this.memory = true;
|
|
58
|
-
}
|
|
59
|
-
delete this.storage[key];
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const COGNITO_KEY = 'TELEMETRY_COGNITO_CREDENTIALS';
|
|
65
|
-
function getCredentials(IdentityPoolId, options = {}) {
|
|
66
|
-
const fipsSubdomainSuffix = options.fips === true ? '-fips' : '';
|
|
67
|
-
const COGNITO_URL = `https://cognito-identity${fipsSubdomainSuffix}.us-east-1.amazonaws.com/`;
|
|
68
|
-
let cached = storage.get(COGNITO_KEY);
|
|
69
|
-
if (cached && Date.now() / 1000 < cached.Expiration)
|
|
70
|
-
return Promise.resolve(cached);
|
|
71
|
-
const fetchOptions = {
|
|
72
|
-
method: 'POST',
|
|
73
|
-
headers: {
|
|
74
|
-
'Content-type': 'application/x-amz-json-1.1',
|
|
75
|
-
'X-Amz-Target': 'AWSCognitoIdentityService.GetId',
|
|
76
|
-
},
|
|
77
|
-
body: JSON.stringify({ IdentityPoolId }),
|
|
78
|
-
};
|
|
79
|
-
return fetch(COGNITO_URL, fetchOptions)
|
|
80
|
-
.then((response) => {
|
|
81
|
-
if (!response.ok) {
|
|
82
|
-
throw new Error(response.statusText);
|
|
83
|
-
}
|
|
84
|
-
return response.json();
|
|
85
|
-
})
|
|
86
|
-
.then((response) => {
|
|
87
|
-
const { IdentityId } = response;
|
|
88
|
-
const options = {
|
|
89
|
-
method: 'POST',
|
|
90
|
-
headers: {
|
|
91
|
-
'Content-type': 'application/x-amz-json-1.1',
|
|
92
|
-
'X-Amz-Target': 'AWSCognitoIdentityService.GetCredentialsForIdentity',
|
|
93
|
-
},
|
|
94
|
-
body: JSON.stringify({ IdentityId }),
|
|
95
|
-
};
|
|
96
|
-
return fetch(COGNITO_URL, options);
|
|
97
|
-
})
|
|
98
|
-
.then((response) => {
|
|
99
|
-
if (!response.ok) {
|
|
100
|
-
throw new Error(response.statusText);
|
|
101
|
-
}
|
|
102
|
-
return response.json();
|
|
103
|
-
})
|
|
104
|
-
.then(({ Credentials }) => {
|
|
105
|
-
storage.set(COGNITO_KEY, Credentials);
|
|
106
|
-
return Credentials;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisTelemetry = global.arcgisTelemetry || {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
109
6
|
|
|
110
7
|
function formatTelemetryAttributes({ telemetryData, dimensionLookup = {}, excludeKeys = [], }) {
|
|
111
8
|
return Object.keys(telemetryData)
|
|
@@ -209,83 +106,7 @@
|
|
|
209
106
|
const { referrer, title } = document || {};
|
|
210
107
|
const { hostname, pathname } = window && window.location ? window.location : {};
|
|
211
108
|
return Object.assign(Object.assign({ name: 'pageView', referrer,
|
|
212
|
-
hostname, path: page || pathname, pageUrl: page || pathname, pageName: title, previousPageUrl: previousPage.pageUrl, previousPageName: previousPage.pageName }, attributes), metrics);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var dlv_umd = {exports: {}};
|
|
216
|
-
|
|
217
|
-
(function (module, exports) {
|
|
218
|
-
!function(t,n){module.exports=function(t,n,e,i,o){for(n=n.split?n.split("."):n,i=0;i<n.length;i++)t=t?t[n[i]]:o;return t===o?e:t};}();
|
|
219
|
-
|
|
220
|
-
}(dlv_umd));
|
|
221
|
-
|
|
222
|
-
var i$6 = dlv_umd.exports;
|
|
223
|
-
|
|
224
|
-
var n$5="function",t$4="string",e$3="undefined",r$5="boolean",o$5="object",c$5="number",i$5="symbol",a$7="null",S$4="form",j$4="input",A$5="button",E$5="select",P$4=typeof process!==e$3?process:{};P$4.env&&P$4.env.NODE_ENV||"";var $$4=typeof document!==e$3;null!=P$4.versions&&null!=P$4.versions.node;typeof Deno!==e$3&&typeof Deno.core!==e$3;$$4&&"nodejs"===window.name||typeof navigator!==e$3&&typeof navigator.userAgent!==e$3&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$4(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$4=M$4.bind(null,"toUpperCase"),H$4=M$4.bind(null,"toLowerCase");function J$5(n){return Y$4(n)?U$4(a$7):typeof n===o$5?yn$3(n):Object.prototype.toString.call(n).slice(8,-1)}function R$4(n,t){void 0===t&&(t=!0);var e=J$5(n);return t?H$4(e):e}function V$4(n,t){return typeof t===n}var W$4=V$4.bind(null,n$5),q$4=V$4.bind(null,t$4);V$4.bind(null,e$3);V$4.bind(null,r$5);V$4.bind(null,i$5);function Y$4(n){return null===n}function nn$3(n){return R$4(n)===c$5&&!isNaN(n)}function yn$3(n){return W$4(n.constructor)?n.constructor.name:null}function hn$3(n){return n instanceof Error||q$4(n.message)&&n.constructor&&nn$3(n.constructor.stackTraceLimit)}function Sn$3(n,t){if("object"!=typeof t||Y$4(t))return !1;if(t instanceof n)return !0;var e=R$4(new n(""));if(hn$3(t))for(;t;){if(R$4(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn$3.bind(null,TypeError);Sn$3.bind(null,SyntaxError);function $n$3(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$3(n,t):e}function Tn$3(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$3(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$3($n$3,S$4);_n$3($n$3,A$5);_n$3($n$3,j$4);_n$3($n$3,E$5);
|
|
225
|
-
|
|
226
|
-
function n$4(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o$4(){if($$4){var r=navigator,t=r.languages;return r.userLanguage||(t&&t.length?t[0]:r.language)}}function a$6(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){}}function s$1(r){return function(e){for(var r,t=Object.create(null),o=/([^&=]+)=?([^&]*)/g;r=o.exec(e);){var a=n$4(r[1]),i=n$4(r[2]);if(a)if("[]"===a.substring(a.length-2)){var u=t[a=a.substring(0,a.length-2)]||(t[a]=[]);t[a]=Array.isArray(u)?u:[],t[a].push(i);}else t[a]=""===i||i;}for(var c in t){var l=c.split("[");l.length>1&&(m$2(t,l.map(function(e){return e.replace(/[?[\]\\ ]/g,"")}),t[c]),delete t[c]);}return t}(function(r){if(r){var t=r.match(/\?(.*)/);return t&&t[1]?t[1].split("#")[0]:""}return $$4&&window.location.search.substring(1)}(r))}function m$2(e,r,t){for(var n=r.length-1,o=0;o<n;++o){var a=r[o];if("__proto__"===a||"constructor"===a)break;a in e||(e[a]={}),e=e[a];}e[r[n]]=t;}function b$2(){for(var e="",r=0,t=4294967295*Math.random()|0;r++<36;){var n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[r-1],o=15&t;e+="-"==n||"4"==n?n:("x"==n?o:3&o|8).toString(16),t=r%8==0?4294967295*Math.random()|0:t>>4;}return e}
|
|
227
|
-
|
|
228
|
-
var n$3="function",t$3="string",e$2="undefined",r$4="boolean",o$3="object",c$4="number",i$4="symbol",a$5="null",O$3="__",S$3="form",j$3="input",A$4="button",E$4="select",P$3=typeof process!==e$2?process:{};P$3.env&&P$3.env.NODE_ENV||"";var $$3=typeof document!==e$2;null!=P$3.versions&&null!=P$3.versions.node;typeof Deno!==e$2&&typeof Deno.core!==e$2;$$3&&"nodejs"===window.name||typeof navigator!==e$2&&typeof navigator.userAgent!==e$2&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$3(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$3=M$3.bind(null,"toUpperCase"),H$3=M$3.bind(null,"toLowerCase");function J$4(n){return Y$3(n)?U$3(a$5):typeof n===o$3?yn$2(n):Object.prototype.toString.call(n).slice(8,-1)}function R$3(n,t){void 0===t&&(t=!0);var e=J$4(n);return t?H$3(e):e}function V$3(n,t){return typeof t===n}var W$3=V$3.bind(null,n$3),q$3=V$3.bind(null,t$3);V$3.bind(null,e$2);V$3.bind(null,r$4);V$3.bind(null,i$4);function Y$3(n){return null===n}function nn$2(n){return R$3(n)===c$4&&!isNaN(n)}function yn$2(n){return W$3(n.constructor)?n.constructor.name:null}function hn$2(n){return n instanceof Error||q$3(n.message)&&n.constructor&&nn$2(n.constructor.stackTraceLimit)}function Sn$2(n,t){if("object"!=typeof t||Y$3(t))return !1;if(t instanceof n)return !0;var e=R$3(new n(""));if(hn$2(t))for(;t;){if(R$3(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn$2.bind(null,TypeError);Sn$2.bind(null,SyntaxError);function $n$2(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$2(n,t):e}function Tn$2(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$2(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$2($n$2,S$3);_n$2($n$2,A$4);_n$2($n$2,j$3);_n$2($n$2,E$4);
|
|
229
|
-
|
|
230
|
-
var n$2="global",o$2=O$3+n$2+O$3,l$1=typeof self===o$3&&self.self===self&&self||typeof global===o$3&&global[n$2]===global&&global||void 0;function f(t){return l$1[o$2][t]}function a$4(t,e){return l$1[o$2][t]=e}function i$3(t){delete l$1[o$2][t];}function u$2(t,e,r){var n;try{if(s(t)){var o=window[t];n=o[e].bind(o);}}catch(t){}return n||r}l$1[o$2]||(l$1[o$2]={});var c$3={};function s(t){if(typeof c$3[t]!==e$2)return c$3[t];try{var e=window[t];e.setItem(e$2,e$2),e.removeItem(e$2);}catch(e){return c$3[t]=!1}return c$3[t]=!0}
|
|
231
|
-
|
|
232
|
-
var n$1="function",t$2="string",e$1="undefined",r$3="boolean",o$1="object",u$1="array",c$2="number",i$2="symbol",a$3="null",O$2="__",S$2="form",j$2="input",A$3="button",E$3="select",P$2=typeof process!==e$1?process:{};P$2.env&&P$2.env.NODE_ENV||"";var $$2=typeof document!==e$1;null!=P$2.versions&&null!=P$2.versions.node;typeof Deno!==e$1&&typeof Deno.core!==e$1;$$2&&"nodejs"===window.name||typeof navigator!==e$1&&typeof navigator.userAgent!==e$1&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M$2(n,t){return t.charAt(0)[n]()+t.slice(1)}var U$2=M$2.bind(null,"toUpperCase"),H$2=M$2.bind(null,"toLowerCase");function J$3(n){return Y$2(n)?U$2(a$3):typeof n===o$1?yn$1(n):Object.prototype.toString.call(n).slice(8,-1)}function R$2(n,t){void 0===t&&(t=!0);var e=J$3(n);return t?H$2(e):e}function V$2(n,t){return typeof t===n}var W$2=V$2.bind(null,n$1),q$2=V$2.bind(null,t$2);V$2.bind(null,e$1);var Q$1=V$2.bind(null,r$3);V$2.bind(null,i$2);function Y$2(n){return null===n}function nn$1(n){return R$2(n)===c$2&&!isNaN(n)}function rn(n){return R$2(n)===u$1}function on$1(n){if(!un$1(n))return !1;for(var t=n;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function un$1(n){return n&&(typeof n===o$1||null!==n)}function yn$1(n){return W$2(n.constructor)?n.constructor.name:null}function hn$1(n){return n instanceof Error||q$2(n.message)&&n.constructor&&nn$1(n.constructor.stackTraceLimit)}function Sn$1(n,t){if("object"!=typeof t||Y$2(t))return !1;if(t instanceof n)return !0;var e=R$2(new n(""));if(hn$1(t))for(;t;){if(R$2(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn$1.bind(null,TypeError);Sn$1.bind(null,SyntaxError);function $n$1(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn$1(n,t):e}function Tn$1(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n$1(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n$1($n$1,S$2);_n$1($n$1,A$3);_n$1($n$1,j$2);_n$1($n$1,E$3);
|
|
233
|
-
|
|
234
|
-
function h$1(){return h$1=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)({}).hasOwnProperty.call(t,r)&&(e[r]=t[r]);}return e},h$1.apply(null,arguments)}var y="function",b$1="undefined",I$2="reducer",w="@@redux/",E$2=w+"INIT",P$1=w+Math.random().toString(36),S$1=/* #__PURE__ */function(){return typeof Symbol===y&&Symbol.observable||"@@observable"}(),N$1=" != "+y;function O$1(e,n,t){var r;if(typeof n===y&&typeof t===b$1&&(t=n,n=void 0),typeof t!==b$1){if(typeof t!==y)throw new Error("enhancer"+N$1);return t(O$1)(e,n)}if(typeof e!==y)throw new Error(I$2+N$1);var i=e,a=n,o=[],u=o,c=!1;function s(){u===o&&(u=o.slice());}function f(){return a}function d(e){if(typeof e!==y)throw new Error("Listener"+N$1);var n=!0;return s(),u.push(e),function(){if(n){n=!1,s();var t=u.indexOf(e);u.splice(t,1);}}}function p(e){if(!on$1(e))throw new Error("Act != obj");if(typeof e.type===b$1)throw new Error("ActType "+b$1);if(c)throw new Error("Dispatch in "+I$2);try{c=!0,a=i(a,e);}finally{c=!1;}for(var n=o=u,t=0;t<n.length;t++)(0, n[t])();return e}return p({type:E$2}),(r={dispatch:p,subscribe:d,getState:f,replaceReducer:function(e){if(typeof e!==y)throw new Error("next "+I$2+N$1);i=e,p({type:E$2});}})[S$1]=function(){var e,n=d;return (e={subscribe:function(e){if("object"!=typeof e)throw new TypeError("Observer != obj");function t(){e.next&&e.next(f());}return t(),{unsubscribe:n(t)}}})[S$1]=function(){return this},e},r}function A$2(e,n){var t=n&&n.type;return "action "+(t&&t.toString()||"?")+I$2+" "+e+" returns "+b$1}function _(){var e=[].slice.call(arguments);return 0===e.length?function(e){return e}:1===e.length?e[0]:e.reduce(function(e,n){return function(){return e(n.apply(void 0,[].slice.call(arguments)))}})}function k$1(){var e=arguments;return function(n){return function(t,r,i){var a,o=n(t,r,i),u=o.dispatch,c={getState:o.getState,dispatch:function(e){return u(e)}};return a=[].slice.call(e).map(function(e){return e(c)}),h$1({},o,{dispatch:u=_.apply(void 0,a)(o.dispatch)})}}}var x$1=O$2+"anon_id",j$1=O$2+"user_id",T=O$2+"user_traits",M$1="analytics",q$1="userId",U$1="anonymousId",V$1=["bootstrap","params","campaign","initializeStart","initialize","initializeEnd","ready","resetStart","reset","resetEnd","pageStart","page","pageEnd","pageAborted","trackStart","track","trackEnd","trackAborted","identifyStart","identify","identifyEnd","identifyAborted","userIdChanged","registerPlugins","enablePlugin","disablePlugin","online","offline","setItemStart","setItem","setItemEnd","setItemAborted","removeItemStart","removeItem","removeItemEnd","removeItemAborted"],L$1=["name","EVENTS","config","loaded"],C$1=V$1.reduce(function(e,n){return e[n]=n,e},{registerPluginType:function(e){return "registerPlugin:"+e},pluginReadyType:function(e){return "ready:"+e}}),R$1=/^utm_/,$$1=/^an_prop_/,D=/^an_trait_/;function B(e){var n=e.storage.setItem;return function(t){return function(r){return function(i){if(i.type===C$1.bootstrap){var a=i.params,o=i.user,u=i.persistedUser,c=i.initialUser,s=u.userId===o.userId;u.anonymousId!==o.anonymousId&&n(x$1,o.anonymousId),s||n(j$1,o.userId),c.traits&&n(T,h$1({},s&&u.traits?u.traits:{},c.traits));var l=Object.keys(i.params);if(l.length){var f=a.an_uid,d=a.an_event,p=l.reduce(function(e,n){if(n.match(R$1)||n.match(/^(d|g)clid/)){var t=n.replace(R$1,"");e.campaign["campaign"===t?"name":t]=a[n];}return n.match($$1)&&(e.props[n.replace($$1,"")]=a[n]),n.match(D)&&(e.traits[n.replace(D,"")]=a[n]),e},{campaign:{},props:{},traits:{}});t.dispatch(h$1({type:C$1.params,raw:a},p,f?{userId:f}:{})),f&&setTimeout(function(){return e.identify(f,p.traits)},0),d&&setTimeout(function(){return e.track(d,p.props)},0),Object.keys(p.campaign).length&&t.dispatch({type:C$1.campaign,campaign:p.campaign});}}return r(i)}}}}function X(e){return function(n,t){if(void 0===n&&(n={}),void 0===t&&(t={}),t.type===C$1.setItemEnd){if(t.key===x$1)return h$1({},n,{anonymousId:t.value});if(t.key===j$1)return h$1({},n,{userId:t.value})}switch(t.type){case C$1.identify:return Object.assign({},n,{userId:t.userId,traits:h$1({},n.traits,t.traits)});case C$1.reset:return [j$1,x$1,T].forEach(function(n){e.removeItem(n);}),Object.assign({},n,{userId:null,anonymousId:null,traits:{}});default:return n}}}function J$2(e){return {userId:e.getItem(j$1),anonymousId:e.getItem(x$1),traits:e.getItem(T)}}var W$1=function(e){return O$2+"TEMP"+O$2+e};function H$1(n){var t=n.storage,r=t.setItem,i=t.removeItem,a=t.getItem;return function(n){return function(t){return function(u){var c=u.userId,s=u.traits,l=u.options;if(u.type===C$1.reset&&([j$1,T,x$1].forEach(function(e){i(e);}),[q$1,U$1,"traits"].forEach(function(e){i$3(W$1(e));})),u.type===C$1.identify){a(x$1)||r(x$1,b$2());var f=a(j$1),d=a(T)||{};f&&f!==c&&n.dispatch({type:C$1.userIdChanged,old:{userId:f,traits:d},new:{userId:c,traits:s},options:l}),c&&r(j$1,c),s&&r(T,h$1({},d,s));}return t(u)}}}}var F$1={};function G$1(e,n){F$1[e]&&W$2(F$1[e])&&(F$1[e](n),delete F$1[e]);}function K(e,n,t){return new Promise(function(r,i){return n()?r(e):t<1?i(h$1({},e,{queue:!0})):new Promise(function(e){return setTimeout(e,10)}).then(function(a){return K(e,n,t-10).then(r,i)})})}function Q(e){return {abort:e}}function Y$1(e,n,t){var r={},i=n(),a=e.getState(),o=a.plugins,u=a.queue,c=a.user;if(!a.context.offline&&u&&u.actions&&u.actions.length){var s=u.actions.reduce(function(e,n,t){return o[n.plugin].loaded?(e.process.push(n),e.processIndex.push(t)):(e.requeue.push(n),e.requeueIndex.push(t)),e},{processIndex:[],process:[],requeue:[],requeueIndex:[]});if(s.processIndex&&s.processIndex.length){s.processIndex.forEach(function(n){var a=u.actions[n],s=a.plugin,f=a.payload.type,p=i[s][f];if(p&&W$2(p)){var m,g=function(e,n){return void 0===e&&(e={}),void 0===n&&(n={}),[q$1,U$1].reduce(function(t,r){return e.hasOwnProperty(r)&&n[r]&&n[r]!==e[r]&&(t[r]=n[r]),t},e)}(a.payload,c),v=r[g.meta.rid];if(!v&&(m=p({payload:g,config:o[s].config,instance:t,abort:Q}))&&on$1(m)&&m.abort)return void(r[g.meta.rid]=!0);if(!v){var y=f+":"+s;e.dispatch(h$1({},g,{type:y,_:{called:y,from:"queueDrain"}}));}}});var f=u.actions.filter(function(e,n){return !~s.processIndex.indexOf(n)});u.actions=f;}}}var Z=function(e){var n=e.data,t=e.action,r=e.instance,i=e.state,a=e.allPlugins,o=e.allMatches,u=e.store,c=e.EVENTS;try{var s=i.plugins,f=i.context,p=t.type,m=p.match(ee),g=n.exact.map(function(e){return e.pluginName});m&&(g=o.during.map(function(e){return e.pluginName}));var v=function(e,n){return function(t,r,i){var a=r.config,o=r.name,u=o+"."+t.type;i&&(u=i.event);var c=t.type.match(ee)?function(e,n,t,r,i){return function(a,o){var u=r?r.name:e,c=o&&se(o)?o:t;if(r&&(!(c=o&&se(o)?o:[e]).includes(e)||1!==c.length))throw new Error("Method "+n+" can only abort "+e+" plugin. "+JSON.stringify(c)+" input valid");return h$1({},i,{abort:{reason:a,plugins:c,caller:n,_:u}})}}(o,u,n,i,t):function(e,n){return function(){throw new Error(e.type+" action not cancellable. Remove abort in "+n)}}(t,u);return {payload:de(t),instance:e,config:a||{},abort:c}}}(r,g),y=n.exact.reduce(function(e,n){var t=n.pluginName,r=n.methodName,i=!1;return r.match(/^initialize/)||r.match(/^reset/)||(i=!s[t].loaded),f.offline&&r.match(/^(page|track|identify)/)&&(i=!0),e[""+t]=i,e},{});return Promise.resolve(n.exact.reduce(function(e,i,o){var u=i.pluginName;return Promise.resolve(e).then(function(e){function i(){return Promise.resolve(e)}var o=function(){if(n.namespaced&&n.namespaced[u])return Promise.resolve(n.namespaced[u].reduce(function(e,n,t){return Promise.resolve(e).then(function(e){return n.method&&W$2(n.method)?(function(e,n){var t=fe(e);if(t&&t.name===n){var r=fe(t.method);throw new Error([n+" plugin is calling method "+e,"Plugins cant call self","Use "+t.method+" "+(r?"or "+r.method:"")+" in "+n+" plugin insteadof "+e].join("\n"))}}(n.methodName,n.pluginName),Promise.resolve(n.method({payload:e,instance:r,abort:(t=e,i=u,o=n.pluginName,function(e,n){return h$1({},t,{abort:{reason:e,plugins:n||[i],caller:p,from:o||i}})}),config:ie(n.pluginName,s,a),plugins:s})).then(function(n){var t=on$1(n)?n:{};return Promise.resolve(h$1({},e,t))})):e;var t,i,o;})},Promise.resolve(t))).then(function(n){e[u]=n;});e[u]=t;}();return o&&o.then?o.then(i):i()})},Promise.resolve({}))).then(function(e){return Promise.resolve(n.exact.reduce(function(t,i,o){try{var c=n.exact.length===o+1,f=i.pluginName,d=a[f];return Promise.resolve(t).then(function(n){var t=e[f]?e[f]:{};if(m&&(t=n),ue(t,f))return re({data:t,method:p,instance:r,pluginName:f,store:u}),Promise.resolve(n);if(ue(n,f))return c&&re({data:n,method:p,instance:r,store:u}),Promise.resolve(n);if(y.hasOwnProperty(f)&&!0===y[f])return u.dispatch({type:"queue",plugin:f,payload:t,_:{called:"queue",from:"queueMechanism"}}),Promise.resolve(n);var i=v(e[f],a[f]);return Promise.resolve(d[p]({abort:i.abort,payload:t,instance:r,config:ie(f,s,a),plugins:s})).then(function(i){var a=on$1(i)?i:{},o=h$1({},n,a),c=e[f];if(ue(c,f))re({data:c,method:p,instance:r,pluginName:f,store:u});else {var s=p+":"+f;(s.match(/:/g)||[]).length<2&&!p.match(ne)&&!p.match(te)&&r.dispatch(h$1({},m?o:t,{type:s,_:{called:s,from:"submethod"}}));}return Promise.resolve(o)})})}catch(e){return Promise.reject(e)}},Promise.resolve(t))).then(function(e){if(!(p.match(ee)||p.match(/^registerPlugin/)||p.match(te)||p.match(ne)||p.match(/^params/)||p.match(/^userIdChanged/))){if(c.plugins.includes(p),e._&&e._.originalAction===p)return e;var t=h$1({},e,{_:{originalAction:e.type,called:e.type,from:"engineEnd"}});ce(e,n.exact.length)&&!p.match(/End$/)&&(t=h$1({},t,{type:e.type+"Aborted"})),u.dispatch(t);}return e})})}catch(e){return Promise.reject(e)}},ee=/Start$/,ne=/^bootstrap/,te=/^ready/;function re(e){var n=e.pluginName,t=e.method+"Aborted"+(n?":"+n:"");e.store.dispatch(h$1({},e.data,{type:t,_:{called:t,from:"abort"}}));}function ie(e,n,t){var r=n[e]||t[e];return r&&r.config?r.config:{}}function ae(e,n){return n.reduce(function(n,t){return t[e]?n.concat({methodName:e,pluginName:t.name,method:t[e]}):n},[])}function oe(e,n){var t=e.replace(ee,""),r=n?":"+n:"";return [""+e+r,""+t+r,t+"End"+r]}function ue(e,n){var t=e.abort;return !!t&&(!0===t||le(t,n)||t&&le(t.plugins,n))}function ce(e,n){var t=e.abort;if(!t)return !1;if(!0===t||q$2(t))return !0;var r=t.plugins;return se(t)&&t.length===n||se(r)&&r.length===n}function se(e){return Array.isArray(e)}function le(e,n){return !(!e||!se(e))&&e.includes(n)}function fe(e){var n=e.match(/(.*):(.*)/);return !!n&&{method:n[1],name:n[2]}}function de(e){return Object.keys(e).reduce(function(n,t){return "type"===t||(n[t]=on$1(e[t])?Object.assign({},e[t]):e[t]),n},{})}function pe(e,n,t){var r={};return function(i){return function(a){return function(o){try{var u,c=function(e){return u?e:a(f)},s=o.type,l=o.plugins,f=o;if(o.abort)return Promise.resolve(a(o));if(s===C$1.enablePlugin&&i.dispatch({type:C$1.initializeStart,plugins:l,disabled:[],fromEnable:!0,meta:o.meta}),s===C$1.disablePlugin&&setTimeout(function(){return G$1(o.meta.rid,{payload:o})},0),s===C$1.initializeEnd){var m=n(),g=Object.keys(m),v=g.filter(function(e){return l.includes(e)}).map(function(e){return m[e]}),y=[],b=[],I=o.disabled,w=v.map(function(e){var n=e.loaded,t=e.name,a=e.config;return K(e,function(){return n({config:a})},1e4).then(function(n){return r[t]||(i.dispatch({type:C$1.pluginReadyType(t),name:t,events:Object.keys(e).filter(function(e){return !L$1.includes(e)})}),r[t]=!0),y=y.concat(t),e}).catch(function(e){if(e instanceof Error)throw new Error(e);return b=b.concat(e.name),e})});Promise.all(w).then(function(e){var n={plugins:y,failed:b,disabled:I};setTimeout(function(){g.length===w.length+I.length&&i.dispatch(h$1({},{type:C$1.ready},n));},0);});}var E=function(){if(s!==C$1.bootstrap)return /^ready:([^:]*)$/.test(s)&&setTimeout(function(){return Y$1(i,n,e)},0),Promise.resolve(function(e,n,t,r,i){try{var a=W$2(n)?n():n,o=e.type,u=o.replace(ee,"");if(e._&&e._.called)return Promise.resolve(e);var c=t.getState(),s=(m=a,void 0===(g=c.plugins)&&(g={}),void 0===(v=e.options)&&(v={}),Object.keys(m).filter(function(e){var n=v.plugins||{};return Q$1(n[e])?n[e]:!1!==n.all&&(!g[e]||!1!==g[e].enabled)}).map(function(e){return m[e]}));o===C$1.initializeStart&&e.fromEnable&&(s=Object.keys(c.plugins).filter(function(n){var t=c.plugins[n];return e.plugins.includes(n)&&!t.initialized}).map(function(e){return a[e]}));var l=s.map(function(e){return e.name}),f=function(e,n){var t=oe(e).map(function(e){return ae(e,n)});return n.reduce(function(t,r){var i=r.name,a=oe(e,i).map(function(e){return ae(e,n)}),o=a[0],u=a[1],c=a[2];return o.length&&(t.beforeNS[i]=o),u.length&&(t.duringNS[i]=u),c.length&&(t.afterNS[i]=c),t},{before:t[0],beforeNS:{},during:t[1],duringNS:{},after:t[2],afterNS:{}})}(o,s);return Promise.resolve(Z({action:e,data:{exact:f.before,namespaced:f.beforeNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){function n(){var n=function(){if(o.match(ee))return Promise.resolve(Z({action:h$1({},s,{type:u+"End"}),data:{exact:f.after,namespaced:f.afterNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){e.meta&&e.meta.hasCallback&&G$1(e.meta.rid,{payload:e});})}();return n&&n.then?n.then(function(){return e}):e}if(ce(e,l.length))return e;var s,d=function(){if(o!==u)return Promise.resolve(Z({action:h$1({},e,{type:u}),data:{exact:f.during,namespaced:f.duringNS},state:c,allPlugins:a,allMatches:f,instance:t,store:r,EVENTS:i})).then(function(e){s=e;});s=e;}();return d&&d.then?d.then(n):n()})}catch(e){return Promise.reject(e)}var m,g,v;}(o,n,e,i,t)).then(function(e){var n=a(e);return u=1,n})}();return Promise.resolve(E&&E.then?E.then(c):c(E))}catch(e){return Promise.reject(e)}}}}}function me(e){return function(n){return function(n){return function(t){var r=t.type,i=t.key,a=t.value,o=t.options;if(r===C$1.setItem||r===C$1.removeItem){if(t.abort)return n(t);r===C$1.setItem?e.setItem(i,a,o):e.removeItem(i,o);}return n(t)}}}}var ge=function(){var e=this;this.before=[],this.after=[],this.addMiddleware=function(n,t){e[t]=e[t].concat(n);},this.removeMiddleware=function(n,t){var r=e[t].findIndex(function(e){return e===n});-1!==r&&(e[t]=[].concat(e[t].slice(0,r),e[t].slice(r+1)));},this.dynamicMiddlewares=function(n){return function(t){return function(r){return function(i){var a={getState:t.getState,dispatch:function(e){return t.dispatch(e)}},o=e[n].map(function(e){return e(a)});return _.apply(void 0,o)(r)(i)}}}};};function ve(e){return function(n,t){void 0===n&&(n={});var r={};if("initialize:aborted"===t.type)return n;if(/^registerPlugin:([^:]*)$/.test(t.type)){var i=he(t.type,"registerPlugin"),a=e()[i];if(!a||!i)return n;var o=t.enabled,u=a.config;return r[i]={enabled:o,initialized:!!o&&Boolean(!a.initialize),loaded:!!o&&Boolean(a.loaded({config:u})),config:u},h$1({},n,r)}if(/^initialize:([^:]*)$/.test(t.type)){var c=he(t.type,C$1.initialize),s=e()[c];return s&&c?(r[c]=h$1({},n[c],{initialized:!0,loaded:Boolean(s.loaded({config:s.config}))}),h$1({},n,r)):n}if(/^ready:([^:]*)$/.test(t.type))return r[t.name]=h$1({},n[t.name],{loaded:!0}),h$1({},n,r);switch(t.type){case C$1.disablePlugin:return h$1({},n,ye(t.plugins,!1,n));case C$1.enablePlugin:return h$1({},n,ye(t.plugins,!0,n));default:return n}}}function he(e,n){return e.substring(n.length+1,e.length)}function ye(e,n,t){return e.reduce(function(e,r){return e[r]=h$1({},t[r],{enabled:n}),e},t)}function be(e){try{return JSON.parse(JSON.stringify(e))}catch(e){}return e}var Ie={last:{},history:[]};function we(e,n){void 0===e&&(e=Ie);var t=n.options,r=n.meta;if(n.type===C$1.track){var i=be(h$1({event:n.event,properties:n.properties},Object.keys(t).length&&{options:t},{meta:r}));return h$1({},e,{last:i,history:e.history.concat(i)})}return e}var Ee={actions:[]};function Pe(e,n){void 0===e&&(e=Ee);var t=n.payload;switch(n.type){case"queue":var r;return r=t&&t.type&&t.type===C$1.identify?[n].concat(e.actions):e.actions.concat(n),h$1({},e,{actions:r});case"dequeue":return [];default:return e}}var Se=/#.*$/;function Ne(e){var n=/(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);return "/"+(n&&n[3]?n[3].split("?")[0].replace(Se,""):"")}var Oe,Ae,_e,ke,xe=function(e){if(void 0===e&&(e={}),!$$2)return e;var n=document,t=n.title,r=n.referrer,i=window,a=i.location,o=i.innerWidth,u=i.innerHeight,c=a.hash,s=a.search,l=function(e){var n=function(){if($$2)for(var e,n=document.getElementsByTagName("link"),t=0;e=n[t];t++)if("canonical"===e.getAttribute("rel"))return e.getAttribute("href")}();return n?n.match(/\?/)?n:n+e:window.location.href.replace(Se,"")}(s),f={title:t,url:l,path:Ne(l),hash:c,search:s,width:o,height:u};return r&&""!==r&&(f.referrer=r),h$1({},f,e)},je={last:{},history:[]};function Te(e,n){void 0===e&&(e=je);var t=n.options;if(n.type===C$1.page){var r=be(h$1({properties:n.properties,meta:n.meta},Object.keys(t).length&&{options:t}));return h$1({},e,{last:r,history:e.history.concat(r)})}return e}Oe=function(){if(!$$2)return !1;var e=navigator.appVersion;return ~e.indexOf("Win")?"Windows":~e.indexOf("Mac")?"MacOS":~e.indexOf("X11")?"UNIX":~e.indexOf("Linux")?"Linux":"Unknown OS"}(),Ae=$$2?document.referrer:null,_e=o$4(),ke=a$6();var ze={initialized:!1,sessionId:b$2(),app:null,version:null,debug:!1,offline:!!$$2&&!navigator.onLine,os:{name:Oe},userAgent:$$2?navigator.userAgent:"node",library:{name:M$1,version:"0.13.1"},timezone:ke,locale:_e,campaign:{},referrer:Ae};function Me(e,n){void 0===e&&(e=ze);var t=e.initialized,r=n.campaign;switch(n.type){case C$1.campaign:return h$1({},e,{campaign:r});case C$1.offline:return h$1({},e,{offline:!0});case C$1.online:return h$1({},e,{offline:!1});default:return t?e:h$1({},ze,e,{initialized:!0})}}var qe=["plugins","reducers","storage"];function Ue(e,n,t){if($$2){var r=window[(t?"add":"remove")+"EventListener"];e.split(" ").forEach(function(e){r(e,n);});}}function Ve(e){var n=Ue.bind(null,"online offline",function(n){return Promise.resolve(!navigator.onLine).then(e)});return n(!0),function(e){return n(!1)}}function Le(){return a$4(M$1,[]),function(e){return function(n,t,r){var i=e(n,t,r),a=i.dispatch;return Object.assign(i,{dispatch:function(e){return l$1[o$2][M$1].push(e.action||e),a(e)}})}}}function Ce(e){return function(){return _(_.apply(null,arguments),Le())}}function Re(e){return e?rn(e)?e:[e]:[]}function $e(n,t,r){void 0===n&&(n={});var i,a,o=b$2();return t&&(F$1[o]=(i=t,a=function(e){for(var n,t=e||Array.prototype.slice.call(arguments),r=0;r<t.length;r++)if(W$2(t[r])){n=t[r];break}return n}(r),function(e){a&&a(e),i(e);})),h$1({},n,{rid:o,ts:(new Date).getTime()},t?{hasCallback:!0}:{})}function De(n){void 0===n&&(n={});var t=n.reducers||{},c=n.initialUser||{},s=(n.plugins||[]).reduce(function(e,n){if(W$2(n))return e.middlewares=e.middlewares.concat(n),e;if(n.NAMESPACE&&(n.name=n.NAMESPACE),!n.name)throw new Error("https://lytics.dev/errors/1");n.config||(n.config={});var t=n.EVENTS?Object.keys(n.EVENTS).map(function(e){return n.EVENTS[e]}):[];e.pluginEnabled[n.name]=!(!1===n.enabled||!1===n.config.enabled),delete n.enabled,n.methods&&(e.methods[n.name]=Object.keys(n.methods).reduce(function(e,t){var r;return e[t]=(r=n.methods[t],function(){for(var e=Array.prototype.slice.call(arguments),n=new Array(r.length),t=0;t<e.length;t++)n[t]=e[t];return n[n.length]=Z,r.apply({instance:Z},n)}),e},{}),delete n.methods);var r=Object.keys(n).concat(t),i=new Set(e.events.concat(r));if(e.events=Array.from(i),e.pluginsArray=e.pluginsArray.concat(n),e.plugins[n.name])throw new Error(n.name+"AlreadyLoaded");return e.plugins[n.name]=n,e.plugins[n.name].loaded||(e.plugins[n.name].loaded=function(){return !0}),e},{plugins:{},pluginEnabled:{},methods:{},pluginsArray:[],middlewares:[],events:[]}),f$1=n.storage?n.storage:{getItem:f,setItem:a$4,removeItem:i$3},p=function(e){return function(n,t,r){return t.getState("user")[n]||(r&&on$1(r)&&r[n]?r[n]:J$2(e)[n]||f(W$1(n))||null)}}(f$1),v=s.plugins,w=s.events.filter(function(e){return !L$1.includes(e)}).sort(),S=new Set(w.concat(V$1).filter(function(e){return !L$1.includes(e)})),N=Array.from(S).sort(),j=function(){return v},T=new ge,z=T.addMiddleware,M=T.removeMiddleware,R=T.dynamicMiddlewares,$=function(){throw new Error("Abort disabled inListener")},D=s$1(),F=J$2(f$1),G=h$1({},F,c,D.an_uid?{userId:D.an_uid}:{},D.an_aid?{anonymousId:D.an_aid}:{});G.anonymousId||(G.anonymousId=b$2());var K=h$1({enable:function(e,n){return new Promise(function(t){se.dispatch({type:C$1.enablePlugin,plugins:Re(e),_:{originalAction:C$1.enablePlugin}},t,[n]);})},disable:function(e,n){return new Promise(function(t){se.dispatch({type:C$1.disablePlugin,plugins:Re(e),_:{originalAction:C$1.disablePlugin}},t,[n]);})}},s.methods),Q=!1,Z={identify:function(e,n,t,r){try{var i=q$2(e)?e:null,a=on$1(e)?e:n,o=t||{},c=Z.user();a$4(W$1(q$1),i);var s=i||a.userId||p(q$1,Z,a);return Promise.resolve(new Promise(function(e){se.dispatch(h$1({type:C$1.identifyStart,userId:s,traits:a||{},options:o,anonymousId:c.anonymousId},c.id&&c.id!==i&&{previousId:c.id}),e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},track:function(e,n,t,r){try{var i=on$1(e)?e.event:e;if(!i||!q$2(i))throw new Error("EventMissing");var a=on$1(e)?e:n||{},o=on$1(t)?t:{};return Promise.resolve(new Promise(function(e){se.dispatch({type:C$1.trackStart,event:i,properties:a,options:o,userId:p(q$1,Z,n),anonymousId:p(U$1,Z,n)},e,[n,t,r]);}))}catch(e){return Promise.reject(e)}},page:function(e,n,t){try{var r=on$1(e)?e:{},i=on$1(n)?n:{};return Promise.resolve(new Promise(function(a){se.dispatch({type:C$1.pageStart,properties:xe(r),options:i,userId:p(q$1,Z,r),anonymousId:p(U$1,Z,r)},a,[e,n,t]);}))}catch(e){return Promise.reject(e)}},user:function(e){if(e===q$1||"id"===e)return p(q$1,Z);if(e===U$1||"anonId"===e)return p(U$1,Z);var n=Z.getState("user");return e?i$6(n,e):n},reset:function(e){return new Promise(function(n){se.dispatch({type:C$1.resetStart},n,e);})},ready:function(e){return Q&&e({plugins:K,instance:Z}),Z.on(C$1.ready,function(n){e&&e(n),Q=!0;})},on:function(e,n){if(!e||!W$2(n))return !1;if(e===C$1.bootstrap)throw new Error(".on disabled for "+e);var t=/Start$|Start:/;if("*"===e){var r=function(e){return function(e){return function(r){return r.type.match(t)&&n({payload:r,instance:Z,plugins:v}),e(r)}}},i=function(e){return function(e){return function(r){return r.type.match(t)||n({payload:r,instance:Z,plugins:v}),e(r)}}};return z(r,Be),z(i,Xe),function(){M(r,Be),M(i,Xe);}}var a=e.match(t)?Be:Xe,o=function(t){return function(t){return function(r){return r.type===e&&n({payload:r,instance:Z,plugins:v,abort:$}),t(r)}}};return z(o,a),function(){return M(o,a)}},once:function(e,n){if(!e||!W$2(n))return !1;if(e===C$1.bootstrap)throw new Error(".once disabled for "+e);var t=Z.on(e,function(e){n({payload:e.payload,instance:Z,plugins:v,abort:$}),t();});return t},getState:function(e){var n=se.getState();return e?i$6(n,e):Object.assign({},n)},dispatch:function(e){var n=q$2(e)?{type:e}:e;if(V$1.includes(n.type))throw new Error("reserved action "+n.type);var t=h$1({},n,{_:h$1({originalAction:n.type},e._||{})});se.dispatch(t);},enablePlugin:K.enable,disablePlugin:K.disable,plugins:K,storage:{getItem:f$1.getItem,setItem:function(e,n,t){se.dispatch({type:C$1.setItemStart,key:e,value:n,options:t});},removeItem:function(e,n){se.dispatch({type:C$1.removeItemStart,key:e,options:n});}},setAnonymousId:function(e,n){Z.storage.setItem(x$1,e,n);},events:{core:V$1,plugins:w}},ee=s.middlewares.concat([function(e){return function(e){return function(n){return n.meta||(n.meta=$e()),e(n)}}},R(Be),pe(Z,j,{all:N,plugins:w}),me(f$1),B(Z),H$1(Z),R(Xe)]),ne={context:Me,user:X(f$1),page:Te,track:we,plugins:ve(j),queue:Pe},te=_,re=_;if($$2&&n.debug){var ie=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;ie&&(te=ie({trace:!0,traceLimit:25})),re=function(){return 0===arguments.length?Le():on$1(typeof arguments[0])?Ce():Ce().apply(null,arguments)};}var ae,oe=function(e){return Object.keys(e).reduce(function(n,t){return qe.includes(t)||(n[t]=e[t]),n},{})}(n),ue=s.pluginsArray.reduce(function(e,n){var t=n.name,r=n.config,i=n.loaded,a=s.pluginEnabled[t];return e[t]={enabled:a,initialized:!!a&&Boolean(!n.initialize),loaded:Boolean(i({config:r})),config:r},e},{}),ce={context:oe,user:G,plugins:ue},se=O$1(function(e){for(var n=Object.keys(e),t={},r=0;r<n.length;r++){var i=n[r];typeof e[i]===y&&(t[i]=e[i]);}var a,o=Object.keys(t);try{!function(e){Object.keys(e).forEach(function(n){var t=e[n];if(typeof t(void 0,{type:E$2})===b$1||typeof t(void 0,{type:P$1})===b$1)throw new Error(I$2+" "+n+" "+b$1)});}(t);}catch(e){a=e;}return function(e,n){if(void 0===e&&(e={}),a)throw a;for(var r=!1,i={},u=0;u<o.length;u++){var c=o[u],s=e[c],l=(0, t[c])(s,n);if(typeof l===b$1){var f=A$2(c,n);throw new Error(f)}i[c]=l,r=r||l!==s;}return r?i:e}}(h$1({},ne,t)),ce,re(te(k$1.apply(void 0,ee))));se.dispatch=(ae=se.dispatch,function(e,n,t){var r=h$1({},e,{meta:$e(e.meta,n,Re(t))});return ae.apply(null,[r])});var le=Object.keys(v);se.dispatch({type:C$1.bootstrap,plugins:le,config:oe,params:D,user:G,initialUser:c,persistedUser:F});var fe=le.filter(function(e){return s.pluginEnabled[e]}),de=le.filter(function(e){return !s.pluginEnabled[e]});return se.dispatch({type:C$1.registerPlugins,plugins:le,enabled:s.pluginEnabled}),s.pluginsArray.map(function(e,n){var t=e.bootstrap,r=e.config,i=e.name;t&&W$2(t)&&t({instance:Z,config:r,payload:e}),se.dispatch({type:C$1.registerPluginType(i),name:i,enabled:s.pluginEnabled[i],plugin:e}),s.pluginsArray.length===n+1&&se.dispatch({type:C$1.initializeStart,plugins:fe,disabled:de});}),Ve(function(e){se.dispatch({type:e?C$1.offline:C$1.online});}),function(e,n,t){setInterval(function(){return Y$1(e,n,t)},3e3);}(se,j,Z),Z}var Be="before",Xe="after";
|
|
235
|
-
|
|
236
|
-
var t$1="cookie",i$1=a$2(),r$2=d$1,c$1=d$1;function u(e){return i$1?d$1(e,"",-1):i$3(e)}function a$2(){if(void 0!==i$1)return i$1;var e=t$1+t$1;try{d$1(e,e),i$1=-1!==document.cookie.indexOf(e),u(e);}catch(e){i$1=!1;}return i$1}function d$1(n,t,r,c,u,a){if("undefined"!=typeof window){var d=arguments.length>1;return !1===i$1&&(d?a$4(n,t):f(n)),d?document.cookie=n+"="+encodeURIComponent(t)+(r?"; expires="+new Date(+new Date+1e3*r).toUTCString()+(c?"; path="+c:"")+(u?"; domain="+u:"")+(a?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+n+"=")[1]||"").split(";")[0])}}
|
|
237
|
-
|
|
238
|
-
var r$1="localStorage",m$1=s.bind(null,r$1);u$2(r$1,"getItem",f);u$2(r$1,"setItem",a$4);u$2(r$1,"removeItem",i$3);
|
|
239
|
-
|
|
240
|
-
var a$1="sessionStorage",l=s.bind(null,a$1);u$2(a$1,"getItem",f);u$2(a$1,"setItem",a$4);u$2(a$1,"removeItem",i$3);
|
|
241
|
-
|
|
242
|
-
var n="function",t="string",e="undefined",r="boolean",o="object",c="number",i="symbol",a="null",m="any",v="*",S="form",j="input",A$1="button",E$1="select",P=typeof process!==e?process:{};P.env&&P.env.NODE_ENV||"";var $=typeof document!==e;null!=P.versions&&null!=P.versions.node;typeof Deno!==e&&typeof Deno.core!==e;$&&"nodejs"===window.name||typeof navigator!==e&&typeof navigator.userAgent!==e&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom"));function M(n,t){return t.charAt(0)[n]()+t.slice(1)}var U=M.bind(null,"toUpperCase"),H=M.bind(null,"toLowerCase");function J$1(n){return Y(n)?U(a):typeof n===o?yn(n):Object.prototype.toString.call(n).slice(8,-1)}function R(n,t){void 0===t&&(t=!0);var e=J$1(n);return t?H(e):e}function V(n,t){return typeof t===n}var W=V.bind(null,n),q=V.bind(null,t),I$1=V.bind(null,e);V.bind(null,r);V.bind(null,i);function Y(n){return null===n}function nn(n){return R(n)===c&&!isNaN(n)}function on(n){if(!un(n))return !1;for(var t=n;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t}function un(n){return n&&(typeof n===o||null!==n)}function yn(n){return W(n.constructor)?n.constructor.name:null}function hn(n){return n instanceof Error||q(n.message)&&n.constructor&&nn(n.constructor.stackTraceLimit)}function Sn(n,t){if("object"!=typeof t||Y(t))return !1;if(t instanceof n)return !0;var e=R(new n(""));if(hn(t))for(;t;){if(R(t)===e)return !0;t=Object.getPrototypeOf(t);}return !1}Sn.bind(null,TypeError);Sn.bind(null,SyntaxError);function $n(n,t){var e=n instanceof Element||n instanceof HTMLDocument;return e&&t?Tn(n,t):e}function Tn(n,t){return void 0===t&&(t=""),n&&n.nodeName===t.toUpperCase()}function _n(n){var t=[].slice.call(arguments,1);return function(){return n.apply(void 0,[].slice.call(arguments).concat(t))}}_n($n,S);_n($n,A$1);_n($n,j);_n($n,E$1);
|
|
243
|
-
|
|
244
|
-
function I(t){var o=t;try{if("true"===(o=JSON.parse(t)))return !0;if("false"===o)return !1;if(on(o))return o;parseFloat(o)===o&&(o=parseFloat(o));}catch(t){}if(null!==o&&""!==o)return o}var k=m$1(),O=l(),x=a$2();function C(o,e){if(o){var r=A(e),a=!N(r),s=d(r)?I(localStorage.getItem(o)):void 0;if(a&&!I$1(s))return s;var n=h(r)?I(r$2(o)):void 0;if(a&&n)return n;var l=E(r)?I(sessionStorage.getItem(o)):void 0;if(a&&l)return l;var u=f(o);return a?u:{localStorage:s,sessionStorage:l,cookie:n,global:u}}}function L(r,a,l){if(r&&!I$1(a)){var u={},g=A(l),m=JSON.stringify(a),p=!N(g);return d(g)&&(u[r$1]=F(r$1,a,I(localStorage.getItem(r))),localStorage.setItem(r,m),p)?u[r$1]:h(g)&&(u[t$1]=F(t$1,a,I(r$2(r))),c$1(r,m),p)?u[t$1]:E(g)&&(u[a$1]=F(a$1,a,I(sessionStorage.getItem(r))),sessionStorage.setItem(r,m),p)?u[a$1]:(u[n$2]=F(n$2,a,f(r)),a$4(r,a),p?u[n$2]:u)}}function b(t,e){if(t){var a=A(e),i=C(t,v),n={};return !I$1(i.localStorage)&&d(a)&&(localStorage.removeItem(t),n[r$1]=i.localStorage),!I$1(i.cookie)&&h(a)&&(u(t),n[t$1]=i.cookie),!I$1(i.sessionStorage)&&E(a)&&(sessionStorage.removeItem(t),n[a$1]=i.sessionStorage),!I$1(i.global)&&G(a,n$2)&&(i$3(t),n[n$2]=i.global),n}}function A(t){return t?q(t)?t:t.storage:m}function d(t){return k&&G(t,r$1)}function h(t){return x&&G(t,t$1)}function E(t){return O&&G(t,a$1)}function N(t){return t===v||"all"===t}function G(t,o){return t===m||t===o||N(t)}function F(t,o,e){return {location:t,current:o,previous:e}}var J={setItem:L,getItem:C,removeItem:b};
|
|
245
|
-
|
|
246
|
-
function _defineProperty(obj, key, value) {
|
|
247
|
-
if (key in obj) {
|
|
248
|
-
Object.defineProperty(obj, key, {
|
|
249
|
-
value: value,
|
|
250
|
-
enumerable: true,
|
|
251
|
-
configurable: true,
|
|
252
|
-
writable: true
|
|
253
|
-
});
|
|
254
|
-
} else {
|
|
255
|
-
obj[key] = value;
|
|
256
|
-
}
|
|
257
|
-
return obj;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function ownKeys(object, enumerableOnly) {
|
|
261
|
-
var keys = Object.keys(object);
|
|
262
|
-
if (Object.getOwnPropertySymbols) {
|
|
263
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
264
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
265
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
266
|
-
})), keys.push.apply(keys, symbols);
|
|
267
|
-
}
|
|
268
|
-
return keys;
|
|
269
|
-
}
|
|
270
|
-
function _objectSpread2(target) {
|
|
271
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
272
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
273
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
274
|
-
_defineProperty(target, key, source[key]);
|
|
275
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
276
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
return target;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// See ../packages/analytics-core for source code
|
|
283
|
-
function analyticsLib() {
|
|
284
|
-
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
285
|
-
var defaultSettings = {
|
|
286
|
-
storage: J
|
|
287
|
-
};
|
|
288
|
-
return De(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
|
|
109
|
+
hostname, path: page || pathname, pageUrl: page || pathname, pageName: title, previousPageUrl: previousPage === null || previousPage === void 0 ? void 0 : previousPage.pageUrl, previousPageName: previousPage === null || previousPage === void 0 ? void 0 : previousPage.pageName }, attributes), metrics);
|
|
289
110
|
}
|
|
290
111
|
|
|
291
112
|
/******************************************************************************
|
|
@@ -1376,28 +1197,772 @@
|
|
|
1376
1197
|
return { access };
|
|
1377
1198
|
}
|
|
1378
1199
|
|
|
1200
|
+
/**
|
|
1201
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
1202
|
+
* @copyright Michael Hart 2024
|
|
1203
|
+
*/
|
|
1204
|
+
const encoder = new TextEncoder();
|
|
1205
|
+
const HOST_SERVICES = {
|
|
1206
|
+
appstream2: 'appstream',
|
|
1207
|
+
cloudhsmv2: 'cloudhsm',
|
|
1208
|
+
email: 'ses',
|
|
1209
|
+
marketplace: 'aws-marketplace',
|
|
1210
|
+
mobile: 'AWSMobileHubService',
|
|
1211
|
+
pinpoint: 'mobiletargeting',
|
|
1212
|
+
queue: 'sqs',
|
|
1213
|
+
'git-codecommit': 'codecommit',
|
|
1214
|
+
'mturk-requester-sandbox': 'mturk-requester',
|
|
1215
|
+
'personalize-runtime': 'personalize',
|
|
1216
|
+
};
|
|
1217
|
+
const UNSIGNABLE_HEADERS = new Set([
|
|
1218
|
+
'authorization',
|
|
1219
|
+
'content-type',
|
|
1220
|
+
'content-length',
|
|
1221
|
+
'user-agent',
|
|
1222
|
+
'presigned-expires',
|
|
1223
|
+
'expect',
|
|
1224
|
+
'x-amzn-trace-id',
|
|
1225
|
+
'range',
|
|
1226
|
+
'connection',
|
|
1227
|
+
]);
|
|
1228
|
+
class AwsClient {
|
|
1229
|
+
constructor({ accessKeyId, secretAccessKey, sessionToken, service, region, cache, retries, initRetryMs }) {
|
|
1230
|
+
if (accessKeyId == null) throw new TypeError('accessKeyId is a required option')
|
|
1231
|
+
if (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option')
|
|
1232
|
+
this.accessKeyId = accessKeyId;
|
|
1233
|
+
this.secretAccessKey = secretAccessKey;
|
|
1234
|
+
this.sessionToken = sessionToken;
|
|
1235
|
+
this.service = service;
|
|
1236
|
+
this.region = region;
|
|
1237
|
+
this.cache = cache || new Map();
|
|
1238
|
+
this.retries = retries != null ? retries : 10;
|
|
1239
|
+
this.initRetryMs = initRetryMs || 50;
|
|
1240
|
+
}
|
|
1241
|
+
async sign(input, init) {
|
|
1242
|
+
if (input instanceof Request) {
|
|
1243
|
+
const { method, url, headers, body } = input;
|
|
1244
|
+
init = Object.assign({ method, url, headers }, init);
|
|
1245
|
+
if (init.body == null && headers.has('Content-Type')) {
|
|
1246
|
+
init.body = body != null && headers.has('X-Amz-Content-Sha256') ? body : await input.clone().arrayBuffer();
|
|
1247
|
+
}
|
|
1248
|
+
input = url;
|
|
1249
|
+
}
|
|
1250
|
+
const signer = new AwsV4Signer(Object.assign({ url: input.toString() }, init, this, init && init.aws));
|
|
1251
|
+
const signed = Object.assign({}, init, await signer.sign());
|
|
1252
|
+
delete signed.aws;
|
|
1253
|
+
try {
|
|
1254
|
+
return new Request(signed.url.toString(), signed)
|
|
1255
|
+
} catch (e) {
|
|
1256
|
+
if (e instanceof TypeError) {
|
|
1257
|
+
return new Request(signed.url.toString(), Object.assign({ duplex: 'half' }, signed))
|
|
1258
|
+
}
|
|
1259
|
+
throw e
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
async fetch(input, init) {
|
|
1263
|
+
for (let i = 0; i <= this.retries; i++) {
|
|
1264
|
+
const fetched = fetch(await this.sign(input, init));
|
|
1265
|
+
if (i === this.retries) {
|
|
1266
|
+
return fetched
|
|
1267
|
+
}
|
|
1268
|
+
const res = await fetched;
|
|
1269
|
+
if (res.status < 500 && res.status !== 429) {
|
|
1270
|
+
return res
|
|
1271
|
+
}
|
|
1272
|
+
await new Promise(resolve => setTimeout(resolve, Math.random() * this.initRetryMs * Math.pow(2, i)));
|
|
1273
|
+
}
|
|
1274
|
+
throw new Error('An unknown error occurred, ensure retries is not negative')
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
class AwsV4Signer {
|
|
1278
|
+
constructor({ method, url, headers, body, accessKeyId, secretAccessKey, sessionToken, service, region, cache, datetime, signQuery, appendSessionToken, allHeaders, singleEncode }) {
|
|
1279
|
+
if (url == null) throw new TypeError('url is a required option')
|
|
1280
|
+
if (accessKeyId == null) throw new TypeError('accessKeyId is a required option')
|
|
1281
|
+
if (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option')
|
|
1282
|
+
this.method = method || (body ? 'POST' : 'GET');
|
|
1283
|
+
this.url = new URL(url);
|
|
1284
|
+
this.headers = new Headers(headers || {});
|
|
1285
|
+
this.body = body;
|
|
1286
|
+
this.accessKeyId = accessKeyId;
|
|
1287
|
+
this.secretAccessKey = secretAccessKey;
|
|
1288
|
+
this.sessionToken = sessionToken;
|
|
1289
|
+
let guessedService, guessedRegion;
|
|
1290
|
+
if (!service || !region) {
|
|
1291
|
+
[guessedService, guessedRegion] = guessServiceRegion(this.url, this.headers);
|
|
1292
|
+
}
|
|
1293
|
+
this.service = service || guessedService || '';
|
|
1294
|
+
this.region = region || guessedRegion || 'us-east-1';
|
|
1295
|
+
this.cache = cache || new Map();
|
|
1296
|
+
this.datetime = datetime || new Date().toISOString().replace(/[:-]|\.\d{3}/g, '');
|
|
1297
|
+
this.signQuery = signQuery;
|
|
1298
|
+
this.appendSessionToken = appendSessionToken || this.service === 'iotdevicegateway';
|
|
1299
|
+
this.headers.delete('Host');
|
|
1300
|
+
if (this.service === 's3' && !this.signQuery && !this.headers.has('X-Amz-Content-Sha256')) {
|
|
1301
|
+
this.headers.set('X-Amz-Content-Sha256', 'UNSIGNED-PAYLOAD');
|
|
1302
|
+
}
|
|
1303
|
+
const params = this.signQuery ? this.url.searchParams : this.headers;
|
|
1304
|
+
params.set('X-Amz-Date', this.datetime);
|
|
1305
|
+
if (this.sessionToken && !this.appendSessionToken) {
|
|
1306
|
+
params.set('X-Amz-Security-Token', this.sessionToken);
|
|
1307
|
+
}
|
|
1308
|
+
this.signableHeaders = ['host', ...this.headers.keys()]
|
|
1309
|
+
.filter(header => allHeaders || !UNSIGNABLE_HEADERS.has(header))
|
|
1310
|
+
.sort();
|
|
1311
|
+
this.signedHeaders = this.signableHeaders.join(';');
|
|
1312
|
+
this.canonicalHeaders = this.signableHeaders
|
|
1313
|
+
.map(header => header + ':' + (header === 'host' ? this.url.host : (this.headers.get(header) || '').replace(/\s+/g, ' ')))
|
|
1314
|
+
.join('\n');
|
|
1315
|
+
this.credentialString = [this.datetime.slice(0, 8), this.region, this.service, 'aws4_request'].join('/');
|
|
1316
|
+
if (this.signQuery) {
|
|
1317
|
+
if (this.service === 's3' && !params.has('X-Amz-Expires')) {
|
|
1318
|
+
params.set('X-Amz-Expires', '86400');
|
|
1319
|
+
}
|
|
1320
|
+
params.set('X-Amz-Algorithm', 'AWS4-HMAC-SHA256');
|
|
1321
|
+
params.set('X-Amz-Credential', this.accessKeyId + '/' + this.credentialString);
|
|
1322
|
+
params.set('X-Amz-SignedHeaders', this.signedHeaders);
|
|
1323
|
+
}
|
|
1324
|
+
if (this.service === 's3') {
|
|
1325
|
+
try {
|
|
1326
|
+
this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\+/g, ' '));
|
|
1327
|
+
} catch (e) {
|
|
1328
|
+
this.encodedPath = this.url.pathname;
|
|
1329
|
+
}
|
|
1330
|
+
} else {
|
|
1331
|
+
this.encodedPath = this.url.pathname.replace(/\/+/g, '/');
|
|
1332
|
+
}
|
|
1333
|
+
if (!singleEncode) {
|
|
1334
|
+
this.encodedPath = encodeURIComponent(this.encodedPath).replace(/%2F/g, '/');
|
|
1335
|
+
}
|
|
1336
|
+
this.encodedPath = encodeRfc3986(this.encodedPath);
|
|
1337
|
+
const seenKeys = new Set();
|
|
1338
|
+
this.encodedSearch = [...this.url.searchParams]
|
|
1339
|
+
.filter(([k]) => {
|
|
1340
|
+
if (!k) return false
|
|
1341
|
+
if (this.service === 's3') {
|
|
1342
|
+
if (seenKeys.has(k)) return false
|
|
1343
|
+
seenKeys.add(k);
|
|
1344
|
+
}
|
|
1345
|
+
return true
|
|
1346
|
+
})
|
|
1347
|
+
.map(pair => pair.map(p => encodeRfc3986(encodeURIComponent(p))))
|
|
1348
|
+
.sort(([k1, v1], [k2, v2]) => k1 < k2 ? -1 : k1 > k2 ? 1 : v1 < v2 ? -1 : v1 > v2 ? 1 : 0)
|
|
1349
|
+
.map(pair => pair.join('='))
|
|
1350
|
+
.join('&');
|
|
1351
|
+
}
|
|
1352
|
+
async sign() {
|
|
1353
|
+
if (this.signQuery) {
|
|
1354
|
+
this.url.searchParams.set('X-Amz-Signature', await this.signature());
|
|
1355
|
+
if (this.sessionToken && this.appendSessionToken) {
|
|
1356
|
+
this.url.searchParams.set('X-Amz-Security-Token', this.sessionToken);
|
|
1357
|
+
}
|
|
1358
|
+
} else {
|
|
1359
|
+
this.headers.set('Authorization', await this.authHeader());
|
|
1360
|
+
}
|
|
1361
|
+
return {
|
|
1362
|
+
method: this.method,
|
|
1363
|
+
url: this.url,
|
|
1364
|
+
headers: this.headers,
|
|
1365
|
+
body: this.body,
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
async authHeader() {
|
|
1369
|
+
return [
|
|
1370
|
+
'AWS4-HMAC-SHA256 Credential=' + this.accessKeyId + '/' + this.credentialString,
|
|
1371
|
+
'SignedHeaders=' + this.signedHeaders,
|
|
1372
|
+
'Signature=' + (await this.signature()),
|
|
1373
|
+
].join(', ')
|
|
1374
|
+
}
|
|
1375
|
+
async signature() {
|
|
1376
|
+
const date = this.datetime.slice(0, 8);
|
|
1377
|
+
const cacheKey = [this.secretAccessKey, date, this.region, this.service].join();
|
|
1378
|
+
let kCredentials = this.cache.get(cacheKey);
|
|
1379
|
+
if (!kCredentials) {
|
|
1380
|
+
const kDate = await hmac('AWS4' + this.secretAccessKey, date);
|
|
1381
|
+
const kRegion = await hmac(kDate, this.region);
|
|
1382
|
+
const kService = await hmac(kRegion, this.service);
|
|
1383
|
+
kCredentials = await hmac(kService, 'aws4_request');
|
|
1384
|
+
this.cache.set(cacheKey, kCredentials);
|
|
1385
|
+
}
|
|
1386
|
+
return buf2hex(await hmac(kCredentials, await this.stringToSign()))
|
|
1387
|
+
}
|
|
1388
|
+
async stringToSign() {
|
|
1389
|
+
return [
|
|
1390
|
+
'AWS4-HMAC-SHA256',
|
|
1391
|
+
this.datetime,
|
|
1392
|
+
this.credentialString,
|
|
1393
|
+
buf2hex(await hash(await this.canonicalString())),
|
|
1394
|
+
].join('\n')
|
|
1395
|
+
}
|
|
1396
|
+
async canonicalString() {
|
|
1397
|
+
return [
|
|
1398
|
+
this.method.toUpperCase(),
|
|
1399
|
+
this.encodedPath,
|
|
1400
|
+
this.encodedSearch,
|
|
1401
|
+
this.canonicalHeaders + '\n',
|
|
1402
|
+
this.signedHeaders,
|
|
1403
|
+
await this.hexBodyHash(),
|
|
1404
|
+
].join('\n')
|
|
1405
|
+
}
|
|
1406
|
+
async hexBodyHash() {
|
|
1407
|
+
let hashHeader = this.headers.get('X-Amz-Content-Sha256') || (this.service === 's3' && this.signQuery ? 'UNSIGNED-PAYLOAD' : null);
|
|
1408
|
+
if (hashHeader == null) {
|
|
1409
|
+
if (this.body && typeof this.body !== 'string' && !('byteLength' in this.body)) {
|
|
1410
|
+
throw new Error('body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header')
|
|
1411
|
+
}
|
|
1412
|
+
hashHeader = buf2hex(await hash(this.body || ''));
|
|
1413
|
+
}
|
|
1414
|
+
return hashHeader
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
async function hmac(key, string) {
|
|
1418
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
1419
|
+
'raw',
|
|
1420
|
+
typeof key === 'string' ? encoder.encode(key) : key,
|
|
1421
|
+
{ name: 'HMAC', hash: { name: 'SHA-256' } },
|
|
1422
|
+
false,
|
|
1423
|
+
['sign'],
|
|
1424
|
+
);
|
|
1425
|
+
return crypto.subtle.sign('HMAC', cryptoKey, encoder.encode(string))
|
|
1426
|
+
}
|
|
1427
|
+
async function hash(content) {
|
|
1428
|
+
return crypto.subtle.digest('SHA-256', typeof content === 'string' ? encoder.encode(content) : content)
|
|
1429
|
+
}
|
|
1430
|
+
const HEX_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
|
|
1431
|
+
function buf2hex(arrayBuffer) {
|
|
1432
|
+
const buffer = new Uint8Array(arrayBuffer);
|
|
1433
|
+
let out = '';
|
|
1434
|
+
for (let idx = 0; idx < buffer.length; idx++) {
|
|
1435
|
+
const n = buffer[idx];
|
|
1436
|
+
out += HEX_CHARS[(n >>> 4) & 0xF];
|
|
1437
|
+
out += HEX_CHARS[n & 0xF];
|
|
1438
|
+
}
|
|
1439
|
+
return out
|
|
1440
|
+
}
|
|
1441
|
+
function encodeRfc3986(urlEncodedStr) {
|
|
1442
|
+
return urlEncodedStr.replace(/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase())
|
|
1443
|
+
}
|
|
1444
|
+
function guessServiceRegion(url, headers) {
|
|
1445
|
+
const { hostname, pathname } = url;
|
|
1446
|
+
if (hostname.endsWith('.on.aws')) {
|
|
1447
|
+
const match = hostname.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);
|
|
1448
|
+
return match != null ? ['lambda', match[1] || ''] : ['', '']
|
|
1449
|
+
}
|
|
1450
|
+
if (hostname.endsWith('.r2.cloudflarestorage.com')) {
|
|
1451
|
+
return ['s3', 'auto']
|
|
1452
|
+
}
|
|
1453
|
+
if (hostname.endsWith('.backblazeb2.com')) {
|
|
1454
|
+
const match = hostname.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);
|
|
1455
|
+
return match != null ? ['s3', match[1] || ''] : ['', '']
|
|
1456
|
+
}
|
|
1457
|
+
const match = hostname.replace('dualstack.', '').match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/);
|
|
1458
|
+
let service = (match && match[1]) || '';
|
|
1459
|
+
let region = match && match[2];
|
|
1460
|
+
if (region === 'us-gov') {
|
|
1461
|
+
region = 'us-gov-west-1';
|
|
1462
|
+
} else if (region === 's3' || region === 's3-accelerate') {
|
|
1463
|
+
region = 'us-east-1';
|
|
1464
|
+
service = 's3';
|
|
1465
|
+
} else if (service === 'iot') {
|
|
1466
|
+
if (hostname.startsWith('iot.')) {
|
|
1467
|
+
service = 'execute-api';
|
|
1468
|
+
} else if (hostname.startsWith('data.jobs.iot.')) {
|
|
1469
|
+
service = 'iot-jobs-data';
|
|
1470
|
+
} else {
|
|
1471
|
+
service = pathname === '/mqtt' ? 'iotdevicegateway' : 'iotdata';
|
|
1472
|
+
}
|
|
1473
|
+
} else if (service === 'autoscaling') {
|
|
1474
|
+
const targetPrefix = (headers.get('X-Amz-Target') || '').split('.')[0];
|
|
1475
|
+
if (targetPrefix === 'AnyScaleFrontendService') {
|
|
1476
|
+
service = 'application-autoscaling';
|
|
1477
|
+
} else if (targetPrefix === 'AnyScaleScalingPlannerFrontendService') {
|
|
1478
|
+
service = 'autoscaling-plans';
|
|
1479
|
+
}
|
|
1480
|
+
} else if (region == null && service.startsWith('s3-')) {
|
|
1481
|
+
region = service.slice(3).replace(/^fips-|^external-1/, '');
|
|
1482
|
+
service = 's3';
|
|
1483
|
+
} else if (service.endsWith('-fips')) {
|
|
1484
|
+
service = service.slice(0, -5);
|
|
1485
|
+
} else if (region && /-\d$/.test(service) && !/-\d$/.test(region)) {
|
|
1486
|
+
[service, region] = [region, service];
|
|
1487
|
+
}
|
|
1488
|
+
return [HOST_SERVICES[service] || service, region || '']
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
const storage = {
|
|
1492
|
+
storage: {},
|
|
1493
|
+
memory: true,
|
|
1494
|
+
get(key) {
|
|
1495
|
+
let stored;
|
|
1496
|
+
try {
|
|
1497
|
+
stored =
|
|
1498
|
+
(window.localStorage && window.localStorage.getItem(key)) ||
|
|
1499
|
+
this.storage[key];
|
|
1500
|
+
}
|
|
1501
|
+
catch (e) {
|
|
1502
|
+
stored = this.storage[key];
|
|
1503
|
+
}
|
|
1504
|
+
if (stored) {
|
|
1505
|
+
try {
|
|
1506
|
+
return JSON.parse(stored);
|
|
1507
|
+
}
|
|
1508
|
+
catch (e) {
|
|
1509
|
+
return undefined;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
else {
|
|
1513
|
+
return undefined;
|
|
1514
|
+
}
|
|
1515
|
+
},
|
|
1516
|
+
set(key, value) {
|
|
1517
|
+
// handle Safari private mode (setItem is not allowed)
|
|
1518
|
+
const valueToString = JSON.stringify(value);
|
|
1519
|
+
try {
|
|
1520
|
+
window.localStorage.setItem(key, valueToString);
|
|
1521
|
+
}
|
|
1522
|
+
catch (e) {
|
|
1523
|
+
if (!this.memory) {
|
|
1524
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
|
1525
|
+
this.memory = true;
|
|
1526
|
+
}
|
|
1527
|
+
this.storage[key] = value;
|
|
1528
|
+
}
|
|
1529
|
+
},
|
|
1530
|
+
delete(key) {
|
|
1531
|
+
try {
|
|
1532
|
+
window.localStorage.removeItem(key);
|
|
1533
|
+
}
|
|
1534
|
+
catch (e) {
|
|
1535
|
+
if (!this.memory) {
|
|
1536
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
|
1537
|
+
this.memory = true;
|
|
1538
|
+
}
|
|
1539
|
+
delete this.storage[key];
|
|
1540
|
+
}
|
|
1541
|
+
},
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1544
|
+
const COGNITO_KEY = 'TELEMETRY_COGNITO_CREDENTIALS';
|
|
1545
|
+
function getCredentials(IdentityPoolId, options = {}) {
|
|
1546
|
+
const fipsSubdomainSuffix = options.fips === true ? '-fips' : '';
|
|
1547
|
+
const COGNITO_URL = `https://cognito-identity${fipsSubdomainSuffix}.us-east-1.amazonaws.com/`;
|
|
1548
|
+
let cached = storage.get(COGNITO_KEY);
|
|
1549
|
+
if (cached && Date.now() / 1000 < cached.Expiration)
|
|
1550
|
+
return Promise.resolve(cached);
|
|
1551
|
+
const fetchOptions = {
|
|
1552
|
+
method: 'POST',
|
|
1553
|
+
headers: {
|
|
1554
|
+
'Content-type': 'application/x-amz-json-1.1',
|
|
1555
|
+
'X-Amz-Target': 'AWSCognitoIdentityService.GetId',
|
|
1556
|
+
},
|
|
1557
|
+
body: JSON.stringify({ IdentityPoolId }),
|
|
1558
|
+
};
|
|
1559
|
+
return fetch(COGNITO_URL, fetchOptions)
|
|
1560
|
+
.then((response) => {
|
|
1561
|
+
if (!response.ok) {
|
|
1562
|
+
throw new Error(response.statusText);
|
|
1563
|
+
}
|
|
1564
|
+
return response.json();
|
|
1565
|
+
})
|
|
1566
|
+
.then((response) => {
|
|
1567
|
+
const { IdentityId } = response;
|
|
1568
|
+
const options = {
|
|
1569
|
+
method: 'POST',
|
|
1570
|
+
headers: {
|
|
1571
|
+
'Content-type': 'application/x-amz-json-1.1',
|
|
1572
|
+
'X-Amz-Target': 'AWSCognitoIdentityService.GetCredentialsForIdentity',
|
|
1573
|
+
},
|
|
1574
|
+
body: JSON.stringify({ IdentityId }),
|
|
1575
|
+
};
|
|
1576
|
+
return fetch(COGNITO_URL, options);
|
|
1577
|
+
})
|
|
1578
|
+
.then((response) => {
|
|
1579
|
+
if (!response.ok) {
|
|
1580
|
+
throw new Error(response.statusText);
|
|
1581
|
+
}
|
|
1582
|
+
return response.json();
|
|
1583
|
+
})
|
|
1584
|
+
.then(({ Credentials }) => {
|
|
1585
|
+
storage.set(COGNITO_KEY, Credentials);
|
|
1586
|
+
return Credentials;
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
// Shared utilities for plugins
|
|
1591
|
+
const PINPOINT_ENDPOINT_KEY = 'TELEMETRY_PINPOINT_ENDPOINT_ID';
|
|
1592
|
+
const DEFAULT_PINPOINT_REGION = 'us-east-1';
|
|
1593
|
+
const LOG_PREFIX = '[telemetry-amazon]';
|
|
1594
|
+
function isDebugEnabled$1() {
|
|
1595
|
+
var _a;
|
|
1596
|
+
const processEnv = typeof globalThis !== 'undefined'
|
|
1597
|
+
? (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env
|
|
1598
|
+
: undefined;
|
|
1599
|
+
return ((processEnv === null || processEnv === void 0 ? void 0 : processEnv.TELEMETRY_AMAZON_DEBUG) === 'true' ||
|
|
1600
|
+
(processEnv === null || processEnv === void 0 ? void 0 : processEnv.NODE_ENV) === 'development');
|
|
1601
|
+
}
|
|
1602
|
+
function debugLog$1(message, details) {
|
|
1603
|
+
if (!isDebugEnabled$1() || typeof console === 'undefined') {
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
if (details && typeof console.debug === 'function') {
|
|
1607
|
+
console.debug(`${LOG_PREFIX} ${message}`, details);
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
if (typeof console.debug === 'function') {
|
|
1611
|
+
console.debug(`${LOG_PREFIX} ${message}`);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
function warnLog$1(message, details) {
|
|
1615
|
+
if (typeof console === 'undefined' || typeof console.warn !== 'function') {
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
if (details) {
|
|
1619
|
+
console.warn(`${LOG_PREFIX} ${message}`, details);
|
|
1620
|
+
return;
|
|
1621
|
+
}
|
|
1622
|
+
console.warn(`${LOG_PREFIX} ${message}`);
|
|
1623
|
+
}
|
|
1624
|
+
function getEndpointId$1() {
|
|
1625
|
+
const cached = storage.get(PINPOINT_ENDPOINT_KEY);
|
|
1626
|
+
if (cached && typeof cached === 'object' && cached.endpointId) {
|
|
1627
|
+
return cached.endpointId;
|
|
1628
|
+
}
|
|
1629
|
+
if (typeof cached === 'string') {
|
|
1630
|
+
return cached;
|
|
1631
|
+
}
|
|
1632
|
+
const generated = `telemetry-${Date.now()}-${Math.random()
|
|
1633
|
+
.toString(16)
|
|
1634
|
+
.slice(2)}`;
|
|
1635
|
+
storage.set(PINPOINT_ENDPOINT_KEY, { endpointId: generated });
|
|
1636
|
+
return generated;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
function isDebugEnabled() {
|
|
1640
|
+
var _a;
|
|
1641
|
+
const processEnv = typeof globalThis !== 'undefined'
|
|
1642
|
+
? (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env
|
|
1643
|
+
: undefined;
|
|
1644
|
+
return ((processEnv === null || processEnv === void 0 ? void 0 : processEnv.TELEMETRY_AMAZON_DEBUG) === 'true' ||
|
|
1645
|
+
(processEnv === null || processEnv === void 0 ? void 0 : processEnv.NODE_ENV) === 'development');
|
|
1646
|
+
}
|
|
1647
|
+
function debugLog(message, details) {
|
|
1648
|
+
if (!isDebugEnabled() || typeof console === 'undefined') {
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
if (details && typeof console.debug === 'function') {
|
|
1652
|
+
console.debug(`${LOG_PREFIX} ${message}`, details);
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
if (typeof console.debug === 'function') {
|
|
1656
|
+
console.debug(`${LOG_PREFIX} ${message}`);
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
function warnLog(message, details) {
|
|
1660
|
+
if (typeof console === 'undefined' || typeof console.warn !== 'function') {
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
if (details) {
|
|
1664
|
+
console.warn(`${LOG_PREFIX} ${message}`, details);
|
|
1665
|
+
return;
|
|
1666
|
+
}
|
|
1667
|
+
console.warn(`${LOG_PREFIX} ${message}`);
|
|
1668
|
+
}
|
|
1669
|
+
function getEndpointId() {
|
|
1670
|
+
const cached = storage.get(PINPOINT_ENDPOINT_KEY);
|
|
1671
|
+
if (cached && typeof cached === 'object' && cached.endpointId) {
|
|
1672
|
+
return cached.endpointId;
|
|
1673
|
+
}
|
|
1674
|
+
if (typeof cached === 'string') {
|
|
1675
|
+
return cached;
|
|
1676
|
+
}
|
|
1677
|
+
const generated = `telemetry-${Date.now()}-${Math.random()
|
|
1678
|
+
.toString(16)
|
|
1679
|
+
.slice(2)}`;
|
|
1680
|
+
storage.set(PINPOINT_ENDPOINT_KEY, { endpointId: generated });
|
|
1681
|
+
return generated;
|
|
1682
|
+
}
|
|
1683
|
+
function buildEventData(payload) {
|
|
1684
|
+
const Attributes = {};
|
|
1685
|
+
const Metrics = {};
|
|
1686
|
+
Object.entries(payload || {}).forEach(([key, value]) => {
|
|
1687
|
+
if (value === undefined || value === null || key === 'name') {
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
1691
|
+
Metrics[key] = value;
|
|
1692
|
+
return;
|
|
1693
|
+
}
|
|
1694
|
+
if (typeof value === 'string' || typeof value === 'boolean') {
|
|
1695
|
+
Attributes[key] = [String(value)];
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
if (Array.isArray(value)) {
|
|
1699
|
+
Attributes[key] = value.map((item) => String(item));
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
return {
|
|
1703
|
+
Attributes: Object.keys(Attributes).length ? Attributes : undefined,
|
|
1704
|
+
Metrics: Object.keys(Metrics).length ? Metrics : undefined,
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
function createPinpointPlugin({ appName, appVersion, appId, userPoolID, fips, region = DEFAULT_PINPOINT_REGION, }) {
|
|
1708
|
+
debugLog('createPinpointPlugin initialized', {
|
|
1709
|
+
appId,
|
|
1710
|
+
region,
|
|
1711
|
+
fips: Boolean(fips),
|
|
1712
|
+
hasAppName: Boolean(appName),
|
|
1713
|
+
hasAppVersion: Boolean(appVersion),
|
|
1714
|
+
});
|
|
1715
|
+
return {
|
|
1716
|
+
track: (eventName, payload) => {
|
|
1717
|
+
if (!appId || typeof fetch !== 'function') {
|
|
1718
|
+
debugLog('Skipping Pinpoint track call', {
|
|
1719
|
+
eventName,
|
|
1720
|
+
reason: !appId ? 'missing-app-id' : 'fetch-unavailable',
|
|
1721
|
+
});
|
|
1722
|
+
return false;
|
|
1723
|
+
}
|
|
1724
|
+
const endpointId = getEndpointId();
|
|
1725
|
+
const eventId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1726
|
+
const eventData = buildEventData(payload);
|
|
1727
|
+
const host = fips
|
|
1728
|
+
? `pinpoint-fips.${region}.amazonaws.com`
|
|
1729
|
+
: `pinpoint.${region}.amazonaws.com`;
|
|
1730
|
+
const url = `https://${host}/v1/apps/${appId}/events`;
|
|
1731
|
+
debugLog('Sending Pinpoint event', {
|
|
1732
|
+
eventName,
|
|
1733
|
+
endpointId,
|
|
1734
|
+
appId,
|
|
1735
|
+
region,
|
|
1736
|
+
host,
|
|
1737
|
+
});
|
|
1738
|
+
void getCredentials(userPoolID, { fips })
|
|
1739
|
+
.then((credentials) => {
|
|
1740
|
+
const accessKeyId = (credentials === null || credentials === void 0 ? void 0 : credentials.AccessKeyId) || (credentials === null || credentials === void 0 ? void 0 : credentials.accessKeyId);
|
|
1741
|
+
const secretAccessKey = (credentials === null || credentials === void 0 ? void 0 : credentials.SecretKey) || (credentials === null || credentials === void 0 ? void 0 : credentials.secretAccessKey);
|
|
1742
|
+
const sessionToken = (credentials === null || credentials === void 0 ? void 0 : credentials.SessionToken) || (credentials === null || credentials === void 0 ? void 0 : credentials.sessionToken);
|
|
1743
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
1744
|
+
warnLog('Pinpoint credentials missing required key fields', {
|
|
1745
|
+
hasAccessKeyId: Boolean(accessKeyId),
|
|
1746
|
+
hasSecretAccessKey: Boolean(secretAccessKey),
|
|
1747
|
+
});
|
|
1748
|
+
throw new Error('Pinpoint credentials are missing required key fields.');
|
|
1749
|
+
}
|
|
1750
|
+
const client = new AwsClient({
|
|
1751
|
+
accessKeyId,
|
|
1752
|
+
secretAccessKey,
|
|
1753
|
+
sessionToken,
|
|
1754
|
+
service: 'mobiletargeting',
|
|
1755
|
+
region,
|
|
1756
|
+
});
|
|
1757
|
+
return client.fetch(url, {
|
|
1758
|
+
method: 'POST',
|
|
1759
|
+
headers: {
|
|
1760
|
+
'Content-Type': 'application/json',
|
|
1761
|
+
},
|
|
1762
|
+
body: JSON.stringify({
|
|
1763
|
+
BatchItem: {
|
|
1764
|
+
[endpointId]: {
|
|
1765
|
+
Endpoint: {
|
|
1766
|
+
Address: endpointId,
|
|
1767
|
+
ChannelType: 'CUSTOM',
|
|
1768
|
+
Demographic: {
|
|
1769
|
+
AppVersion: appVersion,
|
|
1770
|
+
Make: appName,
|
|
1771
|
+
},
|
|
1772
|
+
},
|
|
1773
|
+
Events: {
|
|
1774
|
+
[eventId]: Object.assign({ EventType: eventName, Timestamp: new Date().toISOString() }, eventData),
|
|
1775
|
+
},
|
|
1776
|
+
},
|
|
1777
|
+
},
|
|
1778
|
+
}),
|
|
1779
|
+
});
|
|
1780
|
+
})
|
|
1781
|
+
.then(() => {
|
|
1782
|
+
debugLog('Pinpoint event sent', {
|
|
1783
|
+
eventName,
|
|
1784
|
+
endpointId,
|
|
1785
|
+
});
|
|
1786
|
+
})
|
|
1787
|
+
.catch((error) => {
|
|
1788
|
+
warnLog('Pinpoint track failed', {
|
|
1789
|
+
eventName,
|
|
1790
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
1791
|
+
});
|
|
1792
|
+
});
|
|
1793
|
+
return true;
|
|
1794
|
+
},
|
|
1795
|
+
};
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
function getString(value, fallback = '') {
|
|
1799
|
+
if (value === undefined || value === null) {
|
|
1800
|
+
return fallback;
|
|
1801
|
+
}
|
|
1802
|
+
return String(value);
|
|
1803
|
+
}
|
|
1804
|
+
function getNumber(value, fallback = 0) {
|
|
1805
|
+
const numeric = Number(value);
|
|
1806
|
+
return Number.isFinite(numeric) ? numeric : fallback;
|
|
1807
|
+
}
|
|
1808
|
+
function splitEventData(payload) {
|
|
1809
|
+
const attributes = {};
|
|
1810
|
+
const metrics = {};
|
|
1811
|
+
const excludedKeys = new Set([
|
|
1812
|
+
'name',
|
|
1813
|
+
'appTitle',
|
|
1814
|
+
'appVersion',
|
|
1815
|
+
'clientSdkVersion',
|
|
1816
|
+
'deviceMake',
|
|
1817
|
+
'deviceModel',
|
|
1818
|
+
'city',
|
|
1819
|
+
'country',
|
|
1820
|
+
'lat',
|
|
1821
|
+
'lon',
|
|
1822
|
+
]);
|
|
1823
|
+
Object.entries(payload || {}).forEach(([key, value]) => {
|
|
1824
|
+
if (excludedKeys.has(key) || value === undefined || value === null) {
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
1828
|
+
metrics[key] = value;
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
if (typeof value === 'string' || typeof value === 'boolean') {
|
|
1832
|
+
attributes[key] = String(value);
|
|
1833
|
+
return;
|
|
1834
|
+
}
|
|
1835
|
+
if (Array.isArray(value) || typeof value === 'object') {
|
|
1836
|
+
attributes[key] = JSON.stringify(value);
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
return {
|
|
1840
|
+
attributes,
|
|
1841
|
+
metrics,
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1844
|
+
function buildBatchEventPayload({ eventName, payload, trackerName, appName, appVersion, }) {
|
|
1845
|
+
const endpointId = getEndpointId$1();
|
|
1846
|
+
const sessionId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1847
|
+
const timestamp = new Date().toISOString();
|
|
1848
|
+
const { attributes, metrics } = splitEventData(payload);
|
|
1849
|
+
return {
|
|
1850
|
+
BatchEvent: {
|
|
1851
|
+
Endpoint: {
|
|
1852
|
+
Id: endpointId,
|
|
1853
|
+
Device: {
|
|
1854
|
+
Make: getString(payload === null || payload === void 0 ? void 0 : payload.deviceMake),
|
|
1855
|
+
Model: getString(payload === null || payload === void 0 ? void 0 : payload.deviceModel),
|
|
1856
|
+
},
|
|
1857
|
+
Location: {
|
|
1858
|
+
City: getString(payload === null || payload === void 0 ? void 0 : payload.city),
|
|
1859
|
+
Country: getString(payload === null || payload === void 0 ? void 0 : payload.country),
|
|
1860
|
+
Lat: getNumber(payload === null || payload === void 0 ? void 0 : payload.lat),
|
|
1861
|
+
Lon: getNumber(payload === null || payload === void 0 ? void 0 : payload.lon),
|
|
1862
|
+
},
|
|
1863
|
+
Application: {
|
|
1864
|
+
AppTitle: getString(payload === null || payload === void 0 ? void 0 : payload.appTitle, appName || trackerName),
|
|
1865
|
+
AppVersion: getString(payload === null || payload === void 0 ? void 0 : payload.appVersion, appVersion),
|
|
1866
|
+
ClientSdkVersion: getString(payload === null || payload === void 0 ? void 0 : payload.clientSdkVersion, trackerName),
|
|
1867
|
+
},
|
|
1868
|
+
},
|
|
1869
|
+
Events: [
|
|
1870
|
+
{
|
|
1871
|
+
EventType: eventName,
|
|
1872
|
+
Timestamp: timestamp,
|
|
1873
|
+
Session: {
|
|
1874
|
+
Id: sessionId,
|
|
1875
|
+
StartTimestamp: timestamp,
|
|
1876
|
+
EndTimestamp: timestamp,
|
|
1877
|
+
Duration: 0,
|
|
1878
|
+
},
|
|
1879
|
+
Attributes: attributes,
|
|
1880
|
+
Metrics: metrics,
|
|
1881
|
+
},
|
|
1882
|
+
],
|
|
1883
|
+
},
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
function createEsriPlugin({ url, headers = {}, trackerName, appName, appVersion, }) {
|
|
1887
|
+
debugLog$1('createEsriPlugin initialized', {
|
|
1888
|
+
trackerName,
|
|
1889
|
+
hasUrl: Boolean(url),
|
|
1890
|
+
headerCount: Object.keys(headers).length,
|
|
1891
|
+
});
|
|
1892
|
+
return {
|
|
1893
|
+
track: (eventName, payload) => {
|
|
1894
|
+
if (!url || typeof fetch !== 'function') {
|
|
1895
|
+
debugLog$1('Skipping endpoint track call', {
|
|
1896
|
+
eventName,
|
|
1897
|
+
reason: !url ? 'missing-url' : 'fetch-unavailable',
|
|
1898
|
+
});
|
|
1899
|
+
return false;
|
|
1900
|
+
}
|
|
1901
|
+
debugLog$1('Sending endpoint event', {
|
|
1902
|
+
eventName,
|
|
1903
|
+
trackerName,
|
|
1904
|
+
url,
|
|
1905
|
+
});
|
|
1906
|
+
void fetch(url, {
|
|
1907
|
+
method: 'POST',
|
|
1908
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, headers),
|
|
1909
|
+
body: JSON.stringify(buildBatchEventPayload({
|
|
1910
|
+
eventName,
|
|
1911
|
+
payload,
|
|
1912
|
+
trackerName,
|
|
1913
|
+
appName,
|
|
1914
|
+
appVersion,
|
|
1915
|
+
})),
|
|
1916
|
+
})
|
|
1917
|
+
.then(() => {
|
|
1918
|
+
debugLog$1('Endpoint event sent', {
|
|
1919
|
+
eventName,
|
|
1920
|
+
trackerName,
|
|
1921
|
+
});
|
|
1922
|
+
})
|
|
1923
|
+
.catch((error) => {
|
|
1924
|
+
warnLog$1('Endpoint track failed', {
|
|
1925
|
+
eventName,
|
|
1926
|
+
trackerName,
|
|
1927
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
1928
|
+
});
|
|
1929
|
+
});
|
|
1930
|
+
return true;
|
|
1931
|
+
},
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
|
|
1379
1935
|
/**
|
|
1380
1936
|
* Amazon Telemetry
|
|
1381
|
-
* Supports
|
|
1937
|
+
* Supports Pinpoint and Esri endpoint modes
|
|
1382
1938
|
*/
|
|
1383
1939
|
class Amazon {
|
|
1384
1940
|
constructor(options) {
|
|
1385
1941
|
this.name = 'amazon';
|
|
1942
|
+
this.previousPage = {};
|
|
1386
1943
|
this.isInitialized = false;
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1944
|
+
this.mode = 'pinpoint';
|
|
1945
|
+
const { app = {}, endpoint = {}, fips, userPoolID, mode = 'pinpoint', } = options;
|
|
1946
|
+
const { url = 'https://bh1xqvcevk.execute-api.us-east-1.amazonaws.com/akira/v1/apps/1e9a61d8a1e74aa5a6faa9112fd63d70/events', headers = {}, } = endpoint;
|
|
1947
|
+
this.mode = mode;
|
|
1948
|
+
if (this.mode === 'pinpoint') {
|
|
1949
|
+
this.analytics = createPinpointPlugin({
|
|
1950
|
+
appName: app.name,
|
|
1951
|
+
appVersion: app.version,
|
|
1952
|
+
appId: app.id,
|
|
1953
|
+
userPoolID,
|
|
1954
|
+
fips,
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
else {
|
|
1958
|
+
this.analytics = createEsriPlugin({
|
|
1959
|
+
url,
|
|
1960
|
+
headers,
|
|
1961
|
+
trackerName: this.name,
|
|
1962
|
+
appName: app.name,
|
|
1963
|
+
appVersion: app.version,
|
|
1964
|
+
});
|
|
1965
|
+
}
|
|
1401
1966
|
Object.assign(this, options);
|
|
1402
1967
|
}
|
|
1403
1968
|
init() {
|
|
@@ -1429,7 +1994,7 @@
|
|
|
1429
1994
|
});
|
|
1430
1995
|
const { pageUrl, pageName } = telemetryPayload;
|
|
1431
1996
|
this.previousPage = { pageUrl, pageName };
|
|
1432
|
-
this.analytics.track('pageView', telemetryPayload);
|
|
1997
|
+
return this.analytics.track('pageView', telemetryPayload);
|
|
1433
1998
|
}
|
|
1434
1999
|
logEvent(event = {}) {
|
|
1435
2000
|
const telemetryPayload = createEventLog({
|
|
@@ -1438,7 +2003,7 @@
|
|
|
1438
2003
|
metricLookup: this.metrics,
|
|
1439
2004
|
});
|
|
1440
2005
|
const { name } = telemetryPayload;
|
|
1441
|
-
this.analytics.track(name, telemetryPayload);
|
|
2006
|
+
return this.analytics.track(name, telemetryPayload);
|
|
1442
2007
|
}
|
|
1443
2008
|
}
|
|
1444
2009
|
|