@esri/telemetry-amazon 6.0.0-beta.1 → 6.0.0-beta.3
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 +7 -7
- package/dist/esm/index.js +22 -14
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.test.js +46 -19
- package/dist/esm/index.test.js.map +1 -1
- package/dist/esm/plugins/esri.js +77 -30
- package/dist/esm/plugins/esri.js.map +1 -1
- package/dist/esm/plugins/esri.test.js +80 -13
- package/dist/esm/plugins/esri.test.js.map +1 -1
- package/dist/node/index.js +23 -14
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.test.js +47 -19
- package/dist/node/index.test.js.map +1 -1
- package/dist/node/plugins/esri.js +77 -30
- package/dist/node/plugins/esri.js.map +1 -1
- package/dist/node/plugins/esri.test.js +80 -13
- package/dist/node/plugins/esri.test.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/plugins/esri.d.ts +4 -3
- package/dist/types/types.d.ts +13 -9
- package/dist/umd/telemetry-amazon.js +280 -309
- package/dist/umd/telemetry-amazon.js.map +1 -1
- package/dist/umd/telemetry-amazon.min.js +280 -309
- package/dist/umd/telemetry-amazon.min.js.map +1 -1
- package/package.json +3 -1
- package/dist/esm/plugins/pinpoint.js +0 -163
- package/dist/esm/plugins/pinpoint.js.map +0 -1
- package/dist/node/plugins/pinpoint.js +0 -167
- package/dist/node/plugins/pinpoint.js.map +0 -1
- package/dist/types/plugins/pinpoint.d.ts +0 -11
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
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';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@analytics/aws-pinpoint')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@analytics/aws-pinpoint'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisTelemetry = global.arcgisTelemetry || {}, global.analyticsAWSPinpoint));
|
|
5
|
+
})(this, (function (exports, awsPinpointPlugin) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var awsPinpointPlugin__default = /*#__PURE__*/_interopDefaultLegacy(awsPinpointPlugin);
|
|
6
10
|
|
|
7
11
|
function formatTelemetryAttributes({ telemetryData, dimensionLookup = {}, excludeKeys = [], }) {
|
|
8
12
|
return Object.keys(telemetryData)
|
|
@@ -109,6 +113,181 @@
|
|
|
109
113
|
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);
|
|
110
114
|
}
|
|
111
115
|
|
|
116
|
+
var dlv_umd = {exports: {}};
|
|
117
|
+
|
|
118
|
+
(function (module, exports) {
|
|
119
|
+
!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};}();
|
|
120
|
+
|
|
121
|
+
}(dlv_umd));
|
|
122
|
+
|
|
123
|
+
var i$6 = dlv_umd.exports;
|
|
124
|
+
|
|
125
|
+
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);
|
|
126
|
+
|
|
127
|
+
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}
|
|
128
|
+
|
|
129
|
+
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);
|
|
130
|
+
|
|
131
|
+
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}
|
|
132
|
+
|
|
133
|
+
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);
|
|
134
|
+
|
|
135
|
+
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";
|
|
136
|
+
|
|
137
|
+
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])}}
|
|
138
|
+
|
|
139
|
+
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);
|
|
140
|
+
|
|
141
|
+
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);
|
|
142
|
+
|
|
143
|
+
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);
|
|
144
|
+
|
|
145
|
+
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};
|
|
146
|
+
|
|
147
|
+
function _defineProperty(obj, key, value) {
|
|
148
|
+
if (key in obj) {
|
|
149
|
+
Object.defineProperty(obj, key, {
|
|
150
|
+
value: value,
|
|
151
|
+
enumerable: true,
|
|
152
|
+
configurable: true,
|
|
153
|
+
writable: true
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
obj[key] = value;
|
|
157
|
+
}
|
|
158
|
+
return obj;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function ownKeys(object, enumerableOnly) {
|
|
162
|
+
var keys = Object.keys(object);
|
|
163
|
+
if (Object.getOwnPropertySymbols) {
|
|
164
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
165
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
166
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
167
|
+
})), keys.push.apply(keys, symbols);
|
|
168
|
+
}
|
|
169
|
+
return keys;
|
|
170
|
+
}
|
|
171
|
+
function _objectSpread2(target) {
|
|
172
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
173
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
174
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
175
|
+
_defineProperty(target, key, source[key]);
|
|
176
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
177
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return target;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// See ../packages/analytics-core for source code
|
|
184
|
+
function analyticsLib() {
|
|
185
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
186
|
+
var defaultSettings = {
|
|
187
|
+
storage: J
|
|
188
|
+
};
|
|
189
|
+
return De(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const storage = {
|
|
193
|
+
storage: {},
|
|
194
|
+
memory: true,
|
|
195
|
+
get(key) {
|
|
196
|
+
let stored;
|
|
197
|
+
try {
|
|
198
|
+
stored =
|
|
199
|
+
(window.localStorage && window.localStorage.getItem(key)) ||
|
|
200
|
+
this.storage[key];
|
|
201
|
+
}
|
|
202
|
+
catch (e) {
|
|
203
|
+
stored = this.storage[key];
|
|
204
|
+
}
|
|
205
|
+
if (stored) {
|
|
206
|
+
try {
|
|
207
|
+
return JSON.parse(stored);
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
set(key, value) {
|
|
218
|
+
// handle Safari private mode (setItem is not allowed)
|
|
219
|
+
const valueToString = JSON.stringify(value);
|
|
220
|
+
try {
|
|
221
|
+
window.localStorage.setItem(key, valueToString);
|
|
222
|
+
}
|
|
223
|
+
catch (e) {
|
|
224
|
+
if (!this.memory) {
|
|
225
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
|
226
|
+
this.memory = true;
|
|
227
|
+
}
|
|
228
|
+
this.storage[key] = value;
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
delete(key) {
|
|
232
|
+
try {
|
|
233
|
+
window.localStorage.removeItem(key);
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
if (!this.memory) {
|
|
237
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
|
238
|
+
this.memory = true;
|
|
239
|
+
}
|
|
240
|
+
delete this.storage[key];
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const COGNITO_KEY = 'TELEMETRY_COGNITO_CREDENTIALS';
|
|
246
|
+
function getCredentials(IdentityPoolId, options = {}) {
|
|
247
|
+
const fipsSubdomainSuffix = options.fips === true ? '-fips' : '';
|
|
248
|
+
const COGNITO_URL = `https://cognito-identity${fipsSubdomainSuffix}.us-east-1.amazonaws.com/`;
|
|
249
|
+
let cached = storage.get(COGNITO_KEY);
|
|
250
|
+
if (cached && Date.now() / 1000 < cached.Expiration)
|
|
251
|
+
return Promise.resolve(cached);
|
|
252
|
+
const fetchOptions = {
|
|
253
|
+
method: 'POST',
|
|
254
|
+
headers: {
|
|
255
|
+
'Content-type': 'application/x-amz-json-1.1',
|
|
256
|
+
'X-Amz-Target': 'AWSCognitoIdentityService.GetId',
|
|
257
|
+
},
|
|
258
|
+
body: JSON.stringify({ IdentityPoolId }),
|
|
259
|
+
};
|
|
260
|
+
return fetch(COGNITO_URL, fetchOptions)
|
|
261
|
+
.then((response) => {
|
|
262
|
+
if (!response.ok) {
|
|
263
|
+
throw new Error(response.statusText);
|
|
264
|
+
}
|
|
265
|
+
return response.json();
|
|
266
|
+
})
|
|
267
|
+
.then((response) => {
|
|
268
|
+
const { IdentityId } = response;
|
|
269
|
+
const options = {
|
|
270
|
+
method: 'POST',
|
|
271
|
+
headers: {
|
|
272
|
+
'Content-type': 'application/x-amz-json-1.1',
|
|
273
|
+
'X-Amz-Target': 'AWSCognitoIdentityService.GetCredentialsForIdentity',
|
|
274
|
+
},
|
|
275
|
+
body: JSON.stringify({ IdentityId }),
|
|
276
|
+
};
|
|
277
|
+
return fetch(COGNITO_URL, options);
|
|
278
|
+
})
|
|
279
|
+
.then((response) => {
|
|
280
|
+
if (!response.ok) {
|
|
281
|
+
throw new Error(response.statusText);
|
|
282
|
+
}
|
|
283
|
+
return response.json();
|
|
284
|
+
})
|
|
285
|
+
.then(({ Credentials }) => {
|
|
286
|
+
storage.set(COGNITO_KEY, Credentials);
|
|
287
|
+
return Credentials;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
112
291
|
/******************************************************************************
|
|
113
292
|
Copyright (c) Microsoft Corporation.
|
|
114
293
|
|
|
@@ -1488,154 +1667,9 @@
|
|
|
1488
1667
|
return [HOST_SERVICES[service] || service, region || '']
|
|
1489
1668
|
}
|
|
1490
1669
|
|
|
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
1670
|
// Shared utilities for plugins
|
|
1591
1671
|
const PINPOINT_ENDPOINT_KEY = 'TELEMETRY_PINPOINT_ENDPOINT_ID';
|
|
1592
|
-
const DEFAULT_PINPOINT_REGION = 'us-east-1';
|
|
1593
1672
|
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
1673
|
function isDebugEnabled() {
|
|
1640
1674
|
var _a;
|
|
1641
1675
|
const processEnv = typeof globalThis !== 'undefined'
|
|
@@ -1680,127 +1714,11 @@
|
|
|
1680
1714
|
storage.set(PINPOINT_ENDPOINT_KEY, { endpointId: generated });
|
|
1681
1715
|
return generated;
|
|
1682
1716
|
}
|
|
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
1717
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
return String(value);
|
|
1803
|
-
}
|
|
1718
|
+
const ESRI_SIGNING_SERVICE = 'execute-api';
|
|
1719
|
+
const ESRI_SIGNING_REGION = 'us-east-1';
|
|
1720
|
+
const ESRI_ENDPOINT_URL = (appId) => `https://tedev.arcgis.com/v1/apps/${appId}/events`;
|
|
1721
|
+
/** Converts a string to a number, guarded against invalid values */
|
|
1804
1722
|
function getNumber(value, fallback = 0) {
|
|
1805
1723
|
const numeric = Number(value);
|
|
1806
1724
|
return Number.isFinite(numeric) ? numeric : fallback;
|
|
@@ -1842,7 +1760,8 @@
|
|
|
1842
1760
|
};
|
|
1843
1761
|
}
|
|
1844
1762
|
function buildBatchEventPayload({ eventName, payload, trackerName, appName, appVersion, }) {
|
|
1845
|
-
|
|
1763
|
+
var _a, _b, _c, _d;
|
|
1764
|
+
const endpointId = getEndpointId();
|
|
1846
1765
|
const sessionId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1847
1766
|
const timestamp = new Date().toISOString();
|
|
1848
1767
|
const { attributes, metrics } = splitEventData(payload);
|
|
@@ -1851,19 +1770,19 @@
|
|
|
1851
1770
|
Endpoint: {
|
|
1852
1771
|
Id: endpointId,
|
|
1853
1772
|
Device: {
|
|
1854
|
-
Make:
|
|
1855
|
-
Model:
|
|
1773
|
+
Make: (payload === null || payload === void 0 ? void 0 : payload.deviceMake) || '',
|
|
1774
|
+
Model: (payload === null || payload === void 0 ? void 0 : payload.deviceModel) || '',
|
|
1856
1775
|
},
|
|
1857
1776
|
Location: {
|
|
1858
|
-
City:
|
|
1859
|
-
Country:
|
|
1777
|
+
City: (payload === null || payload === void 0 ? void 0 : payload.city) || '',
|
|
1778
|
+
Country: (payload === null || payload === void 0 ? void 0 : payload.country) || '',
|
|
1860
1779
|
Lat: getNumber(payload === null || payload === void 0 ? void 0 : payload.lat),
|
|
1861
1780
|
Lon: getNumber(payload === null || payload === void 0 ? void 0 : payload.lon),
|
|
1862
1781
|
},
|
|
1863
1782
|
Application: {
|
|
1864
|
-
AppTitle:
|
|
1865
|
-
AppVersion:
|
|
1866
|
-
ClientSdkVersion:
|
|
1783
|
+
AppTitle: (_b = (_a = payload === null || payload === void 0 ? void 0 : payload.appTitle) !== null && _a !== void 0 ? _a : appName) !== null && _b !== void 0 ? _b : trackerName,
|
|
1784
|
+
AppVersion: (_c = payload === null || payload === void 0 ? void 0 : payload.appVersion) !== null && _c !== void 0 ? _c : appVersion,
|
|
1785
|
+
ClientSdkVersion: (_d = payload === null || payload === void 0 ? void 0 : payload.clientSdkVersion) !== null && _d !== void 0 ? _d : trackerName,
|
|
1867
1786
|
},
|
|
1868
1787
|
},
|
|
1869
1788
|
Events: [
|
|
@@ -1883,45 +1802,91 @@
|
|
|
1883
1802
|
},
|
|
1884
1803
|
};
|
|
1885
1804
|
}
|
|
1886
|
-
function createEsriPlugin({
|
|
1887
|
-
|
|
1805
|
+
function createEsriPlugin({ trackerName, appName, appId, appVersion, userPoolID, fips, }) {
|
|
1806
|
+
const url = ESRI_ENDPOINT_URL(appId);
|
|
1807
|
+
let isDisabled = false;
|
|
1808
|
+
let hasWarned = false;
|
|
1809
|
+
const warnOnce = (message, details) => {
|
|
1810
|
+
if (hasWarned) {
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
hasWarned = true;
|
|
1814
|
+
warnLog(message, details);
|
|
1815
|
+
};
|
|
1816
|
+
debugLog('createEsriPlugin initialized', {
|
|
1888
1817
|
trackerName,
|
|
1889
1818
|
hasUrl: Boolean(url),
|
|
1890
|
-
headerCount: Object.keys(headers).length,
|
|
1891
1819
|
});
|
|
1820
|
+
if (!url) {
|
|
1821
|
+
isDisabled = true;
|
|
1822
|
+
warnOnce('Esri telemetry disabled due to missing internal endpoint URL', {
|
|
1823
|
+
trackerName,
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
if (!userPoolID) {
|
|
1827
|
+
isDisabled = true;
|
|
1828
|
+
warnOnce('Esri telemetry disabled due to missing userPoolID', {
|
|
1829
|
+
trackerName,
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
if (typeof fetch !== 'function') {
|
|
1833
|
+
isDisabled = true;
|
|
1834
|
+
warnOnce('Esri telemetry disabled because fetch is unavailable', {
|
|
1835
|
+
trackerName,
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1892
1838
|
return {
|
|
1893
1839
|
track: (eventName, payload) => {
|
|
1894
|
-
if (!url ||
|
|
1895
|
-
debugLog
|
|
1840
|
+
if (isDisabled || !url || !userPoolID) {
|
|
1841
|
+
debugLog('Skipping esri track call', {
|
|
1896
1842
|
eventName,
|
|
1897
|
-
reason:
|
|
1843
|
+
reason: 'plugin-disabled',
|
|
1898
1844
|
});
|
|
1899
1845
|
return false;
|
|
1900
1846
|
}
|
|
1901
|
-
debugLog
|
|
1847
|
+
debugLog('Sending esri endpoint event', {
|
|
1902
1848
|
eventName,
|
|
1903
1849
|
trackerName,
|
|
1904
1850
|
url,
|
|
1905
1851
|
});
|
|
1906
|
-
void
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1852
|
+
void getCredentials(userPoolID, { fips })
|
|
1853
|
+
.then((credentials) => {
|
|
1854
|
+
const accessKeyId = (credentials === null || credentials === void 0 ? void 0 : credentials.AccessKeyId) || (credentials === null || credentials === void 0 ? void 0 : credentials.accessKeyId);
|
|
1855
|
+
const secretAccessKey = (credentials === null || credentials === void 0 ? void 0 : credentials.SecretKey) || (credentials === null || credentials === void 0 ? void 0 : credentials.secretAccessKey);
|
|
1856
|
+
const sessionToken = (credentials === null || credentials === void 0 ? void 0 : credentials.SessionToken) || (credentials === null || credentials === void 0 ? void 0 : credentials.sessionToken);
|
|
1857
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
1858
|
+
throw new Error('Signed endpoint credentials are missing required key fields.');
|
|
1859
|
+
}
|
|
1860
|
+
const client = new AwsClient({
|
|
1861
|
+
accessKeyId,
|
|
1862
|
+
secretAccessKey,
|
|
1863
|
+
sessionToken,
|
|
1864
|
+
service: ESRI_SIGNING_SERVICE,
|
|
1865
|
+
region: ESRI_SIGNING_REGION,
|
|
1866
|
+
});
|
|
1867
|
+
return client.fetch(url, {
|
|
1868
|
+
method: 'POST',
|
|
1869
|
+
headers: {
|
|
1870
|
+
'Content-Type': 'application/json',
|
|
1871
|
+
},
|
|
1872
|
+
body: JSON.stringify(buildBatchEventPayload({
|
|
1873
|
+
eventName,
|
|
1874
|
+
payload: payload,
|
|
1875
|
+
trackerName,
|
|
1876
|
+
appName,
|
|
1877
|
+
appVersion,
|
|
1878
|
+
})),
|
|
1879
|
+
});
|
|
1916
1880
|
})
|
|
1917
1881
|
.then(() => {
|
|
1918
|
-
debugLog
|
|
1882
|
+
debugLog('Endpoint event sent', {
|
|
1919
1883
|
eventName,
|
|
1920
1884
|
trackerName,
|
|
1921
1885
|
});
|
|
1922
1886
|
})
|
|
1923
1887
|
.catch((error) => {
|
|
1924
|
-
|
|
1888
|
+
isDisabled = true;
|
|
1889
|
+
warnOnce('Esri telemetry disabled after endpoint track failure', {
|
|
1925
1890
|
eventName,
|
|
1926
1891
|
trackerName,
|
|
1927
1892
|
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
@@ -1941,26 +1906,30 @@
|
|
|
1941
1906
|
this.name = 'amazon';
|
|
1942
1907
|
this.previousPage = {};
|
|
1943
1908
|
this.isInitialized = false;
|
|
1944
|
-
|
|
1945
|
-
const { app = {},
|
|
1946
|
-
const { url = 'https://bh1xqvcevk.execute-api.us-east-1.amazonaws.com/akira/v1/apps/1e9a61d8a1e74aa5a6faa9112fd63d70/events', headers = {}, } = endpoint;
|
|
1909
|
+
// default to `esri` mode if not specified
|
|
1910
|
+
const { app = {}, fips, userPoolID, mode = 'esri' } = options;
|
|
1947
1911
|
this.mode = mode;
|
|
1948
1912
|
if (this.mode === 'pinpoint') {
|
|
1949
|
-
this.analytics =
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1913
|
+
this.analytics = analyticsLib({
|
|
1914
|
+
app: app.name,
|
|
1915
|
+
version: app.version,
|
|
1916
|
+
plugins: [
|
|
1917
|
+
awsPinpointPlugin__default["default"]({
|
|
1918
|
+
fips,
|
|
1919
|
+
pinpointAppId: app.id,
|
|
1920
|
+
getCredentials: () => getCredentials(userPoolID, { fips }),
|
|
1921
|
+
}),
|
|
1922
|
+
],
|
|
1955
1923
|
});
|
|
1956
1924
|
}
|
|
1957
1925
|
else {
|
|
1958
1926
|
this.analytics = createEsriPlugin({
|
|
1959
|
-
url,
|
|
1960
|
-
headers,
|
|
1961
1927
|
trackerName: this.name,
|
|
1962
1928
|
appName: app.name,
|
|
1963
1929
|
appVersion: app.version,
|
|
1930
|
+
appId: app.id,
|
|
1931
|
+
userPoolID,
|
|
1932
|
+
fips,
|
|
1964
1933
|
});
|
|
1965
1934
|
}
|
|
1966
1935
|
Object.assign(this, options);
|
|
@@ -1994,7 +1963,8 @@
|
|
|
1994
1963
|
});
|
|
1995
1964
|
const { pageUrl, pageName } = telemetryPayload;
|
|
1996
1965
|
this.previousPage = { pageUrl, pageName };
|
|
1997
|
-
|
|
1966
|
+
const result = this.analytics.track('pageView', telemetryPayload);
|
|
1967
|
+
return typeof result === 'boolean' ? result : true;
|
|
1998
1968
|
}
|
|
1999
1969
|
logEvent(event = {}) {
|
|
2000
1970
|
const telemetryPayload = createEventLog({
|
|
@@ -2003,7 +1973,8 @@
|
|
|
2003
1973
|
metricLookup: this.metrics,
|
|
2004
1974
|
});
|
|
2005
1975
|
const { name } = telemetryPayload;
|
|
2006
|
-
|
|
1976
|
+
const result = this.analytics.track(name, telemetryPayload);
|
|
1977
|
+
return typeof result === 'boolean' ? result : true;
|
|
2007
1978
|
}
|
|
2008
1979
|
}
|
|
2009
1980
|
|