@esri/telemetry-amazon 6.0.0-beta.1 → 6.0.0-beta.10
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/auth.js +22 -31
- package/dist/esm/auth.js.map +1 -1
- package/dist/esm/create-event-log.js +15 -15
- package/dist/esm/create-event-log.js.map +1 -1
- package/dist/esm/create-event-log.test.js +50 -8
- package/dist/esm/create-event-log.test.js.map +1 -1
- package/dist/esm/create-page-view-log.js +0 -5
- package/dist/esm/create-page-view-log.js.map +1 -1
- package/dist/esm/format-telemetry-attributes.js +8 -4
- package/dist/esm/format-telemetry-attributes.js.map +1 -1
- package/dist/esm/index.js +41 -25
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.test.js +90 -16
- package/dist/esm/index.test.js.map +1 -1
- package/dist/esm/plugins/esri.js +346 -65
- package/dist/esm/plugins/esri.js.map +1 -1
- package/dist/esm/plugins/esri.test.js +498 -36
- package/dist/esm/plugins/esri.test.js.map +1 -1
- package/dist/esm/plugins/utils/browser.js +97 -0
- package/dist/esm/plugins/utils/browser.js.map +1 -0
- package/dist/esm/plugins/utils/browser.test.js +130 -0
- package/dist/esm/plugins/utils/browser.test.js.map +1 -0
- package/dist/esm/plugins/utils/os.js +140 -0
- package/dist/esm/plugins/utils/os.js.map +1 -0
- package/dist/esm/plugins/utils/os.test.js +54 -0
- package/dist/esm/plugins/utils/os.test.js.map +1 -0
- package/dist/esm/plugins/{shared.js → utils/shared.js} +1 -1
- package/dist/esm/plugins/utils/shared.js.map +1 -0
- package/dist/esm/types.js +97 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/node/auth.js +22 -31
- package/dist/node/auth.js.map +1 -1
- package/dist/node/create-event-log.js +15 -15
- package/dist/node/create-event-log.js.map +1 -1
- package/dist/node/create-event-log.test.js +50 -8
- package/dist/node/create-event-log.test.js.map +1 -1
- package/dist/node/create-page-view-log.js +0 -5
- package/dist/node/create-page-view-log.js.map +1 -1
- package/dist/node/format-telemetry-attributes.js +8 -4
- package/dist/node/format-telemetry-attributes.js.map +1 -1
- package/dist/node/index.js +42 -25
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.test.js +91 -16
- package/dist/node/index.test.js.map +1 -1
- package/dist/node/plugins/esri.js +346 -65
- package/dist/node/plugins/esri.js.map +1 -1
- package/dist/node/plugins/esri.test.js +499 -36
- package/dist/node/plugins/esri.test.js.map +1 -1
- package/dist/node/plugins/utils/browser.js +101 -0
- package/dist/node/plugins/utils/browser.js.map +1 -0
- package/dist/node/plugins/utils/browser.test.js +132 -0
- package/dist/node/plugins/utils/browser.test.js.map +1 -0
- package/dist/node/plugins/utils/os.js +144 -0
- package/dist/node/plugins/utils/os.js.map +1 -0
- package/dist/node/plugins/utils/os.test.js +56 -0
- package/dist/node/plugins/utils/os.test.js.map +1 -0
- package/dist/node/plugins/{shared.js → utils/shared.js} +3 -2
- package/dist/node/plugins/utils/shared.js.map +1 -0
- package/dist/node/types.js +98 -0
- package/dist/node/types.js.map +1 -1
- package/dist/types/create-event-log.d.ts +2 -2
- package/dist/types/format-telemetry-attributes.d.ts +3 -3
- package/dist/types/index.d.ts +7 -3
- package/dist/types/plugins/esri.d.ts +5 -9
- package/dist/types/plugins/utils/browser.d.ts +12 -0
- package/dist/types/plugins/utils/browser.test.d.ts +1 -0
- package/dist/types/plugins/utils/os.d.ts +5 -0
- package/dist/types/plugins/utils/os.test.d.ts +1 -0
- package/dist/types/plugins/{shared.d.ts → utils/shared.d.ts} +1 -0
- package/dist/types/types.d.ts +108 -18
- package/dist/umd/telemetry-amazon.js +915 -368
- package/dist/umd/telemetry-amazon.js.map +1 -1
- package/dist/umd/telemetry-amazon.min.js +915 -368
- package/dist/umd/telemetry-amazon.min.js.map +1 -1
- package/package.json +4 -2
- package/dist/esm/plugins/pinpoint.js +0 -163
- package/dist/esm/plugins/pinpoint.js.map +0 -1
- package/dist/esm/plugins/shared.js.map +0 -1
- package/dist/node/plugins/pinpoint.js +0 -167
- package/dist/node/plugins/pinpoint.js.map +0 -1
- package/dist/node/plugins/shared.js.map +0 -1
- package/dist/types/plugins/pinpoint.d.ts +0 -11
|
@@ -1,19 +1,93 @@
|
|
|
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
6
|
|
|
7
|
-
function
|
|
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 AMAZON_EVENT_ATTRIBUTE_KEYS = [
|
|
12
|
+
'action',
|
|
13
|
+
'attribute',
|
|
14
|
+
'category',
|
|
15
|
+
'datasetId',
|
|
16
|
+
'details',
|
|
17
|
+
'error',
|
|
18
|
+
'facetValue',
|
|
19
|
+
'hostname',
|
|
20
|
+
'json',
|
|
21
|
+
'label',
|
|
22
|
+
'lastLogin',
|
|
23
|
+
'objectId',
|
|
24
|
+
'org',
|
|
25
|
+
'pageUrl',
|
|
26
|
+
'path',
|
|
27
|
+
'pageName',
|
|
28
|
+
'previousPageName',
|
|
29
|
+
'previousPageUrl',
|
|
30
|
+
'referrer',
|
|
31
|
+
'searchQuery',
|
|
32
|
+
'serviceQuery',
|
|
33
|
+
'statusCode',
|
|
34
|
+
'user',
|
|
35
|
+
'userSince',
|
|
36
|
+
'urlRequested',
|
|
37
|
+
'internalUser',
|
|
38
|
+
'accountType',
|
|
39
|
+
'workflowId',
|
|
40
|
+
'browserWebCapabilities',
|
|
41
|
+
/**
|
|
42
|
+
* Original plan was to union this in as `AmazonDimensionKey`, but it's strictly defined in the schema that there are 20 dimensions
|
|
43
|
+
* so a little non-DRY is fine for readability's sake
|
|
44
|
+
*/
|
|
45
|
+
'dimension1',
|
|
46
|
+
'dimension2',
|
|
47
|
+
'dimension3',
|
|
48
|
+
'dimension4',
|
|
49
|
+
'dimension5',
|
|
50
|
+
'dimension6',
|
|
51
|
+
'dimension7',
|
|
52
|
+
'dimension8',
|
|
53
|
+
'dimension9',
|
|
54
|
+
'dimension10',
|
|
55
|
+
'dimension11',
|
|
56
|
+
'dimension12',
|
|
57
|
+
'dimension13',
|
|
58
|
+
'dimension14',
|
|
59
|
+
'dimension15',
|
|
60
|
+
'dimension16',
|
|
61
|
+
'dimension17',
|
|
62
|
+
'dimension18',
|
|
63
|
+
'dimension19',
|
|
64
|
+
'dimension20',
|
|
65
|
+
/**
|
|
66
|
+
* NOTE: `eventType` is NOT an attribute, but instead a core property on the telemetry payload. Many apps have been treating it
|
|
67
|
+
* as an attribute though, so it's included here for backwards compatibility. Internally it is re-mapped to `eventType`, where all other attributes
|
|
68
|
+
* are mapped to `a_attributeName` in the telemetry payload. This is a known issue and will be addressed in a future release.
|
|
69
|
+
*/
|
|
70
|
+
'eventType',
|
|
71
|
+
/**
|
|
72
|
+
* NOTE: `pathname` is NOT an attribute, nor an official property at all. It is internally mapped to `path`, but is used interchangeably by consuming apps.
|
|
73
|
+
* It's included here for backwards compatibility, but should not be used in new telemetry events. If `path` is set, this will never be used.
|
|
74
|
+
*/
|
|
75
|
+
'pathname',
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
function isAmazonEventAttributeKey(key) {
|
|
79
|
+
return AMAZON_EVENT_ATTRIBUTE_KEYS.includes(key);
|
|
80
|
+
}
|
|
81
|
+
function formatTelemetryAttributes({ telemetryData, dimensionLookup = {}, }) {
|
|
8
82
|
return Object.keys(telemetryData)
|
|
9
83
|
.filter((key) => {
|
|
10
|
-
return
|
|
84
|
+
return isAmazonEventAttributeKey(key);
|
|
11
85
|
})
|
|
12
86
|
.map((key) => {
|
|
13
87
|
if (dimensionLookup[key]) {
|
|
14
88
|
return {
|
|
15
89
|
key: getCustomDimensionKey(dimensionLookup, key),
|
|
16
|
-
value: telemetryData
|
|
90
|
+
value: getValue(telemetryData, key),
|
|
17
91
|
};
|
|
18
92
|
}
|
|
19
93
|
return {
|
|
@@ -30,7 +104,7 @@
|
|
|
30
104
|
if (key === 'json') {
|
|
31
105
|
return data[key] ? JSON.stringify(data[key]) : 'null';
|
|
32
106
|
}
|
|
33
|
-
return data[key] === undefined ? 'null' : data[key]
|
|
107
|
+
return data[key] === undefined ? 'null' : String(data[key]);
|
|
34
108
|
}
|
|
35
109
|
function getCustomDimensionKey(lookup, key) {
|
|
36
110
|
return `dimension${lookup[key]}`;
|
|
@@ -64,31 +138,30 @@
|
|
|
64
138
|
}
|
|
65
139
|
|
|
66
140
|
function createEventLog({ event = {}, dimensionLookup = {}, metricLookup = {}, }) {
|
|
67
|
-
var _a, _b;
|
|
141
|
+
var _a, _b, _c;
|
|
142
|
+
const acceptedAttributeKeys = new Set(AMAZON_EVENT_ATTRIBUTE_KEYS);
|
|
68
143
|
const { pathname: eventPathname, eventType = 'other' } = event;
|
|
69
144
|
const metrics = formatTelemetryMetrics(event, metricLookup);
|
|
70
|
-
const
|
|
71
|
-
telemetryData: Object.assign({
|
|
145
|
+
const formattedEventAttributes = formatTelemetryAttributes({
|
|
146
|
+
telemetryData: Object.assign({}, event),
|
|
72
147
|
dimensionLookup,
|
|
73
|
-
excludeKeys: [
|
|
74
|
-
'workflow',
|
|
75
|
-
'pathname',
|
|
76
|
-
...Object.keys(metrics),
|
|
77
|
-
...Object.keys(metricLookup),
|
|
78
|
-
],
|
|
79
148
|
});
|
|
80
|
-
const
|
|
149
|
+
const eventAttributes = Object.fromEntries(Object.entries(formattedEventAttributes).filter(([key]) => {
|
|
150
|
+
return acceptedAttributeKeys.has(key);
|
|
151
|
+
}));
|
|
152
|
+
const telemetryPayload = Object.assign(Object.assign(Object.assign({}, eventAttributes), metrics), { name: eventType });
|
|
81
153
|
// Set browser properties if available
|
|
82
|
-
if (typeof document !== 'undefined' &&
|
|
154
|
+
if (typeof document !== 'undefined' &&
|
|
155
|
+
document.referrer &&
|
|
156
|
+
!telemetryPayload.referrer) {
|
|
83
157
|
telemetryPayload.referrer = document.referrer;
|
|
84
158
|
}
|
|
85
159
|
if (typeof window !== 'undefined' && !telemetryPayload.hostname) {
|
|
86
160
|
telemetryPayload.hostname = (_a = window.location) === null || _a === void 0 ? void 0 : _a.hostname;
|
|
87
161
|
}
|
|
88
|
-
telemetryPayload.path =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: eventPathname;
|
|
162
|
+
(_b = telemetryPayload.path) !== null && _b !== void 0 ? _b : (telemetryPayload.path = typeof window !== 'undefined' && window.location.pathname
|
|
163
|
+
? (_c = window.location) === null || _c === void 0 ? void 0 : _c.pathname
|
|
164
|
+
: eventPathname);
|
|
92
165
|
return telemetryPayload;
|
|
93
166
|
}
|
|
94
167
|
|
|
@@ -97,11 +170,6 @@
|
|
|
97
170
|
const attributes = formatTelemetryAttributes({
|
|
98
171
|
telemetryData: options,
|
|
99
172
|
dimensionLookup,
|
|
100
|
-
excludeKeys: [
|
|
101
|
-
'workflow',
|
|
102
|
-
...Object.keys(metrics),
|
|
103
|
-
...Object.keys(metricLookup),
|
|
104
|
-
],
|
|
105
173
|
});
|
|
106
174
|
const { referrer, title } = document || {};
|
|
107
175
|
const { hostname, pathname } = window && window.location ? window.location : {};
|
|
@@ -109,6 +177,172 @@
|
|
|
109
177
|
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
178
|
}
|
|
111
179
|
|
|
180
|
+
var dlv_umd = {exports: {}};
|
|
181
|
+
|
|
182
|
+
(function (module, exports) {
|
|
183
|
+
!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};}();
|
|
184
|
+
|
|
185
|
+
}(dlv_umd));
|
|
186
|
+
|
|
187
|
+
var i$6 = dlv_umd.exports;
|
|
188
|
+
|
|
189
|
+
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);
|
|
190
|
+
|
|
191
|
+
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}
|
|
192
|
+
|
|
193
|
+
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);
|
|
194
|
+
|
|
195
|
+
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}
|
|
196
|
+
|
|
197
|
+
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);
|
|
198
|
+
|
|
199
|
+
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";
|
|
200
|
+
|
|
201
|
+
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])}}
|
|
202
|
+
|
|
203
|
+
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);
|
|
204
|
+
|
|
205
|
+
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);
|
|
206
|
+
|
|
207
|
+
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);
|
|
208
|
+
|
|
209
|
+
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};
|
|
210
|
+
|
|
211
|
+
function _defineProperty(obj, key, value) {
|
|
212
|
+
if (key in obj) {
|
|
213
|
+
Object.defineProperty(obj, key, {
|
|
214
|
+
value: value,
|
|
215
|
+
enumerable: true,
|
|
216
|
+
configurable: true,
|
|
217
|
+
writable: true
|
|
218
|
+
});
|
|
219
|
+
} else {
|
|
220
|
+
obj[key] = value;
|
|
221
|
+
}
|
|
222
|
+
return obj;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function ownKeys(object, enumerableOnly) {
|
|
226
|
+
var keys = Object.keys(object);
|
|
227
|
+
if (Object.getOwnPropertySymbols) {
|
|
228
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
229
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
230
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
231
|
+
})), keys.push.apply(keys, symbols);
|
|
232
|
+
}
|
|
233
|
+
return keys;
|
|
234
|
+
}
|
|
235
|
+
function _objectSpread2(target) {
|
|
236
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
237
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
238
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
239
|
+
_defineProperty(target, key, source[key]);
|
|
240
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
241
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return target;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// See ../packages/analytics-core for source code
|
|
248
|
+
function analyticsLib() {
|
|
249
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
250
|
+
var defaultSettings = {
|
|
251
|
+
storage: J
|
|
252
|
+
};
|
|
253
|
+
return De(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const storage = {
|
|
257
|
+
storage: {},
|
|
258
|
+
memory: true,
|
|
259
|
+
get(key) {
|
|
260
|
+
let stored;
|
|
261
|
+
try {
|
|
262
|
+
stored =
|
|
263
|
+
(window.localStorage && window.localStorage.getItem(key)) ||
|
|
264
|
+
this.storage[key];
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
stored = this.storage[key];
|
|
268
|
+
}
|
|
269
|
+
if (stored) {
|
|
270
|
+
try {
|
|
271
|
+
return JSON.parse(stored);
|
|
272
|
+
}
|
|
273
|
+
catch (e) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
set(key, value) {
|
|
282
|
+
// handle Safari private mode (setItem is not allowed)
|
|
283
|
+
const valueToString = JSON.stringify(value);
|
|
284
|
+
try {
|
|
285
|
+
window.localStorage.setItem(key, valueToString);
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
if (!this.memory) {
|
|
289
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
|
290
|
+
this.memory = true;
|
|
291
|
+
}
|
|
292
|
+
this.storage[key] = value;
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
delete(key) {
|
|
296
|
+
try {
|
|
297
|
+
window.localStorage.removeItem(key);
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
if (!this.memory) {
|
|
301
|
+
console.error('setting local storage failed, falling back to in-memory storage');
|
|
302
|
+
this.memory = true;
|
|
303
|
+
}
|
|
304
|
+
delete this.storage[key];
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const COGNITO_KEY = 'TELEMETRY_COGNITO_CREDENTIALS';
|
|
310
|
+
async function getCredentials(IdentityPoolId, options = {}) {
|
|
311
|
+
const fipsSubdomainSuffix = options.fips === true ? '-fips' : '';
|
|
312
|
+
const COGNITO_URL = `https://cognito-identity${fipsSubdomainSuffix}.us-east-1.amazonaws.com/`;
|
|
313
|
+
let cached = storage.get(COGNITO_KEY);
|
|
314
|
+
if (cached && Date.now() / 1000 < cached.Expiration)
|
|
315
|
+
return cached;
|
|
316
|
+
const fetchOptions = {
|
|
317
|
+
method: 'POST',
|
|
318
|
+
headers: {
|
|
319
|
+
'Content-type': 'application/x-amz-json-1.1',
|
|
320
|
+
'X-Amz-Target': 'AWSCognitoIdentityService.GetId',
|
|
321
|
+
},
|
|
322
|
+
body: JSON.stringify({ IdentityPoolId }),
|
|
323
|
+
};
|
|
324
|
+
const getIdResponse = await fetch(COGNITO_URL, fetchOptions);
|
|
325
|
+
if (!getIdResponse.ok) {
|
|
326
|
+
throw new Error(getIdResponse.statusText);
|
|
327
|
+
}
|
|
328
|
+
const { IdentityId } = await getIdResponse.json();
|
|
329
|
+
const credentialsOptions = {
|
|
330
|
+
method: 'POST',
|
|
331
|
+
headers: {
|
|
332
|
+
'Content-type': 'application/x-amz-json-1.1',
|
|
333
|
+
'X-Amz-Target': 'AWSCognitoIdentityService.GetCredentialsForIdentity',
|
|
334
|
+
},
|
|
335
|
+
body: JSON.stringify({ IdentityId }),
|
|
336
|
+
};
|
|
337
|
+
const getCredentialsResponse = await fetch(COGNITO_URL, credentialsOptions);
|
|
338
|
+
if (!getCredentialsResponse.ok) {
|
|
339
|
+
throw new Error(getCredentialsResponse.statusText);
|
|
340
|
+
}
|
|
341
|
+
const { Credentials } = await getCredentialsResponse.json();
|
|
342
|
+
storage.set(COGNITO_KEY, Credentials);
|
|
343
|
+
return Credentials;
|
|
344
|
+
}
|
|
345
|
+
|
|
112
346
|
/******************************************************************************
|
|
113
347
|
Copyright (c) Microsoft Corporation.
|
|
114
348
|
|
|
@@ -1080,6 +1314,26 @@
|
|
|
1080
1314
|
function bboxToString(extent) {
|
|
1081
1315
|
return extent.join(",");
|
|
1082
1316
|
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Returns the full thumbnail URL for an item.
|
|
1319
|
+
*
|
|
1320
|
+
* @param item - The item to decorate
|
|
1321
|
+
* @param portal - The portal URL
|
|
1322
|
+
* @param token - Optional token to append if the item is private
|
|
1323
|
+
* @returns The item with decorated thumbnail
|
|
1324
|
+
*/
|
|
1325
|
+
function decorateThumbnail(item, portal, token) {
|
|
1326
|
+
if (!item)
|
|
1327
|
+
return item;
|
|
1328
|
+
let thumbnailUrl = null;
|
|
1329
|
+
if (typeof item.thumbnail === "string") {
|
|
1330
|
+
thumbnailUrl = `${portal}/content/items/${item.id}/info/${item.thumbnail}`;
|
|
1331
|
+
if (thumbnailUrl && item.access !== "public" && token) {
|
|
1332
|
+
thumbnailUrl += `?${token}`;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
return Object.assign(Object.assign({}, item), (thumbnailUrl ? { thumbnailUrl } : {}));
|
|
1336
|
+
}
|
|
1083
1337
|
|
|
1084
1338
|
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
|
|
1085
1339
|
* Apache-2.0 */
|
|
@@ -1116,6 +1370,16 @@
|
|
|
1116
1370
|
if (requestOptions.params.extent && isBBox(requestOptions.params.extent)) {
|
|
1117
1371
|
requestOptions.params.extent = bboxToString(requestOptions.params.extent);
|
|
1118
1372
|
}
|
|
1373
|
+
const portal = getPortalUrl(requestOptions);
|
|
1374
|
+
const decoratedThumbnail = decorateThumbnail(Object.assign(Object.assign({}, requestOptions.item), { access: requestOptions.item.access }), portal);
|
|
1375
|
+
const paramsThumbnailUrl = requestOptions.params.thumbnailUrl;
|
|
1376
|
+
if (typeof decoratedThumbnail.thumbnailUrl === "string" &&
|
|
1377
|
+
typeof paramsThumbnailUrl === "string") {
|
|
1378
|
+
if (decoratedThumbnail.thumbnailUrl.split("?")[0] ===
|
|
1379
|
+
paramsThumbnailUrl.split("?")[0]) {
|
|
1380
|
+
delete requestOptions.params.thumbnailUrl;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1119
1383
|
return request(url, requestOptions);
|
|
1120
1384
|
});
|
|
1121
1385
|
}
|
|
@@ -1142,7 +1406,22 @@
|
|
|
1142
1406
|
const url = getItemBaseUrl(id, requestOptions);
|
|
1143
1407
|
// default to a GET request
|
|
1144
1408
|
const options = Object.assign({ httpMethod: "GET" }, requestOptions);
|
|
1145
|
-
return request(url, options)
|
|
1409
|
+
return request(url, options).then(async (item) => {
|
|
1410
|
+
const portal = (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.portal) || getPortalUrl(requestOptions);
|
|
1411
|
+
let token;
|
|
1412
|
+
// if authentication is provided and it’s an authentication manager and the item is not public then request a token for secure access
|
|
1413
|
+
if ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.authentication) &&
|
|
1414
|
+
typeof requestOptions.authentication !== "string" &&
|
|
1415
|
+
item.access !== "public") {
|
|
1416
|
+
try {
|
|
1417
|
+
token = await requestOptions.authentication.getToken(url);
|
|
1418
|
+
}
|
|
1419
|
+
catch (e) {
|
|
1420
|
+
// Ignore token acquisition errors because `getToken()` can fail for some authentication types, but we still want to return the item info when possible since the browser may still provide thumbnail access via an auth cookie.
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
return decorateThumbnail(item, portal, token);
|
|
1424
|
+
});
|
|
1146
1425
|
}
|
|
1147
1426
|
/**
|
|
1148
1427
|
* Get the fully qualified base URL to the REST end point for an item.
|
|
@@ -1488,154 +1767,244 @@
|
|
|
1488
1767
|
return [HOST_SERVICES[service] || service, region || '']
|
|
1489
1768
|
}
|
|
1490
1769
|
|
|
1491
|
-
const
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1770
|
+
const LINUX_DISTRO_TOKENS = [
|
|
1771
|
+
'ubuntu',
|
|
1772
|
+
'debian',
|
|
1773
|
+
'opensuse',
|
|
1774
|
+
'suse',
|
|
1775
|
+
'gentoo',
|
|
1776
|
+
'arch linux',
|
|
1777
|
+
'arch',
|
|
1778
|
+
'fedora',
|
|
1779
|
+
'centos',
|
|
1780
|
+
'red hat',
|
|
1781
|
+
'rhel',
|
|
1782
|
+
'rocky linux',
|
|
1783
|
+
'rocky',
|
|
1784
|
+
'almalinux',
|
|
1785
|
+
'alma',
|
|
1786
|
+
'amazon linux',
|
|
1787
|
+
'amazonlinux',
|
|
1788
|
+
'amzn',
|
|
1789
|
+
'manjaro',
|
|
1790
|
+
'linux mint',
|
|
1791
|
+
'mint',
|
|
1792
|
+
'pop!_os',
|
|
1793
|
+
'pop_os',
|
|
1794
|
+
'kali',
|
|
1795
|
+
'alpine',
|
|
1796
|
+
'nixos',
|
|
1797
|
+
'linux',
|
|
1798
|
+
];
|
|
1799
|
+
function escapeRegExp(value) {
|
|
1800
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1801
|
+
}
|
|
1802
|
+
const LINUX_DISTRO_TOKEN_SOURCE = [...LINUX_DISTRO_TOKENS]
|
|
1803
|
+
.sort((a, b) => b.length - a.length)
|
|
1804
|
+
.map((token) => escapeRegExp(token))
|
|
1805
|
+
.join('|');
|
|
1806
|
+
const LINUX_DISTRO_TOKEN_REGEX = new RegExp(`\\b(${LINUX_DISTRO_TOKEN_SOURCE})\\b`, 'i');
|
|
1807
|
+
const LINUX_DISTRO_VERSION_REGEX = new RegExp(`\\b(?:${LINUX_DISTRO_TOKEN_SOURCE})[\\s\\/_-]*([\\d\\.]+)`, 'i');
|
|
1808
|
+
const LINUX_DISTRO_NAME_MAP = {
|
|
1809
|
+
ubuntu: 'Ubuntu',
|
|
1810
|
+
debian: 'Debian',
|
|
1811
|
+
opensuse: 'openSUSE',
|
|
1812
|
+
suse: 'SUSE',
|
|
1813
|
+
gentoo: 'Gentoo',
|
|
1814
|
+
arch: 'Arch Linux',
|
|
1815
|
+
'arch linux': 'Arch Linux',
|
|
1816
|
+
fedora: 'Fedora',
|
|
1817
|
+
centos: 'CentOS',
|
|
1818
|
+
'red hat': 'Red Hat',
|
|
1819
|
+
rhel: 'Red Hat',
|
|
1820
|
+
rocky: 'Rocky Linux',
|
|
1821
|
+
'rocky linux': 'Rocky Linux',
|
|
1822
|
+
alma: 'AlmaLinux',
|
|
1823
|
+
almalinux: 'AlmaLinux',
|
|
1824
|
+
'amazon linux': 'Amazon Linux',
|
|
1825
|
+
amazonlinux: 'Amazon Linux',
|
|
1826
|
+
amzn: 'Amazon Linux',
|
|
1827
|
+
manjaro: 'Manjaro',
|
|
1828
|
+
'linux mint': 'Linux Mint',
|
|
1829
|
+
mint: 'Linux Mint',
|
|
1830
|
+
'pop!_os': 'Pop!_OS',
|
|
1831
|
+
pop_os: 'Pop!_OS',
|
|
1832
|
+
kali: 'Kali Linux',
|
|
1833
|
+
alpine: 'Alpine Linux',
|
|
1834
|
+
nixos: 'NixOS',
|
|
1835
|
+
linux: 'Linux',
|
|
1542
1836
|
};
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1837
|
+
function resolveLinuxDistroName(userAgent) {
|
|
1838
|
+
const token = (userAgent.match(LINUX_DISTRO_TOKEN_REGEX) || [])[1];
|
|
1839
|
+
if (!token) {
|
|
1840
|
+
return undefined;
|
|
1841
|
+
}
|
|
1842
|
+
return LINUX_DISTRO_NAME_MAP[token.toLowerCase()];
|
|
1843
|
+
}
|
|
1844
|
+
function extractVersion(userAgent, versionRegex) {
|
|
1845
|
+
if (!versionRegex) {
|
|
1846
|
+
return undefined;
|
|
1847
|
+
}
|
|
1848
|
+
const version = (userAgent.match(versionRegex) || [])[1];
|
|
1849
|
+
if (!version) {
|
|
1850
|
+
return undefined;
|
|
1851
|
+
}
|
|
1852
|
+
return version.replace(/_/g, '.');
|
|
1853
|
+
}
|
|
1854
|
+
function parseOS(userAgent) {
|
|
1855
|
+
if (!userAgent) {
|
|
1856
|
+
return {};
|
|
1857
|
+
}
|
|
1858
|
+
const normalizedAgent = userAgent.toLowerCase();
|
|
1859
|
+
const osMatchers = [
|
|
1860
|
+
{
|
|
1861
|
+
name: 'Windows Phone',
|
|
1862
|
+
regex: /windows phone|windows mobile/i,
|
|
1863
|
+
versionRegex: /windows (?:phone(?: os)?|mobile)[\s\/]*([\d\.]+)/i,
|
|
1556
1864
|
},
|
|
1557
|
-
|
|
1865
|
+
{
|
|
1866
|
+
name: 'Windows',
|
|
1867
|
+
regex: /windows nt|windows\s\d+/i,
|
|
1868
|
+
versionRegex: /windows nt[\s\/]*([\d\.]+)/i,
|
|
1869
|
+
},
|
|
1870
|
+
{
|
|
1871
|
+
name: 'iOS',
|
|
1872
|
+
regex: /iphone|ipad|ipod|cpu (?:iphone )?os /i,
|
|
1873
|
+
versionRegex: /os\s([\d_\.]+)/i,
|
|
1874
|
+
},
|
|
1875
|
+
{
|
|
1876
|
+
name: 'Android',
|
|
1877
|
+
regex: /android/i,
|
|
1878
|
+
versionRegex: /android[\s\/]*([\d\.]+)/i,
|
|
1879
|
+
},
|
|
1880
|
+
{
|
|
1881
|
+
name: 'ChromeOS',
|
|
1882
|
+
regex: /\bcros\b/i,
|
|
1883
|
+
versionRegex: /\bcros\b[^\)]*?([\d]+(?:\.[\d]+)+)/i,
|
|
1884
|
+
},
|
|
1885
|
+
{
|
|
1886
|
+
name: 'MacOS',
|
|
1887
|
+
regex: /mac os x|macos|macintosh|macintel|darwin/i,
|
|
1888
|
+
versionRegex: /(?:mac os x|os x|macos)[\s\/]*([\d_\.]+)/i,
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
name: 'Linux',
|
|
1892
|
+
regex: LINUX_DISTRO_TOKEN_REGEX,
|
|
1893
|
+
versionRegex: LINUX_DISTRO_VERSION_REGEX,
|
|
1894
|
+
},
|
|
1895
|
+
];
|
|
1896
|
+
const matched = osMatchers.find((entry) => entry.regex.test(normalizedAgent));
|
|
1897
|
+
if (!matched) {
|
|
1898
|
+
return {};
|
|
1899
|
+
}
|
|
1900
|
+
const version = extractVersion(normalizedAgent, matched.versionRegex);
|
|
1901
|
+
const name = matched.name === 'Linux'
|
|
1902
|
+
? resolveLinuxDistroName(normalizedAgent) || 'Linux'
|
|
1903
|
+
: matched.name;
|
|
1904
|
+
return {
|
|
1905
|
+
name,
|
|
1906
|
+
version,
|
|
1558
1907
|
};
|
|
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
1908
|
}
|
|
1589
1909
|
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
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;
|
|
1910
|
+
function getNavigatorSafe() {
|
|
1911
|
+
if (typeof window === 'undefined' || !window.navigator) {
|
|
1912
|
+
return undefined;
|
|
1605
1913
|
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1914
|
+
return window.navigator;
|
|
1915
|
+
}
|
|
1916
|
+
function getLanguageInfo(nav) {
|
|
1917
|
+
if (!nav) {
|
|
1918
|
+
return '';
|
|
1919
|
+
}
|
|
1920
|
+
const lang = nav.language ||
|
|
1921
|
+
nav.browserLanguage ||
|
|
1922
|
+
(Array.isArray(nav.languages) && nav.languages.length > 0
|
|
1923
|
+
? nav.languages[0]
|
|
1924
|
+
: 'en_US') ||
|
|
1925
|
+
'';
|
|
1926
|
+
return String(lang).toLowerCase().replace('-', '_');
|
|
1927
|
+
}
|
|
1928
|
+
function getBrowserTimezone() {
|
|
1929
|
+
const tzMatch = /\(([A-Za-z\s].*)\)/.exec(new Date().toString());
|
|
1930
|
+
return tzMatch ? tzMatch[1] || '' : '';
|
|
1931
|
+
}
|
|
1932
|
+
function parseBrowserType(userAgent) {
|
|
1933
|
+
const operaMatch = /.+(Opera[\s[A-Z]*|OPR[\sA-Z]*)\/([0-9\.]+).*/i.exec(userAgent);
|
|
1934
|
+
if (operaMatch) {
|
|
1935
|
+
return {
|
|
1936
|
+
type: operaMatch[1],
|
|
1937
|
+
version: operaMatch[2],
|
|
1938
|
+
};
|
|
1609
1939
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
1940
|
+
const edgeOrTridentMatch = /.+(Trident|Edge)\/([0-9\.]+).*/i.exec(userAgent);
|
|
1941
|
+
if (edgeOrTridentMatch) {
|
|
1942
|
+
return {
|
|
1943
|
+
type: edgeOrTridentMatch[1],
|
|
1944
|
+
version: edgeOrTridentMatch[2],
|
|
1945
|
+
};
|
|
1612
1946
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1947
|
+
const headlessMatch = /(headlesschrome)(?:\/([\w\.]+)| )/i.exec(userAgent);
|
|
1948
|
+
if (headlessMatch) {
|
|
1949
|
+
return {
|
|
1950
|
+
type: headlessMatch[1],
|
|
1951
|
+
version: headlessMatch[2],
|
|
1952
|
+
};
|
|
1617
1953
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
return
|
|
1954
|
+
const browserMatch = /.+(Chrome|Firefox|FxiOS)\/([0-9\.]+).*/i.exec(userAgent);
|
|
1955
|
+
if (browserMatch) {
|
|
1956
|
+
return {
|
|
1957
|
+
type: browserMatch[1],
|
|
1958
|
+
version: browserMatch[2],
|
|
1959
|
+
};
|
|
1621
1960
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1961
|
+
const safariMatch = /.+(Safari)\/([0-9\.]+).*/i.exec(userAgent);
|
|
1962
|
+
if (safariMatch) {
|
|
1963
|
+
return {
|
|
1964
|
+
type: safariMatch[1],
|
|
1965
|
+
version: safariMatch[2],
|
|
1966
|
+
};
|
|
1628
1967
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1968
|
+
const webkitMatch = /.+(AppleWebKit)\/([0-9\.]+).*/i.exec(userAgent);
|
|
1969
|
+
if (webkitMatch) {
|
|
1970
|
+
return {
|
|
1971
|
+
type: webkitMatch[1],
|
|
1972
|
+
version: webkitMatch[2],
|
|
1973
|
+
};
|
|
1631
1974
|
}
|
|
1632
|
-
const
|
|
1633
|
-
.
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1975
|
+
const anyMatch = /.*([A-Z]+)\/([0-9\.]+).*/i.exec(userAgent);
|
|
1976
|
+
const fallback = anyMatch || ['', 'NA', '0.0.0'];
|
|
1977
|
+
return {
|
|
1978
|
+
type: fallback[1],
|
|
1979
|
+
version: fallback[2],
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
function getBrowserClientInfo() {
|
|
1983
|
+
const nav = getNavigatorSafe();
|
|
1984
|
+
if (!nav) {
|
|
1985
|
+
return {};
|
|
1986
|
+
}
|
|
1987
|
+
const userAgent = nav.userAgent || '';
|
|
1988
|
+
const browser = parseBrowserType(userAgent);
|
|
1989
|
+
const isBrave = (nav.brave && nav.brave.isBrave) || false;
|
|
1990
|
+
const type = isBrave ? 'Brave' : browser.type;
|
|
1991
|
+
const os = parseOS(userAgent);
|
|
1992
|
+
const vendorToken = (nav.vendor || '').split(' ').filter(Boolean)[0];
|
|
1993
|
+
const make = type === 'Brave' ? type : vendorToken || nav.product || '';
|
|
1994
|
+
return {
|
|
1995
|
+
language: getLanguageInfo(nav),
|
|
1996
|
+
make,
|
|
1997
|
+
model: type,
|
|
1998
|
+
version: browser.version,
|
|
1999
|
+
name: [type, browser.version].filter(Boolean).join('/'),
|
|
2000
|
+
timezone: getBrowserTimezone(),
|
|
2001
|
+
platform: nav.platform,
|
|
2002
|
+
os,
|
|
2003
|
+
};
|
|
1637
2004
|
}
|
|
1638
2005
|
|
|
2006
|
+
const PINPOINT_ENDPOINT_KEY = 'TELEMETRY_PINPOINT_ENDPOINT_ID';
|
|
2007
|
+
const LOG_PREFIX = '[telemetry-amazon]';
|
|
1639
2008
|
function isDebugEnabled() {
|
|
1640
2009
|
var _a;
|
|
1641
2010
|
const processEnv = typeof globalThis !== 'undefined'
|
|
@@ -1680,131 +2049,20 @@
|
|
|
1680
2049
|
storage.set(PINPOINT_ENDPOINT_KEY, { endpointId: generated });
|
|
1681
2050
|
return generated;
|
|
1682
2051
|
}
|
|
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
2052
|
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
2053
|
+
const ESRI_SIGNING_SERVICE = 'execute-api';
|
|
2054
|
+
const ESRI_SIGNING_REGION = 'us-east-1';
|
|
2055
|
+
const ESRI_ENDPOINT_URL = (appId) => `https://tedev.arcgis.com/v1/apps/${appId}/events`;
|
|
2056
|
+
const SESSION_START_EVENT = '_session.start';
|
|
2057
|
+
const SESSION_STOP_EVENT = '_session.stop';
|
|
2058
|
+
const DEFAULT_IDLE_TIMEOUT_MS = 30 * 60 * 1000;
|
|
2059
|
+
const DEFAULT_DEBOUNCE_MS = 5000;
|
|
2060
|
+
/** Converts a string to a number, guarded against invalid values */
|
|
1804
2061
|
function getNumber(value, fallback = 0) {
|
|
1805
2062
|
const numeric = Number(value);
|
|
1806
2063
|
return Number.isFinite(numeric) ? numeric : fallback;
|
|
1807
2064
|
}
|
|
2065
|
+
/** Splits an EsriBatchEventPayload into attributes and metrics */
|
|
1808
2066
|
function splitEventData(payload) {
|
|
1809
2067
|
const attributes = {};
|
|
1810
2068
|
const metrics = {};
|
|
@@ -1841,97 +2099,374 @@
|
|
|
1841
2099
|
metrics,
|
|
1842
2100
|
};
|
|
1843
2101
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
const
|
|
1848
|
-
|
|
2102
|
+
/** Constructs an event payload in the shape expected by the endpoint. */
|
|
2103
|
+
function buildBatchEventPayload({ queuedEvents, trackerName, appName, appVersion, }) {
|
|
2104
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2105
|
+
const endpointEvent = queuedEvents[queuedEvents.length - 1] ||
|
|
2106
|
+
{
|
|
2107
|
+
payload: {},
|
|
2108
|
+
browserInfo: {},
|
|
2109
|
+
};
|
|
2110
|
+
const payload = endpointEvent.payload || {};
|
|
2111
|
+
const browserInfo = endpointEvent.browserInfo || {};
|
|
2112
|
+
const endpointId = getEndpointId();
|
|
2113
|
+
const location = {};
|
|
2114
|
+
if (payload === null || payload === void 0 ? void 0 : payload.city) {
|
|
2115
|
+
location.City = payload.city;
|
|
2116
|
+
}
|
|
2117
|
+
if (payload === null || payload === void 0 ? void 0 : payload.country) {
|
|
2118
|
+
location.Country = payload.country;
|
|
2119
|
+
}
|
|
2120
|
+
if ((payload === null || payload === void 0 ? void 0 : payload.lat) !== undefined && (payload === null || payload === void 0 ? void 0 : payload.lat) !== null) {
|
|
2121
|
+
location.Lat = getNumber(payload.lat);
|
|
2122
|
+
}
|
|
2123
|
+
if ((payload === null || payload === void 0 ? void 0 : payload.lon) !== undefined && (payload === null || payload === void 0 ? void 0 : payload.lon) !== null) {
|
|
2124
|
+
location.Lon = getNumber(payload.lon);
|
|
2125
|
+
}
|
|
1849
2126
|
return {
|
|
1850
2127
|
BatchEvent: {
|
|
1851
2128
|
Endpoint: {
|
|
1852
2129
|
Id: endpointId,
|
|
1853
|
-
Device: {
|
|
1854
|
-
|
|
1855
|
-
|
|
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
|
-
},
|
|
2130
|
+
Device: Object.assign({ Locale: (browserInfo === null || browserInfo === void 0 ? void 0 : browserInfo.language) || '', Make: (payload === null || payload === void 0 ? void 0 : payload.deviceMake) || (browserInfo === null || browserInfo === void 0 ? void 0 : browserInfo.make) || '', Model: (payload === null || payload === void 0 ? void 0 : payload.deviceModel) || (browserInfo === null || browserInfo === void 0 ? void 0 : browserInfo.model) || '', ModelVersion: (browserInfo === null || browserInfo === void 0 ? void 0 : browserInfo.version) || '', Platform: ((_a = browserInfo === null || browserInfo === void 0 ? void 0 : browserInfo.os) === null || _a === void 0 ? void 0 : _a.name) || (browserInfo === null || browserInfo === void 0 ? void 0 : browserInfo.platform) || '' }, (((_b = browserInfo === null || browserInfo === void 0 ? void 0 : browserInfo.os) === null || _b === void 0 ? void 0 : _b.version)
|
|
2131
|
+
? { PlatformVersion: browserInfo.os.version }
|
|
2132
|
+
: {})),
|
|
2133
|
+
Location: location,
|
|
1863
2134
|
Application: {
|
|
1864
|
-
AppTitle:
|
|
1865
|
-
AppVersion:
|
|
1866
|
-
ClientSdkVersion:
|
|
2135
|
+
AppTitle: (_d = (_c = payload === null || payload === void 0 ? void 0 : payload.appTitle) !== null && _c !== void 0 ? _c : appName) !== null && _d !== void 0 ? _d : trackerName,
|
|
2136
|
+
AppVersion: (_e = payload === null || payload === void 0 ? void 0 : payload.appVersion) !== null && _e !== void 0 ? _e : appVersion,
|
|
2137
|
+
ClientSdkVersion: (_f = payload === null || payload === void 0 ? void 0 : payload.clientSdkVersion) !== null && _f !== void 0 ? _f : trackerName,
|
|
1867
2138
|
},
|
|
1868
2139
|
},
|
|
1869
|
-
Events:
|
|
1870
|
-
|
|
1871
|
-
|
|
2140
|
+
Events: queuedEvents.map((queuedEvent) => {
|
|
2141
|
+
const timestamp = queuedEvent.timestamp;
|
|
2142
|
+
const { attributes, metrics } = splitEventData(queuedEvent.payload);
|
|
2143
|
+
const sessionContext = queuedEvent.session ||
|
|
2144
|
+
{
|
|
2145
|
+
id: `${queuedEvent.unixMs}-${Math.random().toString(16).slice(2)}`,
|
|
2146
|
+
startTimestamp: timestamp,
|
|
2147
|
+
startUnixMs: queuedEvent.unixMs,
|
|
2148
|
+
};
|
|
2149
|
+
const isStopEvent = queuedEvent.eventName === SESSION_STOP_EVENT;
|
|
2150
|
+
return {
|
|
2151
|
+
EventType: queuedEvent.eventName,
|
|
1872
2152
|
Timestamp: timestamp,
|
|
1873
2153
|
Session: {
|
|
1874
|
-
Id:
|
|
1875
|
-
StartTimestamp:
|
|
2154
|
+
Id: sessionContext.id,
|
|
2155
|
+
StartTimestamp: sessionContext.startTimestamp,
|
|
1876
2156
|
EndTimestamp: timestamp,
|
|
1877
|
-
Duration:
|
|
2157
|
+
Duration: isStopEvent
|
|
2158
|
+
? Math.max(0, queuedEvent.unixMs - sessionContext.startUnixMs)
|
|
2159
|
+
: 0,
|
|
1878
2160
|
},
|
|
1879
2161
|
Attributes: attributes,
|
|
1880
2162
|
Metrics: metrics,
|
|
1881
|
-
}
|
|
1882
|
-
|
|
2163
|
+
};
|
|
2164
|
+
}),
|
|
1883
2165
|
},
|
|
1884
2166
|
};
|
|
1885
2167
|
}
|
|
1886
|
-
function createEsriPlugin({
|
|
1887
|
-
|
|
2168
|
+
function createEsriPlugin({ trackerName, appName, appId, appVersion, userPoolID, fips, debounceMs = DEFAULT_DEBOUNCE_MS, }) {
|
|
2169
|
+
const url = ESRI_ENDPOINT_URL(appId);
|
|
2170
|
+
let isDisabled = false;
|
|
2171
|
+
let hasWarned = false;
|
|
2172
|
+
let hasSessionStarted = false;
|
|
2173
|
+
let sessionStopSent = false;
|
|
2174
|
+
let activeSession;
|
|
2175
|
+
let idleTimerId;
|
|
2176
|
+
let debounceTimerId;
|
|
2177
|
+
let lifecycleListenersAttached = false;
|
|
2178
|
+
const removeLifecycleListeners = [];
|
|
2179
|
+
let pendingEvents = [];
|
|
2180
|
+
const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2181
|
+
const warnOnce = (message, details) => {
|
|
2182
|
+
if (hasWarned) {
|
|
2183
|
+
return;
|
|
2184
|
+
}
|
|
2185
|
+
hasWarned = true;
|
|
2186
|
+
warnLog(message, details);
|
|
2187
|
+
};
|
|
2188
|
+
debugLog('createEsriPlugin initialized', {
|
|
1888
2189
|
trackerName,
|
|
1889
2190
|
hasUrl: Boolean(url),
|
|
1890
|
-
headerCount: Object.keys(headers).length,
|
|
1891
2191
|
});
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
2192
|
+
if (!url) {
|
|
2193
|
+
isDisabled = true;
|
|
2194
|
+
warnOnce('Esri telemetry disabled due to missing internal endpoint URL', {
|
|
2195
|
+
trackerName,
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
if (!userPoolID) {
|
|
2199
|
+
isDisabled = true;
|
|
2200
|
+
warnOnce('Esri telemetry disabled due to missing userPoolID', {
|
|
2201
|
+
trackerName,
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
if (typeof fetch !== 'function') {
|
|
2205
|
+
isDisabled = true;
|
|
2206
|
+
warnOnce('Esri telemetry disabled because fetch is unavailable', {
|
|
2207
|
+
trackerName,
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
const clearIdleTimer = () => {
|
|
2211
|
+
if (!idleTimerId) {
|
|
2212
|
+
return;
|
|
2213
|
+
}
|
|
2214
|
+
clearTimeout(idleTimerId);
|
|
2215
|
+
idleTimerId = undefined;
|
|
2216
|
+
};
|
|
2217
|
+
const clearDebounceTimer = () => {
|
|
2218
|
+
if (!debounceTimerId) {
|
|
2219
|
+
return;
|
|
2220
|
+
}
|
|
2221
|
+
clearTimeout(debounceTimerId);
|
|
2222
|
+
debounceTimerId = undefined;
|
|
2223
|
+
};
|
|
2224
|
+
const clearPendingEvents = () => {
|
|
2225
|
+
pendingEvents = [];
|
|
2226
|
+
};
|
|
2227
|
+
const enqueueEvent = (event) => {
|
|
2228
|
+
pendingEvents.push(event);
|
|
2229
|
+
};
|
|
2230
|
+
const dequeuePendingEvents = () => {
|
|
2231
|
+
if (pendingEvents.length === 0) {
|
|
2232
|
+
return [];
|
|
2233
|
+
}
|
|
2234
|
+
const queuedEvents = pendingEvents;
|
|
2235
|
+
pendingEvents = [];
|
|
2236
|
+
return queuedEvents;
|
|
2237
|
+
};
|
|
2238
|
+
const sendQueuedEvents = (queuedEvents) => {
|
|
2239
|
+
var _a;
|
|
2240
|
+
if (queuedEvents.length === 0) {
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
if (isDisabled || !url || !userPoolID) {
|
|
2244
|
+
debugLog('Skipping esri track call', {
|
|
2245
|
+
eventName: (_a = queuedEvents[queuedEvents.length - 1]) === null || _a === void 0 ? void 0 : _a.eventName,
|
|
2246
|
+
reason: 'plugin-disabled',
|
|
1905
2247
|
});
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
.
|
|
1918
|
-
|
|
1919
|
-
|
|
2248
|
+
return;
|
|
2249
|
+
}
|
|
2250
|
+
debugLog('Sending esri endpoint batch event', {
|
|
2251
|
+
trackerName,
|
|
2252
|
+
url,
|
|
2253
|
+
eventCount: queuedEvents.length,
|
|
2254
|
+
});
|
|
2255
|
+
void (async () => {
|
|
2256
|
+
var _a;
|
|
2257
|
+
try {
|
|
2258
|
+
const credentials = await getCredentials(userPoolID, { fips });
|
|
2259
|
+
const accessKeyId = (credentials === null || credentials === void 0 ? void 0 : credentials.AccessKeyId) || (credentials === null || credentials === void 0 ? void 0 : credentials.accessKeyId);
|
|
2260
|
+
const secretAccessKey = (credentials === null || credentials === void 0 ? void 0 : credentials.SecretKey) || (credentials === null || credentials === void 0 ? void 0 : credentials.secretAccessKey);
|
|
2261
|
+
const sessionToken = (credentials === null || credentials === void 0 ? void 0 : credentials.SessionToken) || (credentials === null || credentials === void 0 ? void 0 : credentials.sessionToken);
|
|
2262
|
+
if (!accessKeyId || !secretAccessKey) {
|
|
2263
|
+
throw new Error('Signed endpoint credentials are missing required key fields.');
|
|
2264
|
+
}
|
|
2265
|
+
const client = new AwsClient({
|
|
2266
|
+
accessKeyId,
|
|
2267
|
+
secretAccessKey,
|
|
2268
|
+
sessionToken,
|
|
2269
|
+
service: ESRI_SIGNING_SERVICE,
|
|
2270
|
+
region: ESRI_SIGNING_REGION,
|
|
2271
|
+
});
|
|
2272
|
+
await client.fetch(url, {
|
|
2273
|
+
method: 'POST',
|
|
2274
|
+
headers: {
|
|
2275
|
+
'Content-Type': 'application/json',
|
|
2276
|
+
},
|
|
2277
|
+
body: JSON.stringify(buildBatchEventPayload({
|
|
2278
|
+
queuedEvents,
|
|
2279
|
+
trackerName,
|
|
2280
|
+
appName,
|
|
2281
|
+
appVersion,
|
|
2282
|
+
})),
|
|
2283
|
+
});
|
|
2284
|
+
debugLog('Endpoint event sent', {
|
|
1920
2285
|
trackerName,
|
|
2286
|
+
eventCount: queuedEvents.length,
|
|
1921
2287
|
});
|
|
1922
|
-
}
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
2288
|
+
}
|
|
2289
|
+
catch (error) {
|
|
2290
|
+
isDisabled = true;
|
|
2291
|
+
clearIdleTimer();
|
|
2292
|
+
clearDebounceTimer();
|
|
2293
|
+
clearPendingEvents();
|
|
2294
|
+
removeAllLifecycleListeners();
|
|
2295
|
+
warnOnce('Esri telemetry disabled after endpoint track failure', {
|
|
2296
|
+
eventName: (_a = queuedEvents[queuedEvents.length - 1]) === null || _a === void 0 ? void 0 : _a.eventName,
|
|
1926
2297
|
trackerName,
|
|
1927
2298
|
message: (error === null || error === void 0 ? void 0 : error.message) || String(error),
|
|
1928
2299
|
});
|
|
2300
|
+
}
|
|
2301
|
+
})();
|
|
2302
|
+
};
|
|
2303
|
+
const flushPendingEvents = (eventToAppend) => {
|
|
2304
|
+
clearDebounceTimer();
|
|
2305
|
+
const queuedEvents = dequeuePendingEvents();
|
|
2306
|
+
if (eventToAppend) {
|
|
2307
|
+
queuedEvents.push(eventToAppend);
|
|
2308
|
+
}
|
|
2309
|
+
sendQueuedEvents(queuedEvents);
|
|
2310
|
+
};
|
|
2311
|
+
const scheduleDebounceFlush = () => {
|
|
2312
|
+
clearDebounceTimer();
|
|
2313
|
+
debounceTimerId = setTimeout(() => {
|
|
2314
|
+
flushPendingEvents();
|
|
2315
|
+
}, debounceMs);
|
|
2316
|
+
};
|
|
2317
|
+
const removeAllLifecycleListeners = () => {
|
|
2318
|
+
removeLifecycleListeners.splice(0).forEach((removeListener) => {
|
|
2319
|
+
removeListener();
|
|
2320
|
+
});
|
|
2321
|
+
lifecycleListenersAttached = false;
|
|
2322
|
+
};
|
|
2323
|
+
const createSession = () => {
|
|
2324
|
+
const now = Date.now();
|
|
2325
|
+
return {
|
|
2326
|
+
id: `${now}-${Math.random().toString(16).slice(2)}`,
|
|
2327
|
+
startTimestamp: new Date(now).toISOString(),
|
|
2328
|
+
startUnixMs: now,
|
|
2329
|
+
};
|
|
2330
|
+
};
|
|
2331
|
+
const sendEvent = (eventName, payload, sessionOverride, options, forceImmediate = false) => {
|
|
2332
|
+
if (isDisabled || !url || !userPoolID) {
|
|
2333
|
+
debugLog('Skipping esri track call', {
|
|
2334
|
+
eventName,
|
|
2335
|
+
reason: 'plugin-disabled',
|
|
1929
2336
|
});
|
|
1930
|
-
return
|
|
2337
|
+
return false;
|
|
2338
|
+
}
|
|
2339
|
+
debugLog('Queueing esri endpoint event', {
|
|
2340
|
+
eventName,
|
|
2341
|
+
trackerName,
|
|
2342
|
+
immediate: Boolean((options === null || options === void 0 ? void 0 : options.immediate) || forceImmediate),
|
|
2343
|
+
});
|
|
2344
|
+
const queuedEvent = {
|
|
2345
|
+
eventName,
|
|
2346
|
+
payload: payload,
|
|
2347
|
+
session: sessionOverride || activeSession,
|
|
2348
|
+
browserInfo: getBrowserClientInfo(),
|
|
2349
|
+
timestamp: new Date().toISOString(),
|
|
2350
|
+
unixMs: Date.now(),
|
|
2351
|
+
};
|
|
2352
|
+
if ((options === null || options === void 0 ? void 0 : options.immediate) || forceImmediate) {
|
|
2353
|
+
flushPendingEvents(queuedEvent);
|
|
2354
|
+
}
|
|
2355
|
+
else {
|
|
2356
|
+
enqueueEvent(queuedEvent);
|
|
2357
|
+
scheduleDebounceFlush();
|
|
2358
|
+
}
|
|
2359
|
+
return true;
|
|
2360
|
+
};
|
|
2361
|
+
const sendSessionLifecycleEvent = (eventName, reason, sessionOverride) => {
|
|
2362
|
+
return sendEvent(eventName, {
|
|
2363
|
+
reason,
|
|
2364
|
+
}, sessionOverride, undefined, true);
|
|
2365
|
+
};
|
|
2366
|
+
const stopSession = (reason) => {
|
|
2367
|
+
if (!hasSessionStarted || sessionStopSent) {
|
|
2368
|
+
return false;
|
|
2369
|
+
}
|
|
2370
|
+
const sessionToStop = activeSession;
|
|
2371
|
+
const didStop = sendSessionLifecycleEvent(SESSION_STOP_EVENT, reason, sessionToStop);
|
|
2372
|
+
if (didStop) {
|
|
2373
|
+
sessionStopSent = true;
|
|
2374
|
+
hasSessionStarted = false;
|
|
2375
|
+
clearIdleTimer();
|
|
2376
|
+
activeSession = undefined;
|
|
2377
|
+
}
|
|
2378
|
+
return didStop;
|
|
2379
|
+
};
|
|
2380
|
+
const startSession = (reason) => {
|
|
2381
|
+
if (hasSessionStarted) {
|
|
2382
|
+
return false;
|
|
2383
|
+
}
|
|
2384
|
+
activeSession = activeSession || createSession();
|
|
2385
|
+
const sessionToStart = activeSession;
|
|
2386
|
+
const didStart = sendSessionLifecycleEvent(SESSION_START_EVENT, reason, sessionToStart);
|
|
2387
|
+
if (didStart) {
|
|
2388
|
+
hasSessionStarted = true;
|
|
2389
|
+
sessionStopSent = false;
|
|
2390
|
+
}
|
|
2391
|
+
else {
|
|
2392
|
+
activeSession = undefined;
|
|
2393
|
+
}
|
|
2394
|
+
return didStart;
|
|
2395
|
+
};
|
|
2396
|
+
const resetIdleTimer = () => {
|
|
2397
|
+
if (!isBrowser || isDisabled || !hasSessionStarted) {
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2400
|
+
clearIdleTimer();
|
|
2401
|
+
idleTimerId = setTimeout(() => {
|
|
2402
|
+
stopSession('idle');
|
|
2403
|
+
}, DEFAULT_IDLE_TIMEOUT_MS);
|
|
2404
|
+
};
|
|
2405
|
+
const handleActivity = () => {
|
|
2406
|
+
if (isDisabled) {
|
|
2407
|
+
return;
|
|
2408
|
+
}
|
|
2409
|
+
if (!hasSessionStarted) {
|
|
2410
|
+
startSession('wakeup');
|
|
2411
|
+
}
|
|
2412
|
+
resetIdleTimer();
|
|
2413
|
+
};
|
|
2414
|
+
const addLifecycleListener = (target, eventName, listener) => {
|
|
2415
|
+
target.addEventListener(eventName, listener);
|
|
2416
|
+
removeLifecycleListeners.push(() => {
|
|
2417
|
+
target.removeEventListener(eventName, listener);
|
|
2418
|
+
});
|
|
2419
|
+
};
|
|
2420
|
+
const attachLifecycleListeners = () => {
|
|
2421
|
+
if (!isBrowser || lifecycleListenersAttached || isDisabled) {
|
|
2422
|
+
return;
|
|
2423
|
+
}
|
|
2424
|
+
const activityEvents = ['pointerdown', 'keydown', 'scroll', 'focus'];
|
|
2425
|
+
activityEvents.forEach((eventName) => {
|
|
2426
|
+
addLifecycleListener(window, eventName, handleActivity);
|
|
2427
|
+
});
|
|
2428
|
+
addLifecycleListener(window, 'beforeunload', () => {
|
|
2429
|
+
stopSession('beforeunload');
|
|
2430
|
+
});
|
|
2431
|
+
lifecycleListenersAttached = true;
|
|
2432
|
+
};
|
|
2433
|
+
return {
|
|
2434
|
+
track: (eventName, payload, options) => {
|
|
2435
|
+
attachLifecycleListeners();
|
|
2436
|
+
const isSessionStopEvent = eventName === SESSION_STOP_EVENT;
|
|
2437
|
+
if (!hasSessionStarted &&
|
|
2438
|
+
eventName !== SESSION_START_EVENT &&
|
|
2439
|
+
!isSessionStopEvent) {
|
|
2440
|
+
startSession('init');
|
|
2441
|
+
}
|
|
2442
|
+
if (eventName === SESSION_START_EVENT) {
|
|
2443
|
+
activeSession = activeSession || createSession();
|
|
2444
|
+
hasSessionStarted = true;
|
|
2445
|
+
sessionStopSent = false;
|
|
2446
|
+
}
|
|
2447
|
+
if (isSessionStopEvent) {
|
|
2448
|
+
sessionStopSent = true;
|
|
2449
|
+
hasSessionStarted = false;
|
|
2450
|
+
clearIdleTimer();
|
|
2451
|
+
}
|
|
2452
|
+
if (hasSessionStarted && !activeSession && !isSessionStopEvent) {
|
|
2453
|
+
activeSession = createSession();
|
|
2454
|
+
}
|
|
2455
|
+
if (hasSessionStarted && !isSessionStopEvent) {
|
|
2456
|
+
resetIdleTimer();
|
|
2457
|
+
}
|
|
2458
|
+
const sessionForEvent = activeSession;
|
|
2459
|
+
const didSend = sendEvent(eventName, payload, sessionForEvent, options, eventName === SESSION_START_EVENT || eventName === SESSION_STOP_EVENT);
|
|
2460
|
+
if (isSessionStopEvent && didSend) {
|
|
2461
|
+
activeSession = undefined;
|
|
2462
|
+
}
|
|
2463
|
+
return didSend;
|
|
1931
2464
|
},
|
|
1932
2465
|
};
|
|
1933
2466
|
}
|
|
1934
2467
|
|
|
2468
|
+
// October 31, 2026
|
|
2469
|
+
const PINPOINT_RETIREMENT_CUTOFF_UTC_MS = Date.parse('2026-10-31T00:00:00.000Z');
|
|
1935
2470
|
/**
|
|
1936
2471
|
* Amazon Telemetry
|
|
1937
2472
|
* Supports Pinpoint and Esri endpoint modes
|
|
@@ -1941,29 +2476,39 @@
|
|
|
1941
2476
|
this.name = 'amazon';
|
|
1942
2477
|
this.previousPage = {};
|
|
1943
2478
|
this.isInitialized = false;
|
|
1944
|
-
this.
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
2479
|
+
this.appConfig = {};
|
|
2480
|
+
this.isPinpointRetired = (nowMs = Date.now()) => nowMs >= PINPOINT_RETIREMENT_CUTOFF_UTC_MS;
|
|
2481
|
+
// default to `esri` mode if not specified
|
|
2482
|
+
const { app = {}, fips, userPoolID, mode = 'esri' } = options;
|
|
2483
|
+
Object.assign(this, options);
|
|
2484
|
+
this.appConfig = app;
|
|
2485
|
+
this.userPoolIDConfig = userPoolID;
|
|
2486
|
+
this.fipsConfig = fips;
|
|
2487
|
+
/** @deprecated Pinpoint is retiring on October 31, 2026. After this point all traffic will be routed to the in-house endpoint */
|
|
2488
|
+
if (mode === 'pinpoint' && !this.isPinpointRetired()) {
|
|
2489
|
+
this.mode = 'pinpoint';
|
|
2490
|
+
this.analytics = analyticsLib({
|
|
2491
|
+
app: app.name,
|
|
2492
|
+
version: app.version,
|
|
2493
|
+
plugins: [
|
|
2494
|
+
awsPinpointPlugin__default["default"]({
|
|
2495
|
+
fips,
|
|
2496
|
+
pinpointAppId: app.id,
|
|
2497
|
+
getCredentials: () => getCredentials(userPoolID, { fips }),
|
|
2498
|
+
}),
|
|
2499
|
+
],
|
|
1964
2500
|
});
|
|
2501
|
+
return;
|
|
1965
2502
|
}
|
|
1966
|
-
|
|
2503
|
+
this.mode = 'esri';
|
|
2504
|
+
this.analytics = createEsriPlugin({
|
|
2505
|
+
trackerName: this.name,
|
|
2506
|
+
appName: this.appConfig.name,
|
|
2507
|
+
appVersion: this.appConfig.version,
|
|
2508
|
+
appId: this.appConfig.id,
|
|
2509
|
+
userPoolID: this.userPoolIDConfig,
|
|
2510
|
+
fips: this.fipsConfig,
|
|
2511
|
+
});
|
|
1967
2512
|
}
|
|
1968
2513
|
init() {
|
|
1969
2514
|
// if already initialized, return
|
|
@@ -1994,16 +2539,18 @@
|
|
|
1994
2539
|
});
|
|
1995
2540
|
const { pageUrl, pageName } = telemetryPayload;
|
|
1996
2541
|
this.previousPage = { pageUrl, pageName };
|
|
1997
|
-
|
|
2542
|
+
const result = this.analytics.track('pageView', telemetryPayload);
|
|
2543
|
+
return typeof result === 'boolean' ? result : true;
|
|
1998
2544
|
}
|
|
1999
|
-
logEvent(event = {}) {
|
|
2545
|
+
logEvent(event = {}, trackOptions) {
|
|
2000
2546
|
const telemetryPayload = createEventLog({
|
|
2001
2547
|
event,
|
|
2002
2548
|
dimensionLookup: this.dimensions,
|
|
2003
2549
|
metricLookup: this.metrics,
|
|
2004
2550
|
});
|
|
2005
2551
|
const { name } = telemetryPayload;
|
|
2006
|
-
|
|
2552
|
+
const result = this.analytics.track(name, telemetryPayload, trackOptions);
|
|
2553
|
+
return typeof result === 'boolean' ? result : true;
|
|
2007
2554
|
}
|
|
2008
2555
|
}
|
|
2009
2556
|
|