@aws-amplify/analytics 5.2.23-unstable.7 → 5.2.23
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.
|
@@ -410,12 +410,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
410
410
|
/* harmony import */ var _whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./whatwgEncodingApi */ "../../node_modules/@aws-crypto/crc32/node_modules/@aws-sdk/util-utf8-browser/dist-es/whatwgEncodingApi.js");
|
|
411
411
|
|
|
412
412
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
};
|
|
416
|
-
var toUtf8 = function (input) {
|
|
417
|
-
return typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
418
|
-
};
|
|
413
|
+
const fromUtf8 = (input) => typeof TextEncoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["fromUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["fromUtf8"])(input);
|
|
414
|
+
const toUtf8 = (input) => typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
419
415
|
|
|
420
416
|
|
|
421
417
|
/***/ }),
|
|
@@ -431,44 +427,44 @@ var toUtf8 = function (input) {
|
|
|
431
427
|
__webpack_require__.r(__webpack_exports__);
|
|
432
428
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromUtf8", function() { return fromUtf8; });
|
|
433
429
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toUtf8", function() { return toUtf8; });
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
for (
|
|
437
|
-
|
|
430
|
+
const fromUtf8 = (input) => {
|
|
431
|
+
const bytes = [];
|
|
432
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
433
|
+
const value = input.charCodeAt(i);
|
|
438
434
|
if (value < 0x80) {
|
|
439
435
|
bytes.push(value);
|
|
440
436
|
}
|
|
441
437
|
else if (value < 0x800) {
|
|
442
|
-
bytes.push((value >> 6) |
|
|
438
|
+
bytes.push((value >> 6) | 0b11000000, (value & 0b111111) | 0b10000000);
|
|
443
439
|
}
|
|
444
440
|
else if (i + 1 < input.length && (value & 0xfc00) === 0xd800 && (input.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
445
|
-
|
|
446
|
-
bytes.push((surrogatePair >> 18) |
|
|
441
|
+
const surrogatePair = 0x10000 + ((value & 0b1111111111) << 10) + (input.charCodeAt(++i) & 0b1111111111);
|
|
442
|
+
bytes.push((surrogatePair >> 18) | 0b11110000, ((surrogatePair >> 12) & 0b111111) | 0b10000000, ((surrogatePair >> 6) & 0b111111) | 0b10000000, (surrogatePair & 0b111111) | 0b10000000);
|
|
447
443
|
}
|
|
448
444
|
else {
|
|
449
|
-
bytes.push((value >> 12) |
|
|
445
|
+
bytes.push((value >> 12) | 0b11100000, ((value >> 6) & 0b111111) | 0b10000000, (value & 0b111111) | 0b10000000);
|
|
450
446
|
}
|
|
451
447
|
}
|
|
452
448
|
return Uint8Array.from(bytes);
|
|
453
449
|
};
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
for (
|
|
457
|
-
|
|
450
|
+
const toUtf8 = (input) => {
|
|
451
|
+
let decoded = "";
|
|
452
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
453
|
+
const byte = input[i];
|
|
458
454
|
if (byte < 0x80) {
|
|
459
455
|
decoded += String.fromCharCode(byte);
|
|
460
456
|
}
|
|
461
|
-
else if (
|
|
462
|
-
|
|
463
|
-
decoded += String.fromCharCode(((byte &
|
|
457
|
+
else if (0b11000000 <= byte && byte < 0b11100000) {
|
|
458
|
+
const nextByte = input[++i];
|
|
459
|
+
decoded += String.fromCharCode(((byte & 0b11111) << 6) | (nextByte & 0b111111));
|
|
464
460
|
}
|
|
465
|
-
else if (
|
|
466
|
-
|
|
467
|
-
|
|
461
|
+
else if (0b11110000 <= byte && byte < 0b101101101) {
|
|
462
|
+
const surrogatePair = [byte, input[++i], input[++i], input[++i]];
|
|
463
|
+
const encoded = "%" + surrogatePair.map((byteValue) => byteValue.toString(16)).join("%");
|
|
468
464
|
decoded += decodeURIComponent(encoded);
|
|
469
465
|
}
|
|
470
466
|
else {
|
|
471
|
-
decoded += String.fromCharCode(((byte &
|
|
467
|
+
decoded += String.fromCharCode(((byte & 0b1111) << 12) | ((input[++i] & 0b111111) << 6) | (input[++i] & 0b111111));
|
|
472
468
|
}
|
|
473
469
|
}
|
|
474
470
|
return decoded;
|
|
@@ -1060,12 +1056,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1060
1056
|
/* harmony import */ var _whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./whatwgEncodingApi */ "../../node_modules/@aws-crypto/sha256-browser/node_modules/@aws-sdk/util-utf8-browser/dist-es/whatwgEncodingApi.js");
|
|
1061
1057
|
|
|
1062
1058
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
};
|
|
1066
|
-
var toUtf8 = function (input) {
|
|
1067
|
-
return typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1068
|
-
};
|
|
1059
|
+
const fromUtf8 = (input) => typeof TextEncoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["fromUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["fromUtf8"])(input);
|
|
1060
|
+
const toUtf8 = (input) => typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1069
1061
|
|
|
1070
1062
|
|
|
1071
1063
|
/***/ }),
|
|
@@ -1081,44 +1073,44 @@ var toUtf8 = function (input) {
|
|
|
1081
1073
|
__webpack_require__.r(__webpack_exports__);
|
|
1082
1074
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromUtf8", function() { return fromUtf8; });
|
|
1083
1075
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toUtf8", function() { return toUtf8; });
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
for (
|
|
1087
|
-
|
|
1076
|
+
const fromUtf8 = (input) => {
|
|
1077
|
+
const bytes = [];
|
|
1078
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1079
|
+
const value = input.charCodeAt(i);
|
|
1088
1080
|
if (value < 0x80) {
|
|
1089
1081
|
bytes.push(value);
|
|
1090
1082
|
}
|
|
1091
1083
|
else if (value < 0x800) {
|
|
1092
|
-
bytes.push((value >> 6) |
|
|
1084
|
+
bytes.push((value >> 6) | 0b11000000, (value & 0b111111) | 0b10000000);
|
|
1093
1085
|
}
|
|
1094
1086
|
else if (i + 1 < input.length && (value & 0xfc00) === 0xd800 && (input.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
1095
|
-
|
|
1096
|
-
bytes.push((surrogatePair >> 18) |
|
|
1087
|
+
const surrogatePair = 0x10000 + ((value & 0b1111111111) << 10) + (input.charCodeAt(++i) & 0b1111111111);
|
|
1088
|
+
bytes.push((surrogatePair >> 18) | 0b11110000, ((surrogatePair >> 12) & 0b111111) | 0b10000000, ((surrogatePair >> 6) & 0b111111) | 0b10000000, (surrogatePair & 0b111111) | 0b10000000);
|
|
1097
1089
|
}
|
|
1098
1090
|
else {
|
|
1099
|
-
bytes.push((value >> 12) |
|
|
1091
|
+
bytes.push((value >> 12) | 0b11100000, ((value >> 6) & 0b111111) | 0b10000000, (value & 0b111111) | 0b10000000);
|
|
1100
1092
|
}
|
|
1101
1093
|
}
|
|
1102
1094
|
return Uint8Array.from(bytes);
|
|
1103
1095
|
};
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
for (
|
|
1107
|
-
|
|
1096
|
+
const toUtf8 = (input) => {
|
|
1097
|
+
let decoded = "";
|
|
1098
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1099
|
+
const byte = input[i];
|
|
1108
1100
|
if (byte < 0x80) {
|
|
1109
1101
|
decoded += String.fromCharCode(byte);
|
|
1110
1102
|
}
|
|
1111
|
-
else if (
|
|
1112
|
-
|
|
1113
|
-
decoded += String.fromCharCode(((byte &
|
|
1103
|
+
else if (0b11000000 <= byte && byte < 0b11100000) {
|
|
1104
|
+
const nextByte = input[++i];
|
|
1105
|
+
decoded += String.fromCharCode(((byte & 0b11111) << 6) | (nextByte & 0b111111));
|
|
1114
1106
|
}
|
|
1115
|
-
else if (
|
|
1116
|
-
|
|
1117
|
-
|
|
1107
|
+
else if (0b11110000 <= byte && byte < 0b101101101) {
|
|
1108
|
+
const surrogatePair = [byte, input[++i], input[++i], input[++i]];
|
|
1109
|
+
const encoded = "%" + surrogatePair.map((byteValue) => byteValue.toString(16)).join("%");
|
|
1118
1110
|
decoded += decodeURIComponent(encoded);
|
|
1119
1111
|
}
|
|
1120
1112
|
else {
|
|
1121
|
-
decoded += String.fromCharCode(((byte &
|
|
1113
|
+
decoded += String.fromCharCode(((byte & 0b1111) << 12) | ((input[++i] & 0b111111) << 6) | (input[++i] & 0b111111));
|
|
1122
1114
|
}
|
|
1123
1115
|
}
|
|
1124
1116
|
return decoded;
|
|
@@ -1655,12 +1647,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1655
1647
|
/* harmony import */ var _whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./whatwgEncodingApi */ "../../node_modules/@aws-crypto/sha256-js/node_modules/@aws-sdk/util-utf8-browser/dist-es/whatwgEncodingApi.js");
|
|
1656
1648
|
|
|
1657
1649
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
};
|
|
1661
|
-
var toUtf8 = function (input) {
|
|
1662
|
-
return typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1663
|
-
};
|
|
1650
|
+
const fromUtf8 = (input) => typeof TextEncoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["fromUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["fromUtf8"])(input);
|
|
1651
|
+
const toUtf8 = (input) => typeof TextDecoder === "function" ? Object(_whatwgEncodingApi__WEBPACK_IMPORTED_MODULE_1__["toUtf8"])(input) : Object(_pureJs__WEBPACK_IMPORTED_MODULE_0__["toUtf8"])(input);
|
|
1664
1652
|
|
|
1665
1653
|
|
|
1666
1654
|
/***/ }),
|
|
@@ -1676,44 +1664,44 @@ var toUtf8 = function (input) {
|
|
|
1676
1664
|
__webpack_require__.r(__webpack_exports__);
|
|
1677
1665
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fromUtf8", function() { return fromUtf8; });
|
|
1678
1666
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toUtf8", function() { return toUtf8; });
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
for (
|
|
1682
|
-
|
|
1667
|
+
const fromUtf8 = (input) => {
|
|
1668
|
+
const bytes = [];
|
|
1669
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1670
|
+
const value = input.charCodeAt(i);
|
|
1683
1671
|
if (value < 0x80) {
|
|
1684
1672
|
bytes.push(value);
|
|
1685
1673
|
}
|
|
1686
1674
|
else if (value < 0x800) {
|
|
1687
|
-
bytes.push((value >> 6) |
|
|
1675
|
+
bytes.push((value >> 6) | 0b11000000, (value & 0b111111) | 0b10000000);
|
|
1688
1676
|
}
|
|
1689
1677
|
else if (i + 1 < input.length && (value & 0xfc00) === 0xd800 && (input.charCodeAt(i + 1) & 0xfc00) === 0xdc00) {
|
|
1690
|
-
|
|
1691
|
-
bytes.push((surrogatePair >> 18) |
|
|
1678
|
+
const surrogatePair = 0x10000 + ((value & 0b1111111111) << 10) + (input.charCodeAt(++i) & 0b1111111111);
|
|
1679
|
+
bytes.push((surrogatePair >> 18) | 0b11110000, ((surrogatePair >> 12) & 0b111111) | 0b10000000, ((surrogatePair >> 6) & 0b111111) | 0b10000000, (surrogatePair & 0b111111) | 0b10000000);
|
|
1692
1680
|
}
|
|
1693
1681
|
else {
|
|
1694
|
-
bytes.push((value >> 12) |
|
|
1682
|
+
bytes.push((value >> 12) | 0b11100000, ((value >> 6) & 0b111111) | 0b10000000, (value & 0b111111) | 0b10000000);
|
|
1695
1683
|
}
|
|
1696
1684
|
}
|
|
1697
1685
|
return Uint8Array.from(bytes);
|
|
1698
1686
|
};
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
for (
|
|
1702
|
-
|
|
1687
|
+
const toUtf8 = (input) => {
|
|
1688
|
+
let decoded = "";
|
|
1689
|
+
for (let i = 0, len = input.length; i < len; i++) {
|
|
1690
|
+
const byte = input[i];
|
|
1703
1691
|
if (byte < 0x80) {
|
|
1704
1692
|
decoded += String.fromCharCode(byte);
|
|
1705
1693
|
}
|
|
1706
|
-
else if (
|
|
1707
|
-
|
|
1708
|
-
decoded += String.fromCharCode(((byte &
|
|
1694
|
+
else if (0b11000000 <= byte && byte < 0b11100000) {
|
|
1695
|
+
const nextByte = input[++i];
|
|
1696
|
+
decoded += String.fromCharCode(((byte & 0b11111) << 6) | (nextByte & 0b111111));
|
|
1709
1697
|
}
|
|
1710
|
-
else if (
|
|
1711
|
-
|
|
1712
|
-
|
|
1698
|
+
else if (0b11110000 <= byte && byte < 0b101101101) {
|
|
1699
|
+
const surrogatePair = [byte, input[++i], input[++i], input[++i]];
|
|
1700
|
+
const encoded = "%" + surrogatePair.map((byteValue) => byteValue.toString(16)).join("%");
|
|
1713
1701
|
decoded += decodeURIComponent(encoded);
|
|
1714
1702
|
}
|
|
1715
1703
|
else {
|
|
1716
|
-
decoded += String.fromCharCode(((byte &
|
|
1704
|
+
decoded += String.fromCharCode(((byte & 0b1111) << 12) | ((input[++i] & 0b111111) << 6) | (input[++i] & 0b111111));
|
|
1717
1705
|
}
|
|
1718
1706
|
}
|
|
1719
1707
|
return decoded;
|
|
@@ -56191,7 +56179,7 @@ function calculateBodyLength(body) {
|
|
|
56191
56179
|
"use strict";
|
|
56192
56180
|
__webpack_require__.r(__webpack_exports__);
|
|
56193
56181
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "locateWindow", function() { return locateWindow; });
|
|
56194
|
-
|
|
56182
|
+
const fallbackWindow = {};
|
|
56195
56183
|
function locateWindow() {
|
|
56196
56184
|
if (typeof window !== "undefined") {
|
|
56197
56185
|
return window;
|
|
@@ -63197,25 +63185,20 @@ var __assign = undefined && undefined.__assign || function () {
|
|
|
63197
63185
|
__assign = Object.assign || function (t) {
|
|
63198
63186
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
63199
63187
|
s = arguments[i];
|
|
63200
|
-
|
|
63201
63188
|
for (var p in s) {
|
|
63202
63189
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
63203
63190
|
}
|
|
63204
63191
|
}
|
|
63205
|
-
|
|
63206
63192
|
return t;
|
|
63207
63193
|
};
|
|
63208
|
-
|
|
63209
63194
|
return __assign.apply(this, arguments);
|
|
63210
63195
|
};
|
|
63211
|
-
|
|
63212
63196
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
63213
63197
|
function adopt(value) {
|
|
63214
63198
|
return value instanceof P ? value : new P(function (resolve) {
|
|
63215
63199
|
resolve(value);
|
|
63216
63200
|
});
|
|
63217
63201
|
}
|
|
63218
|
-
|
|
63219
63202
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
63220
63203
|
function fulfilled(value) {
|
|
63221
63204
|
try {
|
|
@@ -63224,7 +63207,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
63224
63207
|
reject(e);
|
|
63225
63208
|
}
|
|
63226
63209
|
}
|
|
63227
|
-
|
|
63228
63210
|
function rejected(value) {
|
|
63229
63211
|
try {
|
|
63230
63212
|
step(generator["throw"](value));
|
|
@@ -63232,29 +63214,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
63232
63214
|
reject(e);
|
|
63233
63215
|
}
|
|
63234
63216
|
}
|
|
63235
|
-
|
|
63236
63217
|
function step(result) {
|
|
63237
63218
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
63238
63219
|
}
|
|
63239
|
-
|
|
63240
63220
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
63241
63221
|
});
|
|
63242
63222
|
};
|
|
63243
|
-
|
|
63244
63223
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
63245
63224
|
var _ = {
|
|
63246
|
-
|
|
63247
|
-
|
|
63248
|
-
|
|
63249
|
-
|
|
63225
|
+
label: 0,
|
|
63226
|
+
sent: function sent() {
|
|
63227
|
+
if (t[0] & 1) throw t[1];
|
|
63228
|
+
return t[1];
|
|
63229
|
+
},
|
|
63230
|
+
trys: [],
|
|
63231
|
+
ops: []
|
|
63250
63232
|
},
|
|
63251
|
-
|
|
63252
|
-
|
|
63253
|
-
|
|
63254
|
-
|
|
63255
|
-
y,
|
|
63256
|
-
t,
|
|
63257
|
-
g;
|
|
63233
|
+
f,
|
|
63234
|
+
y,
|
|
63235
|
+
t,
|
|
63236
|
+
g;
|
|
63258
63237
|
return g = {
|
|
63259
63238
|
next: verb(0),
|
|
63260
63239
|
"throw": verb(1),
|
|
@@ -63262,79 +63241,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
63262
63241
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
63263
63242
|
return this;
|
|
63264
63243
|
}), g;
|
|
63265
|
-
|
|
63266
63244
|
function verb(n) {
|
|
63267
63245
|
return function (v) {
|
|
63268
63246
|
return step([n, v]);
|
|
63269
63247
|
};
|
|
63270
63248
|
}
|
|
63271
|
-
|
|
63272
63249
|
function step(op) {
|
|
63273
63250
|
if (f) throw new TypeError("Generator is already executing.");
|
|
63274
|
-
|
|
63275
63251
|
while (_) {
|
|
63276
63252
|
try {
|
|
63277
63253
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
63278
63254
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
63279
|
-
|
|
63280
63255
|
switch (op[0]) {
|
|
63281
63256
|
case 0:
|
|
63282
63257
|
case 1:
|
|
63283
63258
|
t = op;
|
|
63284
63259
|
break;
|
|
63285
|
-
|
|
63286
63260
|
case 4:
|
|
63287
63261
|
_.label++;
|
|
63288
63262
|
return {
|
|
63289
63263
|
value: op[1],
|
|
63290
63264
|
done: false
|
|
63291
63265
|
};
|
|
63292
|
-
|
|
63293
63266
|
case 5:
|
|
63294
63267
|
_.label++;
|
|
63295
63268
|
y = op[1];
|
|
63296
63269
|
op = [0];
|
|
63297
63270
|
continue;
|
|
63298
|
-
|
|
63299
63271
|
case 7:
|
|
63300
63272
|
op = _.ops.pop();
|
|
63301
|
-
|
|
63302
63273
|
_.trys.pop();
|
|
63303
|
-
|
|
63304
63274
|
continue;
|
|
63305
|
-
|
|
63306
63275
|
default:
|
|
63307
63276
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
63308
63277
|
_ = 0;
|
|
63309
63278
|
continue;
|
|
63310
63279
|
}
|
|
63311
|
-
|
|
63312
63280
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
63313
63281
|
_.label = op[1];
|
|
63314
63282
|
break;
|
|
63315
63283
|
}
|
|
63316
|
-
|
|
63317
63284
|
if (op[0] === 6 && _.label < t[1]) {
|
|
63318
63285
|
_.label = t[1];
|
|
63319
63286
|
t = op;
|
|
63320
63287
|
break;
|
|
63321
63288
|
}
|
|
63322
|
-
|
|
63323
63289
|
if (t && _.label < t[2]) {
|
|
63324
63290
|
_.label = t[2];
|
|
63325
|
-
|
|
63326
63291
|
_.ops.push(op);
|
|
63327
|
-
|
|
63328
63292
|
break;
|
|
63329
63293
|
}
|
|
63330
|
-
|
|
63331
63294
|
if (t[2]) _.ops.pop();
|
|
63332
|
-
|
|
63333
63295
|
_.trys.pop();
|
|
63334
|
-
|
|
63335
63296
|
continue;
|
|
63336
63297
|
}
|
|
63337
|
-
|
|
63338
63298
|
op = body.call(thisArg, _);
|
|
63339
63299
|
} catch (e) {
|
|
63340
63300
|
op = [6, e];
|
|
@@ -63343,7 +63303,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
63343
63303
|
f = t = 0;
|
|
63344
63304
|
}
|
|
63345
63305
|
}
|
|
63346
|
-
|
|
63347
63306
|
if (op[0] & 5) throw op[1];
|
|
63348
63307
|
return {
|
|
63349
63308
|
value: op[0] ? op[1] : void 0,
|
|
@@ -63354,10 +63313,8 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
63354
63313
|
|
|
63355
63314
|
|
|
63356
63315
|
|
|
63357
|
-
|
|
63358
63316
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('AnalyticsClass');
|
|
63359
63317
|
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
63360
|
-
|
|
63361
63318
|
var dispatchAnalyticsEvent = function dispatchAnalyticsEvent(event, data, message) {
|
|
63362
63319
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].dispatch('analytics', {
|
|
63363
63320
|
event: event,
|
|
@@ -63365,7 +63322,6 @@ var dispatchAnalyticsEvent = function dispatchAnalyticsEvent(event, data, messag
|
|
|
63365
63322
|
message: message
|
|
63366
63323
|
}, 'Analytics', AMPLIFY_SYMBOL);
|
|
63367
63324
|
};
|
|
63368
|
-
|
|
63369
63325
|
var trackers = {
|
|
63370
63326
|
pageView: _trackers__WEBPACK_IMPORTED_MODULE_2__["PageViewTracker"],
|
|
63371
63327
|
event: _trackers__WEBPACK_IMPORTED_MODULE_2__["EventTracker"],
|
|
@@ -63375,10 +63331,7 @@ var _instance = null;
|
|
|
63375
63331
|
/**
|
|
63376
63332
|
* Provide mobile analytics client functions
|
|
63377
63333
|
*/
|
|
63378
|
-
|
|
63379
|
-
var AnalyticsClass =
|
|
63380
|
-
/** @class */
|
|
63381
|
-
function () {
|
|
63334
|
+
var AnalyticsClass = /** @class */function () {
|
|
63382
63335
|
/**
|
|
63383
63336
|
* Initialize Analtyics
|
|
63384
63337
|
* @param config - Configuration of the Analytics
|
|
@@ -63394,7 +63347,6 @@ function () {
|
|
|
63394
63347
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].listen('storage', listener);
|
|
63395
63348
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].listen('analytics', listener);
|
|
63396
63349
|
}
|
|
63397
|
-
|
|
63398
63350
|
AnalyticsClass.prototype.getModuleName = function () {
|
|
63399
63351
|
return 'Analytics';
|
|
63400
63352
|
};
|
|
@@ -63402,25 +63354,19 @@ function () {
|
|
|
63402
63354
|
* configure Analytics
|
|
63403
63355
|
* @param {Object} config - Configuration of the Analytics
|
|
63404
63356
|
*/
|
|
63405
|
-
|
|
63406
|
-
|
|
63407
63357
|
AnalyticsClass.prototype.configure = function (config) {
|
|
63408
63358
|
var _this = this;
|
|
63409
|
-
|
|
63410
63359
|
if (!config) return this._config;
|
|
63411
63360
|
logger.debug('configure Analytics', config);
|
|
63412
63361
|
var amplifyConfig = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Parser"].parseMobilehubConfig(config);
|
|
63413
63362
|
this._config = Object.assign({}, this._config, amplifyConfig.Analytics, config);
|
|
63414
|
-
|
|
63415
63363
|
if (this._config['disabled']) {
|
|
63416
63364
|
this._disabled = true;
|
|
63417
|
-
}
|
|
63418
|
-
|
|
63419
|
-
|
|
63365
|
+
}
|
|
63366
|
+
// turn on the autoSessionRecord if not specified
|
|
63420
63367
|
if (this._config['autoSessionRecord'] === undefined) {
|
|
63421
63368
|
this._config['autoSessionRecord'] = true;
|
|
63422
63369
|
}
|
|
63423
|
-
|
|
63424
63370
|
this._pluggables.forEach(function (pluggable) {
|
|
63425
63371
|
// for backward compatibility
|
|
63426
63372
|
var providerConfig = pluggable.getProviderName() === 'AWSPinpoint' && !_this._config['AWSPinpoint'] ? _this._config : _this._config[pluggable.getProviderName()];
|
|
@@ -63429,11 +63375,9 @@ function () {
|
|
|
63429
63375
|
autoSessionRecord: _this._config['autoSessionRecord']
|
|
63430
63376
|
}, providerConfig));
|
|
63431
63377
|
});
|
|
63432
|
-
|
|
63433
63378
|
if (this._pluggables.length === 0) {
|
|
63434
63379
|
this.addPluggable(new _Providers_AWSPinpointProvider__WEBPACK_IMPORTED_MODULE_1__["AWSPinpointProvider"]());
|
|
63435
63380
|
}
|
|
63436
|
-
|
|
63437
63381
|
dispatchAnalyticsEvent('configured', null, "The Analytics category has been configured successfully");
|
|
63438
63382
|
logger.debug('current configuration', this._config);
|
|
63439
63383
|
return this._config;
|
|
@@ -63442,19 +63386,14 @@ function () {
|
|
|
63442
63386
|
* add plugin into Analytics category
|
|
63443
63387
|
* @param pluggable - an instance of the plugin
|
|
63444
63388
|
*/
|
|
63445
|
-
|
|
63446
|
-
|
|
63447
63389
|
AnalyticsClass.prototype.addPluggable = function (pluggable) {
|
|
63448
63390
|
if (pluggable && pluggable.getCategory() === 'Analytics') {
|
|
63449
|
-
this._pluggables.push(pluggable);
|
|
63450
|
-
|
|
63451
|
-
|
|
63391
|
+
this._pluggables.push(pluggable);
|
|
63392
|
+
// for backward compatibility
|
|
63452
63393
|
var providerConfig = pluggable.getProviderName() === 'AWSPinpoint' && !this._config['AWSPinpoint'] ? this._config : this._config[pluggable.getProviderName()];
|
|
63453
|
-
|
|
63454
63394
|
var config = __assign({
|
|
63455
63395
|
disabled: this._config['disabled']
|
|
63456
63396
|
}, providerConfig);
|
|
63457
|
-
|
|
63458
63397
|
pluggable.configure(config);
|
|
63459
63398
|
return config;
|
|
63460
63399
|
}
|
|
@@ -63463,17 +63402,13 @@ function () {
|
|
|
63463
63402
|
* Get the plugin object
|
|
63464
63403
|
* @param providerName - the name of the provider to be removed
|
|
63465
63404
|
*/
|
|
63466
|
-
|
|
63467
|
-
|
|
63468
63405
|
AnalyticsClass.prototype.getPluggable = function (providerName) {
|
|
63469
63406
|
for (var i = 0; i < this._pluggables.length; i += 1) {
|
|
63470
63407
|
var pluggable = this._pluggables[i];
|
|
63471
|
-
|
|
63472
63408
|
if (pluggable.getProviderName() === providerName) {
|
|
63473
63409
|
return pluggable;
|
|
63474
63410
|
}
|
|
63475
63411
|
}
|
|
63476
|
-
|
|
63477
63412
|
logger.debug('No plugin found with providerName', providerName);
|
|
63478
63413
|
return null;
|
|
63479
63414
|
};
|
|
@@ -63481,41 +63416,31 @@ function () {
|
|
|
63481
63416
|
* Remove the plugin object
|
|
63482
63417
|
* @param providerName - the name of the provider to be removed
|
|
63483
63418
|
*/
|
|
63484
|
-
|
|
63485
|
-
|
|
63486
63419
|
AnalyticsClass.prototype.removePluggable = function (providerName) {
|
|
63487
63420
|
var idx = 0;
|
|
63488
|
-
|
|
63489
63421
|
while (idx < this._pluggables.length) {
|
|
63490
63422
|
if (this._pluggables[idx].getProviderName() === providerName) {
|
|
63491
63423
|
break;
|
|
63492
63424
|
}
|
|
63493
|
-
|
|
63494
63425
|
idx += 1;
|
|
63495
63426
|
}
|
|
63496
|
-
|
|
63497
63427
|
if (idx === this._pluggables.length) {
|
|
63498
63428
|
logger.debug('No plugin found with providerName', providerName);
|
|
63499
63429
|
return;
|
|
63500
63430
|
} else {
|
|
63501
63431
|
this._pluggables.splice(idx, idx + 1);
|
|
63502
|
-
|
|
63503
63432
|
return;
|
|
63504
63433
|
}
|
|
63505
63434
|
};
|
|
63506
63435
|
/**
|
|
63507
63436
|
* stop sending events
|
|
63508
63437
|
*/
|
|
63509
|
-
|
|
63510
|
-
|
|
63511
63438
|
AnalyticsClass.prototype.disable = function () {
|
|
63512
63439
|
this._disabled = true;
|
|
63513
63440
|
};
|
|
63514
63441
|
/**
|
|
63515
63442
|
* start sending events
|
|
63516
63443
|
*/
|
|
63517
|
-
|
|
63518
|
-
|
|
63519
63444
|
AnalyticsClass.prototype.enable = function () {
|
|
63520
63445
|
this._disabled = false;
|
|
63521
63446
|
};
|
|
@@ -63524,8 +63449,6 @@ function () {
|
|
|
63524
63449
|
* @param [provider] - name of the provider.
|
|
63525
63450
|
* @return - A promise which resolves if buffer doesn't overflow
|
|
63526
63451
|
*/
|
|
63527
|
-
|
|
63528
|
-
|
|
63529
63452
|
AnalyticsClass.prototype.startSession = function (provider) {
|
|
63530
63453
|
return __awaiter(this, void 0, void 0, function () {
|
|
63531
63454
|
var params;
|
|
@@ -63536,9 +63459,7 @@ function () {
|
|
|
63536
63459
|
},
|
|
63537
63460
|
provider: provider
|
|
63538
63461
|
};
|
|
63539
|
-
return [2
|
|
63540
|
-
/*return*/
|
|
63541
|
-
, this._sendEvent(params)];
|
|
63462
|
+
return [2 /*return*/, this._sendEvent(params)];
|
|
63542
63463
|
});
|
|
63543
63464
|
});
|
|
63544
63465
|
};
|
|
@@ -63547,8 +63468,6 @@ function () {
|
|
|
63547
63468
|
* @param [provider] - name of the provider.
|
|
63548
63469
|
* @return - A promise which resolves if buffer doesn't overflow
|
|
63549
63470
|
*/
|
|
63550
|
-
|
|
63551
|
-
|
|
63552
63471
|
AnalyticsClass.prototype.stopSession = function (provider) {
|
|
63553
63472
|
return __awaiter(this, void 0, void 0, function () {
|
|
63554
63473
|
var params;
|
|
@@ -63559,19 +63478,16 @@ function () {
|
|
|
63559
63478
|
},
|
|
63560
63479
|
provider: provider
|
|
63561
63480
|
};
|
|
63562
|
-
return [2
|
|
63563
|
-
/*return*/
|
|
63564
|
-
, this._sendEvent(params)];
|
|
63481
|
+
return [2 /*return*/, this._sendEvent(params)];
|
|
63565
63482
|
});
|
|
63566
63483
|
});
|
|
63567
63484
|
};
|
|
63568
|
-
|
|
63569
63485
|
AnalyticsClass.prototype.record = function (event, providerOrAttributes, metrics) {
|
|
63570
63486
|
return __awaiter(this, void 0, void 0, function () {
|
|
63571
63487
|
var params;
|
|
63572
63488
|
return __generator(this, function (_a) {
|
|
63573
|
-
params = null;
|
|
63574
|
-
|
|
63489
|
+
params = null;
|
|
63490
|
+
// this is just for compatibility, going to be deprecated
|
|
63575
63491
|
if (typeof event === 'string') {
|
|
63576
63492
|
params = {
|
|
63577
63493
|
event: {
|
|
@@ -63587,14 +63503,10 @@ function () {
|
|
|
63587
63503
|
provider: providerOrAttributes
|
|
63588
63504
|
};
|
|
63589
63505
|
}
|
|
63590
|
-
|
|
63591
|
-
return [2
|
|
63592
|
-
/*return*/
|
|
63593
|
-
, this._sendEvent(params)];
|
|
63506
|
+
return [2 /*return*/, this._sendEvent(params)];
|
|
63594
63507
|
});
|
|
63595
63508
|
});
|
|
63596
63509
|
};
|
|
63597
|
-
|
|
63598
63510
|
AnalyticsClass.prototype.updateEndpoint = function (attrs, provider) {
|
|
63599
63511
|
return __awaiter(this, void 0, void 0, function () {
|
|
63600
63512
|
var event;
|
|
@@ -63602,21 +63514,16 @@ function () {
|
|
|
63602
63514
|
event = __assign(__assign({}, attrs), {
|
|
63603
63515
|
name: '_update_endpoint'
|
|
63604
63516
|
});
|
|
63605
|
-
return [2
|
|
63606
|
-
/*return*/
|
|
63607
|
-
, this.record(event, provider)];
|
|
63517
|
+
return [2 /*return*/, this.record(event, provider)];
|
|
63608
63518
|
});
|
|
63609
63519
|
});
|
|
63610
63520
|
};
|
|
63611
|
-
|
|
63612
63521
|
AnalyticsClass.prototype._sendEvent = function (params) {
|
|
63613
63522
|
var _this = this;
|
|
63614
|
-
|
|
63615
63523
|
if (this._disabled) {
|
|
63616
63524
|
logger.debug('Analytics has been disabled');
|
|
63617
63525
|
return Promise.resolve();
|
|
63618
63526
|
}
|
|
63619
|
-
|
|
63620
63527
|
var provider = params.provider ? params.provider : 'AWSPinpoint';
|
|
63621
63528
|
return new Promise(function (resolve, reject) {
|
|
63622
63529
|
_this._pluggables.forEach(function (pluggable) {
|
|
@@ -63629,64 +63536,51 @@ function () {
|
|
|
63629
63536
|
});
|
|
63630
63537
|
});
|
|
63631
63538
|
};
|
|
63632
|
-
|
|
63633
63539
|
AnalyticsClass.prototype.autoTrack = function (trackerType, opts) {
|
|
63634
63540
|
if (!trackers[trackerType]) {
|
|
63635
63541
|
logger.debug('invalid tracker type');
|
|
63636
63542
|
return;
|
|
63637
|
-
}
|
|
63638
|
-
|
|
63639
|
-
|
|
63543
|
+
}
|
|
63544
|
+
// to sync up two different configuration ways of auto session tracking
|
|
63640
63545
|
if (trackerType === 'session') {
|
|
63641
63546
|
this._config['autoSessionRecord'] = opts['enable'];
|
|
63642
63547
|
}
|
|
63643
|
-
|
|
63644
63548
|
var tracker = this._trackers[trackerType];
|
|
63645
|
-
|
|
63646
63549
|
if (!tracker) {
|
|
63647
63550
|
this._trackers[trackerType] = new trackers[trackerType](this.record, opts);
|
|
63648
63551
|
} else {
|
|
63649
63552
|
tracker.configure(opts);
|
|
63650
63553
|
}
|
|
63651
63554
|
};
|
|
63652
|
-
|
|
63653
63555
|
return AnalyticsClass;
|
|
63654
63556
|
}();
|
|
63655
63557
|
|
|
63656
|
-
|
|
63657
63558
|
var endpointUpdated = false;
|
|
63658
63559
|
var authConfigured = false;
|
|
63659
63560
|
var analyticsConfigured = false;
|
|
63660
|
-
|
|
63661
63561
|
var listener = function listener(capsule) {
|
|
63662
63562
|
var channel = capsule.channel,
|
|
63663
|
-
|
|
63563
|
+
payload = capsule.payload;
|
|
63664
63564
|
logger.debug('on hub capsule ' + channel, payload);
|
|
63665
|
-
|
|
63666
63565
|
switch (channel) {
|
|
63667
63566
|
case 'auth':
|
|
63668
63567
|
authEvent(payload);
|
|
63669
63568
|
break;
|
|
63670
|
-
|
|
63671
63569
|
case 'storage':
|
|
63672
63570
|
storageEvent(payload);
|
|
63673
63571
|
break;
|
|
63674
|
-
|
|
63675
63572
|
case 'analytics':
|
|
63676
63573
|
analyticsEvent(payload);
|
|
63677
63574
|
break;
|
|
63678
|
-
|
|
63679
63575
|
default:
|
|
63680
63576
|
break;
|
|
63681
63577
|
}
|
|
63682
63578
|
};
|
|
63683
|
-
|
|
63684
63579
|
var storageEvent = function storageEvent(payload) {
|
|
63685
63580
|
var _a = payload.data,
|
|
63686
|
-
|
|
63687
|
-
|
|
63581
|
+
attrs = _a.attrs,
|
|
63582
|
+
metrics = _a.metrics;
|
|
63688
63583
|
if (!attrs) return;
|
|
63689
|
-
|
|
63690
63584
|
if (analyticsConfigured) {
|
|
63691
63585
|
_instance.record({
|
|
63692
63586
|
name: 'Storage',
|
|
@@ -63697,50 +63591,32 @@ var storageEvent = function storageEvent(payload) {
|
|
|
63697
63591
|
});
|
|
63698
63592
|
}
|
|
63699
63593
|
};
|
|
63700
|
-
|
|
63701
63594
|
var authEvent = function authEvent(payload) {
|
|
63702
63595
|
var event = payload.event;
|
|
63703
|
-
|
|
63704
63596
|
if (!event) {
|
|
63705
63597
|
return;
|
|
63706
63598
|
}
|
|
63707
|
-
|
|
63708
63599
|
var recordAuthEvent = function recordAuthEvent(eventName) {
|
|
63709
63600
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
63710
63601
|
var err_1;
|
|
63711
63602
|
return __generator(this, function (_a) {
|
|
63712
63603
|
switch (_a.label) {
|
|
63713
63604
|
case 0:
|
|
63714
|
-
if (!(authConfigured && analyticsConfigured)) return [3
|
|
63715
|
-
/*break*/
|
|
63716
|
-
, 4];
|
|
63605
|
+
if (!(authConfigured && analyticsConfigured)) return [3 /*break*/, 4];
|
|
63717
63606
|
_a.label = 1;
|
|
63718
|
-
|
|
63719
63607
|
case 1:
|
|
63720
63608
|
_a.trys.push([1, 3,, 4]);
|
|
63721
|
-
|
|
63722
|
-
return [4
|
|
63723
|
-
/*yield*/
|
|
63724
|
-
, _instance.record({
|
|
63609
|
+
return [4 /*yield*/, _instance.record({
|
|
63725
63610
|
name: "_userauth." + eventName
|
|
63726
63611
|
})];
|
|
63727
|
-
|
|
63728
63612
|
case 2:
|
|
63729
|
-
return [2
|
|
63730
|
-
/*return*/
|
|
63731
|
-
, _a.sent()];
|
|
63732
|
-
|
|
63613
|
+
return [2 /*return*/, _a.sent()];
|
|
63733
63614
|
case 3:
|
|
63734
63615
|
err_1 = _a.sent();
|
|
63735
63616
|
logger.debug("Failed to send the " + eventName + " event automatically", err_1);
|
|
63736
|
-
return [3
|
|
63737
|
-
/*break*/
|
|
63738
|
-
, 4];
|
|
63739
|
-
|
|
63617
|
+
return [3 /*break*/, 4];
|
|
63740
63618
|
case 4:
|
|
63741
|
-
return [2
|
|
63742
|
-
/*return*/
|
|
63743
|
-
];
|
|
63619
|
+
return [2 /*return*/];
|
|
63744
63620
|
}
|
|
63745
63621
|
});
|
|
63746
63622
|
});
|
|
@@ -63749,61 +63625,46 @@ var authEvent = function authEvent(payload) {
|
|
|
63749
63625
|
switch (event) {
|
|
63750
63626
|
case 'signIn':
|
|
63751
63627
|
return recordAuthEvent('sign_in');
|
|
63752
|
-
|
|
63753
63628
|
case 'signUp':
|
|
63754
63629
|
return recordAuthEvent('sign_up');
|
|
63755
|
-
|
|
63756
63630
|
case 'signOut':
|
|
63757
63631
|
return recordAuthEvent('sign_out');
|
|
63758
|
-
|
|
63759
63632
|
case 'signIn_failure':
|
|
63760
63633
|
return recordAuthEvent('auth_fail');
|
|
63761
|
-
|
|
63762
63634
|
case 'configured':
|
|
63763
63635
|
authConfigured = true;
|
|
63764
|
-
|
|
63765
63636
|
if (authConfigured && analyticsConfigured) {
|
|
63766
63637
|
sendEvents();
|
|
63767
63638
|
}
|
|
63768
|
-
|
|
63769
63639
|
break;
|
|
63770
63640
|
}
|
|
63771
63641
|
};
|
|
63772
|
-
|
|
63773
63642
|
var analyticsEvent = function analyticsEvent(payload) {
|
|
63774
63643
|
var event = payload.event;
|
|
63775
63644
|
if (!event) return;
|
|
63776
|
-
|
|
63777
63645
|
switch (event) {
|
|
63778
63646
|
case 'pinpointProvider_configured':
|
|
63779
63647
|
analyticsConfigured = true;
|
|
63780
|
-
|
|
63781
63648
|
if (authConfigured && analyticsConfigured) {
|
|
63782
63649
|
sendEvents();
|
|
63783
63650
|
}
|
|
63784
|
-
|
|
63785
63651
|
break;
|
|
63786
63652
|
}
|
|
63787
63653
|
};
|
|
63788
|
-
|
|
63789
63654
|
var sendEvents = function sendEvents() {
|
|
63790
63655
|
var config = _instance.configure();
|
|
63791
|
-
|
|
63792
63656
|
if (!endpointUpdated && config['autoSessionRecord']) {
|
|
63793
63657
|
_instance.updateEndpoint({
|
|
63794
63658
|
immediate: true
|
|
63795
63659
|
})["catch"](function (e) {
|
|
63796
63660
|
logger.debug('Failed to update the endpoint', e);
|
|
63797
63661
|
});
|
|
63798
|
-
|
|
63799
63662
|
endpointUpdated = true;
|
|
63800
63663
|
}
|
|
63801
|
-
|
|
63802
63664
|
_instance.autoTrack('session', {
|
|
63803
63665
|
enable: config['autoSessionRecord']
|
|
63804
63666
|
});
|
|
63805
63667
|
};
|
|
63806
|
-
|
|
63807
63668
|
var Analytics = new AnalyticsClass();
|
|
63808
63669
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Amplify"].register(Analytics);
|
|
63809
63670
|
|
|
@@ -63847,17 +63708,13 @@ var __extends = undefined && undefined.__extends || function () {
|
|
|
63847
63708
|
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
63848
63709
|
}
|
|
63849
63710
|
};
|
|
63850
|
-
|
|
63851
63711
|
return _extendStatics(d, b);
|
|
63852
63712
|
};
|
|
63853
|
-
|
|
63854
63713
|
return function (d, b) {
|
|
63855
63714
|
_extendStatics(d, b);
|
|
63856
|
-
|
|
63857
63715
|
function __() {
|
|
63858
63716
|
this.constructor = d;
|
|
63859
63717
|
}
|
|
63860
|
-
|
|
63861
63718
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
63862
63719
|
};
|
|
63863
63720
|
}();
|
|
@@ -63865,51 +63722,37 @@ var __extends = undefined && undefined.__extends || function () {
|
|
|
63865
63722
|
|
|
63866
63723
|
|
|
63867
63724
|
|
|
63868
|
-
|
|
63869
63725
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('AWSKineisFirehoseProvider');
|
|
63870
|
-
|
|
63871
|
-
var AWSKinesisFirehoseProvider =
|
|
63872
|
-
/** @class */
|
|
63873
|
-
function (_super) {
|
|
63726
|
+
var AWSKinesisFirehoseProvider = /** @class */function (_super) {
|
|
63874
63727
|
__extends(AWSKinesisFirehoseProvider, _super);
|
|
63875
|
-
|
|
63876
63728
|
function AWSKinesisFirehoseProvider(config) {
|
|
63877
63729
|
return _super.call(this, config) || this;
|
|
63878
63730
|
}
|
|
63879
63731
|
/**
|
|
63880
63732
|
* get provider name of the plugin
|
|
63881
63733
|
*/
|
|
63882
|
-
|
|
63883
|
-
|
|
63884
63734
|
AWSKinesisFirehoseProvider.prototype.getProviderName = function () {
|
|
63885
63735
|
return 'AWSKinesisFirehose';
|
|
63886
63736
|
};
|
|
63887
|
-
|
|
63888
63737
|
AWSKinesisFirehoseProvider.prototype._sendEvents = function (group) {
|
|
63889
63738
|
var _this = this;
|
|
63890
|
-
|
|
63891
63739
|
if (group.length === 0) {
|
|
63892
63740
|
return;
|
|
63893
63741
|
}
|
|
63894
|
-
|
|
63895
63742
|
var _a = group[0],
|
|
63896
|
-
|
|
63897
|
-
|
|
63898
|
-
|
|
63743
|
+
config = _a.config,
|
|
63744
|
+
credentials = _a.credentials;
|
|
63899
63745
|
var initClients = this._init(config, credentials);
|
|
63900
|
-
|
|
63901
63746
|
if (!initClients) return false;
|
|
63902
63747
|
var records = {};
|
|
63903
63748
|
group.map(function (params) {
|
|
63904
63749
|
// split by streamName
|
|
63905
63750
|
var evt = params.event;
|
|
63906
63751
|
var streamName = evt.streamName,
|
|
63907
|
-
|
|
63908
|
-
|
|
63752
|
+
data = evt.data;
|
|
63909
63753
|
if (records[streamName] === undefined) {
|
|
63910
63754
|
records[streamName] = [];
|
|
63911
63755
|
}
|
|
63912
|
-
|
|
63913
63756
|
var bufferData = data && typeof data !== 'string' ? JSON.stringify(data) : data;
|
|
63914
63757
|
var Data = Object(_aws_sdk_util_utf8_browser__WEBPACK_IMPORTED_MODULE_3__["fromUtf8"])(bufferData);
|
|
63915
63758
|
var record = {
|
|
@@ -63919,7 +63762,6 @@ function (_super) {
|
|
|
63919
63762
|
});
|
|
63920
63763
|
Object.keys(records).map(function (streamName) {
|
|
63921
63764
|
logger.debug('putting records to kinesis', streamName, 'with records', records[streamName]);
|
|
63922
|
-
|
|
63923
63765
|
_this._kinesisFirehose.send(new _aws_sdk_client_firehose__WEBPACK_IMPORTED_MODULE_2__["PutRecordBatchCommand"]({
|
|
63924
63766
|
Records: records[streamName],
|
|
63925
63767
|
DeliveryStreamName: streamName
|
|
@@ -63930,20 +63772,16 @@ function (_super) {
|
|
|
63930
63772
|
});
|
|
63931
63773
|
});
|
|
63932
63774
|
};
|
|
63933
|
-
|
|
63934
63775
|
AWSKinesisFirehoseProvider.prototype._init = function (config, credentials) {
|
|
63935
63776
|
logger.debug('init clients');
|
|
63936
|
-
|
|
63937
63777
|
if (this._kinesisFirehose && this._config.credentials && this._config.credentials.sessionToken === credentials.sessionToken && this._config.credentials.identityId === credentials.identityId) {
|
|
63938
63778
|
logger.debug('no change for analytics config, directly return from init');
|
|
63939
63779
|
return true;
|
|
63940
63780
|
}
|
|
63941
|
-
|
|
63942
63781
|
this._config.credentials = credentials;
|
|
63943
63782
|
var region = config.region;
|
|
63944
63783
|
return this._initFirehose(region, credentials);
|
|
63945
63784
|
};
|
|
63946
|
-
|
|
63947
63785
|
AWSKinesisFirehoseProvider.prototype._initFirehose = function (region, credentials) {
|
|
63948
63786
|
logger.debug('initialize kinesis firehose with credentials', credentials);
|
|
63949
63787
|
this._kinesisFirehose = new _aws_sdk_client_firehose__WEBPACK_IMPORTED_MODULE_2__["FirehoseClient"]({
|
|
@@ -63953,15 +63791,12 @@ function (_super) {
|
|
|
63953
63791
|
});
|
|
63954
63792
|
return true;
|
|
63955
63793
|
};
|
|
63956
|
-
|
|
63957
63794
|
return AWSKinesisFirehoseProvider;
|
|
63958
63795
|
}(_AWSKinesisProvider__WEBPACK_IMPORTED_MODULE_1__["AWSKinesisProvider"]);
|
|
63959
63796
|
|
|
63960
|
-
|
|
63961
63797
|
/**
|
|
63962
63798
|
* @deprecated use named import
|
|
63963
63799
|
*/
|
|
63964
|
-
|
|
63965
63800
|
/* harmony default export */ __webpack_exports__["default"] = (AWSKinesisFirehoseProvider);
|
|
63966
63801
|
|
|
63967
63802
|
/***/ }),
|
|
@@ -63998,7 +63833,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
63998
63833
|
resolve(value);
|
|
63999
63834
|
});
|
|
64000
63835
|
}
|
|
64001
|
-
|
|
64002
63836
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
64003
63837
|
function fulfilled(value) {
|
|
64004
63838
|
try {
|
|
@@ -64007,7 +63841,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
64007
63841
|
reject(e);
|
|
64008
63842
|
}
|
|
64009
63843
|
}
|
|
64010
|
-
|
|
64011
63844
|
function rejected(value) {
|
|
64012
63845
|
try {
|
|
64013
63846
|
step(generator["throw"](value));
|
|
@@ -64015,29 +63848,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
64015
63848
|
reject(e);
|
|
64016
63849
|
}
|
|
64017
63850
|
}
|
|
64018
|
-
|
|
64019
63851
|
function step(result) {
|
|
64020
63852
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
64021
63853
|
}
|
|
64022
|
-
|
|
64023
63854
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64024
63855
|
});
|
|
64025
63856
|
};
|
|
64026
|
-
|
|
64027
63857
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
64028
63858
|
var _ = {
|
|
64029
|
-
|
|
64030
|
-
|
|
64031
|
-
|
|
64032
|
-
|
|
63859
|
+
label: 0,
|
|
63860
|
+
sent: function sent() {
|
|
63861
|
+
if (t[0] & 1) throw t[1];
|
|
63862
|
+
return t[1];
|
|
63863
|
+
},
|
|
63864
|
+
trys: [],
|
|
63865
|
+
ops: []
|
|
64033
63866
|
},
|
|
64034
|
-
|
|
64035
|
-
|
|
64036
|
-
|
|
64037
|
-
|
|
64038
|
-
y,
|
|
64039
|
-
t,
|
|
64040
|
-
g;
|
|
63867
|
+
f,
|
|
63868
|
+
y,
|
|
63869
|
+
t,
|
|
63870
|
+
g;
|
|
64041
63871
|
return g = {
|
|
64042
63872
|
next: verb(0),
|
|
64043
63873
|
"throw": verb(1),
|
|
@@ -64045,79 +63875,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
64045
63875
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
64046
63876
|
return this;
|
|
64047
63877
|
}), g;
|
|
64048
|
-
|
|
64049
63878
|
function verb(n) {
|
|
64050
63879
|
return function (v) {
|
|
64051
63880
|
return step([n, v]);
|
|
64052
63881
|
};
|
|
64053
63882
|
}
|
|
64054
|
-
|
|
64055
63883
|
function step(op) {
|
|
64056
63884
|
if (f) throw new TypeError("Generator is already executing.");
|
|
64057
|
-
|
|
64058
63885
|
while (_) {
|
|
64059
63886
|
try {
|
|
64060
63887
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
64061
63888
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
64062
|
-
|
|
64063
63889
|
switch (op[0]) {
|
|
64064
63890
|
case 0:
|
|
64065
63891
|
case 1:
|
|
64066
63892
|
t = op;
|
|
64067
63893
|
break;
|
|
64068
|
-
|
|
64069
63894
|
case 4:
|
|
64070
63895
|
_.label++;
|
|
64071
63896
|
return {
|
|
64072
63897
|
value: op[1],
|
|
64073
63898
|
done: false
|
|
64074
63899
|
};
|
|
64075
|
-
|
|
64076
63900
|
case 5:
|
|
64077
63901
|
_.label++;
|
|
64078
63902
|
y = op[1];
|
|
64079
63903
|
op = [0];
|
|
64080
63904
|
continue;
|
|
64081
|
-
|
|
64082
63905
|
case 7:
|
|
64083
63906
|
op = _.ops.pop();
|
|
64084
|
-
|
|
64085
63907
|
_.trys.pop();
|
|
64086
|
-
|
|
64087
63908
|
continue;
|
|
64088
|
-
|
|
64089
63909
|
default:
|
|
64090
63910
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
64091
63911
|
_ = 0;
|
|
64092
63912
|
continue;
|
|
64093
63913
|
}
|
|
64094
|
-
|
|
64095
63914
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
64096
63915
|
_.label = op[1];
|
|
64097
63916
|
break;
|
|
64098
63917
|
}
|
|
64099
|
-
|
|
64100
63918
|
if (op[0] === 6 && _.label < t[1]) {
|
|
64101
63919
|
_.label = t[1];
|
|
64102
63920
|
t = op;
|
|
64103
63921
|
break;
|
|
64104
63922
|
}
|
|
64105
|
-
|
|
64106
63923
|
if (t && _.label < t[2]) {
|
|
64107
63924
|
_.label = t[2];
|
|
64108
|
-
|
|
64109
63925
|
_.ops.push(op);
|
|
64110
|
-
|
|
64111
63926
|
break;
|
|
64112
63927
|
}
|
|
64113
|
-
|
|
64114
63928
|
if (t[2]) _.ops.pop();
|
|
64115
|
-
|
|
64116
63929
|
_.trys.pop();
|
|
64117
|
-
|
|
64118
63930
|
continue;
|
|
64119
63931
|
}
|
|
64120
|
-
|
|
64121
63932
|
op = body.call(thisArg, _);
|
|
64122
63933
|
} catch (e) {
|
|
64123
63934
|
op = [6, e];
|
|
@@ -64126,7 +63937,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
64126
63937
|
f = t = 0;
|
|
64127
63938
|
}
|
|
64128
63939
|
}
|
|
64129
|
-
|
|
64130
63940
|
if (op[0] & 5) throw op[1];
|
|
64131
63941
|
return {
|
|
64132
63942
|
value: op[0] ? op[1] : void 0,
|
|
@@ -64137,18 +63947,13 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
64137
63947
|
|
|
64138
63948
|
|
|
64139
63949
|
|
|
64140
|
-
|
|
64141
|
-
|
|
64142
|
-
|
|
63950
|
+
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('AWSKinesisProvider');
|
|
63951
|
+
// events buffer
|
|
64143
63952
|
var BUFFER_SIZE = 1000;
|
|
64144
63953
|
var FLUSH_SIZE = 100;
|
|
64145
63954
|
var FLUSH_INTERVAL = 5 * 1000; // 5s
|
|
64146
|
-
|
|
64147
63955
|
var RESEND_LIMIT = 5;
|
|
64148
|
-
|
|
64149
|
-
var AWSKinesisProvider =
|
|
64150
|
-
/** @class */
|
|
64151
|
-
function () {
|
|
63956
|
+
var AWSKinesisProvider = /** @class */function () {
|
|
64152
63957
|
function AWSKinesisProvider(config) {
|
|
64153
63958
|
this._buffer = [];
|
|
64154
63959
|
this._config = config || {};
|
|
@@ -64156,46 +63961,35 @@ function () {
|
|
|
64156
63961
|
this._config.flushSize = this._config.flushSize || FLUSH_SIZE;
|
|
64157
63962
|
this._config.flushInterval = this._config.flushInterval || FLUSH_INTERVAL;
|
|
64158
63963
|
this._config.resendLimit = this._config.resendLimit || RESEND_LIMIT;
|
|
64159
|
-
|
|
64160
63964
|
this._setupTimer();
|
|
64161
63965
|
}
|
|
64162
|
-
|
|
64163
63966
|
AWSKinesisProvider.prototype._setupTimer = function () {
|
|
64164
63967
|
var _this = this;
|
|
64165
|
-
|
|
64166
63968
|
if (this._timer) {
|
|
64167
63969
|
clearInterval(this._timer);
|
|
64168
63970
|
}
|
|
64169
|
-
|
|
64170
63971
|
var _a = this._config,
|
|
64171
|
-
|
|
64172
|
-
|
|
63972
|
+
flushSize = _a.flushSize,
|
|
63973
|
+
flushInterval = _a.flushInterval;
|
|
64173
63974
|
this._timer = setInterval(function () {
|
|
64174
63975
|
var size = _this._buffer.length < flushSize ? _this._buffer.length : flushSize;
|
|
64175
63976
|
var events = [];
|
|
64176
|
-
|
|
64177
63977
|
for (var i = 0; i < size; i += 1) {
|
|
64178
63978
|
var params = _this._buffer.shift();
|
|
64179
|
-
|
|
64180
63979
|
events.push(params);
|
|
64181
63980
|
}
|
|
64182
|
-
|
|
64183
63981
|
_this._sendFromBuffer(events);
|
|
64184
63982
|
}, flushInterval);
|
|
64185
63983
|
};
|
|
64186
63984
|
/**
|
|
64187
63985
|
* get the category of the plugin
|
|
64188
63986
|
*/
|
|
64189
|
-
|
|
64190
|
-
|
|
64191
63987
|
AWSKinesisProvider.prototype.getCategory = function () {
|
|
64192
63988
|
return 'Analytics';
|
|
64193
63989
|
};
|
|
64194
63990
|
/**
|
|
64195
63991
|
* get provider name of the plugin
|
|
64196
63992
|
*/
|
|
64197
|
-
|
|
64198
|
-
|
|
64199
63993
|
AWSKinesisProvider.prototype.getProviderName = function () {
|
|
64200
63994
|
return 'AWSKinesis';
|
|
64201
63995
|
};
|
|
@@ -64203,50 +63997,36 @@ function () {
|
|
|
64203
63997
|
* configure the plugin
|
|
64204
63998
|
* @param {Object} config - configuration
|
|
64205
63999
|
*/
|
|
64206
|
-
|
|
64207
|
-
|
|
64208
64000
|
AWSKinesisProvider.prototype.configure = function (config) {
|
|
64209
64001
|
logger.debug('configure Analytics', config);
|
|
64210
64002
|
var conf = config || {};
|
|
64211
64003
|
this._config = Object.assign({}, this._config, conf);
|
|
64212
|
-
|
|
64213
64004
|
this._setupTimer();
|
|
64214
|
-
|
|
64215
64005
|
return this._config;
|
|
64216
64006
|
};
|
|
64217
64007
|
/**
|
|
64218
64008
|
* record an event
|
|
64219
64009
|
* @param {Object} params - the params of an event
|
|
64220
64010
|
*/
|
|
64221
|
-
|
|
64222
|
-
|
|
64223
64011
|
AWSKinesisProvider.prototype.record = function (params) {
|
|
64224
64012
|
return __awaiter(this, void 0, void 0, function () {
|
|
64225
64013
|
var credentials;
|
|
64226
64014
|
return __generator(this, function (_a) {
|
|
64227
64015
|
switch (_a.label) {
|
|
64228
64016
|
case 0:
|
|
64229
|
-
return [4
|
|
64230
|
-
/*yield*/
|
|
64231
|
-
, this._getCredentials()];
|
|
64232
|
-
|
|
64017
|
+
return [4 /*yield*/, this._getCredentials()];
|
|
64233
64018
|
case 1:
|
|
64234
64019
|
credentials = _a.sent();
|
|
64235
|
-
if (!credentials) return [2
|
|
64236
|
-
/*return*/
|
|
64237
|
-
, Promise.resolve(false)];
|
|
64020
|
+
if (!credentials) return [2 /*return*/, Promise.resolve(false)];
|
|
64238
64021
|
Object.assign(params, {
|
|
64239
64022
|
config: this._config,
|
|
64240
64023
|
credentials: credentials
|
|
64241
64024
|
});
|
|
64242
|
-
return [2
|
|
64243
|
-
/*return*/
|
|
64244
|
-
, this._putToBuffer(params)];
|
|
64025
|
+
return [2 /*return*/, this._putToBuffer(params)];
|
|
64245
64026
|
}
|
|
64246
64027
|
});
|
|
64247
64028
|
});
|
|
64248
64029
|
};
|
|
64249
|
-
|
|
64250
64030
|
AWSKinesisProvider.prototype.updateEndpoint = function () {
|
|
64251
64031
|
logger.debug('updateEndpoint is not implemented in Kinesis provider');
|
|
64252
64032
|
return Promise.resolve(true);
|
|
@@ -64256,31 +64036,24 @@ function () {
|
|
|
64256
64036
|
* @param params - params for the event recording
|
|
64257
64037
|
* Put events into buffer
|
|
64258
64038
|
*/
|
|
64259
|
-
|
|
64260
|
-
|
|
64261
64039
|
AWSKinesisProvider.prototype._putToBuffer = function (params) {
|
|
64262
64040
|
if (this._buffer.length < BUFFER_SIZE) {
|
|
64263
64041
|
this._buffer.push(params);
|
|
64264
|
-
|
|
64265
64042
|
return Promise.resolve(true);
|
|
64266
64043
|
} else {
|
|
64267
64044
|
logger.debug('exceed analytics events buffer size');
|
|
64268
64045
|
return Promise.reject(false);
|
|
64269
64046
|
}
|
|
64270
64047
|
};
|
|
64271
|
-
|
|
64272
64048
|
AWSKinesisProvider.prototype._sendFromBuffer = function (events) {
|
|
64273
|
-
var _this = this;
|
|
64049
|
+
var _this = this;
|
|
64050
|
+
// collapse events by credentials
|
|
64274
64051
|
// events = [ {params} ]
|
|
64275
|
-
|
|
64276
|
-
|
|
64277
64052
|
var eventsGroups = [];
|
|
64278
64053
|
var preCred = null;
|
|
64279
64054
|
var group = [];
|
|
64280
|
-
|
|
64281
64055
|
for (var i = 0; i < events.length; i += 1) {
|
|
64282
64056
|
var cred = events[i].credentials;
|
|
64283
|
-
|
|
64284
64057
|
if (i === 0) {
|
|
64285
64058
|
group.push(events[i]);
|
|
64286
64059
|
preCred = cred;
|
|
@@ -64296,37 +64069,29 @@ function () {
|
|
|
64296
64069
|
}
|
|
64297
64070
|
}
|
|
64298
64071
|
}
|
|
64299
|
-
|
|
64300
64072
|
eventsGroups.push(group);
|
|
64301
64073
|
eventsGroups.map(function (evts) {
|
|
64302
64074
|
_this._sendEvents(evts);
|
|
64303
64075
|
});
|
|
64304
64076
|
};
|
|
64305
|
-
|
|
64306
64077
|
AWSKinesisProvider.prototype._sendEvents = function (group) {
|
|
64307
64078
|
var _this = this;
|
|
64308
|
-
|
|
64309
64079
|
if (group.length === 0) {
|
|
64310
64080
|
return;
|
|
64311
64081
|
}
|
|
64312
|
-
|
|
64313
64082
|
var _a = group[0],
|
|
64314
|
-
|
|
64315
|
-
|
|
64316
|
-
|
|
64083
|
+
config = _a.config,
|
|
64084
|
+
credentials = _a.credentials;
|
|
64317
64085
|
var initClients = this._init(config, credentials);
|
|
64318
|
-
|
|
64319
64086
|
if (!initClients) return false;
|
|
64320
64087
|
var records = {};
|
|
64321
64088
|
group.map(function (params) {
|
|
64322
64089
|
// spit by streamName
|
|
64323
64090
|
var evt = params.event;
|
|
64324
64091
|
var streamName = evt.streamName;
|
|
64325
|
-
|
|
64326
64092
|
if (records[streamName] === undefined) {
|
|
64327
64093
|
records[streamName] = [];
|
|
64328
64094
|
}
|
|
64329
|
-
|
|
64330
64095
|
var bufferData = evt.data && typeof evt.data !== 'string' ? JSON.stringify(evt.data) : evt.data;
|
|
64331
64096
|
var Data = Object(_aws_sdk_util_utf8_browser__WEBPACK_IMPORTED_MODULE_2__["fromUtf8"])(bufferData);
|
|
64332
64097
|
var PartitionKey = evt.partitionKey || 'partition-' + credentials.identityId;
|
|
@@ -64344,37 +64109,23 @@ function () {
|
|
|
64344
64109
|
case 0:
|
|
64345
64110
|
logger.debug('putting records to kinesis with records', records[streamName]);
|
|
64346
64111
|
_a.label = 1;
|
|
64347
|
-
|
|
64348
64112
|
case 1:
|
|
64349
64113
|
_a.trys.push([1, 3,, 4]);
|
|
64350
|
-
|
|
64351
64114
|
command = new _aws_sdk_client_kinesis__WEBPACK_IMPORTED_MODULE_1__["PutRecordsCommand"]({
|
|
64352
64115
|
Records: records[streamName],
|
|
64353
64116
|
StreamName: streamName
|
|
64354
64117
|
});
|
|
64355
|
-
return [4
|
|
64356
|
-
/*yield*/
|
|
64357
|
-
, this._kinesis.send(command)];
|
|
64358
|
-
|
|
64118
|
+
return [4 /*yield*/, this._kinesis.send(command)];
|
|
64359
64119
|
case 2:
|
|
64360
64120
|
_a.sent();
|
|
64361
|
-
|
|
64362
64121
|
logger.debug('Upload records to stream', streamName);
|
|
64363
|
-
return [3
|
|
64364
|
-
/*break*/
|
|
64365
|
-
, 4];
|
|
64366
|
-
|
|
64122
|
+
return [3 /*break*/, 4];
|
|
64367
64123
|
case 3:
|
|
64368
64124
|
err_1 = _a.sent();
|
|
64369
64125
|
logger.debug('Failed to upload records to Kinesis', err_1);
|
|
64370
|
-
return [3
|
|
64371
|
-
/*break*/
|
|
64372
|
-
, 4];
|
|
64373
|
-
|
|
64126
|
+
return [3 /*break*/, 4];
|
|
64374
64127
|
case 4:
|
|
64375
|
-
return [2
|
|
64376
|
-
/*return*/
|
|
64377
|
-
];
|
|
64128
|
+
return [2 /*return*/];
|
|
64378
64129
|
}
|
|
64379
64130
|
});
|
|
64380
64131
|
});
|
|
@@ -64383,18 +64134,15 @@ function () {
|
|
|
64383
64134
|
|
|
64384
64135
|
AWSKinesisProvider.prototype._init = function (config, credentials) {
|
|
64385
64136
|
logger.debug('init clients');
|
|
64386
|
-
|
|
64387
64137
|
if (this._kinesis && this._config.credentials && this._config.credentials.sessionToken === credentials.sessionToken && this._config.credentials.identityId === credentials.identityId) {
|
|
64388
64138
|
logger.debug('no change for analytics config, directly return from init');
|
|
64389
64139
|
return true;
|
|
64390
64140
|
}
|
|
64391
|
-
|
|
64392
64141
|
this._config.credentials = credentials;
|
|
64393
64142
|
var region = config.region,
|
|
64394
|
-
|
|
64143
|
+
endpoint = config.endpoint;
|
|
64395
64144
|
return this._initKinesis(region, endpoint, credentials);
|
|
64396
64145
|
};
|
|
64397
|
-
|
|
64398
64146
|
AWSKinesisProvider.prototype._initKinesis = function (region, endpoint, credentials) {
|
|
64399
64147
|
logger.debug('initialize kinesis with credentials', credentials);
|
|
64400
64148
|
this._kinesis = new _aws_sdk_client_kinesis__WEBPACK_IMPORTED_MODULE_1__["KinesisClient"]({
|
|
@@ -64409,11 +64157,8 @@ function () {
|
|
|
64409
64157
|
* @private
|
|
64410
64158
|
* check if current credentials exists
|
|
64411
64159
|
*/
|
|
64412
|
-
|
|
64413
|
-
|
|
64414
64160
|
AWSKinesisProvider.prototype._getCredentials = function () {
|
|
64415
64161
|
var _this = this;
|
|
64416
|
-
|
|
64417
64162
|
return _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get().then(function (credentials) {
|
|
64418
64163
|
if (!credentials) return null;
|
|
64419
64164
|
logger.debug('set credentials for analytics', _this._config.credentials);
|
|
@@ -64423,15 +64168,12 @@ function () {
|
|
|
64423
64168
|
return null;
|
|
64424
64169
|
});
|
|
64425
64170
|
};
|
|
64426
|
-
|
|
64427
64171
|
return AWSKinesisProvider;
|
|
64428
64172
|
}();
|
|
64429
64173
|
|
|
64430
|
-
|
|
64431
64174
|
/**
|
|
64432
64175
|
* @deprecated use named import
|
|
64433
64176
|
*/
|
|
64434
|
-
|
|
64435
64177
|
/* harmony default export */ __webpack_exports__["default"] = (AWSKinesisProvider);
|
|
64436
64178
|
|
|
64437
64179
|
/***/ }),
|
|
@@ -64475,31 +64217,24 @@ function _typeof(obj) {
|
|
|
64475
64217
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
|
|
64476
64218
|
* and limitations under the License.
|
|
64477
64219
|
*/
|
|
64478
|
-
|
|
64479
|
-
|
|
64480
64220
|
var __assign = undefined && undefined.__assign || function () {
|
|
64481
64221
|
__assign = Object.assign || function (t) {
|
|
64482
64222
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
64483
64223
|
s = arguments[i];
|
|
64484
|
-
|
|
64485
64224
|
for (var p in s) {
|
|
64486
64225
|
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
64487
64226
|
}
|
|
64488
64227
|
}
|
|
64489
|
-
|
|
64490
64228
|
return t;
|
|
64491
64229
|
};
|
|
64492
|
-
|
|
64493
64230
|
return __assign.apply(this, arguments);
|
|
64494
64231
|
};
|
|
64495
|
-
|
|
64496
64232
|
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
64497
64233
|
function adopt(value) {
|
|
64498
64234
|
return value instanceof P ? value : new P(function (resolve) {
|
|
64499
64235
|
resolve(value);
|
|
64500
64236
|
});
|
|
64501
64237
|
}
|
|
64502
|
-
|
|
64503
64238
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
64504
64239
|
function fulfilled(value) {
|
|
64505
64240
|
try {
|
|
@@ -64508,7 +64243,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
64508
64243
|
reject(e);
|
|
64509
64244
|
}
|
|
64510
64245
|
}
|
|
64511
|
-
|
|
64512
64246
|
function rejected(value) {
|
|
64513
64247
|
try {
|
|
64514
64248
|
step(generator["throw"](value));
|
|
@@ -64516,29 +64250,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
64516
64250
|
reject(e);
|
|
64517
64251
|
}
|
|
64518
64252
|
}
|
|
64519
|
-
|
|
64520
64253
|
function step(result) {
|
|
64521
64254
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
64522
64255
|
}
|
|
64523
|
-
|
|
64524
64256
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64525
64257
|
});
|
|
64526
64258
|
};
|
|
64527
|
-
|
|
64528
64259
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
64529
64260
|
var _ = {
|
|
64530
|
-
|
|
64531
|
-
|
|
64532
|
-
|
|
64533
|
-
|
|
64261
|
+
label: 0,
|
|
64262
|
+
sent: function sent() {
|
|
64263
|
+
if (t[0] & 1) throw t[1];
|
|
64264
|
+
return t[1];
|
|
64265
|
+
},
|
|
64266
|
+
trys: [],
|
|
64267
|
+
ops: []
|
|
64534
64268
|
},
|
|
64535
|
-
|
|
64536
|
-
|
|
64537
|
-
|
|
64538
|
-
|
|
64539
|
-
y,
|
|
64540
|
-
t,
|
|
64541
|
-
g;
|
|
64269
|
+
f,
|
|
64270
|
+
y,
|
|
64271
|
+
t,
|
|
64272
|
+
g;
|
|
64542
64273
|
return g = {
|
|
64543
64274
|
next: verb(0),
|
|
64544
64275
|
"throw": verb(1),
|
|
@@ -64546,79 +64277,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
64546
64277
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
64547
64278
|
return this;
|
|
64548
64279
|
}), g;
|
|
64549
|
-
|
|
64550
64280
|
function verb(n) {
|
|
64551
64281
|
return function (v) {
|
|
64552
64282
|
return step([n, v]);
|
|
64553
64283
|
};
|
|
64554
64284
|
}
|
|
64555
|
-
|
|
64556
64285
|
function step(op) {
|
|
64557
64286
|
if (f) throw new TypeError("Generator is already executing.");
|
|
64558
|
-
|
|
64559
64287
|
while (_) {
|
|
64560
64288
|
try {
|
|
64561
64289
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
64562
64290
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
64563
|
-
|
|
64564
64291
|
switch (op[0]) {
|
|
64565
64292
|
case 0:
|
|
64566
64293
|
case 1:
|
|
64567
64294
|
t = op;
|
|
64568
64295
|
break;
|
|
64569
|
-
|
|
64570
64296
|
case 4:
|
|
64571
64297
|
_.label++;
|
|
64572
64298
|
return {
|
|
64573
64299
|
value: op[1],
|
|
64574
64300
|
done: false
|
|
64575
64301
|
};
|
|
64576
|
-
|
|
64577
64302
|
case 5:
|
|
64578
64303
|
_.label++;
|
|
64579
64304
|
y = op[1];
|
|
64580
64305
|
op = [0];
|
|
64581
64306
|
continue;
|
|
64582
|
-
|
|
64583
64307
|
case 7:
|
|
64584
64308
|
op = _.ops.pop();
|
|
64585
|
-
|
|
64586
64309
|
_.trys.pop();
|
|
64587
|
-
|
|
64588
64310
|
continue;
|
|
64589
|
-
|
|
64590
64311
|
default:
|
|
64591
64312
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
64592
64313
|
_ = 0;
|
|
64593
64314
|
continue;
|
|
64594
64315
|
}
|
|
64595
|
-
|
|
64596
64316
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
64597
64317
|
_.label = op[1];
|
|
64598
64318
|
break;
|
|
64599
64319
|
}
|
|
64600
|
-
|
|
64601
64320
|
if (op[0] === 6 && _.label < t[1]) {
|
|
64602
64321
|
_.label = t[1];
|
|
64603
64322
|
t = op;
|
|
64604
64323
|
break;
|
|
64605
64324
|
}
|
|
64606
|
-
|
|
64607
64325
|
if (t && _.label < t[2]) {
|
|
64608
64326
|
_.label = t[2];
|
|
64609
|
-
|
|
64610
64327
|
_.ops.push(op);
|
|
64611
|
-
|
|
64612
64328
|
break;
|
|
64613
64329
|
}
|
|
64614
|
-
|
|
64615
64330
|
if (t[2]) _.ops.pop();
|
|
64616
|
-
|
|
64617
64331
|
_.trys.pop();
|
|
64618
|
-
|
|
64619
64332
|
continue;
|
|
64620
64333
|
}
|
|
64621
|
-
|
|
64622
64334
|
op = body.call(thisArg, _);
|
|
64623
64335
|
} catch (e) {
|
|
64624
64336
|
op = [6, e];
|
|
@@ -64627,7 +64339,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
64627
64339
|
f = t = 0;
|
|
64628
64340
|
}
|
|
64629
64341
|
}
|
|
64630
|
-
|
|
64631
64342
|
if (op[0] & 5) throw op[1];
|
|
64632
64343
|
return {
|
|
64633
64344
|
value: op[0] ? op[1] : void 0,
|
|
@@ -64635,14 +64346,11 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
64635
64346
|
};
|
|
64636
64347
|
}
|
|
64637
64348
|
};
|
|
64638
|
-
|
|
64639
64349
|
var __rest = undefined && undefined.__rest || function (s, e) {
|
|
64640
64350
|
var t = {};
|
|
64641
|
-
|
|
64642
64351
|
for (var p in s) {
|
|
64643
64352
|
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
64644
64353
|
}
|
|
64645
|
-
|
|
64646
64354
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
64647
64355
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
64648
64356
|
}
|
|
@@ -64653,16 +64361,13 @@ var __rest = undefined && undefined.__rest || function (s, e) {
|
|
|
64653
64361
|
|
|
64654
64362
|
|
|
64655
64363
|
|
|
64656
|
-
|
|
64657
64364
|
var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
|
|
64658
|
-
|
|
64659
64365
|
var dispatchAnalyticsEvent = function dispatchAnalyticsEvent(event, data) {
|
|
64660
64366
|
_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].dispatch('analytics', {
|
|
64661
64367
|
event: event,
|
|
64662
64368
|
data: data
|
|
64663
64369
|
}, 'Analytics', AMPLIFY_SYMBOL);
|
|
64664
64370
|
};
|
|
64665
|
-
|
|
64666
64371
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('AWSPinpointProvider');
|
|
64667
64372
|
var RETRYABLE_CODES = [429, 500];
|
|
64668
64373
|
var ACCEPTED_CODES = [202];
|
|
@@ -64672,17 +64377,14 @@ var EXPIRED_TOKEN_CODE = 'ExpiredTokenException';
|
|
|
64672
64377
|
var UPDATE_ENDPOINT = '_update_endpoint';
|
|
64673
64378
|
var SESSION_START = '_session.start';
|
|
64674
64379
|
var SESSION_STOP = '_session.stop';
|
|
64675
|
-
var BEACON_SUPPORTED = typeof navigator !== 'undefined' && navigator && typeof navigator.sendBeacon === 'function';
|
|
64676
|
-
|
|
64380
|
+
var BEACON_SUPPORTED = typeof navigator !== 'undefined' && navigator && typeof navigator.sendBeacon === 'function';
|
|
64381
|
+
// events buffer
|
|
64677
64382
|
var BUFFER_SIZE = 1000;
|
|
64678
64383
|
var FLUSH_SIZE = 100;
|
|
64679
64384
|
var FLUSH_INTERVAL = 5 * 1000; // 5s
|
|
64680
|
-
|
|
64681
|
-
|
|
64682
|
-
|
|
64683
|
-
var AWSPinpointProvider =
|
|
64684
|
-
/** @class */
|
|
64685
|
-
function () {
|
|
64385
|
+
var RESEND_LIMIT = 5;
|
|
64386
|
+
// params: { event: {name: , .... }, timeStamp, config, resendLimits }
|
|
64387
|
+
var AWSPinpointProvider = /** @class */function () {
|
|
64686
64388
|
function AWSPinpointProvider(config) {
|
|
64687
64389
|
this._endpointGenerating = true;
|
|
64688
64390
|
this._endpointUpdateInProgress = false;
|
|
@@ -64698,16 +64400,12 @@ function () {
|
|
|
64698
64400
|
/**
|
|
64699
64401
|
* get the category of the plugin
|
|
64700
64402
|
*/
|
|
64701
|
-
|
|
64702
|
-
|
|
64703
64403
|
AWSPinpointProvider.prototype.getCategory = function () {
|
|
64704
64404
|
return AWSPinpointProvider.category;
|
|
64705
64405
|
};
|
|
64706
64406
|
/**
|
|
64707
64407
|
* get provider name of the plugin
|
|
64708
64408
|
*/
|
|
64709
|
-
|
|
64710
|
-
|
|
64711
64409
|
AWSPinpointProvider.prototype.getProviderName = function () {
|
|
64712
64410
|
return AWSPinpointProvider.providerName;
|
|
64713
64411
|
};
|
|
@@ -64715,22 +64413,17 @@ function () {
|
|
|
64715
64413
|
* configure the plugin
|
|
64716
64414
|
* @param {Object} config - configuration
|
|
64717
64415
|
*/
|
|
64718
|
-
|
|
64719
|
-
|
|
64720
64416
|
AWSPinpointProvider.prototype.configure = function (config) {
|
|
64721
64417
|
var _this = this;
|
|
64722
|
-
|
|
64723
64418
|
logger.debug('configure Analytics', config);
|
|
64724
64419
|
var conf = config || {};
|
|
64725
|
-
this._config = Object.assign({}, this._config, conf);
|
|
64420
|
+
this._config = Object.assign({}, this._config, conf);
|
|
64421
|
+
// If autoSessionRecord is enabled, we need to wait for the endpoint to be
|
|
64726
64422
|
// updated before sending any events. See `sendEvents` in `Analytics.ts`
|
|
64727
|
-
|
|
64728
64423
|
this._endpointGenerating = !!config['autoSessionRecord'];
|
|
64729
|
-
|
|
64730
64424
|
if (this._config.appId && !this._config.disabled) {
|
|
64731
64425
|
if (!this._config.endpointId) {
|
|
64732
64426
|
var cacheKey = this.getProviderName() + '_' + this._config.appId;
|
|
64733
|
-
|
|
64734
64427
|
this._getEndpointId(cacheKey).then(function (endpointId) {
|
|
64735
64428
|
logger.debug('setting endpoint id from the cache', endpointId);
|
|
64736
64429
|
_this._config.endpointId = endpointId;
|
|
@@ -64744,15 +64437,12 @@ function () {
|
|
|
64744
64437
|
} else {
|
|
64745
64438
|
this._flushBuffer();
|
|
64746
64439
|
}
|
|
64747
|
-
|
|
64748
64440
|
return this._config;
|
|
64749
64441
|
};
|
|
64750
64442
|
/**
|
|
64751
64443
|
* record an event
|
|
64752
64444
|
* @param {Object} params - the params of an event
|
|
64753
64445
|
*/
|
|
64754
|
-
|
|
64755
|
-
|
|
64756
64446
|
AWSPinpointProvider.prototype.record = function (params, handlers) {
|
|
64757
64447
|
return __awaiter(this, void 0, void 0, function () {
|
|
64758
64448
|
var credentials, timestamp;
|
|
@@ -64760,43 +64450,28 @@ function () {
|
|
|
64760
64450
|
switch (_a.label) {
|
|
64761
64451
|
case 0:
|
|
64762
64452
|
logger.debug('_public record', params);
|
|
64763
|
-
return [4
|
|
64764
|
-
/*yield*/
|
|
64765
|
-
, this._getCredentials()];
|
|
64766
|
-
|
|
64453
|
+
return [4 /*yield*/, this._getCredentials()];
|
|
64767
64454
|
case 1:
|
|
64768
64455
|
credentials = _a.sent();
|
|
64769
|
-
|
|
64770
64456
|
if (!credentials || !this._config.appId || !this._config.region) {
|
|
64771
64457
|
logger.debug('cannot send events without credentials, applicationId or region');
|
|
64772
|
-
return [2
|
|
64773
|
-
/*return*/
|
|
64774
|
-
, handlers.reject(new Error('No credentials, applicationId or region'))];
|
|
64458
|
+
return [2 /*return*/, handlers.reject(new Error('No credentials, applicationId or region'))];
|
|
64775
64459
|
}
|
|
64776
|
-
|
|
64777
64460
|
this._initClients(credentials);
|
|
64778
|
-
|
|
64779
|
-
|
|
64780
|
-
|
|
64461
|
+
timestamp = new Date().getTime();
|
|
64462
|
+
// attach the session and eventId
|
|
64781
64463
|
this._generateSession(params);
|
|
64782
|
-
|
|
64783
64464
|
params.event.eventId = Object(uuid__WEBPACK_IMPORTED_MODULE_3__["v1"])();
|
|
64784
64465
|
Object.assign(params, {
|
|
64785
64466
|
timestamp: timestamp,
|
|
64786
64467
|
config: this._config
|
|
64787
64468
|
});
|
|
64788
|
-
|
|
64789
64469
|
if (params.event.immediate) {
|
|
64790
|
-
return [2
|
|
64791
|
-
/*return*/
|
|
64792
|
-
, this._send(params, handlers)];
|
|
64470
|
+
return [2 /*return*/, this._send(params, handlers)];
|
|
64793
64471
|
} else {
|
|
64794
64472
|
this._putToBuffer(params, handlers);
|
|
64795
64473
|
}
|
|
64796
|
-
|
|
64797
|
-
return [2
|
|
64798
|
-
/*return*/
|
|
64799
|
-
];
|
|
64474
|
+
return [2 /*return*/];
|
|
64800
64475
|
}
|
|
64801
64476
|
});
|
|
64802
64477
|
});
|
|
@@ -64810,26 +64485,17 @@ function () {
|
|
|
64810
64485
|
case 0:
|
|
64811
64486
|
if (this._endpointUpdateInProgress) {
|
|
64812
64487
|
this._endpointBuffer.push(endpointObject);
|
|
64813
|
-
|
|
64814
|
-
return [2
|
|
64815
|
-
/*return*/
|
|
64816
|
-
];
|
|
64488
|
+
return [2 /*return*/];
|
|
64817
64489
|
}
|
|
64818
64490
|
|
|
64819
64491
|
this._endpointUpdateInProgress = true;
|
|
64820
|
-
return [4
|
|
64821
|
-
/*yield*/
|
|
64822
|
-
, this._updateEndpoint(endpointObject)];
|
|
64823
|
-
|
|
64492
|
+
return [4 /*yield*/, this._updateEndpoint(endpointObject)];
|
|
64824
64493
|
case 1:
|
|
64825
64494
|
_a.sent();
|
|
64826
|
-
|
|
64827
64495
|
next = this._endpointBuffer.shift();
|
|
64828
64496
|
this._endpointUpdateInProgress = false;
|
|
64829
64497
|
next && this._sendEndpointUpdate(next);
|
|
64830
|
-
return [2
|
|
64831
|
-
/*return*/
|
|
64832
|
-
];
|
|
64498
|
+
return [2 /*return*/];
|
|
64833
64499
|
}
|
|
64834
64500
|
});
|
|
64835
64501
|
});
|
|
@@ -64839,28 +64505,22 @@ function () {
|
|
|
64839
64505
|
* @param params - params for event recording
|
|
64840
64506
|
* Put events into buffer
|
|
64841
64507
|
*/
|
|
64842
|
-
|
|
64843
|
-
|
|
64844
64508
|
AWSPinpointProvider.prototype._putToBuffer = function (params, handlers) {
|
|
64845
64509
|
if (params.event.name === UPDATE_ENDPOINT) {
|
|
64846
64510
|
this._sendEndpointUpdate({
|
|
64847
64511
|
params: params,
|
|
64848
64512
|
handlers: handlers
|
|
64849
64513
|
});
|
|
64850
|
-
|
|
64851
64514
|
return;
|
|
64852
64515
|
}
|
|
64853
|
-
|
|
64854
64516
|
this._buffer && this._buffer.push({
|
|
64855
64517
|
params: params,
|
|
64856
64518
|
handlers: handlers
|
|
64857
64519
|
});
|
|
64858
64520
|
};
|
|
64859
|
-
|
|
64860
64521
|
AWSPinpointProvider.prototype._generateSession = function (params) {
|
|
64861
64522
|
this._sessionId = this._sessionId || Object(uuid__WEBPACK_IMPORTED_MODULE_3__["v1"])();
|
|
64862
64523
|
var event = params.event;
|
|
64863
|
-
|
|
64864
64524
|
switch (event.name) {
|
|
64865
64525
|
case SESSION_START:
|
|
64866
64526
|
// refresh the session id and session start time
|
|
@@ -64871,7 +64531,6 @@ function () {
|
|
|
64871
64531
|
StartTimestamp: new Date(this._sessionStartTimestamp).toISOString()
|
|
64872
64532
|
};
|
|
64873
64533
|
break;
|
|
64874
|
-
|
|
64875
64534
|
case SESSION_STOP:
|
|
64876
64535
|
var stopTimestamp = new Date().getTime();
|
|
64877
64536
|
this._sessionStartTimestamp = this._sessionStartTimestamp || new Date().getTime();
|
|
@@ -64885,7 +64544,6 @@ function () {
|
|
|
64885
64544
|
this._sessionId = undefined;
|
|
64886
64545
|
this._sessionStartTimestamp = undefined;
|
|
64887
64546
|
break;
|
|
64888
|
-
|
|
64889
64547
|
default:
|
|
64890
64548
|
this._sessionStartTimestamp = this._sessionStartTimestamp || new Date().getTime();
|
|
64891
64549
|
this._sessionId = this._sessionId || Object(uuid__WEBPACK_IMPORTED_MODULE_3__["v1"])();
|
|
@@ -64895,53 +64553,39 @@ function () {
|
|
|
64895
64553
|
};
|
|
64896
64554
|
}
|
|
64897
64555
|
};
|
|
64898
|
-
|
|
64899
64556
|
AWSPinpointProvider.prototype._send = function (params, handlers) {
|
|
64900
64557
|
return __awaiter(this, void 0, void 0, function () {
|
|
64901
64558
|
var event;
|
|
64902
64559
|
return __generator(this, function (_a) {
|
|
64903
64560
|
event = params.event;
|
|
64904
|
-
|
|
64905
64561
|
switch (event.name) {
|
|
64906
64562
|
case UPDATE_ENDPOINT:
|
|
64907
|
-
return [2
|
|
64908
|
-
/*return*/
|
|
64909
|
-
, this._updateEndpoint({
|
|
64563
|
+
return [2 /*return*/, this._updateEndpoint({
|
|
64910
64564
|
params: params,
|
|
64911
64565
|
handlers: handlers
|
|
64912
64566
|
})];
|
|
64913
|
-
|
|
64914
64567
|
case SESSION_STOP:
|
|
64915
|
-
return [2
|
|
64916
|
-
/*return*/
|
|
64917
|
-
, this._pinpointSendStopSession(params, handlers)];
|
|
64918
|
-
|
|
64568
|
+
return [2 /*return*/, this._pinpointSendStopSession(params, handlers)];
|
|
64919
64569
|
default:
|
|
64920
|
-
return [2
|
|
64921
|
-
/*return*/
|
|
64922
|
-
, this._pinpointPutEvents(params, handlers)];
|
|
64570
|
+
return [2 /*return*/, this._pinpointPutEvents(params, handlers)];
|
|
64923
64571
|
}
|
|
64924
|
-
|
|
64925
|
-
return [2
|
|
64926
|
-
/*return*/
|
|
64927
|
-
];
|
|
64572
|
+
return [2 /*return*/];
|
|
64928
64573
|
});
|
|
64929
64574
|
});
|
|
64930
64575
|
};
|
|
64931
64576
|
|
|
64932
64577
|
AWSPinpointProvider.prototype._generateBatchItemContext = function (params) {
|
|
64933
64578
|
var _a;
|
|
64934
|
-
|
|
64935
64579
|
var event = params.event,
|
|
64936
|
-
|
|
64937
|
-
|
|
64580
|
+
timestamp = params.timestamp,
|
|
64581
|
+
config = params.config;
|
|
64938
64582
|
var name = event.name,
|
|
64939
|
-
|
|
64940
|
-
|
|
64941
|
-
|
|
64942
|
-
|
|
64583
|
+
attributes = event.attributes,
|
|
64584
|
+
metrics = event.metrics,
|
|
64585
|
+
eventId = event.eventId,
|
|
64586
|
+
session = event.session;
|
|
64943
64587
|
var appId = config.appId,
|
|
64944
|
-
|
|
64588
|
+
endpointId = config.endpointId;
|
|
64945
64589
|
var endpointContext = {};
|
|
64946
64590
|
var eventParams = {
|
|
64947
64591
|
ApplicationId: appId,
|
|
@@ -64961,11 +64605,9 @@ function () {
|
|
|
64961
64605
|
eventParams.EventsRequest.BatchItem[endpointId] = endpointObj;
|
|
64962
64606
|
return eventParams;
|
|
64963
64607
|
};
|
|
64964
|
-
|
|
64965
64608
|
AWSPinpointProvider.prototype._pinpointPutEvents = function (params, handlers) {
|
|
64966
64609
|
return __awaiter(this, void 0, void 0, function () {
|
|
64967
64610
|
var eventId, endpointId, eventParams, command, data, _a, _b, _c, _d, StatusCode, Message, err_1;
|
|
64968
|
-
|
|
64969
64611
|
return __generator(this, function (_e) {
|
|
64970
64612
|
switch (_e.label) {
|
|
64971
64613
|
case 0:
|
|
@@ -64973,51 +64615,30 @@ function () {
|
|
|
64973
64615
|
eventParams = this._generateBatchItemContext(params);
|
|
64974
64616
|
command = new _aws_sdk_client_pinpoint__WEBPACK_IMPORTED_MODULE_1__["PutEventsCommand"](eventParams);
|
|
64975
64617
|
_e.label = 1;
|
|
64976
|
-
|
|
64977
64618
|
case 1:
|
|
64978
64619
|
_e.trys.push([1, 3,, 4]);
|
|
64979
|
-
|
|
64980
|
-
return [4
|
|
64981
|
-
/*yield*/
|
|
64982
|
-
, this.pinpointClient.send(command)];
|
|
64983
|
-
|
|
64620
|
+
return [4 /*yield*/, this.pinpointClient.send(command)];
|
|
64984
64621
|
case 2:
|
|
64985
64622
|
data = _e.sent();
|
|
64986
64623
|
_a = data, _b = endpointId, _c = eventId, _d = _a.EventsResponse.Results[_b].EventsItemResponse[_c], StatusCode = _d.StatusCode, Message = _d.Message;
|
|
64987
|
-
|
|
64988
64624
|
if (ACCEPTED_CODES.includes(StatusCode)) {
|
|
64989
64625
|
logger.debug('record event success. ', data);
|
|
64990
|
-
return [2
|
|
64991
|
-
/*return*/
|
|
64992
|
-
, handlers.resolve(data)];
|
|
64626
|
+
return [2 /*return*/, handlers.resolve(data)];
|
|
64993
64627
|
} else {
|
|
64994
64628
|
if (RETRYABLE_CODES.includes(StatusCode)) {
|
|
64995
64629
|
this._retry(params, handlers);
|
|
64996
64630
|
} else {
|
|
64997
64631
|
logger.error("Event " + eventId + " is not accepted, the error is " + Message);
|
|
64998
|
-
return [2
|
|
64999
|
-
/*return*/
|
|
65000
|
-
, handlers.reject(data)];
|
|
64632
|
+
return [2 /*return*/, handlers.reject(data)];
|
|
65001
64633
|
}
|
|
65002
64634
|
}
|
|
65003
|
-
|
|
65004
|
-
return [3
|
|
65005
|
-
/*break*/
|
|
65006
|
-
, 4];
|
|
65007
|
-
|
|
64635
|
+
return [3 /*break*/, 4];
|
|
65008
64636
|
case 3:
|
|
65009
64637
|
err_1 = _e.sent();
|
|
65010
|
-
|
|
65011
64638
|
this._eventError(err_1);
|
|
65012
|
-
|
|
65013
|
-
return [2
|
|
65014
|
-
/*return*/
|
|
65015
|
-
, handlers.reject(err_1)];
|
|
65016
|
-
|
|
64639
|
+
return [2 /*return*/, handlers.reject(err_1)];
|
|
65017
64640
|
case 4:
|
|
65018
|
-
return [2
|
|
65019
|
-
/*return*/
|
|
65020
|
-
];
|
|
64641
|
+
return [2 /*return*/];
|
|
65021
64642
|
}
|
|
65022
64643
|
});
|
|
65023
64644
|
});
|
|
@@ -65026,15 +64647,12 @@ function () {
|
|
|
65026
64647
|
AWSPinpointProvider.prototype._pinpointSendStopSession = function (params, handlers) {
|
|
65027
64648
|
if (!BEACON_SUPPORTED) {
|
|
65028
64649
|
this._pinpointPutEvents(params, handlers);
|
|
65029
|
-
|
|
65030
64650
|
return;
|
|
65031
64651
|
}
|
|
65032
|
-
|
|
65033
64652
|
var eventParams = this._generateBatchItemContext(params);
|
|
65034
|
-
|
|
65035
64653
|
var region = this._config.region;
|
|
65036
64654
|
var ApplicationId = eventParams.ApplicationId,
|
|
65037
|
-
|
|
64655
|
+
EventsRequest = eventParams.EventsRequest;
|
|
65038
64656
|
var accessInfo = {
|
|
65039
64657
|
secret_key: this._config.credentials.secretAccessKey,
|
|
65040
64658
|
access_key: this._config.credentials.accessKeyId,
|
|
@@ -65054,28 +64672,22 @@ function () {
|
|
|
65054
64672
|
};
|
|
65055
64673
|
var requestUrl = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Signer"].signUrl(request, accessInfo, serviceInfo, null);
|
|
65056
64674
|
var success = navigator.sendBeacon(requestUrl, body);
|
|
65057
|
-
|
|
65058
64675
|
if (success) {
|
|
65059
64676
|
return handlers.resolve('sendBeacon success');
|
|
65060
64677
|
}
|
|
65061
|
-
|
|
65062
64678
|
return handlers.reject('sendBeacon failure');
|
|
65063
64679
|
};
|
|
65064
|
-
|
|
65065
64680
|
AWSPinpointProvider.prototype._retry = function (params, handlers) {
|
|
65066
|
-
var resendLimit = params.config.resendLimit;
|
|
65067
|
-
|
|
64681
|
+
var resendLimit = params.config.resendLimit;
|
|
64682
|
+
// For backward compatibility
|
|
65068
64683
|
params.resendLimit = typeof params.resendLimit === 'number' ? params.resendLimit : resendLimit;
|
|
65069
|
-
|
|
65070
64684
|
if (params.resendLimit-- > 0) {
|
|
65071
64685
|
logger.debug("resending event " + params.eventName + " with " + params.resendLimit + " retry times left");
|
|
65072
|
-
|
|
65073
64686
|
this._pinpointPutEvents(params, handlers);
|
|
65074
64687
|
} else {
|
|
65075
64688
|
logger.debug("retry times used up for event " + params.eventName);
|
|
65076
64689
|
}
|
|
65077
64690
|
};
|
|
65078
|
-
|
|
65079
64691
|
AWSPinpointProvider.prototype._updateEndpoint = function (endpointObject) {
|
|
65080
64692
|
return __awaiter(this, void 0, void 0, function () {
|
|
65081
64693
|
var params, handlers, config, event, appId, endpointId, request, update_params, command, data, err_2, failureData;
|
|
@@ -65092,27 +64704,17 @@ function () {
|
|
|
65092
64704
|
EndpointRequest: request
|
|
65093
64705
|
};
|
|
65094
64706
|
_a.label = 1;
|
|
65095
|
-
|
|
65096
64707
|
case 1:
|
|
65097
64708
|
_a.trys.push([1, 3,, 4]);
|
|
65098
|
-
|
|
65099
64709
|
command = new _aws_sdk_client_pinpoint__WEBPACK_IMPORTED_MODULE_1__["UpdateEndpointCommand"](update_params);
|
|
65100
|
-
return [4
|
|
65101
|
-
/*yield*/
|
|
65102
|
-
, this.pinpointClient.send(command)];
|
|
65103
|
-
|
|
64710
|
+
return [4 /*yield*/, this.pinpointClient.send(command)];
|
|
65104
64711
|
case 2:
|
|
65105
64712
|
data = _a.sent();
|
|
65106
64713
|
logger.debug('updateEndpoint success', data);
|
|
65107
64714
|
this._endpointGenerating = false;
|
|
65108
|
-
|
|
65109
64715
|
this._resumeBuffer();
|
|
65110
|
-
|
|
65111
64716
|
handlers.resolve(data);
|
|
65112
|
-
return [2
|
|
65113
|
-
/*return*/
|
|
65114
|
-
];
|
|
65115
|
-
|
|
64717
|
+
return [2 /*return*/];
|
|
65116
64718
|
case 3:
|
|
65117
64719
|
err_2 = _a.sent();
|
|
65118
64720
|
failureData = {
|
|
@@ -65120,14 +64722,9 @@ function () {
|
|
|
65120
64722
|
update_params: update_params,
|
|
65121
64723
|
endpointObject: endpointObject
|
|
65122
64724
|
};
|
|
65123
|
-
return [2
|
|
65124
|
-
/*return*/
|
|
65125
|
-
, this._handleEndpointUpdateFailure(failureData)];
|
|
65126
|
-
|
|
64725
|
+
return [2 /*return*/, this._handleEndpointUpdateFailure(failureData)];
|
|
65127
64726
|
case 4:
|
|
65128
|
-
return [2
|
|
65129
|
-
/*return*/
|
|
65130
|
-
];
|
|
64727
|
+
return [2 /*return*/];
|
|
65131
64728
|
}
|
|
65132
64729
|
});
|
|
65133
64730
|
});
|
|
@@ -65140,65 +64737,48 @@ function () {
|
|
|
65140
64737
|
err = failureData.err, endpointObject = failureData.endpointObject;
|
|
65141
64738
|
statusCode = err.$metadata && err.$metadata.httpStatusCode;
|
|
65142
64739
|
logger.debug('updateEndpoint error', err);
|
|
65143
|
-
|
|
65144
64740
|
switch (statusCode) {
|
|
65145
64741
|
case FORBIDDEN_CODE:
|
|
65146
|
-
return [2
|
|
65147
|
-
/*return*/
|
|
65148
|
-
, this._handleEndpointUpdateForbidden(failureData)];
|
|
65149
|
-
|
|
64742
|
+
return [2 /*return*/, this._handleEndpointUpdateForbidden(failureData)];
|
|
65150
64743
|
default:
|
|
65151
64744
|
if (RETRYABLE_CODES.includes(statusCode)) {
|
|
65152
64745
|
exponential = true;
|
|
65153
|
-
return [2
|
|
65154
|
-
/*return*/
|
|
65155
|
-
, this._retryEndpointUpdate(endpointObject, exponential)];
|
|
64746
|
+
return [2 /*return*/, this._retryEndpointUpdate(endpointObject, exponential)];
|
|
65156
64747
|
}
|
|
65157
|
-
|
|
65158
64748
|
logger.error('updateEndpoint failed', err);
|
|
65159
64749
|
endpointObject.handlers.reject(err);
|
|
65160
64750
|
}
|
|
65161
|
-
|
|
65162
|
-
return [2
|
|
65163
|
-
/*return*/
|
|
65164
|
-
];
|
|
64751
|
+
return [2 /*return*/];
|
|
65165
64752
|
});
|
|
65166
64753
|
});
|
|
65167
64754
|
};
|
|
65168
64755
|
|
|
65169
64756
|
AWSPinpointProvider.prototype._handleEndpointUpdateForbidden = function (failureData) {
|
|
65170
64757
|
var err = failureData.err,
|
|
65171
|
-
|
|
64758
|
+
endpointObject = failureData.endpointObject;
|
|
65172
64759
|
var code = err.code,
|
|
65173
|
-
|
|
65174
|
-
|
|
64760
|
+
retryable = err.retryable;
|
|
65175
64761
|
if (code !== EXPIRED_TOKEN_CODE && !retryable) {
|
|
65176
64762
|
return endpointObject.handlers.reject(err);
|
|
65177
64763
|
}
|
|
65178
|
-
|
|
65179
64764
|
this._retryEndpointUpdate(endpointObject);
|
|
65180
64765
|
};
|
|
65181
|
-
|
|
65182
64766
|
AWSPinpointProvider.prototype._retryEndpointUpdate = function (endpointObject, exponential) {
|
|
65183
64767
|
if (exponential === void 0) {
|
|
65184
64768
|
exponential = false;
|
|
65185
64769
|
}
|
|
65186
|
-
|
|
65187
64770
|
logger.debug('_retryEndpointUpdate', endpointObject);
|
|
65188
|
-
var params = endpointObject.params;
|
|
65189
|
-
|
|
64771
|
+
var params = endpointObject.params;
|
|
64772
|
+
// TODO: implement retry with exp back off once exp function is available
|
|
65190
64773
|
var resendLimit = params.config.resendLimit;
|
|
65191
64774
|
params.resendLimit = typeof params.resendLimit === 'number' ? params.resendLimit : resendLimit;
|
|
65192
|
-
|
|
65193
64775
|
if (params.resendLimit-- > 0) {
|
|
65194
|
-
logger.debug("resending endpoint update " + params.event.eventId + " with " + params.resendLimit + " retry attempts remaining");
|
|
65195
|
-
|
|
64776
|
+
logger.debug("resending endpoint update " + params.event.eventId + " with " + params.resendLimit + " retry attempts remaining");
|
|
64777
|
+
// insert at the front of endpointBuffer
|
|
65196
64778
|
this._endpointBuffer.length ? this._endpointBuffer.unshift(endpointObject) : this._updateEndpoint(endpointObject);
|
|
65197
64779
|
return;
|
|
65198
64780
|
}
|
|
65199
|
-
|
|
65200
64781
|
logger.warn("resending endpoint update " + params.event.eventId + " failed after " + params.config.resendLimit + " attempts");
|
|
65201
|
-
|
|
65202
64782
|
if (this._endpointGenerating) {
|
|
65203
64783
|
logger.error('Initial endpoint update failed. ');
|
|
65204
64784
|
}
|
|
@@ -65208,19 +64788,14 @@ function () {
|
|
|
65208
64788
|
* @param config
|
|
65209
64789
|
* Init the clients
|
|
65210
64790
|
*/
|
|
65211
|
-
|
|
65212
|
-
|
|
65213
64791
|
AWSPinpointProvider.prototype._initClients = function (credentials) {
|
|
65214
64792
|
return __awaiter(this, void 0, void 0, function () {
|
|
65215
64793
|
var identityId, region;
|
|
65216
64794
|
return __generator(this, function (_a) {
|
|
65217
64795
|
logger.debug('init clients');
|
|
65218
|
-
|
|
65219
64796
|
if (this.pinpointClient && this._config.credentials && this._config.credentials.sessionToken === credentials.sessionToken && this._config.credentials.identityId === credentials.identityId) {
|
|
65220
64797
|
logger.debug('no change for aws credentials, directly return from init');
|
|
65221
|
-
return [2
|
|
65222
|
-
/*return*/
|
|
65223
|
-
];
|
|
64798
|
+
return [2 /*return*/];
|
|
65224
64799
|
}
|
|
65225
64800
|
|
|
65226
64801
|
identityId = this._config.credentials ? this._config.credentials.identityId : null;
|
|
@@ -65231,8 +64806,8 @@ function () {
|
|
|
65231
64806
|
region: region,
|
|
65232
64807
|
credentials: credentials,
|
|
65233
64808
|
customUserAgent: Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["getAmplifyUserAgent"])()
|
|
65234
|
-
});
|
|
65235
|
-
|
|
64809
|
+
});
|
|
64810
|
+
// TODO: remove this middleware once a long term fix is implemented by aws-sdk-js team.
|
|
65236
64811
|
this.pinpointClient.middlewareStack.addRelativeTo(function (next) {
|
|
65237
64812
|
return function (args) {
|
|
65238
64813
|
delete args.request.headers['amz-sdk-invocation-id'];
|
|
@@ -65244,7 +64819,6 @@ function () {
|
|
|
65244
64819
|
relation: 'after',
|
|
65245
64820
|
toMiddleware: 'retryMiddleware'
|
|
65246
64821
|
});
|
|
65247
|
-
|
|
65248
64822
|
if (this._bufferExists() && identityId === credentials.identityId) {
|
|
65249
64823
|
// if the identity has remained the same, pass the updated client to the buffer
|
|
65250
64824
|
this._updateBufferClient();
|
|
@@ -65254,12 +64828,8 @@ function () {
|
|
|
65254
64828
|
// with the old credentials and then stop looping and shortly thereafter get picked up by GC
|
|
65255
64829
|
this._initBuffer();
|
|
65256
64830
|
}
|
|
65257
|
-
|
|
65258
64831
|
this._customizePinpointClientReq();
|
|
65259
|
-
|
|
65260
|
-
return [2
|
|
65261
|
-
/*return*/
|
|
65262
|
-
];
|
|
64832
|
+
return [2 /*return*/];
|
|
65263
64833
|
});
|
|
65264
64834
|
});
|
|
65265
64835
|
};
|
|
@@ -65267,41 +64837,35 @@ function () {
|
|
|
65267
64837
|
AWSPinpointProvider.prototype._bufferExists = function () {
|
|
65268
64838
|
return this._buffer && this._buffer instanceof _EventBuffer__WEBPACK_IMPORTED_MODULE_4__["default"];
|
|
65269
64839
|
};
|
|
65270
|
-
|
|
65271
64840
|
AWSPinpointProvider.prototype._initBuffer = function () {
|
|
65272
64841
|
if (this._bufferExists()) {
|
|
65273
64842
|
this._flushBuffer();
|
|
65274
64843
|
}
|
|
65275
|
-
|
|
65276
|
-
|
|
64844
|
+
this._buffer = new _EventBuffer__WEBPACK_IMPORTED_MODULE_4__["default"](this.pinpointClient, this._config);
|
|
64845
|
+
// if the first endpoint update hasn't yet resolved pause the buffer to
|
|
65277
64846
|
// prevent race conditions. It will be resumed as soon as that request succeeds
|
|
65278
|
-
|
|
65279
64847
|
if (this._endpointGenerating) {
|
|
65280
64848
|
this._buffer.pause();
|
|
65281
64849
|
}
|
|
65282
64850
|
};
|
|
65283
|
-
|
|
65284
64851
|
AWSPinpointProvider.prototype._updateBufferClient = function () {
|
|
65285
64852
|
if (this._bufferExists()) {
|
|
65286
64853
|
this._buffer.updateClient(this.pinpointClient);
|
|
65287
64854
|
}
|
|
65288
64855
|
};
|
|
65289
|
-
|
|
65290
64856
|
AWSPinpointProvider.prototype._flushBuffer = function () {
|
|
65291
64857
|
if (this._bufferExists()) {
|
|
65292
64858
|
this._buffer.flush();
|
|
65293
|
-
|
|
65294
64859
|
this._buffer = null;
|
|
65295
64860
|
}
|
|
65296
64861
|
};
|
|
65297
|
-
|
|
65298
64862
|
AWSPinpointProvider.prototype._resumeBuffer = function () {
|
|
65299
64863
|
if (this._bufferExists()) {
|
|
65300
64864
|
this._buffer.resume();
|
|
65301
64865
|
}
|
|
65302
64866
|
};
|
|
65303
|
-
|
|
65304
|
-
|
|
64867
|
+
AWSPinpointProvider.prototype._customizePinpointClientReq = function () {
|
|
64868
|
+
// TODO FIXME: Find a middleware to do this with AWS V3 SDK
|
|
65305
64869
|
// if (Platform.isReactNative) {
|
|
65306
64870
|
// this.pinpointClient.customizeRequests(request => {
|
|
65307
64871
|
// request.on('build', req => {
|
|
@@ -65310,21 +64874,16 @@ function () {
|
|
|
65310
64874
|
// });
|
|
65311
64875
|
// }
|
|
65312
64876
|
};
|
|
65313
|
-
|
|
65314
64877
|
AWSPinpointProvider.prototype._getEndpointId = function (cacheKey) {
|
|
65315
64878
|
return __awaiter(this, void 0, void 0, function () {
|
|
65316
64879
|
var endpointId, ttl, expiration;
|
|
65317
64880
|
return __generator(this, function (_a) {
|
|
65318
64881
|
switch (_a.label) {
|
|
65319
64882
|
case 0:
|
|
65320
|
-
return [4
|
|
65321
|
-
/*yield*/
|
|
65322
|
-
, _aws_amplify_cache__WEBPACK_IMPORTED_MODULE_2___default.a.getItem(cacheKey)];
|
|
65323
|
-
|
|
64883
|
+
return [4 /*yield*/, _aws_amplify_cache__WEBPACK_IMPORTED_MODULE_2___default.a.getItem(cacheKey)];
|
|
65324
64884
|
case 1:
|
|
65325
64885
|
endpointId = _a.sent();
|
|
65326
64886
|
logger.debug('endpointId from cache', endpointId, 'type', _typeof(endpointId));
|
|
65327
|
-
|
|
65328
64887
|
if (!endpointId) {
|
|
65329
64888
|
endpointId = Object(uuid__WEBPACK_IMPORTED_MODULE_3__["v1"])();
|
|
65330
64889
|
ttl = 1000 * 60 * 60 * 24 * 365 * 100;
|
|
@@ -65334,10 +64893,7 @@ function () {
|
|
|
65334
64893
|
priority: 1
|
|
65335
64894
|
});
|
|
65336
64895
|
}
|
|
65337
|
-
|
|
65338
|
-
return [2
|
|
65339
|
-
/*return*/
|
|
65340
|
-
, endpointId];
|
|
64896
|
+
return [2 /*return*/, endpointId];
|
|
65341
64897
|
}
|
|
65342
64898
|
});
|
|
65343
64899
|
});
|
|
@@ -65346,16 +64902,14 @@ function () {
|
|
|
65346
64902
|
* EndPoint request
|
|
65347
64903
|
* @return {Object} - The request of updating endpoint
|
|
65348
64904
|
*/
|
|
65349
|
-
|
|
65350
|
-
|
|
65351
64905
|
AWSPinpointProvider.prototype._endpointRequest = function (config, event) {
|
|
65352
64906
|
var credentials = config.credentials;
|
|
65353
64907
|
var clientInfo = this._clientInfo || {};
|
|
65354
|
-
var clientContext = config.clientContext || {};
|
|
64908
|
+
var clientContext = config.clientContext || {};
|
|
64909
|
+
// for now we have three different ways for default endpoint configurations
|
|
65355
64910
|
// clientInfo
|
|
65356
64911
|
// clientContext (deprecated)
|
|
65357
64912
|
// config.endpoint
|
|
65358
|
-
|
|
65359
64913
|
var defaultEndpointConfig = config.endpoint || {};
|
|
65360
64914
|
var demographicByClientInfo = {
|
|
65361
64915
|
appVersion: clientInfo.appVersion,
|
|
@@ -65363,17 +64917,15 @@ function () {
|
|
|
65363
64917
|
model: clientInfo.model,
|
|
65364
64918
|
modelVersion: clientInfo.version,
|
|
65365
64919
|
platform: clientInfo.platform
|
|
65366
|
-
};
|
|
65367
|
-
|
|
64920
|
+
};
|
|
64921
|
+
// for backward compatibility
|
|
65368
64922
|
var clientId = clientContext.clientId,
|
|
65369
|
-
|
|
65370
|
-
|
|
65371
|
-
|
|
65372
|
-
|
|
65373
|
-
|
|
65374
|
-
|
|
64923
|
+
appTitle = clientContext.appTitle,
|
|
64924
|
+
appVersionName = clientContext.appVersionName,
|
|
64925
|
+
appVersionCode = clientContext.appVersionCode,
|
|
64926
|
+
appPackageName = clientContext.appPackageName,
|
|
64927
|
+
demographicByClientContext = __rest(clientContext, ["clientId", "appTitle", "appVersionName", "appVersionCode", "appPackageName"]);
|
|
65375
64928
|
var channelType = event.address ? clientInfo.platform === 'android' ? 'GCM' : 'APNS' : undefined;
|
|
65376
|
-
|
|
65377
64929
|
var tmp = __assign(__assign(__assign({
|
|
65378
64930
|
channelType: channelType,
|
|
65379
64931
|
requestId: Object(uuid__WEBPACK_IMPORTED_MODULE_3__["v1"])(),
|
|
@@ -65387,25 +64939,21 @@ function () {
|
|
|
65387
64939
|
userId: event.userId || defaultEndpointConfig.userId || credentials.identityId,
|
|
65388
64940
|
userAttributes: __assign(__assign({}, defaultEndpointConfig.userAttributes), event.userAttributes)
|
|
65389
64941
|
}
|
|
65390
|
-
});
|
|
65391
|
-
|
|
65392
|
-
|
|
64942
|
+
});
|
|
64943
|
+
// eliminate unnecessary params
|
|
65393
64944
|
var userId = tmp.userId,
|
|
65394
|
-
|
|
65395
|
-
|
|
65396
|
-
|
|
65397
|
-
|
|
65398
|
-
|
|
65399
|
-
|
|
65400
|
-
|
|
64945
|
+
userAttributes = tmp.userAttributes,
|
|
64946
|
+
name = tmp.name,
|
|
64947
|
+
session = tmp.session,
|
|
64948
|
+
eventId = tmp.eventId,
|
|
64949
|
+
immediate = tmp.immediate,
|
|
64950
|
+
ret = __rest(tmp, ["userId", "userAttributes", "name", "session", "eventId", "immediate"]);
|
|
65401
64951
|
return _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].transferKeyToUpperCase(ret, [], ['metrics', 'userAttributes', 'attributes']);
|
|
65402
64952
|
};
|
|
65403
|
-
|
|
65404
64953
|
AWSPinpointProvider.prototype._eventError = function (err) {
|
|
65405
64954
|
logger.error('record event failed.', err);
|
|
65406
64955
|
logger.warn("Please ensure you have updated your Pinpoint IAM Policy " + "with the Action: \"mobiletargeting:PutEvents\" " + "in order to record events");
|
|
65407
64956
|
};
|
|
65408
|
-
|
|
65409
64957
|
AWSPinpointProvider.prototype._getCredentials = function () {
|
|
65410
64958
|
return __awaiter(this, void 0, void 0, function () {
|
|
65411
64959
|
var credentials, err_3;
|
|
@@ -65413,32 +64961,18 @@ function () {
|
|
|
65413
64961
|
switch (_a.label) {
|
|
65414
64962
|
case 0:
|
|
65415
64963
|
_a.trys.push([0, 2,, 3]);
|
|
65416
|
-
|
|
65417
|
-
return [4
|
|
65418
|
-
/*yield*/
|
|
65419
|
-
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
65420
|
-
|
|
64964
|
+
return [4 /*yield*/, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get()];
|
|
65421
64965
|
case 1:
|
|
65422
64966
|
credentials = _a.sent();
|
|
65423
|
-
if (!credentials) return [2
|
|
65424
|
-
/*return*/
|
|
65425
|
-
, null];
|
|
64967
|
+
if (!credentials) return [2 /*return*/, null];
|
|
65426
64968
|
logger.debug('set credentials for analytics', credentials);
|
|
65427
|
-
return [2
|
|
65428
|
-
/*return*/
|
|
65429
|
-
, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].shear(credentials)];
|
|
65430
|
-
|
|
64969
|
+
return [2 /*return*/, _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].shear(credentials)];
|
|
65431
64970
|
case 2:
|
|
65432
64971
|
err_3 = _a.sent();
|
|
65433
64972
|
logger.debug('ensure credentials error', err_3);
|
|
65434
|
-
return [2
|
|
65435
|
-
/*return*/
|
|
65436
|
-
, null];
|
|
65437
|
-
|
|
64973
|
+
return [2 /*return*/, null];
|
|
65438
64974
|
case 3:
|
|
65439
|
-
return [2
|
|
65440
|
-
/*return*/
|
|
65441
|
-
];
|
|
64975
|
+
return [2 /*return*/];
|
|
65442
64976
|
}
|
|
65443
64977
|
});
|
|
65444
64978
|
});
|
|
@@ -65449,11 +64983,9 @@ function () {
|
|
|
65449
64983
|
return AWSPinpointProvider;
|
|
65450
64984
|
}();
|
|
65451
64985
|
|
|
65452
|
-
|
|
65453
64986
|
/**
|
|
65454
64987
|
* @deprecated use named import
|
|
65455
64988
|
*/
|
|
65456
|
-
|
|
65457
64989
|
/* harmony default export */ __webpack_exports__["default"] = (AWSPinpointProvider);
|
|
65458
64990
|
|
|
65459
64991
|
/***/ }),
|
|
@@ -65469,36 +65001,27 @@ function () {
|
|
|
65469
65001
|
__webpack_require__.r(__webpack_exports__);
|
|
65470
65002
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MediaAutoTrack", function() { return MediaAutoTrack; });
|
|
65471
65003
|
var HTML5_MEDIA_EVENT;
|
|
65472
|
-
|
|
65473
65004
|
(function (HTML5_MEDIA_EVENT) {
|
|
65474
65005
|
HTML5_MEDIA_EVENT["PLAY"] = "play";
|
|
65475
65006
|
HTML5_MEDIA_EVENT["PAUSE"] = "pause";
|
|
65476
65007
|
HTML5_MEDIA_EVENT["ENDED"] = "Ended";
|
|
65477
65008
|
})(HTML5_MEDIA_EVENT || (HTML5_MEDIA_EVENT = {}));
|
|
65478
|
-
|
|
65479
65009
|
var MEDIA_TYPE;
|
|
65480
|
-
|
|
65481
65010
|
(function (MEDIA_TYPE) {
|
|
65482
65011
|
MEDIA_TYPE["IFRAME"] = "IFRAME";
|
|
65483
65012
|
MEDIA_TYPE["VIDEO"] = "VIDEO";
|
|
65484
65013
|
MEDIA_TYPE["AUDIO"] = "AUDIO";
|
|
65485
65014
|
})(MEDIA_TYPE || (MEDIA_TYPE = {}));
|
|
65486
|
-
|
|
65487
65015
|
var EVENT_TYPE;
|
|
65488
|
-
|
|
65489
65016
|
(function (EVENT_TYPE) {
|
|
65490
65017
|
EVENT_TYPE["PLAY"] = "Play";
|
|
65491
65018
|
EVENT_TYPE["ENDED"] = "Ended";
|
|
65492
65019
|
EVENT_TYPE["PAUSE"] = "Pause";
|
|
65493
65020
|
EVENT_TYPE["TIME_WATCHED"] = "TimeWatched";
|
|
65494
65021
|
})(EVENT_TYPE || (EVENT_TYPE = {}));
|
|
65495
|
-
|
|
65496
|
-
var MediaAutoTrack =
|
|
65497
|
-
/** @class */
|
|
65498
|
-
function () {
|
|
65022
|
+
var MediaAutoTrack = /** @class */function () {
|
|
65499
65023
|
function MediaAutoTrack(params, provider) {
|
|
65500
65024
|
var _a;
|
|
65501
|
-
|
|
65502
65025
|
this.eventActionMapping = (_a = {}, _a[EVENT_TYPE.ENDED] = this.endedEventAction.bind(this), _a[EVENT_TYPE.PLAY] = this.playEventAction.bind(this), _a[EVENT_TYPE.PAUSE] = this.pauseEventAction.bind(this), _a);
|
|
65503
65026
|
var eventData = params.eventData;
|
|
65504
65027
|
this._params = params;
|
|
@@ -65510,12 +65033,9 @@ function () {
|
|
|
65510
65033
|
VIDEO: this._html5MediaTracker,
|
|
65511
65034
|
AUDIO: this._html5MediaTracker
|
|
65512
65035
|
};
|
|
65513
|
-
|
|
65514
65036
|
mediaTrackFunMapping[this._mediaElement.tagName].bind(this)();
|
|
65515
|
-
|
|
65516
65037
|
this._initYoutubeFrame();
|
|
65517
65038
|
}
|
|
65518
|
-
|
|
65519
65039
|
MediaAutoTrack.prototype._initYoutubeFrame = function () {
|
|
65520
65040
|
this._youTubeIframeLoader = {
|
|
65521
65041
|
src: 'https://www.youtube.com/iframe_api',
|
|
@@ -65524,28 +65044,21 @@ function () {
|
|
|
65524
65044
|
listeners: [],
|
|
65525
65045
|
load: function load(callback) {
|
|
65526
65046
|
var _this = this;
|
|
65527
|
-
|
|
65528
65047
|
this.listeners.push(callback);
|
|
65529
|
-
|
|
65530
65048
|
if (this.loaded) {
|
|
65531
65049
|
setTimeout(function () {
|
|
65532
65050
|
_this.done();
|
|
65533
65051
|
});
|
|
65534
65052
|
return;
|
|
65535
65053
|
}
|
|
65536
|
-
|
|
65537
65054
|
if (this.loading) {
|
|
65538
65055
|
return;
|
|
65539
65056
|
}
|
|
65540
|
-
|
|
65541
65057
|
this.loading = true;
|
|
65542
|
-
|
|
65543
65058
|
window['onYouTubeIframeAPIReady'] = function () {
|
|
65544
65059
|
_this.loaded = true;
|
|
65545
|
-
|
|
65546
65060
|
_this.done();
|
|
65547
65061
|
};
|
|
65548
|
-
|
|
65549
65062
|
var script = document.createElement('script');
|
|
65550
65063
|
script.type = 'text/javascript';
|
|
65551
65064
|
script.src = this.src;
|
|
@@ -65553,14 +65066,12 @@ function () {
|
|
|
65553
65066
|
},
|
|
65554
65067
|
done: function done() {
|
|
65555
65068
|
delete window['onYouTubeIframeAPIReady'];
|
|
65556
|
-
|
|
65557
65069
|
while (this.listeners.length) {
|
|
65558
65070
|
this.listeners.pop()(window['YT']);
|
|
65559
65071
|
}
|
|
65560
65072
|
}
|
|
65561
65073
|
};
|
|
65562
65074
|
};
|
|
65563
|
-
|
|
65564
65075
|
MediaAutoTrack.prototype._iframeMediaTracker = function () {
|
|
65565
65076
|
var that = this;
|
|
65566
65077
|
setInterval(function () {
|
|
@@ -65568,7 +65079,6 @@ function () {
|
|
|
65568
65079
|
that.recordEvent(MEDIA_TYPE.IFRAME, EVENT_TYPE.TIME_WATCHED);
|
|
65569
65080
|
}
|
|
65570
65081
|
}, 3 * 1000);
|
|
65571
|
-
|
|
65572
65082
|
this._youTubeIframeLoader.load(function (YT) {
|
|
65573
65083
|
that._iframePlayer = new YT.Player(that._mediaElement.id, {
|
|
65574
65084
|
events: {
|
|
@@ -65577,7 +65087,6 @@ function () {
|
|
|
65577
65087
|
});
|
|
65578
65088
|
});
|
|
65579
65089
|
};
|
|
65580
|
-
|
|
65581
65090
|
MediaAutoTrack.prototype._onPlayerStateChange = function (event) {
|
|
65582
65091
|
var iframeEventMapping = {
|
|
65583
65092
|
0: EVENT_TYPE.ENDED,
|
|
@@ -65585,12 +65094,10 @@ function () {
|
|
|
65585
65094
|
2: EVENT_TYPE.PAUSE
|
|
65586
65095
|
};
|
|
65587
65096
|
var eventType = iframeEventMapping[event.data];
|
|
65588
|
-
|
|
65589
65097
|
if (eventType) {
|
|
65590
65098
|
this.eventActionMapping[eventType](MEDIA_TYPE.IFRAME);
|
|
65591
65099
|
}
|
|
65592
65100
|
};
|
|
65593
|
-
|
|
65594
65101
|
MediaAutoTrack.prototype._html5MediaTracker = function () {
|
|
65595
65102
|
var that = this;
|
|
65596
65103
|
setInterval(function () {
|
|
@@ -65598,40 +65105,32 @@ function () {
|
|
|
65598
65105
|
that.recordEvent(MEDIA_TYPE.VIDEO, EVENT_TYPE.TIME_WATCHED);
|
|
65599
65106
|
}
|
|
65600
65107
|
}, 3 * 1000);
|
|
65601
|
-
|
|
65602
65108
|
this._mediaElement.addEventListener(HTML5_MEDIA_EVENT.PLAY, function () {
|
|
65603
65109
|
that.eventActionMapping[EVENT_TYPE.PLAY](MEDIA_TYPE.VIDEO);
|
|
65604
65110
|
}, false);
|
|
65605
|
-
|
|
65606
65111
|
this._mediaElement.addEventListener(HTML5_MEDIA_EVENT.PAUSE, function () {
|
|
65607
65112
|
that.eventActionMapping[EVENT_TYPE.PAUSE](MEDIA_TYPE.VIDEO);
|
|
65608
65113
|
}, false);
|
|
65609
|
-
|
|
65610
65114
|
this._mediaElement.addEventListener(HTML5_MEDIA_EVENT.ENDED, function () {
|
|
65611
65115
|
that.eventActionMapping[EVENT_TYPE.ENDED](MEDIA_TYPE.VIDEO);
|
|
65612
65116
|
}, false);
|
|
65613
65117
|
};
|
|
65614
|
-
|
|
65615
65118
|
MediaAutoTrack.prototype.playEventAction = function (mediaType) {
|
|
65616
65119
|
this._started = true;
|
|
65617
65120
|
this.recordEvent(mediaType, EVENT_TYPE.PLAY);
|
|
65618
65121
|
};
|
|
65619
|
-
|
|
65620
65122
|
MediaAutoTrack.prototype.pauseEventAction = function (mediaType) {
|
|
65621
65123
|
this._started = false;
|
|
65622
65124
|
this.recordEvent(mediaType, EVENT_TYPE.PAUSE);
|
|
65623
65125
|
};
|
|
65624
|
-
|
|
65625
65126
|
MediaAutoTrack.prototype.endedEventAction = function (mediaType) {
|
|
65626
65127
|
this._started = false;
|
|
65627
65128
|
this.recordEvent(mediaType, EVENT_TYPE.ENDED);
|
|
65628
65129
|
};
|
|
65629
|
-
|
|
65630
65130
|
MediaAutoTrack.prototype.recordEvent = function (mediaType, eventType) {
|
|
65631
65131
|
var newParams = Object.assign({}, this._params);
|
|
65632
65132
|
var eventData = newParams.eventData;
|
|
65633
65133
|
eventData.eventType = eventType;
|
|
65634
|
-
|
|
65635
65134
|
if (mediaType === MEDIA_TYPE.VIDEO) {
|
|
65636
65135
|
eventData.properties.timestamp = this._mediaElement.currentTime;
|
|
65637
65136
|
eventData.properties.duration = this._mediaElement.duration;
|
|
@@ -65639,23 +65138,18 @@ function () {
|
|
|
65639
65138
|
eventData.properties.timestamp = this._financial(this._iframePlayer.getCurrentTime());
|
|
65640
65139
|
eventData.properties.duration = this._financial(this._iframePlayer.getDuration());
|
|
65641
65140
|
}
|
|
65642
|
-
|
|
65643
65141
|
var percentage = parseFloat(eventData.properties.timestamp) / parseFloat(eventData.properties.duration);
|
|
65644
65142
|
eventData.properties.eventValue = Number(percentage.toFixed(4));
|
|
65645
65143
|
delete eventData.properties.domElementId;
|
|
65646
|
-
|
|
65647
65144
|
this._provider.putToBuffer(newParams);
|
|
65648
65145
|
};
|
|
65649
|
-
|
|
65650
65146
|
MediaAutoTrack.prototype._financial = function (x) {
|
|
65651
65147
|
return Number.parseFloat(x).toFixed(4);
|
|
65652
65148
|
};
|
|
65653
|
-
|
|
65654
65149
|
return MediaAutoTrack;
|
|
65655
65150
|
}();
|
|
65656
65151
|
|
|
65657
65152
|
|
|
65658
|
-
|
|
65659
65153
|
/***/ }),
|
|
65660
65154
|
|
|
65661
65155
|
/***/ "./lib-esm/Providers/AmazonPersonalizeHelper/SessionInfoManager.js":
|
|
@@ -65691,32 +65185,24 @@ var TIMER_INTERVAL = 30 * 1000;
|
|
|
65691
65185
|
var DELIMITER = '.';
|
|
65692
65186
|
var CACHE_EXPIRY_IN_DAYS = 7;
|
|
65693
65187
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["ConsoleLogger"]('AmazonPersonalizeProvider');
|
|
65694
|
-
|
|
65695
|
-
var SessionInfoManager =
|
|
65696
|
-
/** @class */
|
|
65697
|
-
function () {
|
|
65188
|
+
var SessionInfoManager = /** @class */function () {
|
|
65698
65189
|
function SessionInfoManager(prefixKey) {
|
|
65699
65190
|
if (prefixKey === void 0) {
|
|
65700
65191
|
prefixKey = '';
|
|
65701
65192
|
}
|
|
65702
|
-
|
|
65703
65193
|
this._isBrowser = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_3__["JS"].browserOrNode().isBrowser;
|
|
65704
65194
|
this._timerKey = Object(uuid__WEBPACK_IMPORTED_MODULE_2__["v1"])().substr(0, 15);
|
|
65705
|
-
|
|
65706
65195
|
this._refreshTimer();
|
|
65707
65196
|
}
|
|
65708
|
-
|
|
65709
65197
|
SessionInfoManager.prototype._refreshTimer = function () {
|
|
65710
65198
|
if (this._timer) {
|
|
65711
65199
|
clearInterval(this._timer);
|
|
65712
65200
|
}
|
|
65713
|
-
|
|
65714
65201
|
var that = this;
|
|
65715
65202
|
this._timer = setInterval(function () {
|
|
65716
65203
|
that._timerKey = Object(uuid__WEBPACK_IMPORTED_MODULE_2__["v1"])().substr(0, 15);
|
|
65717
65204
|
}, TIMER_INTERVAL);
|
|
65718
65205
|
};
|
|
65719
|
-
|
|
65720
65206
|
SessionInfoManager.prototype.storeValue = function (key, value) {
|
|
65721
65207
|
var today = new Date();
|
|
65722
65208
|
var expire = new Date();
|
|
@@ -65725,27 +65211,21 @@ function () {
|
|
|
65725
65211
|
expires: expire.getTime()
|
|
65726
65212
|
});
|
|
65727
65213
|
};
|
|
65728
|
-
|
|
65729
65214
|
SessionInfoManager.prototype.retrieveValue = function (key) {
|
|
65730
65215
|
return _aws_amplify_cache__WEBPACK_IMPORTED_MODULE_4___default.a.getItem(this._getCachePrefix(key));
|
|
65731
65216
|
};
|
|
65732
|
-
|
|
65733
65217
|
SessionInfoManager.prototype._getCachePrefix = function (key) {
|
|
65734
65218
|
if (this._isBrowser) {
|
|
65735
65219
|
return key + DELIMITER + window.location.host;
|
|
65736
65220
|
}
|
|
65737
|
-
|
|
65738
65221
|
return DEFAULT_CACHE_PREFIX;
|
|
65739
65222
|
};
|
|
65740
|
-
|
|
65741
65223
|
SessionInfoManager.prototype.getTimerKey = function () {
|
|
65742
65224
|
return this._timerKey;
|
|
65743
65225
|
};
|
|
65744
|
-
|
|
65745
65226
|
SessionInfoManager.prototype.updateSessionInfo = function (userId, sessionInfo) {
|
|
65746
65227
|
var existUserId = sessionInfo.userId;
|
|
65747
65228
|
var existSessionId = sessionInfo.sessionId;
|
|
65748
|
-
|
|
65749
65229
|
if (this._isRequireNewSession(userId, existUserId, existSessionId)) {
|
|
65750
65230
|
var newSessionId = Object(uuid__WEBPACK_IMPORTED_MODULE_2__["v1"])();
|
|
65751
65231
|
this.storeValue(PERSONALIZE_CACHE_USERID, userId);
|
|
@@ -65754,31 +65234,25 @@ function () {
|
|
|
65754
65234
|
} else if (this._isRequireUpdateSessionInfo(userId, existUserId, existSessionId)) {
|
|
65755
65235
|
this.storeValue(PERSONALIZE_CACHE_USERID, userId);
|
|
65756
65236
|
}
|
|
65757
|
-
|
|
65758
65237
|
sessionInfo.userId = userId;
|
|
65759
65238
|
};
|
|
65760
|
-
|
|
65761
65239
|
SessionInfoManager.prototype._isRequireUpdateSessionInfo = function (userId, cachedSessionUserId, cachedSessionSessionId) {
|
|
65762
65240
|
// anonymouse => sign in : hasSession && s_userId == null && curr_userId !=null
|
|
65763
65241
|
var isNoCachedSession = lodash_isEmpty__WEBPACK_IMPORTED_MODULE_0___default()(cachedSessionSessionId);
|
|
65764
65242
|
return !isNoCachedSession && lodash_isEmpty__WEBPACK_IMPORTED_MODULE_0___default()(cachedSessionUserId) && !lodash_isEmpty__WEBPACK_IMPORTED_MODULE_0___default()(userId);
|
|
65765
65243
|
};
|
|
65766
|
-
|
|
65767
65244
|
SessionInfoManager.prototype.retrieveSessionInfo = function (trackingId) {
|
|
65768
65245
|
var sessionInfo = {};
|
|
65769
65246
|
sessionInfo.trackingId = trackingId;
|
|
65770
65247
|
sessionInfo.sessionId = this.retrieveValue(PERSONALIZE_CACHE_SESSIONID);
|
|
65771
65248
|
sessionInfo.userId = this.retrieveValue(PERSONALIZE_CACHE_USERID);
|
|
65772
|
-
|
|
65773
65249
|
if (lodash_isEmpty__WEBPACK_IMPORTED_MODULE_0___default()(sessionInfo.sessionId)) {
|
|
65774
65250
|
sessionInfo.sessionId = Object(uuid__WEBPACK_IMPORTED_MODULE_2__["v1"])();
|
|
65775
65251
|
this.storeValue(PERSONALIZE_CACHE_SESSIONID, sessionInfo.sessionId);
|
|
65776
65252
|
}
|
|
65777
|
-
|
|
65778
65253
|
this.storeValue(PERSONALIZE_CACHE, trackingId);
|
|
65779
65254
|
return sessionInfo;
|
|
65780
65255
|
};
|
|
65781
|
-
|
|
65782
65256
|
SessionInfoManager.prototype._isRequireNewSession = function (userId, cachedSessionUserId, cachedSessionSessionId) {
|
|
65783
65257
|
// new session => 1. no cached session info 2. signOut: s_userId !=null && curr_userId ==null
|
|
65784
65258
|
// 3. switch account: s_userId !=null && curr_userId !=null && s_userId != curr_userId
|
|
@@ -65787,12 +65261,10 @@ function () {
|
|
|
65787
65261
|
var isSwitchUserCase = !lodash_isEmpty__WEBPACK_IMPORTED_MODULE_0___default()(userId) && !lodash_isEmpty__WEBPACK_IMPORTED_MODULE_0___default()(cachedSessionUserId) && !lodash_isEqual__WEBPACK_IMPORTED_MODULE_1___default()(userId, cachedSessionUserId);
|
|
65788
65262
|
return isNoCachedSession || isSignoutCase || isSwitchUserCase;
|
|
65789
65263
|
};
|
|
65790
|
-
|
|
65791
65264
|
return SessionInfoManager;
|
|
65792
65265
|
}();
|
|
65793
65266
|
|
|
65794
65267
|
|
|
65795
|
-
|
|
65796
65268
|
/***/ }),
|
|
65797
65269
|
|
|
65798
65270
|
/***/ "./lib-esm/Providers/AmazonPersonalizeHelper/index.js":
|
|
@@ -65853,7 +65325,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
65853
65325
|
resolve(value);
|
|
65854
65326
|
});
|
|
65855
65327
|
}
|
|
65856
|
-
|
|
65857
65328
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
65858
65329
|
function fulfilled(value) {
|
|
65859
65330
|
try {
|
|
@@ -65862,7 +65333,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
65862
65333
|
reject(e);
|
|
65863
65334
|
}
|
|
65864
65335
|
}
|
|
65865
|
-
|
|
65866
65336
|
function rejected(value) {
|
|
65867
65337
|
try {
|
|
65868
65338
|
step(generator["throw"](value));
|
|
@@ -65870,29 +65340,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
65870
65340
|
reject(e);
|
|
65871
65341
|
}
|
|
65872
65342
|
}
|
|
65873
|
-
|
|
65874
65343
|
function step(result) {
|
|
65875
65344
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
65876
65345
|
}
|
|
65877
|
-
|
|
65878
65346
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
65879
65347
|
});
|
|
65880
65348
|
};
|
|
65881
|
-
|
|
65882
65349
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
65883
65350
|
var _ = {
|
|
65884
|
-
|
|
65885
|
-
|
|
65886
|
-
|
|
65887
|
-
|
|
65351
|
+
label: 0,
|
|
65352
|
+
sent: function sent() {
|
|
65353
|
+
if (t[0] & 1) throw t[1];
|
|
65354
|
+
return t[1];
|
|
65355
|
+
},
|
|
65356
|
+
trys: [],
|
|
65357
|
+
ops: []
|
|
65888
65358
|
},
|
|
65889
|
-
|
|
65890
|
-
|
|
65891
|
-
|
|
65892
|
-
|
|
65893
|
-
y,
|
|
65894
|
-
t,
|
|
65895
|
-
g;
|
|
65359
|
+
f,
|
|
65360
|
+
y,
|
|
65361
|
+
t,
|
|
65362
|
+
g;
|
|
65896
65363
|
return g = {
|
|
65897
65364
|
next: verb(0),
|
|
65898
65365
|
"throw": verb(1),
|
|
@@ -65900,79 +65367,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
65900
65367
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
65901
65368
|
return this;
|
|
65902
65369
|
}), g;
|
|
65903
|
-
|
|
65904
65370
|
function verb(n) {
|
|
65905
65371
|
return function (v) {
|
|
65906
65372
|
return step([n, v]);
|
|
65907
65373
|
};
|
|
65908
65374
|
}
|
|
65909
|
-
|
|
65910
65375
|
function step(op) {
|
|
65911
65376
|
if (f) throw new TypeError("Generator is already executing.");
|
|
65912
|
-
|
|
65913
65377
|
while (_) {
|
|
65914
65378
|
try {
|
|
65915
65379
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
65916
65380
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65917
|
-
|
|
65918
65381
|
switch (op[0]) {
|
|
65919
65382
|
case 0:
|
|
65920
65383
|
case 1:
|
|
65921
65384
|
t = op;
|
|
65922
65385
|
break;
|
|
65923
|
-
|
|
65924
65386
|
case 4:
|
|
65925
65387
|
_.label++;
|
|
65926
65388
|
return {
|
|
65927
65389
|
value: op[1],
|
|
65928
65390
|
done: false
|
|
65929
65391
|
};
|
|
65930
|
-
|
|
65931
65392
|
case 5:
|
|
65932
65393
|
_.label++;
|
|
65933
65394
|
y = op[1];
|
|
65934
65395
|
op = [0];
|
|
65935
65396
|
continue;
|
|
65936
|
-
|
|
65937
65397
|
case 7:
|
|
65938
65398
|
op = _.ops.pop();
|
|
65939
|
-
|
|
65940
65399
|
_.trys.pop();
|
|
65941
|
-
|
|
65942
65400
|
continue;
|
|
65943
|
-
|
|
65944
65401
|
default:
|
|
65945
65402
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
65946
65403
|
_ = 0;
|
|
65947
65404
|
continue;
|
|
65948
65405
|
}
|
|
65949
|
-
|
|
65950
65406
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
65951
65407
|
_.label = op[1];
|
|
65952
65408
|
break;
|
|
65953
65409
|
}
|
|
65954
|
-
|
|
65955
65410
|
if (op[0] === 6 && _.label < t[1]) {
|
|
65956
65411
|
_.label = t[1];
|
|
65957
65412
|
t = op;
|
|
65958
65413
|
break;
|
|
65959
65414
|
}
|
|
65960
|
-
|
|
65961
65415
|
if (t && _.label < t[2]) {
|
|
65962
65416
|
_.label = t[2];
|
|
65963
|
-
|
|
65964
65417
|
_.ops.push(op);
|
|
65965
|
-
|
|
65966
65418
|
break;
|
|
65967
65419
|
}
|
|
65968
|
-
|
|
65969
65420
|
if (t[2]) _.ops.pop();
|
|
65970
|
-
|
|
65971
65421
|
_.trys.pop();
|
|
65972
|
-
|
|
65973
65422
|
continue;
|
|
65974
65423
|
}
|
|
65975
|
-
|
|
65976
65424
|
op = body.call(thisArg, _);
|
|
65977
65425
|
} catch (e) {
|
|
65978
65426
|
op = [6, e];
|
|
@@ -65981,7 +65429,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
65981
65429
|
f = t = 0;
|
|
65982
65430
|
}
|
|
65983
65431
|
}
|
|
65984
|
-
|
|
65985
65432
|
if (op[0] & 5) throw op[1];
|
|
65986
65433
|
return {
|
|
65987
65434
|
value: op[0] ? op[1] : void 0,
|
|
@@ -65995,39 +65442,30 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
65995
65442
|
|
|
65996
65443
|
|
|
65997
65444
|
|
|
65998
|
-
|
|
65999
|
-
|
|
66000
|
-
|
|
65445
|
+
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('AmazonPersonalizeProvider');
|
|
65446
|
+
// events buffer
|
|
66001
65447
|
var FLUSH_SIZE = 5;
|
|
66002
65448
|
var FLUSH_SIZE_THRESHHOLD = 10;
|
|
66003
65449
|
var FLUSH_INTERVAL = 5 * 1000; // 5s
|
|
66004
|
-
|
|
66005
65450
|
var IDENTIFY_EVENT = 'Identify';
|
|
66006
|
-
|
|
66007
|
-
var AmazonPersonalizeProvider =
|
|
66008
|
-
/** @class */
|
|
66009
|
-
function () {
|
|
65451
|
+
var AmazonPersonalizeProvider = /** @class */function () {
|
|
66010
65452
|
function AmazonPersonalizeProvider(config) {
|
|
66011
65453
|
this._buffer = [];
|
|
66012
65454
|
this._config = config ? config : {};
|
|
66013
65455
|
this._config.flushSize = this._config.flushSize > 0 && this._config.flushSize <= FLUSH_SIZE_THRESHHOLD ? this._config.flushSize : FLUSH_SIZE;
|
|
66014
65456
|
this._config.flushInterval = this._config.flushInterval || FLUSH_INTERVAL;
|
|
66015
65457
|
this._sessionManager = new _AmazonPersonalizeHelper__WEBPACK_IMPORTED_MODULE_2__["SessionInfoManager"]();
|
|
66016
|
-
|
|
66017
65458
|
if (!lodash_isEmpty__WEBPACK_IMPORTED_MODULE_4___default()(this._config.trackingId)) {
|
|
66018
65459
|
this._sessionInfo = this._sessionManager.retrieveSessionInfo(this._config.trackingId);
|
|
66019
65460
|
}
|
|
66020
|
-
|
|
66021
|
-
|
|
66022
|
-
|
|
65461
|
+
this._isBrowser = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].browserOrNode().isBrowser;
|
|
65462
|
+
// flush event buffer
|
|
66023
65463
|
this._setupTimer();
|
|
66024
65464
|
}
|
|
66025
|
-
|
|
66026
65465
|
AmazonPersonalizeProvider.prototype._setupTimer = function () {
|
|
66027
65466
|
if (this._timer) {
|
|
66028
65467
|
clearInterval(this._timer);
|
|
66029
65468
|
}
|
|
66030
|
-
|
|
66031
65469
|
var flushInterval = this._config.flushInterval;
|
|
66032
65470
|
var that = this;
|
|
66033
65471
|
this._timer = setInterval(function () {
|
|
@@ -66040,95 +65478,57 @@ function () {
|
|
|
66040
65478
|
* @param properties - properties of the event
|
|
66041
65479
|
* @return Promise
|
|
66042
65480
|
*/
|
|
66043
|
-
|
|
66044
|
-
|
|
66045
65481
|
AmazonPersonalizeProvider.prototype.record = function (params) {
|
|
66046
65482
|
return __awaiter(this, void 0, void 0, function () {
|
|
66047
65483
|
var credentials, _a, eventType, properties, requestParams, isLoaded;
|
|
66048
|
-
|
|
66049
65484
|
return __generator(this, function (_b) {
|
|
66050
65485
|
switch (_b.label) {
|
|
66051
65486
|
case 0:
|
|
66052
|
-
return [4
|
|
66053
|
-
/*yield*/
|
|
66054
|
-
, this._getCredentials()];
|
|
66055
|
-
|
|
65487
|
+
return [4 /*yield*/, this._getCredentials()];
|
|
66056
65488
|
case 1:
|
|
66057
65489
|
credentials = _b.sent();
|
|
66058
|
-
if (!credentials) return [2
|
|
66059
|
-
/*return*/
|
|
66060
|
-
, Promise.resolve(false)];
|
|
65490
|
+
if (!credentials) return [2 /*return*/, Promise.resolve(false)];
|
|
66061
65491
|
Object.assign(params, {
|
|
66062
65492
|
config: this._config,
|
|
66063
65493
|
credentials: credentials,
|
|
66064
65494
|
sentAt: new Date()
|
|
66065
65495
|
});
|
|
66066
65496
|
_a = params.event, eventType = _a.eventType, properties = _a.properties;
|
|
66067
|
-
|
|
66068
65497
|
if (eventType === IDENTIFY_EVENT) {
|
|
66069
65498
|
this._sessionManager.updateSessionInfo(properties && properties.userId ? properties.userId : '', this._sessionInfo);
|
|
66070
|
-
|
|
66071
|
-
return [2
|
|
66072
|
-
/*return*/
|
|
66073
|
-
];
|
|
65499
|
+
return [2 /*return*/];
|
|
66074
65500
|
} else if (!lodash_isEmpty__WEBPACK_IMPORTED_MODULE_4___default()(params.event.userId)) {
|
|
66075
65501
|
this._sessionManager.updateSessionInfo(params.event.userId, this._sessionInfo);
|
|
66076
65502
|
}
|
|
66077
|
-
|
|
66078
65503
|
requestParams = this.generateRequestParams(params, this._sessionInfo);
|
|
66079
|
-
if (!(eventType === 'MediaAutoTrack')) return [3
|
|
66080
|
-
/*break
|
|
66081
|
-
,
|
|
66082
|
-
|
|
66083
|
-
/*break*/
|
|
66084
|
-
, 5];
|
|
66085
|
-
if (!!lodash_isEmpty__WEBPACK_IMPORTED_MODULE_4___default()(lodash_get__WEBPACK_IMPORTED_MODULE_3___default()(requestParams, 'eventData.properties.domElementId', null))) return [3
|
|
66086
|
-
/*break*/
|
|
66087
|
-
, 3];
|
|
66088
|
-
return [4
|
|
66089
|
-
/*yield*/
|
|
66090
|
-
, this.isElementFullyLoaded(this.loadElement, requestParams.eventData.properties['domElementId'], 500, 5)];
|
|
66091
|
-
|
|
65504
|
+
if (!(eventType === 'MediaAutoTrack')) return [3 /*break*/, 7];
|
|
65505
|
+
if (!this._isBrowser) return [3 /*break*/, 5];
|
|
65506
|
+
if (!!lodash_isEmpty__WEBPACK_IMPORTED_MODULE_4___default()(lodash_get__WEBPACK_IMPORTED_MODULE_3___default()(requestParams, 'eventData.properties.domElementId', null))) return [3 /*break*/, 3];
|
|
65507
|
+
return [4 /*yield*/, this.isElementFullyLoaded(this.loadElement, requestParams.eventData.properties['domElementId'], 500, 5)];
|
|
66092
65508
|
case 2:
|
|
66093
65509
|
isLoaded = _b.sent();
|
|
66094
|
-
|
|
66095
65510
|
if (isLoaded) {
|
|
66096
65511
|
new _AmazonPersonalizeHelper__WEBPACK_IMPORTED_MODULE_2__["MediaAutoTrack"](requestParams, this);
|
|
66097
65512
|
} else {
|
|
66098
65513
|
logger.debug('Cannot find the media element.');
|
|
66099
65514
|
}
|
|
66100
|
-
|
|
66101
|
-
return [3
|
|
66102
|
-
/*break*/
|
|
66103
|
-
, 4];
|
|
66104
|
-
|
|
65515
|
+
return [3 /*break*/, 4];
|
|
66105
65516
|
case 3:
|
|
66106
65517
|
logger.debug("Missing domElementId field in 'properties' for MediaAutoTrack event type.");
|
|
66107
65518
|
_b.label = 4;
|
|
66108
|
-
|
|
66109
65519
|
case 4:
|
|
66110
|
-
return [3
|
|
66111
|
-
/*break*/
|
|
66112
|
-
, 6];
|
|
66113
|
-
|
|
65520
|
+
return [3 /*break*/, 6];
|
|
66114
65521
|
case 5:
|
|
66115
65522
|
logger.debug('MediaAutoTrack only for browser');
|
|
66116
65523
|
_b.label = 6;
|
|
66117
|
-
|
|
66118
65524
|
case 6:
|
|
66119
|
-
return [2
|
|
66120
|
-
/*return*/
|
|
66121
|
-
];
|
|
66122
|
-
|
|
65525
|
+
return [2 /*return*/];
|
|
66123
65526
|
case 7:
|
|
66124
|
-
return [2
|
|
66125
|
-
/*return*/
|
|
66126
|
-
, this.putToBuffer(requestParams)];
|
|
65527
|
+
return [2 /*return*/, this.putToBuffer(requestParams)];
|
|
66127
65528
|
}
|
|
66128
65529
|
});
|
|
66129
65530
|
});
|
|
66130
65531
|
};
|
|
66131
|
-
|
|
66132
65532
|
AmazonPersonalizeProvider.prototype.loadElement = function (domId) {
|
|
66133
65533
|
return new Promise(function (resolve, reject) {
|
|
66134
65534
|
if (document.getElementById(domId) && document.getElementById(domId).clientHeight) {
|
|
@@ -66138,22 +65538,18 @@ function () {
|
|
|
66138
65538
|
}
|
|
66139
65539
|
});
|
|
66140
65540
|
};
|
|
66141
|
-
|
|
66142
65541
|
AmazonPersonalizeProvider.prototype.isElementFullyLoaded = function (operation, params, delay, times) {
|
|
66143
65542
|
var _this = this;
|
|
66144
|
-
|
|
66145
65543
|
var wait = function wait(ms) {
|
|
66146
65544
|
return new Promise(function (r) {
|
|
66147
65545
|
return setTimeout(r, ms);
|
|
66148
65546
|
});
|
|
66149
65547
|
};
|
|
66150
|
-
|
|
66151
65548
|
return new Promise(function (resolve, reject) {
|
|
66152
65549
|
return operation(params).then(resolve)["catch"](function (reason) {
|
|
66153
65550
|
if (times - 1 > 0) {
|
|
66154
65551
|
return wait(delay).then(_this.isElementFullyLoaded.bind(null, operation, params, delay, times - 1)).then(resolve)["catch"](reject);
|
|
66155
65552
|
}
|
|
66156
|
-
|
|
66157
65553
|
return reject(reason);
|
|
66158
65554
|
});
|
|
66159
65555
|
});
|
|
@@ -66161,16 +65557,12 @@ function () {
|
|
|
66161
65557
|
/**
|
|
66162
65558
|
* get the category of the plugin
|
|
66163
65559
|
*/
|
|
66164
|
-
|
|
66165
|
-
|
|
66166
65560
|
AmazonPersonalizeProvider.prototype.getCategory = function () {
|
|
66167
65561
|
return 'Analytics';
|
|
66168
65562
|
};
|
|
66169
65563
|
/**
|
|
66170
65564
|
* get provider name of the plugin
|
|
66171
65565
|
*/
|
|
66172
|
-
|
|
66173
|
-
|
|
66174
65566
|
AmazonPersonalizeProvider.prototype.getProviderName = function () {
|
|
66175
65567
|
return 'AmazonPersonalize';
|
|
66176
65568
|
};
|
|
@@ -66178,19 +65570,14 @@ function () {
|
|
|
66178
65570
|
* configure the plugin
|
|
66179
65571
|
* @param {Object} config - configuration
|
|
66180
65572
|
*/
|
|
66181
|
-
|
|
66182
|
-
|
|
66183
65573
|
AmazonPersonalizeProvider.prototype.configure = function (config) {
|
|
66184
65574
|
logger.debug('configure Analytics', config);
|
|
66185
65575
|
var conf = config ? config : {};
|
|
66186
65576
|
this._config = Object.assign({}, this._config, conf);
|
|
66187
|
-
|
|
66188
65577
|
if (!lodash_isEmpty__WEBPACK_IMPORTED_MODULE_4___default()(this._config.trackingId)) {
|
|
66189
65578
|
this._sessionInfo = this._sessionManager.retrieveSessionInfo(this._config.trackingId);
|
|
66190
65579
|
}
|
|
66191
|
-
|
|
66192
65580
|
this._setupTimer();
|
|
66193
|
-
|
|
66194
65581
|
return this._config;
|
|
66195
65582
|
};
|
|
66196
65583
|
/**
|
|
@@ -66200,13 +65587,11 @@ function () {
|
|
|
66200
65587
|
* @param api - api name
|
|
66201
65588
|
* @return RequestParams - wrapper object with all information required for make request
|
|
66202
65589
|
*/
|
|
66203
|
-
|
|
66204
|
-
|
|
66205
65590
|
AmazonPersonalizeProvider.prototype.generateRequestParams = function (params, sessionInfo) {
|
|
66206
65591
|
var requestParams = {};
|
|
66207
65592
|
var _a = params.event,
|
|
66208
|
-
|
|
66209
|
-
|
|
65593
|
+
eventType = _a.eventType,
|
|
65594
|
+
properties = _a.properties;
|
|
66210
65595
|
requestParams.eventData = {
|
|
66211
65596
|
eventType: eventType,
|
|
66212
65597
|
properties: properties
|
|
@@ -66221,36 +65606,25 @@ function () {
|
|
|
66221
65606
|
* record an event
|
|
66222
65607
|
* @param {Object} params - the params of an event
|
|
66223
65608
|
*/
|
|
66224
|
-
|
|
66225
|
-
|
|
66226
65609
|
AmazonPersonalizeProvider.prototype._sendEvents = function (group) {
|
|
66227
65610
|
var groupLen = group.length;
|
|
66228
|
-
|
|
66229
65611
|
if (groupLen === 0) {
|
|
66230
65612
|
logger.debug('events array is empty, directly return');
|
|
66231
65613
|
return;
|
|
66232
65614
|
}
|
|
66233
|
-
|
|
66234
65615
|
var _a = group[0],
|
|
66235
|
-
|
|
66236
|
-
|
|
66237
|
-
|
|
66238
|
-
|
|
65616
|
+
config = _a.config,
|
|
65617
|
+
credentials = _a.credentials,
|
|
65618
|
+
sessionInfo = _a.sessionInfo;
|
|
66239
65619
|
var initClients = this._init(config, credentials);
|
|
66240
|
-
|
|
66241
65620
|
if (!initClients) return false;
|
|
66242
|
-
|
|
66243
65621
|
if (groupLen > 0) {
|
|
66244
65622
|
var events = [];
|
|
66245
|
-
|
|
66246
65623
|
for (var i = 0; i < groupLen; i += 1) {
|
|
66247
65624
|
var params = group.shift();
|
|
66248
|
-
|
|
66249
65625
|
var eventPayload = this._generateSingleRecordPayload(params, sessionInfo);
|
|
66250
|
-
|
|
66251
65626
|
events.push(eventPayload);
|
|
66252
65627
|
}
|
|
66253
|
-
|
|
66254
65628
|
var payload_1 = {};
|
|
66255
65629
|
payload_1.trackingId = sessionInfo.trackingId;
|
|
66256
65630
|
payload_1.sessionId = sessionInfo.sessionId;
|
|
@@ -66261,7 +65635,6 @@ function () {
|
|
|
66261
65635
|
payload_1.eventList.push(event);
|
|
66262
65636
|
});
|
|
66263
65637
|
var command = new _aws_sdk_client_personalize_events__WEBPACK_IMPORTED_MODULE_1__["PutEventsCommand"](payload_1);
|
|
66264
|
-
|
|
66265
65638
|
this._personalize.send(command, function (err) {
|
|
66266
65639
|
if (err) logger.debug('Failed to call putEvents in Personalize', err);else logger.debug('Put events');
|
|
66267
65640
|
});
|
|
@@ -66272,17 +65645,13 @@ function () {
|
|
|
66272
65645
|
* @private
|
|
66273
65646
|
* @param params - params for the event recording
|
|
66274
65647
|
*/
|
|
66275
|
-
|
|
66276
|
-
|
|
66277
65648
|
AmazonPersonalizeProvider.prototype.putToBuffer = function (params) {
|
|
66278
65649
|
if (this._buffer.length < this._config.flushSize) {
|
|
66279
65650
|
this._buffer.push(params);
|
|
66280
65651
|
} else {
|
|
66281
65652
|
this._buffer.push(params);
|
|
66282
|
-
|
|
66283
65653
|
this._sendFromBuffer();
|
|
66284
65654
|
}
|
|
66285
|
-
|
|
66286
65655
|
return Promise.resolve(true);
|
|
66287
65656
|
};
|
|
66288
65657
|
/**
|
|
@@ -66290,23 +65659,17 @@ function () {
|
|
|
66290
65659
|
* @private
|
|
66291
65660
|
* @param eventsParams - the buffer for cache the payload
|
|
66292
65661
|
*/
|
|
66293
|
-
|
|
66294
|
-
|
|
66295
65662
|
AmazonPersonalizeProvider.prototype._sendFromBuffer = function () {
|
|
66296
65663
|
var _this = this;
|
|
66297
|
-
|
|
66298
65664
|
var size = this._buffer.length;
|
|
66299
65665
|
if (size <= 0) return;
|
|
66300
65666
|
var eventsGroups = [];
|
|
66301
65667
|
var preCred = null;
|
|
66302
65668
|
var group = [];
|
|
66303
|
-
|
|
66304
65669
|
for (var i = 0; i < size; i += 1) {
|
|
66305
65670
|
var currRequestParams = this._buffer.shift();
|
|
66306
|
-
|
|
66307
65671
|
var cred = currRequestParams.credentials;
|
|
66308
65672
|
var sessionInfo = currRequestParams.sessionInfo;
|
|
66309
|
-
|
|
66310
65673
|
if (i === 0) {
|
|
66311
65674
|
group.push(currRequestParams);
|
|
66312
65675
|
preCred = cred;
|
|
@@ -66323,7 +65686,6 @@ function () {
|
|
|
66323
65686
|
}
|
|
66324
65687
|
}
|
|
66325
65688
|
}
|
|
66326
|
-
|
|
66327
65689
|
eventsGroups.push(group);
|
|
66328
65690
|
eventsGroups.map(function (group) {
|
|
66329
65691
|
_this._sendEvents(group);
|
|
@@ -66334,11 +65696,9 @@ function () {
|
|
|
66334
65696
|
* @private
|
|
66335
65697
|
* @param params - RequestParams
|
|
66336
65698
|
*/
|
|
66337
|
-
|
|
66338
|
-
|
|
66339
65699
|
AmazonPersonalizeProvider.prototype._generateSingleRecordPayload = function (params, sessionInfo) {
|
|
66340
65700
|
var eventData = params.eventData,
|
|
66341
|
-
|
|
65701
|
+
sentAt = params.sentAt;
|
|
66342
65702
|
var trackPayload = {};
|
|
66343
65703
|
trackPayload.sentAt = sentAt;
|
|
66344
65704
|
trackPayload.properties = eventData.properties && JSON.stringify(eventData.properties);
|
|
@@ -66351,16 +65711,12 @@ function () {
|
|
|
66351
65711
|
* @private
|
|
66352
65712
|
* @param params - RequestParams
|
|
66353
65713
|
*/
|
|
66354
|
-
|
|
66355
|
-
|
|
66356
65714
|
AmazonPersonalizeProvider.prototype._init = function (config, credentials) {
|
|
66357
65715
|
logger.debug('init clients');
|
|
66358
|
-
|
|
66359
65716
|
if (this._personalize && this._config.credentials && this._config.credentials.sessionToken === credentials.sessionToken && this._config.credentials.identityId === credentials.identityId) {
|
|
66360
65717
|
logger.debug('no change for analytics config, directly return from init');
|
|
66361
65718
|
return true;
|
|
66362
65719
|
}
|
|
66363
|
-
|
|
66364
65720
|
this._config.credentials = credentials;
|
|
66365
65721
|
var region = config.region;
|
|
66366
65722
|
logger.debug('initialize personalize with credentials', credentials);
|
|
@@ -66375,8 +65731,6 @@ function () {
|
|
|
66375
65731
|
* check if current credentials exists
|
|
66376
65732
|
* @private
|
|
66377
65733
|
*/
|
|
66378
|
-
|
|
66379
|
-
|
|
66380
65734
|
AmazonPersonalizeProvider.prototype._getCredentials = function () {
|
|
66381
65735
|
var that = this;
|
|
66382
65736
|
return _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Credentials"].get().then(function (credentials) {
|
|
@@ -66388,15 +65742,12 @@ function () {
|
|
|
66388
65742
|
return null;
|
|
66389
65743
|
});
|
|
66390
65744
|
};
|
|
66391
|
-
|
|
66392
65745
|
return AmazonPersonalizeProvider;
|
|
66393
65746
|
}();
|
|
66394
65747
|
|
|
66395
|
-
|
|
66396
65748
|
/**
|
|
66397
65749
|
* @deprecated use named import
|
|
66398
65750
|
*/
|
|
66399
|
-
|
|
66400
65751
|
/* harmony default export */ __webpack_exports__["default"] = (AmazonPersonalizeProvider);
|
|
66401
65752
|
|
|
66402
65753
|
/***/ }),
|
|
@@ -66420,7 +65771,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
66420
65771
|
resolve(value);
|
|
66421
65772
|
});
|
|
66422
65773
|
}
|
|
66423
|
-
|
|
66424
65774
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
66425
65775
|
function fulfilled(value) {
|
|
66426
65776
|
try {
|
|
@@ -66429,7 +65779,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
66429
65779
|
reject(e);
|
|
66430
65780
|
}
|
|
66431
65781
|
}
|
|
66432
|
-
|
|
66433
65782
|
function rejected(value) {
|
|
66434
65783
|
try {
|
|
66435
65784
|
step(generator["throw"](value));
|
|
@@ -66437,29 +65786,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
66437
65786
|
reject(e);
|
|
66438
65787
|
}
|
|
66439
65788
|
}
|
|
66440
|
-
|
|
66441
65789
|
function step(result) {
|
|
66442
65790
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
66443
65791
|
}
|
|
66444
|
-
|
|
66445
65792
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
66446
65793
|
});
|
|
66447
65794
|
};
|
|
66448
|
-
|
|
66449
65795
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
66450
65796
|
var _ = {
|
|
66451
|
-
|
|
66452
|
-
|
|
66453
|
-
|
|
66454
|
-
|
|
65797
|
+
label: 0,
|
|
65798
|
+
sent: function sent() {
|
|
65799
|
+
if (t[0] & 1) throw t[1];
|
|
65800
|
+
return t[1];
|
|
65801
|
+
},
|
|
65802
|
+
trys: [],
|
|
65803
|
+
ops: []
|
|
66455
65804
|
},
|
|
66456
|
-
|
|
66457
|
-
|
|
66458
|
-
|
|
66459
|
-
|
|
66460
|
-
y,
|
|
66461
|
-
t,
|
|
66462
|
-
g;
|
|
65805
|
+
f,
|
|
65806
|
+
y,
|
|
65807
|
+
t,
|
|
65808
|
+
g;
|
|
66463
65809
|
return g = {
|
|
66464
65810
|
next: verb(0),
|
|
66465
65811
|
"throw": verb(1),
|
|
@@ -66467,79 +65813,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
66467
65813
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
66468
65814
|
return this;
|
|
66469
65815
|
}), g;
|
|
66470
|
-
|
|
66471
65816
|
function verb(n) {
|
|
66472
65817
|
return function (v) {
|
|
66473
65818
|
return step([n, v]);
|
|
66474
65819
|
};
|
|
66475
65820
|
}
|
|
66476
|
-
|
|
66477
65821
|
function step(op) {
|
|
66478
65822
|
if (f) throw new TypeError("Generator is already executing.");
|
|
66479
|
-
|
|
66480
65823
|
while (_) {
|
|
66481
65824
|
try {
|
|
66482
65825
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
66483
65826
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
66484
|
-
|
|
66485
65827
|
switch (op[0]) {
|
|
66486
65828
|
case 0:
|
|
66487
65829
|
case 1:
|
|
66488
65830
|
t = op;
|
|
66489
65831
|
break;
|
|
66490
|
-
|
|
66491
65832
|
case 4:
|
|
66492
65833
|
_.label++;
|
|
66493
65834
|
return {
|
|
66494
65835
|
value: op[1],
|
|
66495
65836
|
done: false
|
|
66496
65837
|
};
|
|
66497
|
-
|
|
66498
65838
|
case 5:
|
|
66499
65839
|
_.label++;
|
|
66500
65840
|
y = op[1];
|
|
66501
65841
|
op = [0];
|
|
66502
65842
|
continue;
|
|
66503
|
-
|
|
66504
65843
|
case 7:
|
|
66505
65844
|
op = _.ops.pop();
|
|
66506
|
-
|
|
66507
65845
|
_.trys.pop();
|
|
66508
|
-
|
|
66509
65846
|
continue;
|
|
66510
|
-
|
|
66511
65847
|
default:
|
|
66512
65848
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
66513
65849
|
_ = 0;
|
|
66514
65850
|
continue;
|
|
66515
65851
|
}
|
|
66516
|
-
|
|
66517
65852
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
66518
65853
|
_.label = op[1];
|
|
66519
65854
|
break;
|
|
66520
65855
|
}
|
|
66521
|
-
|
|
66522
65856
|
if (op[0] === 6 && _.label < t[1]) {
|
|
66523
65857
|
_.label = t[1];
|
|
66524
65858
|
t = op;
|
|
66525
65859
|
break;
|
|
66526
65860
|
}
|
|
66527
|
-
|
|
66528
65861
|
if (t && _.label < t[2]) {
|
|
66529
65862
|
_.label = t[2];
|
|
66530
|
-
|
|
66531
65863
|
_.ops.push(op);
|
|
66532
|
-
|
|
66533
65864
|
break;
|
|
66534
65865
|
}
|
|
66535
|
-
|
|
66536
65866
|
if (t[2]) _.ops.pop();
|
|
66537
|
-
|
|
66538
65867
|
_.trys.pop();
|
|
66539
|
-
|
|
66540
65868
|
continue;
|
|
66541
65869
|
}
|
|
66542
|
-
|
|
66543
65870
|
op = body.call(thisArg, _);
|
|
66544
65871
|
} catch (e) {
|
|
66545
65872
|
op = [6, e];
|
|
@@ -66548,7 +65875,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
66548
65875
|
f = t = 0;
|
|
66549
65876
|
}
|
|
66550
65877
|
}
|
|
66551
|
-
|
|
66552
65878
|
if (op[0] & 5) throw op[1];
|
|
66553
65879
|
return {
|
|
66554
65880
|
value: op[0] ? op[1] : void 0,
|
|
@@ -66556,15 +65882,13 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
66556
65882
|
};
|
|
66557
65883
|
}
|
|
66558
65884
|
};
|
|
66559
|
-
|
|
66560
65885
|
var __read = undefined && undefined.__read || function (o, n) {
|
|
66561
65886
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
66562
65887
|
if (!m) return o;
|
|
66563
65888
|
var i = m.call(o),
|
|
66564
|
-
|
|
66565
|
-
|
|
66566
|
-
|
|
66567
|
-
|
|
65889
|
+
r,
|
|
65890
|
+
ar = [],
|
|
65891
|
+
e;
|
|
66568
65892
|
try {
|
|
66569
65893
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
66570
65894
|
ar.push(r.value);
|
|
@@ -66580,28 +65904,21 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
66580
65904
|
if (e) throw e.error;
|
|
66581
65905
|
}
|
|
66582
65906
|
}
|
|
66583
|
-
|
|
66584
65907
|
return ar;
|
|
66585
65908
|
};
|
|
66586
|
-
|
|
66587
65909
|
var __spread = undefined && undefined.__spread || function () {
|
|
66588
65910
|
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
66589
65911
|
ar = ar.concat(__read(arguments[i]));
|
|
66590
65912
|
}
|
|
66591
|
-
|
|
66592
65913
|
return ar;
|
|
66593
65914
|
};
|
|
66594
65915
|
|
|
66595
65916
|
|
|
66596
65917
|
|
|
66597
|
-
|
|
66598
65918
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('EventsBuffer');
|
|
66599
65919
|
var RETRYABLE_CODES = [429, 500];
|
|
66600
65920
|
var ACCEPTED_CODES = [202];
|
|
66601
|
-
|
|
66602
|
-
var EventsBuffer =
|
|
66603
|
-
/** @class */
|
|
66604
|
-
function () {
|
|
65921
|
+
var EventsBuffer = /** @class */function () {
|
|
66605
65922
|
function EventsBuffer(client, config) {
|
|
66606
65923
|
this._pause = false;
|
|
66607
65924
|
this._flush = false;
|
|
@@ -66610,73 +65927,55 @@ function () {
|
|
|
66610
65927
|
this._client = client;
|
|
66611
65928
|
this._config = config;
|
|
66612
65929
|
this._sendBatch = this._sendBatch.bind(this);
|
|
66613
|
-
|
|
66614
65930
|
this._startLoop();
|
|
66615
65931
|
}
|
|
66616
|
-
|
|
66617
65932
|
EventsBuffer.prototype.push = function (event) {
|
|
66618
|
-
var _a;
|
|
66619
|
-
|
|
66620
|
-
|
|
65933
|
+
var _a;
|
|
65934
|
+
// if the buffer is currently at the configured limit, pushing would exceed it
|
|
66621
65935
|
if (this._buffer.length >= this._config.bufferSize) {
|
|
66622
65936
|
logger.debug('Exceeded analytics events buffer size');
|
|
66623
65937
|
return event.handlers.reject(new Error('Exceeded the size of analytics events buffer'));
|
|
66624
65938
|
}
|
|
66625
|
-
|
|
66626
65939
|
var eventId = event.params.event.eventId;
|
|
66627
65940
|
var bufferElement = (_a = {}, _a[eventId] = event, _a);
|
|
66628
|
-
|
|
66629
65941
|
this._buffer.push(bufferElement);
|
|
66630
65942
|
};
|
|
66631
|
-
|
|
66632
65943
|
EventsBuffer.prototype.pause = function () {
|
|
66633
65944
|
this._pause = true;
|
|
66634
65945
|
};
|
|
66635
|
-
|
|
66636
65946
|
EventsBuffer.prototype.resume = function () {
|
|
66637
65947
|
this._pause = false;
|
|
66638
65948
|
};
|
|
66639
|
-
|
|
66640
65949
|
EventsBuffer.prototype.updateClient = function (client) {
|
|
66641
65950
|
this._client = client;
|
|
66642
65951
|
};
|
|
66643
|
-
|
|
66644
65952
|
EventsBuffer.prototype.flush = function () {
|
|
66645
65953
|
this._flush = true;
|
|
66646
65954
|
};
|
|
66647
|
-
|
|
66648
65955
|
EventsBuffer.prototype._startLoop = function () {
|
|
66649
65956
|
if (this._interval) {
|
|
66650
65957
|
clearInterval(this._interval);
|
|
66651
65958
|
}
|
|
66652
|
-
|
|
66653
65959
|
var flushInterval = this._config.flushInterval;
|
|
66654
65960
|
this._interval = setInterval(this._sendBatch, flushInterval);
|
|
66655
65961
|
};
|
|
66656
|
-
|
|
66657
65962
|
EventsBuffer.prototype._sendBatch = function () {
|
|
66658
65963
|
var bufferLength = this._buffer.length;
|
|
66659
|
-
|
|
66660
65964
|
if (this._flush && !bufferLength) {
|
|
66661
65965
|
clearInterval(this._interval);
|
|
66662
|
-
}
|
|
65966
|
+
}
|
|
65967
|
+
// Do not send the batch of events if
|
|
66663
65968
|
// the Buffer is paused or is empty or the App is not in the foreground
|
|
66664
65969
|
// Apps should be in the foreground since
|
|
66665
65970
|
// the OS may restrict access to the network in the background
|
|
66666
|
-
|
|
66667
|
-
|
|
66668
65971
|
if (this._pause || !bufferLength || !Object(_utils_AppUtils__WEBPACK_IMPORTED_MODULE_2__["isAppInForeground"])()) {
|
|
66669
65972
|
return;
|
|
66670
65973
|
}
|
|
66671
|
-
|
|
66672
65974
|
var flushSize = this._config.flushSize;
|
|
66673
65975
|
var batchSize = Math.min(flushSize, bufferLength);
|
|
66674
|
-
|
|
66675
65976
|
var bufferSubset = this._buffer.splice(0, batchSize);
|
|
66676
|
-
|
|
66677
65977
|
this._putEvents(bufferSubset);
|
|
66678
65978
|
};
|
|
66679
|
-
|
|
66680
65979
|
EventsBuffer.prototype._putEvents = function (buffer) {
|
|
66681
65980
|
return __awaiter(this, void 0, void 0, function () {
|
|
66682
65981
|
var eventMap, batchEventParams, command, data, err_1;
|
|
@@ -66686,34 +65985,19 @@ function () {
|
|
|
66686
65985
|
eventMap = this._bufferToMap(buffer);
|
|
66687
65986
|
batchEventParams = this._generateBatchEventParams(eventMap);
|
|
66688
65987
|
_a.label = 1;
|
|
66689
|
-
|
|
66690
65988
|
case 1:
|
|
66691
65989
|
_a.trys.push([1, 3,, 4]);
|
|
66692
|
-
|
|
66693
65990
|
command = new _aws_sdk_client_pinpoint__WEBPACK_IMPORTED_MODULE_1__["PutEventsCommand"](batchEventParams);
|
|
66694
|
-
return [4
|
|
66695
|
-
/*yield*/
|
|
66696
|
-
, this._client.send(command)];
|
|
66697
|
-
|
|
65991
|
+
return [4 /*yield*/, this._client.send(command)];
|
|
66698
65992
|
case 2:
|
|
66699
65993
|
data = _a.sent();
|
|
66700
|
-
|
|
66701
65994
|
this._processPutEventsSuccessResponse(data, eventMap);
|
|
66702
|
-
|
|
66703
|
-
return [3
|
|
66704
|
-
/*break*/
|
|
66705
|
-
, 4];
|
|
66706
|
-
|
|
65995
|
+
return [3 /*break*/, 4];
|
|
66707
65996
|
case 3:
|
|
66708
65997
|
err_1 = _a.sent();
|
|
66709
|
-
return [2
|
|
66710
|
-
/*return*/
|
|
66711
|
-
, this._handlePutEventsFailure(err_1, eventMap)];
|
|
66712
|
-
|
|
65998
|
+
return [2 /*return*/, this._handlePutEventsFailure(err_1, eventMap)];
|
|
66713
65999
|
case 4:
|
|
66714
|
-
return [2
|
|
66715
|
-
/*return*/
|
|
66716
|
-
];
|
|
66000
|
+
return [2 /*return*/];
|
|
66717
66001
|
}
|
|
66718
66002
|
});
|
|
66719
66003
|
});
|
|
@@ -66729,25 +66013,23 @@ function () {
|
|
|
66729
66013
|
Object.values(eventMap).forEach(function (item) {
|
|
66730
66014
|
var params = item.params;
|
|
66731
66015
|
var event = params.event,
|
|
66732
|
-
|
|
66733
|
-
|
|
66016
|
+
timestamp = params.timestamp,
|
|
66017
|
+
config = params.config;
|
|
66734
66018
|
var name = event.name,
|
|
66735
|
-
|
|
66736
|
-
|
|
66737
|
-
|
|
66738
|
-
|
|
66019
|
+
attributes = event.attributes,
|
|
66020
|
+
metrics = event.metrics,
|
|
66021
|
+
eventId = event.eventId,
|
|
66022
|
+
session = event.session;
|
|
66739
66023
|
var appId = config.appId,
|
|
66740
|
-
|
|
66024
|
+
endpointId = config.endpointId;
|
|
66741
66025
|
var batchItem = batchEventParams.EventsRequest.BatchItem;
|
|
66742
66026
|
batchEventParams.ApplicationId = batchEventParams.ApplicationId || appId;
|
|
66743
|
-
|
|
66744
66027
|
if (!batchItem[endpointId]) {
|
|
66745
66028
|
batchItem[endpointId] = {
|
|
66746
66029
|
Endpoint: {},
|
|
66747
66030
|
Events: {}
|
|
66748
66031
|
};
|
|
66749
66032
|
}
|
|
66750
|
-
|
|
66751
66033
|
batchItem[endpointId].Events[eventId] = {
|
|
66752
66034
|
EventType: name,
|
|
66753
66035
|
Timestamp: new Date(timestamp).toISOString(),
|
|
@@ -66758,40 +66040,32 @@ function () {
|
|
|
66758
66040
|
});
|
|
66759
66041
|
return batchEventParams;
|
|
66760
66042
|
};
|
|
66761
|
-
|
|
66762
66043
|
EventsBuffer.prototype._handlePutEventsFailure = function (err, eventMap) {
|
|
66763
66044
|
logger.debug('_putEvents Failed: ', err);
|
|
66764
66045
|
var statusCode = err.$metadata && err.$metadata.httpStatusCode;
|
|
66765
|
-
|
|
66766
66046
|
if (RETRYABLE_CODES.includes(statusCode)) {
|
|
66767
66047
|
var retryableEvents = Object.values(eventMap);
|
|
66768
|
-
|
|
66769
66048
|
this._retry(retryableEvents);
|
|
66770
|
-
|
|
66771
66049
|
return;
|
|
66772
66050
|
}
|
|
66773
66051
|
};
|
|
66774
|
-
|
|
66775
66052
|
EventsBuffer.prototype._processPutEventsSuccessResponse = function (data, eventMap) {
|
|
66776
66053
|
var Results = data.EventsResponse.Results;
|
|
66777
66054
|
var retryableEvents = [];
|
|
66778
66055
|
Object.entries(Results).forEach(function (_a) {
|
|
66779
66056
|
var _b = __read(_a, 2),
|
|
66780
|
-
|
|
66781
|
-
|
|
66782
|
-
|
|
66057
|
+
endpointId = _b[0],
|
|
66058
|
+
endpointValues = _b[1];
|
|
66783
66059
|
var responses = endpointValues.EventsItemResponse;
|
|
66784
66060
|
Object.entries(responses).forEach(function (_a) {
|
|
66785
66061
|
var _b, _c;
|
|
66786
|
-
|
|
66787
66062
|
var _d = __read(_a, 2),
|
|
66788
|
-
|
|
66789
|
-
|
|
66790
|
-
|
|
66791
|
-
|
|
66792
|
-
|
|
66793
|
-
|
|
66794
|
-
|
|
66063
|
+
eventId = _d[0],
|
|
66064
|
+
_e = _d[1],
|
|
66065
|
+
StatusCode = _e.StatusCode,
|
|
66066
|
+
Message = _e.Message;
|
|
66067
|
+
var eventObject = eventMap[eventId];
|
|
66068
|
+
// manually crafting handlers response to keep API consistant
|
|
66795
66069
|
var response = {
|
|
66796
66070
|
EventsResponse: {
|
|
66797
66071
|
Results: (_b = {}, _b[endpointId] = {
|
|
@@ -66802,70 +66076,57 @@ function () {
|
|
|
66802
66076
|
}, _b)
|
|
66803
66077
|
}
|
|
66804
66078
|
};
|
|
66805
|
-
|
|
66806
66079
|
if (ACCEPTED_CODES.includes(StatusCode)) {
|
|
66807
66080
|
eventObject.handlers.resolve(response);
|
|
66808
66081
|
return;
|
|
66809
66082
|
}
|
|
66810
|
-
|
|
66811
66083
|
if (RETRYABLE_CODES.includes(StatusCode)) {
|
|
66812
66084
|
retryableEvents.push(eventObject);
|
|
66813
66085
|
return;
|
|
66814
66086
|
}
|
|
66815
|
-
|
|
66816
66087
|
var name = eventObject.params.event.name;
|
|
66817
66088
|
logger.error("event " + eventId + " : " + name + " failed with error: " + Message);
|
|
66818
66089
|
return eventObject.handlers.reject(response);
|
|
66819
66090
|
});
|
|
66820
66091
|
});
|
|
66821
|
-
|
|
66822
66092
|
if (retryableEvents.length) {
|
|
66823
66093
|
this._retry(retryableEvents);
|
|
66824
66094
|
}
|
|
66825
66095
|
};
|
|
66826
|
-
|
|
66827
66096
|
EventsBuffer.prototype._retry = function (retryableEvents) {
|
|
66828
|
-
var _a;
|
|
66829
|
-
|
|
66830
|
-
|
|
66097
|
+
var _a;
|
|
66098
|
+
// retryable events that haven't reached the resendLimit
|
|
66831
66099
|
var eligibleEvents = [];
|
|
66832
66100
|
retryableEvents.forEach(function (event) {
|
|
66833
66101
|
var _a;
|
|
66834
|
-
|
|
66835
66102
|
var params = event.params;
|
|
66836
66103
|
var _b = params.event,
|
|
66837
|
-
|
|
66838
|
-
|
|
66839
|
-
|
|
66104
|
+
eventId = _b.eventId,
|
|
66105
|
+
name = _b.name;
|
|
66840
66106
|
if (params.resendLimit-- > 0) {
|
|
66841
66107
|
logger.debug("resending event " + eventId + " : " + name + " with " + params.resendLimit + " retry attempts remaining");
|
|
66842
66108
|
eligibleEvents.push((_a = {}, _a[eventId] = event, _a));
|
|
66843
66109
|
return;
|
|
66844
66110
|
}
|
|
66845
|
-
|
|
66846
66111
|
logger.debug("no retry attempts remaining for event " + eventId + " : " + name);
|
|
66847
|
-
});
|
|
66848
|
-
|
|
66112
|
+
});
|
|
66113
|
+
// add the events to the front of the buffer
|
|
66849
66114
|
(_a = this._buffer).unshift.apply(_a, __spread(eligibleEvents));
|
|
66850
|
-
};
|
|
66115
|
+
};
|
|
66116
|
+
// convert buffer to map, i.e. { eventId1: { params, handler }, eventId2: { params, handlers } }
|
|
66851
66117
|
// this allows us to easily access the handlers after receiving a batch response
|
|
66852
|
-
|
|
66853
|
-
|
|
66854
66118
|
EventsBuffer.prototype._bufferToMap = function (buffer) {
|
|
66855
66119
|
return buffer.reduce(function (acc, curVal) {
|
|
66856
66120
|
var _a = __read(Object.entries(curVal), 1),
|
|
66857
|
-
|
|
66858
|
-
|
|
66859
|
-
|
|
66860
|
-
|
|
66121
|
+
_b = __read(_a[0], 2),
|
|
66122
|
+
key = _b[0],
|
|
66123
|
+
value = _b[1];
|
|
66861
66124
|
acc[key] = value;
|
|
66862
66125
|
return acc;
|
|
66863
66126
|
}, {});
|
|
66864
66127
|
};
|
|
66865
|
-
|
|
66866
66128
|
return EventsBuffer;
|
|
66867
66129
|
}();
|
|
66868
|
-
|
|
66869
66130
|
/* harmony default export */ __webpack_exports__["default"] = (EventsBuffer);
|
|
66870
66131
|
|
|
66871
66132
|
/***/ }),
|
|
@@ -66935,7 +66196,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
66935
66196
|
/**
|
|
66936
66197
|
* @deprecated use named import
|
|
66937
66198
|
*/
|
|
66938
|
-
|
|
66939
66199
|
/* harmony default export */ __webpack_exports__["default"] = (_Analytics__WEBPACK_IMPORTED_MODULE_0__["Analytics"]);
|
|
66940
66200
|
|
|
66941
66201
|
|
|
@@ -66973,7 +66233,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
66973
66233
|
resolve(value);
|
|
66974
66234
|
});
|
|
66975
66235
|
}
|
|
66976
|
-
|
|
66977
66236
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
66978
66237
|
function fulfilled(value) {
|
|
66979
66238
|
try {
|
|
@@ -66982,7 +66241,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
66982
66241
|
reject(e);
|
|
66983
66242
|
}
|
|
66984
66243
|
}
|
|
66985
|
-
|
|
66986
66244
|
function rejected(value) {
|
|
66987
66245
|
try {
|
|
66988
66246
|
step(generator["throw"](value));
|
|
@@ -66990,29 +66248,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
66990
66248
|
reject(e);
|
|
66991
66249
|
}
|
|
66992
66250
|
}
|
|
66993
|
-
|
|
66994
66251
|
function step(result) {
|
|
66995
66252
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
66996
66253
|
}
|
|
66997
|
-
|
|
66998
66254
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
66999
66255
|
});
|
|
67000
66256
|
};
|
|
67001
|
-
|
|
67002
66257
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
67003
66258
|
var _ = {
|
|
67004
|
-
|
|
67005
|
-
|
|
67006
|
-
|
|
67007
|
-
|
|
66259
|
+
label: 0,
|
|
66260
|
+
sent: function sent() {
|
|
66261
|
+
if (t[0] & 1) throw t[1];
|
|
66262
|
+
return t[1];
|
|
66263
|
+
},
|
|
66264
|
+
trys: [],
|
|
66265
|
+
ops: []
|
|
67008
66266
|
},
|
|
67009
|
-
|
|
67010
|
-
|
|
67011
|
-
|
|
67012
|
-
|
|
67013
|
-
y,
|
|
67014
|
-
t,
|
|
67015
|
-
g;
|
|
66267
|
+
f,
|
|
66268
|
+
y,
|
|
66269
|
+
t,
|
|
66270
|
+
g;
|
|
67016
66271
|
return g = {
|
|
67017
66272
|
next: verb(0),
|
|
67018
66273
|
"throw": verb(1),
|
|
@@ -67020,79 +66275,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67020
66275
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
67021
66276
|
return this;
|
|
67022
66277
|
}), g;
|
|
67023
|
-
|
|
67024
66278
|
function verb(n) {
|
|
67025
66279
|
return function (v) {
|
|
67026
66280
|
return step([n, v]);
|
|
67027
66281
|
};
|
|
67028
66282
|
}
|
|
67029
|
-
|
|
67030
66283
|
function step(op) {
|
|
67031
66284
|
if (f) throw new TypeError("Generator is already executing.");
|
|
67032
|
-
|
|
67033
66285
|
while (_) {
|
|
67034
66286
|
try {
|
|
67035
66287
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
67036
66288
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
67037
|
-
|
|
67038
66289
|
switch (op[0]) {
|
|
67039
66290
|
case 0:
|
|
67040
66291
|
case 1:
|
|
67041
66292
|
t = op;
|
|
67042
66293
|
break;
|
|
67043
|
-
|
|
67044
66294
|
case 4:
|
|
67045
66295
|
_.label++;
|
|
67046
66296
|
return {
|
|
67047
66297
|
value: op[1],
|
|
67048
66298
|
done: false
|
|
67049
66299
|
};
|
|
67050
|
-
|
|
67051
66300
|
case 5:
|
|
67052
66301
|
_.label++;
|
|
67053
66302
|
y = op[1];
|
|
67054
66303
|
op = [0];
|
|
67055
66304
|
continue;
|
|
67056
|
-
|
|
67057
66305
|
case 7:
|
|
67058
66306
|
op = _.ops.pop();
|
|
67059
|
-
|
|
67060
66307
|
_.trys.pop();
|
|
67061
|
-
|
|
67062
66308
|
continue;
|
|
67063
|
-
|
|
67064
66309
|
default:
|
|
67065
66310
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
67066
66311
|
_ = 0;
|
|
67067
66312
|
continue;
|
|
67068
66313
|
}
|
|
67069
|
-
|
|
67070
66314
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
67071
66315
|
_.label = op[1];
|
|
67072
66316
|
break;
|
|
67073
66317
|
}
|
|
67074
|
-
|
|
67075
66318
|
if (op[0] === 6 && _.label < t[1]) {
|
|
67076
66319
|
_.label = t[1];
|
|
67077
66320
|
t = op;
|
|
67078
66321
|
break;
|
|
67079
66322
|
}
|
|
67080
|
-
|
|
67081
66323
|
if (t && _.label < t[2]) {
|
|
67082
66324
|
_.label = t[2];
|
|
67083
|
-
|
|
67084
66325
|
_.ops.push(op);
|
|
67085
|
-
|
|
67086
66326
|
break;
|
|
67087
66327
|
}
|
|
67088
|
-
|
|
67089
66328
|
if (t[2]) _.ops.pop();
|
|
67090
|
-
|
|
67091
66329
|
_.trys.pop();
|
|
67092
|
-
|
|
67093
66330
|
continue;
|
|
67094
66331
|
}
|
|
67095
|
-
|
|
67096
66332
|
op = body.call(thisArg, _);
|
|
67097
66333
|
} catch (e) {
|
|
67098
66334
|
op = [6, e];
|
|
@@ -67101,7 +66337,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67101
66337
|
f = t = 0;
|
|
67102
66338
|
}
|
|
67103
66339
|
}
|
|
67104
|
-
|
|
67105
66340
|
if (op[0] & 5) throw op[1];
|
|
67106
66341
|
return {
|
|
67107
66342
|
value: op[0] ? op[1] : void 0,
|
|
@@ -67111,7 +66346,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67111
66346
|
};
|
|
67112
66347
|
|
|
67113
66348
|
|
|
67114
|
-
|
|
67115
66349
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('EventTracker');
|
|
67116
66350
|
var defaultOpts = {
|
|
67117
66351
|
enable: false,
|
|
@@ -67119,16 +66353,12 @@ var defaultOpts = {
|
|
|
67119
66353
|
selectorPrefix: 'data-amplify-analytics-',
|
|
67120
66354
|
provider: 'AWSPinpoint'
|
|
67121
66355
|
};
|
|
67122
|
-
|
|
67123
|
-
var EventTracker =
|
|
67124
|
-
/** @class */
|
|
67125
|
-
function () {
|
|
66356
|
+
var EventTracker = /** @class */function () {
|
|
67126
66357
|
function EventTracker(tracker, opts) {
|
|
67127
66358
|
if (!_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser || !window.addEventListener) {
|
|
67128
66359
|
logger.debug('not in the supported web environment');
|
|
67129
66360
|
return;
|
|
67130
66361
|
}
|
|
67131
|
-
|
|
67132
66362
|
this._config = Object.assign({}, defaultOpts, opts);
|
|
67133
66363
|
this._tracker = tracker;
|
|
67134
66364
|
this._delegates = {};
|
|
@@ -67136,12 +66366,9 @@ function () {
|
|
|
67136
66366
|
logger.debug('initialize pageview tracker with opts', this._config);
|
|
67137
66367
|
this.configure(this._config);
|
|
67138
66368
|
}
|
|
67139
|
-
|
|
67140
66369
|
EventTracker.prototype.configure = function (opts) {
|
|
67141
66370
|
var _this = this;
|
|
67142
|
-
|
|
67143
66371
|
Object.assign(this._config, opts);
|
|
67144
|
-
|
|
67145
66372
|
if (!this._config.enable) {
|
|
67146
66373
|
Object.keys(this._delegates).forEach(function (key) {
|
|
67147
66374
|
if (typeof _this._delegates[key].destroy === 'function') _this._delegates[key].destroy();
|
|
@@ -67149,7 +66376,6 @@ function () {
|
|
|
67149
66376
|
this._delegates = {};
|
|
67150
66377
|
} else if (this._config.enable && Object.keys(this._delegates).length === 0) {
|
|
67151
66378
|
var selector_1 = '[' + this._config.selectorPrefix + 'on]';
|
|
67152
|
-
|
|
67153
66379
|
this._config.events.forEach(function (evt) {
|
|
67154
66380
|
_this._delegates[evt] = Object(_vendor_dom_utils__WEBPACK_IMPORTED_MODULE_0__["delegate"])(document, evt, selector_1, _this._trackFunc, {
|
|
67155
66381
|
composed: true,
|
|
@@ -67157,14 +66383,11 @@ function () {
|
|
|
67157
66383
|
});
|
|
67158
66384
|
});
|
|
67159
66385
|
}
|
|
67160
|
-
|
|
67161
66386
|
return this._config;
|
|
67162
66387
|
};
|
|
67163
|
-
|
|
67164
66388
|
EventTracker.prototype._trackFunc = function (event, element) {
|
|
67165
66389
|
return __awaiter(this, void 0, void 0, function () {
|
|
67166
66390
|
var customAttrs, events, eventName, attrs, defaultAttrs, _a, attributes;
|
|
67167
|
-
|
|
67168
66391
|
return __generator(this, function (_b) {
|
|
67169
66392
|
switch (_b.label) {
|
|
67170
66393
|
case 0:
|
|
@@ -67172,31 +66395,20 @@ function () {
|
|
|
67172
66395
|
events = element.getAttribute(this._config.selectorPrefix + 'on').split(/\s*,\s*/);
|
|
67173
66396
|
eventName = element.getAttribute(this._config.selectorPrefix + 'name');
|
|
67174
66397
|
attrs = element.getAttribute(this._config.selectorPrefix + 'attrs');
|
|
67175
|
-
|
|
67176
66398
|
if (attrs) {
|
|
67177
66399
|
attrs.split(/\s*,\s*/).forEach(function (attr) {
|
|
67178
66400
|
var tmp = attr.trim().split(/\s*:\s*/);
|
|
67179
66401
|
customAttrs[tmp[0]] = tmp[1];
|
|
67180
66402
|
});
|
|
67181
66403
|
}
|
|
67182
|
-
|
|
67183
|
-
|
|
67184
|
-
/*break*/
|
|
67185
|
-
, 2];
|
|
67186
|
-
return [4
|
|
67187
|
-
/*yield*/
|
|
67188
|
-
, this._config.attributes()];
|
|
67189
|
-
|
|
66404
|
+
if (!(typeof this._config.attributes === 'function')) return [3 /*break*/, 2];
|
|
66405
|
+
return [4 /*yield*/, this._config.attributes()];
|
|
67190
66406
|
case 1:
|
|
67191
66407
|
_a = _b.sent();
|
|
67192
|
-
return [3
|
|
67193
|
-
/*break*/
|
|
67194
|
-
, 3];
|
|
67195
|
-
|
|
66408
|
+
return [3 /*break*/, 3];
|
|
67196
66409
|
case 2:
|
|
67197
66410
|
_a = this._config.attributes;
|
|
67198
66411
|
_b.label = 3;
|
|
67199
|
-
|
|
67200
66412
|
case 3:
|
|
67201
66413
|
defaultAttrs = _a;
|
|
67202
66414
|
attributes = Object.assign({
|
|
@@ -67205,12 +66417,9 @@ function () {
|
|
|
67205
66417
|
}, defaultAttrs, customAttrs);
|
|
67206
66418
|
logger.debug('events needed to be recorded', events);
|
|
67207
66419
|
logger.debug('attributes needed to be attached', customAttrs);
|
|
67208
|
-
|
|
67209
66420
|
if (events.indexOf(event.type) < 0) {
|
|
67210
66421
|
logger.debug("event " + event.type + " is not selected to be recorded");
|
|
67211
|
-
return [2
|
|
67212
|
-
/*return*/
|
|
67213
|
-
];
|
|
66422
|
+
return [2 /*return*/];
|
|
67214
66423
|
}
|
|
67215
66424
|
|
|
67216
66425
|
this._tracker({
|
|
@@ -67219,10 +66428,7 @@ function () {
|
|
|
67219
66428
|
}, this._config.provider)["catch"](function (e) {
|
|
67220
66429
|
logger.debug("Failed to record the " + event.type + " event', " + e);
|
|
67221
66430
|
});
|
|
67222
|
-
|
|
67223
|
-
return [2
|
|
67224
|
-
/*return*/
|
|
67225
|
-
];
|
|
66431
|
+
return [2 /*return*/];
|
|
67226
66432
|
}
|
|
67227
66433
|
});
|
|
67228
66434
|
});
|
|
@@ -67231,11 +66437,9 @@ function () {
|
|
|
67231
66437
|
return EventTracker;
|
|
67232
66438
|
}();
|
|
67233
66439
|
|
|
67234
|
-
|
|
67235
66440
|
/**
|
|
67236
66441
|
* @deprecated use named import
|
|
67237
66442
|
*/
|
|
67238
|
-
|
|
67239
66443
|
/* harmony default export */ __webpack_exports__["default"] = (EventTracker);
|
|
67240
66444
|
|
|
67241
66445
|
/***/ }),
|
|
@@ -67271,7 +66475,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
67271
66475
|
resolve(value);
|
|
67272
66476
|
});
|
|
67273
66477
|
}
|
|
67274
|
-
|
|
67275
66478
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
67276
66479
|
function fulfilled(value) {
|
|
67277
66480
|
try {
|
|
@@ -67280,7 +66483,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
67280
66483
|
reject(e);
|
|
67281
66484
|
}
|
|
67282
66485
|
}
|
|
67283
|
-
|
|
67284
66486
|
function rejected(value) {
|
|
67285
66487
|
try {
|
|
67286
66488
|
step(generator["throw"](value));
|
|
@@ -67288,29 +66490,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
67288
66490
|
reject(e);
|
|
67289
66491
|
}
|
|
67290
66492
|
}
|
|
67291
|
-
|
|
67292
66493
|
function step(result) {
|
|
67293
66494
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
67294
66495
|
}
|
|
67295
|
-
|
|
67296
66496
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
67297
66497
|
});
|
|
67298
66498
|
};
|
|
67299
|
-
|
|
67300
66499
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
67301
66500
|
var _ = {
|
|
67302
|
-
|
|
67303
|
-
|
|
67304
|
-
|
|
67305
|
-
|
|
66501
|
+
label: 0,
|
|
66502
|
+
sent: function sent() {
|
|
66503
|
+
if (t[0] & 1) throw t[1];
|
|
66504
|
+
return t[1];
|
|
66505
|
+
},
|
|
66506
|
+
trys: [],
|
|
66507
|
+
ops: []
|
|
67306
66508
|
},
|
|
67307
|
-
|
|
67308
|
-
|
|
67309
|
-
|
|
67310
|
-
|
|
67311
|
-
y,
|
|
67312
|
-
t,
|
|
67313
|
-
g;
|
|
66509
|
+
f,
|
|
66510
|
+
y,
|
|
66511
|
+
t,
|
|
66512
|
+
g;
|
|
67314
66513
|
return g = {
|
|
67315
66514
|
next: verb(0),
|
|
67316
66515
|
"throw": verb(1),
|
|
@@ -67318,79 +66517,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67318
66517
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
67319
66518
|
return this;
|
|
67320
66519
|
}), g;
|
|
67321
|
-
|
|
67322
66520
|
function verb(n) {
|
|
67323
66521
|
return function (v) {
|
|
67324
66522
|
return step([n, v]);
|
|
67325
66523
|
};
|
|
67326
66524
|
}
|
|
67327
|
-
|
|
67328
66525
|
function step(op) {
|
|
67329
66526
|
if (f) throw new TypeError("Generator is already executing.");
|
|
67330
|
-
|
|
67331
66527
|
while (_) {
|
|
67332
66528
|
try {
|
|
67333
66529
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
67334
66530
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
67335
|
-
|
|
67336
66531
|
switch (op[0]) {
|
|
67337
66532
|
case 0:
|
|
67338
66533
|
case 1:
|
|
67339
66534
|
t = op;
|
|
67340
66535
|
break;
|
|
67341
|
-
|
|
67342
66536
|
case 4:
|
|
67343
66537
|
_.label++;
|
|
67344
66538
|
return {
|
|
67345
66539
|
value: op[1],
|
|
67346
66540
|
done: false
|
|
67347
66541
|
};
|
|
67348
|
-
|
|
67349
66542
|
case 5:
|
|
67350
66543
|
_.label++;
|
|
67351
66544
|
y = op[1];
|
|
67352
66545
|
op = [0];
|
|
67353
66546
|
continue;
|
|
67354
|
-
|
|
67355
66547
|
case 7:
|
|
67356
66548
|
op = _.ops.pop();
|
|
67357
|
-
|
|
67358
66549
|
_.trys.pop();
|
|
67359
|
-
|
|
67360
66550
|
continue;
|
|
67361
|
-
|
|
67362
66551
|
default:
|
|
67363
66552
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
67364
66553
|
_ = 0;
|
|
67365
66554
|
continue;
|
|
67366
66555
|
}
|
|
67367
|
-
|
|
67368
66556
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
67369
66557
|
_.label = op[1];
|
|
67370
66558
|
break;
|
|
67371
66559
|
}
|
|
67372
|
-
|
|
67373
66560
|
if (op[0] === 6 && _.label < t[1]) {
|
|
67374
66561
|
_.label = t[1];
|
|
67375
66562
|
t = op;
|
|
67376
66563
|
break;
|
|
67377
66564
|
}
|
|
67378
|
-
|
|
67379
66565
|
if (t && _.label < t[2]) {
|
|
67380
66566
|
_.label = t[2];
|
|
67381
|
-
|
|
67382
66567
|
_.ops.push(op);
|
|
67383
|
-
|
|
67384
66568
|
break;
|
|
67385
66569
|
}
|
|
67386
|
-
|
|
67387
66570
|
if (t[2]) _.ops.pop();
|
|
67388
|
-
|
|
67389
66571
|
_.trys.pop();
|
|
67390
|
-
|
|
67391
66572
|
continue;
|
|
67392
66573
|
}
|
|
67393
|
-
|
|
67394
66574
|
op = body.call(thisArg, _);
|
|
67395
66575
|
} catch (e) {
|
|
67396
66576
|
op = [6, e];
|
|
@@ -67399,7 +66579,6 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67399
66579
|
f = t = 0;
|
|
67400
66580
|
}
|
|
67401
66581
|
}
|
|
67402
|
-
|
|
67403
66582
|
if (op[0] & 5) throw op[1];
|
|
67404
66583
|
return {
|
|
67405
66584
|
value: op[0] ? op[1] : void 0,
|
|
@@ -67409,96 +66588,70 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67409
66588
|
};
|
|
67410
66589
|
|
|
67411
66590
|
|
|
67412
|
-
|
|
67413
66591
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('PageViewTracker');
|
|
67414
66592
|
var PREV_URL_KEY = 'aws-amplify-analytics-prevUrl';
|
|
67415
|
-
|
|
67416
66593
|
var getUrl = function getUrl() {
|
|
67417
66594
|
if (!_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser) return '';else return window.location.origin + window.location.pathname;
|
|
67418
66595
|
};
|
|
67419
|
-
|
|
67420
66596
|
var defaultOpts = {
|
|
67421
66597
|
enable: false,
|
|
67422
66598
|
provider: 'AWSPinpoint',
|
|
67423
66599
|
getUrl: getUrl
|
|
67424
66600
|
};
|
|
67425
|
-
|
|
67426
|
-
var PageViewTracker =
|
|
67427
|
-
/** @class */
|
|
67428
|
-
function () {
|
|
66601
|
+
var PageViewTracker = /** @class */function () {
|
|
67429
66602
|
function PageViewTracker(tracker, opts) {
|
|
67430
66603
|
logger.debug('initialize pageview tracker with opts', opts);
|
|
67431
66604
|
this._config = Object.assign({}, defaultOpts, opts);
|
|
67432
66605
|
this._tracker = tracker;
|
|
67433
66606
|
this._hasEnabled = false;
|
|
67434
66607
|
this._trackFunc = this._trackFunc.bind(this);
|
|
67435
|
-
|
|
67436
66608
|
if (this._config.type === 'SPA') {
|
|
67437
66609
|
this._pageViewTrackSPA();
|
|
67438
66610
|
} else {
|
|
67439
66611
|
this._pageViewTrackDefault();
|
|
67440
66612
|
}
|
|
67441
66613
|
}
|
|
67442
|
-
|
|
67443
66614
|
PageViewTracker.prototype.configure = function (opts) {
|
|
67444
|
-
Object.assign(this._config, opts);
|
|
67445
|
-
|
|
66615
|
+
Object.assign(this._config, opts);
|
|
66616
|
+
// if spa, need to remove those listeners if disabled
|
|
67446
66617
|
if (this._config.type === 'SPA') {
|
|
67447
66618
|
this._pageViewTrackSPA();
|
|
67448
66619
|
}
|
|
67449
|
-
|
|
67450
66620
|
return this._config;
|
|
67451
66621
|
};
|
|
67452
|
-
|
|
67453
66622
|
PageViewTracker.prototype._isSameUrl = function () {
|
|
67454
66623
|
var prevUrl = sessionStorage.getItem(PREV_URL_KEY);
|
|
67455
|
-
|
|
67456
66624
|
var curUrl = this._config.getUrl();
|
|
67457
|
-
|
|
67458
66625
|
if (prevUrl === curUrl) {
|
|
67459
66626
|
logger.debug('the url is same');
|
|
67460
66627
|
return true;
|
|
67461
66628
|
} else return false;
|
|
67462
66629
|
};
|
|
67463
|
-
|
|
67464
66630
|
PageViewTracker.prototype._pageViewTrackDefault = function () {
|
|
67465
66631
|
return __awaiter(this, void 0, void 0, function () {
|
|
67466
66632
|
var url, customAttrs, _a, attributes;
|
|
67467
|
-
|
|
67468
66633
|
return __generator(this, function (_b) {
|
|
67469
66634
|
switch (_b.label) {
|
|
67470
66635
|
case 0:
|
|
67471
66636
|
if (!_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser || !window.addEventListener || !window.sessionStorage) {
|
|
67472
66637
|
logger.debug('not in the supported web enviroment');
|
|
67473
|
-
return [2
|
|
67474
|
-
/*return*/
|
|
67475
|
-
];
|
|
66638
|
+
return [2 /*return*/];
|
|
67476
66639
|
}
|
|
67477
66640
|
|
|
67478
66641
|
url = this._config.getUrl();
|
|
67479
|
-
if (!(typeof this._config.attributes === 'function')) return [3
|
|
67480
|
-
/*
|
|
67481
|
-
, 2];
|
|
67482
|
-
return [4
|
|
67483
|
-
/*yield*/
|
|
67484
|
-
, this._config.attributes()];
|
|
67485
|
-
|
|
66642
|
+
if (!(typeof this._config.attributes === 'function')) return [3 /*break*/, 2];
|
|
66643
|
+
return [4 /*yield*/, this._config.attributes()];
|
|
67486
66644
|
case 1:
|
|
67487
66645
|
_a = _b.sent();
|
|
67488
|
-
return [3
|
|
67489
|
-
/*break*/
|
|
67490
|
-
, 3];
|
|
67491
|
-
|
|
66646
|
+
return [3 /*break*/, 3];
|
|
67492
66647
|
case 2:
|
|
67493
66648
|
_a = this._config.attributes;
|
|
67494
66649
|
_b.label = 3;
|
|
67495
|
-
|
|
67496
66650
|
case 3:
|
|
67497
66651
|
customAttrs = _a;
|
|
67498
66652
|
attributes = Object.assign({
|
|
67499
66653
|
url: url
|
|
67500
66654
|
}, customAttrs);
|
|
67501
|
-
|
|
67502
66655
|
if (this._config.enable && !this._isSameUrl()) {
|
|
67503
66656
|
this._tracker({
|
|
67504
66657
|
name: this._config.eventName || 'pageView',
|
|
@@ -67506,13 +66659,9 @@ function () {
|
|
|
67506
66659
|
}, this._config.provider)["catch"](function (e) {
|
|
67507
66660
|
logger.debug('Failed to record the page view event', e);
|
|
67508
66661
|
});
|
|
67509
|
-
|
|
67510
66662
|
sessionStorage.setItem(PREV_URL_KEY, url);
|
|
67511
66663
|
}
|
|
67512
|
-
|
|
67513
|
-
return [2
|
|
67514
|
-
/*return*/
|
|
67515
|
-
];
|
|
66664
|
+
return [2 /*return*/];
|
|
67516
66665
|
}
|
|
67517
66666
|
});
|
|
67518
66667
|
});
|
|
@@ -67521,41 +66670,28 @@ function () {
|
|
|
67521
66670
|
PageViewTracker.prototype._trackFunc = function () {
|
|
67522
66671
|
return __awaiter(this, void 0, void 0, function () {
|
|
67523
66672
|
var url, customAttrs, _a, attributes;
|
|
67524
|
-
|
|
67525
66673
|
return __generator(this, function (_b) {
|
|
67526
66674
|
switch (_b.label) {
|
|
67527
66675
|
case 0:
|
|
67528
66676
|
if (!_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["JS"].browserOrNode().isBrowser || !window.addEventListener || !history.pushState || !window.sessionStorage) {
|
|
67529
66677
|
logger.debug('not in the supported web enviroment');
|
|
67530
|
-
return [2
|
|
67531
|
-
/*return*/
|
|
67532
|
-
];
|
|
66678
|
+
return [2 /*return*/];
|
|
67533
66679
|
}
|
|
67534
66680
|
|
|
67535
66681
|
url = this._config.getUrl();
|
|
67536
|
-
if (!(typeof this._config.attributes === 'function')) return [3
|
|
67537
|
-
/*
|
|
67538
|
-
, 2];
|
|
67539
|
-
return [4
|
|
67540
|
-
/*yield*/
|
|
67541
|
-
, this._config.attributes()];
|
|
67542
|
-
|
|
66682
|
+
if (!(typeof this._config.attributes === 'function')) return [3 /*break*/, 2];
|
|
66683
|
+
return [4 /*yield*/, this._config.attributes()];
|
|
67543
66684
|
case 1:
|
|
67544
66685
|
_a = _b.sent();
|
|
67545
|
-
return [3
|
|
67546
|
-
/*break*/
|
|
67547
|
-
, 3];
|
|
67548
|
-
|
|
66686
|
+
return [3 /*break*/, 3];
|
|
67549
66687
|
case 2:
|
|
67550
66688
|
_a = this._config.attributes;
|
|
67551
66689
|
_b.label = 3;
|
|
67552
|
-
|
|
67553
66690
|
case 3:
|
|
67554
66691
|
customAttrs = _a;
|
|
67555
66692
|
attributes = Object.assign({
|
|
67556
66693
|
url: url
|
|
67557
66694
|
}, customAttrs);
|
|
67558
|
-
|
|
67559
66695
|
if (!this._isSameUrl()) {
|
|
67560
66696
|
this._tracker({
|
|
67561
66697
|
name: this._config.eventName || 'pageView',
|
|
@@ -67563,13 +66699,9 @@ function () {
|
|
|
67563
66699
|
}, this._config.provider)["catch"](function (e) {
|
|
67564
66700
|
logger.debug('Failed to record the page view event', e);
|
|
67565
66701
|
});
|
|
67566
|
-
|
|
67567
66702
|
sessionStorage.setItem(PREV_URL_KEY, url);
|
|
67568
66703
|
}
|
|
67569
|
-
|
|
67570
|
-
return [2
|
|
67571
|
-
/*return*/
|
|
67572
|
-
];
|
|
66704
|
+
return [2 /*return*/];
|
|
67573
66705
|
}
|
|
67574
66706
|
});
|
|
67575
66707
|
});
|
|
@@ -67580,14 +66712,11 @@ function () {
|
|
|
67580
66712
|
logger.debug('not in the supported web enviroment');
|
|
67581
66713
|
return;
|
|
67582
66714
|
}
|
|
67583
|
-
|
|
67584
66715
|
if (this._config.enable && !this._hasEnabled) {
|
|
67585
66716
|
_utils_MethodEmbed__WEBPACK_IMPORTED_MODULE_0__["MethodEmbed"].add(history, 'pushState', this._trackFunc);
|
|
67586
66717
|
_utils_MethodEmbed__WEBPACK_IMPORTED_MODULE_0__["MethodEmbed"].add(history, 'replaceState', this._trackFunc);
|
|
67587
66718
|
window.addEventListener('popstate', this._trackFunc);
|
|
67588
|
-
|
|
67589
66719
|
this._trackFunc();
|
|
67590
|
-
|
|
67591
66720
|
this._hasEnabled = true;
|
|
67592
66721
|
} else {
|
|
67593
66722
|
_utils_MethodEmbed__WEBPACK_IMPORTED_MODULE_0__["MethodEmbed"].remove(history, 'pushState');
|
|
@@ -67596,15 +66725,12 @@ function () {
|
|
|
67596
66725
|
this._hasEnabled = false;
|
|
67597
66726
|
}
|
|
67598
66727
|
};
|
|
67599
|
-
|
|
67600
66728
|
return PageViewTracker;
|
|
67601
66729
|
}();
|
|
67602
66730
|
|
|
67603
|
-
|
|
67604
66731
|
/**
|
|
67605
66732
|
* @deprecated use named import
|
|
67606
66733
|
*/
|
|
67607
|
-
|
|
67608
66734
|
/* harmony default export */ __webpack_exports__["default"] = (PageViewTracker);
|
|
67609
66735
|
|
|
67610
66736
|
/***/ }),
|
|
@@ -67639,7 +66765,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
67639
66765
|
resolve(value);
|
|
67640
66766
|
});
|
|
67641
66767
|
}
|
|
67642
|
-
|
|
67643
66768
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
67644
66769
|
function fulfilled(value) {
|
|
67645
66770
|
try {
|
|
@@ -67648,7 +66773,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
67648
66773
|
reject(e);
|
|
67649
66774
|
}
|
|
67650
66775
|
}
|
|
67651
|
-
|
|
67652
66776
|
function rejected(value) {
|
|
67653
66777
|
try {
|
|
67654
66778
|
step(generator["throw"](value));
|
|
@@ -67656,29 +66780,26 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
|
|
|
67656
66780
|
reject(e);
|
|
67657
66781
|
}
|
|
67658
66782
|
}
|
|
67659
|
-
|
|
67660
66783
|
function step(result) {
|
|
67661
66784
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
67662
66785
|
}
|
|
67663
|
-
|
|
67664
66786
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
67665
66787
|
});
|
|
67666
66788
|
};
|
|
67667
|
-
|
|
67668
66789
|
var __generator = undefined && undefined.__generator || function (thisArg, body) {
|
|
67669
66790
|
var _ = {
|
|
67670
|
-
|
|
67671
|
-
|
|
67672
|
-
|
|
67673
|
-
|
|
66791
|
+
label: 0,
|
|
66792
|
+
sent: function sent() {
|
|
66793
|
+
if (t[0] & 1) throw t[1];
|
|
66794
|
+
return t[1];
|
|
66795
|
+
},
|
|
66796
|
+
trys: [],
|
|
66797
|
+
ops: []
|
|
67674
66798
|
},
|
|
67675
|
-
|
|
67676
|
-
|
|
67677
|
-
|
|
67678
|
-
|
|
67679
|
-
y,
|
|
67680
|
-
t,
|
|
67681
|
-
g;
|
|
66799
|
+
f,
|
|
66800
|
+
y,
|
|
66801
|
+
t,
|
|
66802
|
+
g;
|
|
67682
66803
|
return g = {
|
|
67683
66804
|
next: verb(0),
|
|
67684
66805
|
"throw": verb(1),
|
|
@@ -67686,79 +66807,60 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67686
66807
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
67687
66808
|
return this;
|
|
67688
66809
|
}), g;
|
|
67689
|
-
|
|
67690
66810
|
function verb(n) {
|
|
67691
66811
|
return function (v) {
|
|
67692
66812
|
return step([n, v]);
|
|
67693
66813
|
};
|
|
67694
66814
|
}
|
|
67695
|
-
|
|
67696
66815
|
function step(op) {
|
|
67697
66816
|
if (f) throw new TypeError("Generator is already executing.");
|
|
67698
|
-
|
|
67699
66817
|
while (_) {
|
|
67700
66818
|
try {
|
|
67701
66819
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
67702
66820
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
67703
|
-
|
|
67704
66821
|
switch (op[0]) {
|
|
67705
66822
|
case 0:
|
|
67706
66823
|
case 1:
|
|
67707
66824
|
t = op;
|
|
67708
66825
|
break;
|
|
67709
|
-
|
|
67710
66826
|
case 4:
|
|
67711
66827
|
_.label++;
|
|
67712
66828
|
return {
|
|
67713
66829
|
value: op[1],
|
|
67714
66830
|
done: false
|
|
67715
66831
|
};
|
|
67716
|
-
|
|
67717
66832
|
case 5:
|
|
67718
66833
|
_.label++;
|
|
67719
66834
|
y = op[1];
|
|
67720
66835
|
op = [0];
|
|
67721
66836
|
continue;
|
|
67722
|
-
|
|
67723
66837
|
case 7:
|
|
67724
66838
|
op = _.ops.pop();
|
|
67725
|
-
|
|
67726
66839
|
_.trys.pop();
|
|
67727
|
-
|
|
67728
66840
|
continue;
|
|
67729
|
-
|
|
67730
66841
|
default:
|
|
67731
66842
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
67732
66843
|
_ = 0;
|
|
67733
66844
|
continue;
|
|
67734
66845
|
}
|
|
67735
|
-
|
|
67736
66846
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
67737
66847
|
_.label = op[1];
|
|
67738
66848
|
break;
|
|
67739
66849
|
}
|
|
67740
|
-
|
|
67741
66850
|
if (op[0] === 6 && _.label < t[1]) {
|
|
67742
66851
|
_.label = t[1];
|
|
67743
66852
|
t = op;
|
|
67744
66853
|
break;
|
|
67745
66854
|
}
|
|
67746
|
-
|
|
67747
66855
|
if (t && _.label < t[2]) {
|
|
67748
66856
|
_.label = t[2];
|
|
67749
|
-
|
|
67750
66857
|
_.ops.push(op);
|
|
67751
|
-
|
|
67752
66858
|
break;
|
|
67753
66859
|
}
|
|
67754
|
-
|
|
67755
66860
|
if (t[2]) _.ops.pop();
|
|
67756
|
-
|
|
67757
66861
|
_.trys.pop();
|
|
67758
|
-
|
|
67759
66862
|
continue;
|
|
67760
66863
|
}
|
|
67761
|
-
|
|
67762
66864
|
op = body.call(thisArg, _);
|
|
67763
66865
|
} catch (e) {
|
|
67764
66866
|
op = [6, e];
|
|
@@ -67767,16 +66869,14 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
|
|
|
67767
66869
|
f = t = 0;
|
|
67768
66870
|
}
|
|
67769
66871
|
}
|
|
67770
|
-
|
|
67771
66872
|
if (op[0] & 5) throw op[1];
|
|
67772
66873
|
return {
|
|
67773
66874
|
value: op[0] ? op[1] : void 0,
|
|
67774
66875
|
done: true
|
|
67775
66876
|
};
|
|
67776
66877
|
}
|
|
67777
|
-
};
|
|
67778
|
-
|
|
67779
|
-
|
|
66878
|
+
};
|
|
66879
|
+
// the session tracker for web
|
|
67780
66880
|
|
|
67781
66881
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["ConsoleLogger"]('SessionTracker');
|
|
67782
66882
|
var defaultOpts = {
|
|
@@ -67784,10 +66884,7 @@ var defaultOpts = {
|
|
|
67784
66884
|
provider: 'AWSPinpoint'
|
|
67785
66885
|
};
|
|
67786
66886
|
var initialEventSent = false;
|
|
67787
|
-
|
|
67788
|
-
var SessionTracker =
|
|
67789
|
-
/** @class */
|
|
67790
|
-
function () {
|
|
66887
|
+
var SessionTracker = /** @class */function () {
|
|
67791
66888
|
function SessionTracker(tracker, opts) {
|
|
67792
66889
|
this._config = Object.assign({}, defaultOpts, opts);
|
|
67793
66890
|
this._tracker = tracker;
|
|
@@ -67796,17 +66893,14 @@ function () {
|
|
|
67796
66893
|
this._trackBeforeUnload = this._trackBeforeUnload.bind(this);
|
|
67797
66894
|
this.configure(this._config);
|
|
67798
66895
|
}
|
|
67799
|
-
|
|
67800
66896
|
SessionTracker.prototype._envCheck = function () {
|
|
67801
66897
|
if (!_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].browserOrNode().isBrowser) {
|
|
67802
66898
|
return false;
|
|
67803
66899
|
}
|
|
67804
|
-
|
|
67805
66900
|
if (!document || !document.addEventListener) {
|
|
67806
66901
|
logger.debug('not in the supported web environment');
|
|
67807
66902
|
return false;
|
|
67808
66903
|
}
|
|
67809
|
-
|
|
67810
66904
|
if (typeof document.hidden !== 'undefined') {
|
|
67811
66905
|
this._hidden = 'hidden';
|
|
67812
66906
|
this._visibilityChange = 'visibilitychange';
|
|
@@ -67820,38 +66914,25 @@ function () {
|
|
|
67820
66914
|
logger.debug('not in the supported web environment');
|
|
67821
66915
|
return false;
|
|
67822
66916
|
}
|
|
67823
|
-
|
|
67824
66917
|
return true;
|
|
67825
66918
|
};
|
|
67826
|
-
|
|
67827
66919
|
SessionTracker.prototype._trackFunc = function () {
|
|
67828
66920
|
return __awaiter(this, void 0, void 0, function () {
|
|
67829
66921
|
var customAttrs, _a, attributes;
|
|
67830
|
-
|
|
67831
66922
|
return __generator(this, function (_b) {
|
|
67832
66923
|
switch (_b.label) {
|
|
67833
66924
|
case 0:
|
|
67834
|
-
if (!(typeof this._config.attributes === 'function')) return [3
|
|
67835
|
-
/*
|
|
67836
|
-
, 2];
|
|
67837
|
-
return [4
|
|
67838
|
-
/*yield*/
|
|
67839
|
-
, this._config.attributes()];
|
|
67840
|
-
|
|
66925
|
+
if (!(typeof this._config.attributes === 'function')) return [3 /*break*/, 2];
|
|
66926
|
+
return [4 /*yield*/, this._config.attributes()];
|
|
67841
66927
|
case 1:
|
|
67842
66928
|
_a = _b.sent();
|
|
67843
|
-
return [3
|
|
67844
|
-
/*break*/
|
|
67845
|
-
, 3];
|
|
67846
|
-
|
|
66929
|
+
return [3 /*break*/, 3];
|
|
67847
66930
|
case 2:
|
|
67848
66931
|
_a = this._config.attributes;
|
|
67849
66932
|
_b.label = 3;
|
|
67850
|
-
|
|
67851
66933
|
case 3:
|
|
67852
66934
|
customAttrs = _a;
|
|
67853
66935
|
attributes = Object.assign({}, customAttrs);
|
|
67854
|
-
|
|
67855
66936
|
if (document.visibilityState === this._hidden) {
|
|
67856
66937
|
this._tracker({
|
|
67857
66938
|
name: '_session.stop',
|
|
@@ -67867,10 +66948,7 @@ function () {
|
|
|
67867
66948
|
logger.debug('record session start event failed.', e);
|
|
67868
66949
|
});
|
|
67869
66950
|
}
|
|
67870
|
-
|
|
67871
|
-
return [2
|
|
67872
|
-
/*return*/
|
|
67873
|
-
];
|
|
66951
|
+
return [2 /*return*/];
|
|
67874
66952
|
}
|
|
67875
66953
|
});
|
|
67876
66954
|
});
|
|
@@ -67879,11 +66957,9 @@ function () {
|
|
|
67879
66957
|
SessionTracker.prototype._trackBeforeUnload = function (event) {
|
|
67880
66958
|
// before unload callback cannot be async => https://github.com/aws-amplify/amplify-js/issues/2088
|
|
67881
66959
|
var _this = this;
|
|
67882
|
-
|
|
67883
66960
|
var customAttrs = typeof this._config.attributes === 'function' ? Promise.resolve(this._config.attributes()) : Promise.resolve(this._config.attributes);
|
|
67884
66961
|
customAttrs.then(function (custom) {
|
|
67885
66962
|
var attributes = Object.assign({}, custom);
|
|
67886
|
-
|
|
67887
66963
|
_this._tracker({
|
|
67888
66964
|
name: '_session.stop',
|
|
67889
66965
|
attributes: attributes,
|
|
@@ -67892,56 +66968,38 @@ function () {
|
|
|
67892
66968
|
logger.debug('record session stop event failed.', e);
|
|
67893
66969
|
});
|
|
67894
66970
|
});
|
|
67895
|
-
};
|
|
67896
|
-
|
|
67897
|
-
|
|
66971
|
+
};
|
|
66972
|
+
// to keep configure a synchronized function
|
|
67898
66973
|
SessionTracker.prototype._sendInitialEvent = function () {
|
|
67899
66974
|
return __awaiter(this, void 0, void 0, function () {
|
|
67900
66975
|
var customAttrs, _a, attributes;
|
|
67901
|
-
|
|
67902
66976
|
return __generator(this, function (_b) {
|
|
67903
66977
|
switch (_b.label) {
|
|
67904
66978
|
case 0:
|
|
67905
66979
|
if (initialEventSent) {
|
|
67906
66980
|
logger.debug('the start session has been sent when the page is loaded');
|
|
67907
|
-
return [2
|
|
67908
|
-
/*return*/
|
|
67909
|
-
];
|
|
66981
|
+
return [2 /*return*/];
|
|
67910
66982
|
} else {
|
|
67911
66983
|
initialEventSent = true;
|
|
67912
66984
|
}
|
|
67913
|
-
|
|
67914
|
-
|
|
67915
|
-
/*break*/
|
|
67916
|
-
, 2];
|
|
67917
|
-
return [4
|
|
67918
|
-
/*yield*/
|
|
67919
|
-
, this._config.attributes()];
|
|
67920
|
-
|
|
66985
|
+
if (!(typeof this._config.attributes === 'function')) return [3 /*break*/, 2];
|
|
66986
|
+
return [4 /*yield*/, this._config.attributes()];
|
|
67921
66987
|
case 1:
|
|
67922
66988
|
_a = _b.sent();
|
|
67923
|
-
return [3
|
|
67924
|
-
/*break*/
|
|
67925
|
-
, 3];
|
|
67926
|
-
|
|
66989
|
+
return [3 /*break*/, 3];
|
|
67927
66990
|
case 2:
|
|
67928
66991
|
_a = this._config.attributes;
|
|
67929
66992
|
_b.label = 3;
|
|
67930
|
-
|
|
67931
66993
|
case 3:
|
|
67932
66994
|
customAttrs = _a;
|
|
67933
66995
|
attributes = Object.assign({}, customAttrs);
|
|
67934
|
-
|
|
67935
66996
|
this._tracker({
|
|
67936
66997
|
name: '_session.start',
|
|
67937
66998
|
attributes: attributes
|
|
67938
66999
|
}, this._config.provider)["catch"](function (e) {
|
|
67939
67000
|
logger.debug('record session start event failed.', e);
|
|
67940
67001
|
});
|
|
67941
|
-
|
|
67942
|
-
return [2
|
|
67943
|
-
/*return*/
|
|
67944
|
-
];
|
|
67002
|
+
return [2 /*return*/];
|
|
67945
67003
|
}
|
|
67946
67004
|
});
|
|
67947
67005
|
});
|
|
@@ -67951,14 +67009,11 @@ function () {
|
|
|
67951
67009
|
if (!this._envCheck()) {
|
|
67952
67010
|
return this._config;
|
|
67953
67011
|
}
|
|
67954
|
-
|
|
67955
67012
|
Object.assign(this._config, opts);
|
|
67956
|
-
|
|
67957
67013
|
if (this._config.enable && !this._hasEnabled) {
|
|
67958
67014
|
// send a start session as soon as it's enabled
|
|
67959
|
-
this._sendInitialEvent();
|
|
67960
|
-
|
|
67961
|
-
|
|
67015
|
+
this._sendInitialEvent();
|
|
67016
|
+
// listen on events
|
|
67962
67017
|
document.addEventListener(this._visibilityChange, this._trackFunc, false);
|
|
67963
67018
|
window.addEventListener('beforeunload', this._trackBeforeUnload, false);
|
|
67964
67019
|
this._hasEnabled = true;
|
|
@@ -67967,18 +67022,14 @@ function () {
|
|
|
67967
67022
|
window.removeEventListener('beforeunload', this._trackBeforeUnload, false);
|
|
67968
67023
|
this._hasEnabled = false;
|
|
67969
67024
|
}
|
|
67970
|
-
|
|
67971
67025
|
return this._config;
|
|
67972
67026
|
};
|
|
67973
|
-
|
|
67974
67027
|
return SessionTracker;
|
|
67975
67028
|
}();
|
|
67976
67029
|
|
|
67977
|
-
|
|
67978
67030
|
/**
|
|
67979
67031
|
* @deprecated use named import
|
|
67980
67032
|
*/
|
|
67981
|
-
|
|
67982
67033
|
/* harmony default export */ __webpack_exports__["default"] = (SessionTracker);
|
|
67983
67034
|
|
|
67984
67035
|
/***/ }),
|
|
@@ -68022,7 +67073,6 @@ var isAppInForeground = function isAppInForeground() {
|
|
|
68022
67073
|
};
|
|
68023
67074
|
|
|
68024
67075
|
|
|
68025
|
-
|
|
68026
67076
|
/***/ }),
|
|
68027
67077
|
|
|
68028
67078
|
/***/ "./lib-esm/utils/MethodEmbed.js":
|
|
@@ -68051,10 +67101,9 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
68051
67101
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
68052
67102
|
if (!m) return o;
|
|
68053
67103
|
var i = m.call(o),
|
|
68054
|
-
|
|
68055
|
-
|
|
68056
|
-
|
|
68057
|
-
|
|
67104
|
+
r,
|
|
67105
|
+
ar = [],
|
|
67106
|
+
e;
|
|
68058
67107
|
try {
|
|
68059
67108
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
|
|
68060
67109
|
ar.push(r.value);
|
|
@@ -68070,77 +67119,56 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
68070
67119
|
if (e) throw e.error;
|
|
68071
67120
|
}
|
|
68072
67121
|
}
|
|
68073
|
-
|
|
68074
67122
|
return ar;
|
|
68075
67123
|
};
|
|
68076
|
-
|
|
68077
67124
|
var __spread = undefined && undefined.__spread || function () {
|
|
68078
67125
|
for (var ar = [], i = 0; i < arguments.length; i++) {
|
|
68079
67126
|
ar = ar.concat(__read(arguments[i]));
|
|
68080
67127
|
}
|
|
68081
|
-
|
|
68082
67128
|
return ar;
|
|
68083
67129
|
};
|
|
68084
|
-
|
|
68085
67130
|
var lists = [];
|
|
68086
|
-
|
|
68087
|
-
var MethodEmbed =
|
|
68088
|
-
/** @class */
|
|
68089
|
-
function () {
|
|
67131
|
+
var MethodEmbed = /** @class */function () {
|
|
68090
67132
|
function MethodEmbed(context, methodName) {
|
|
68091
67133
|
this.context = context;
|
|
68092
67134
|
this.methodName = methodName;
|
|
68093
67135
|
this._originalMethod = context[methodName].bind(context);
|
|
68094
67136
|
}
|
|
68095
|
-
|
|
68096
67137
|
MethodEmbed.add = function (context, methodName, methodOverride) {
|
|
68097
67138
|
getInstance(context, methodName).set(methodOverride);
|
|
68098
67139
|
};
|
|
68099
|
-
|
|
68100
67140
|
MethodEmbed.remove = function (context, methodName) {
|
|
68101
67141
|
getInstance(context, methodName).remove();
|
|
68102
67142
|
};
|
|
68103
|
-
|
|
68104
67143
|
MethodEmbed.prototype.set = function (methodOverride) {
|
|
68105
67144
|
var _this = this;
|
|
68106
|
-
|
|
68107
67145
|
this.context[this.methodName] = function () {
|
|
68108
67146
|
var args = [];
|
|
68109
|
-
|
|
68110
67147
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
68111
67148
|
args[_i] = arguments[_i];
|
|
68112
67149
|
}
|
|
68113
|
-
|
|
68114
67150
|
return methodOverride(_this._originalMethod.apply(_this, __spread(args)));
|
|
68115
67151
|
};
|
|
68116
67152
|
};
|
|
68117
|
-
|
|
68118
67153
|
MethodEmbed.prototype.remove = function () {
|
|
68119
67154
|
this.context[this.methodName] = this._originalMethod;
|
|
68120
67155
|
};
|
|
68121
|
-
|
|
68122
67156
|
return MethodEmbed;
|
|
68123
67157
|
}();
|
|
68124
67158
|
|
|
68125
|
-
|
|
68126
|
-
|
|
68127
67159
|
function getInstance(context, methodName) {
|
|
68128
67160
|
var instance = lists.filter(function (h) {
|
|
68129
67161
|
return h.context === context && h.methodName === methodName;
|
|
68130
67162
|
})[0];
|
|
68131
|
-
|
|
68132
67163
|
if (!instance) {
|
|
68133
67164
|
instance = new MethodEmbed(context, methodName);
|
|
68134
67165
|
lists.push(instance);
|
|
68135
67166
|
}
|
|
68136
|
-
|
|
68137
67167
|
return instance;
|
|
68138
67168
|
}
|
|
68139
67169
|
/**
|
|
68140
67170
|
* @deprecated use named import
|
|
68141
67171
|
*/
|
|
68142
|
-
|
|
68143
|
-
|
|
68144
67172
|
/* harmony default export */ __webpack_exports__["default"] = (MethodEmbed);
|
|
68145
67173
|
|
|
68146
67174
|
/***/ }),
|
|
@@ -68170,15 +67198,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68170
67198
|
* the passed element itself.
|
|
68171
67199
|
* @return {Element|undefined} The matching element or undefined.
|
|
68172
67200
|
*/
|
|
68173
|
-
|
|
68174
67201
|
function closest(element, selector, shouldCheckSelf) {
|
|
68175
67202
|
if (shouldCheckSelf === void 0) {
|
|
68176
67203
|
shouldCheckSelf = false;
|
|
68177
67204
|
}
|
|
68178
|
-
|
|
68179
67205
|
if (!(element && element.nodeType === 1 && selector)) return;
|
|
68180
67206
|
var parentElements = (shouldCheckSelf ? [element] : []).concat(Object(_parents__WEBPACK_IMPORTED_MODULE_1__["parents"])(element));
|
|
68181
|
-
|
|
68182
67207
|
for (var i = 0, parent_1; parent_1 = parentElements[i]; i++) {
|
|
68183
67208
|
if (Object(_matches__WEBPACK_IMPORTED_MODULE_0__["matches"])(parent_1, selector)) return parent_1;
|
|
68184
67209
|
}
|
|
@@ -68215,20 +67240,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68215
67240
|
* - deep<boolean>: If true, delegate into shadow trees.
|
|
68216
67241
|
* @return {Object} The delegate object. It contains a destroy method.
|
|
68217
67242
|
*/
|
|
68218
|
-
|
|
68219
67243
|
function delegate(ancestor, eventType, selector, callback, opts) {
|
|
68220
67244
|
if (opts === void 0) {
|
|
68221
67245
|
opts = {};
|
|
68222
|
-
}
|
|
68223
|
-
|
|
68224
|
-
|
|
67246
|
+
}
|
|
67247
|
+
// Defines the event listener.
|
|
68225
67248
|
var listener = function listener(event) {
|
|
68226
|
-
var delegateTarget;
|
|
67249
|
+
var delegateTarget;
|
|
67250
|
+
// If opts.composed is true and the event originated from inside a Shadow
|
|
68227
67251
|
// tree, check the composed path nodes.
|
|
68228
|
-
|
|
68229
67252
|
if (opts['composed'] && typeof event['composedPath'] === 'function') {
|
|
68230
67253
|
var composedPath = event.composedPath();
|
|
68231
|
-
|
|
68232
67254
|
for (var i = 0, node = void 0; node = composedPath[i]; i++) {
|
|
68233
67255
|
if (node.nodeType === 1 && Object(_matches__WEBPACK_IMPORTED_MODULE_1__["matches"])(node, selector)) {
|
|
68234
67256
|
delegateTarget = node;
|
|
@@ -68238,12 +67260,10 @@ function delegate(ancestor, eventType, selector, callback, opts) {
|
|
|
68238
67260
|
// Otherwise check the parents.
|
|
68239
67261
|
delegateTarget = Object(_closest__WEBPACK_IMPORTED_MODULE_0__["closest"])(event.target, selector, true);
|
|
68240
67262
|
}
|
|
68241
|
-
|
|
68242
67263
|
if (delegateTarget) {
|
|
68243
67264
|
callback.call(delegateTarget, event, delegateTarget);
|
|
68244
67265
|
}
|
|
68245
67266
|
};
|
|
68246
|
-
|
|
68247
67267
|
ancestor.addEventListener(eventType, listener, opts['useCapture']);
|
|
68248
67268
|
return {
|
|
68249
67269
|
destroy: function destroy() {
|
|
@@ -68276,7 +67296,6 @@ function _typeof(obj) {
|
|
|
68276
67296
|
/**
|
|
68277
67297
|
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
68278
67298
|
*/
|
|
68279
|
-
|
|
68280
67299
|
/**
|
|
68281
67300
|
* Dispatches an event on the passed element.
|
|
68282
67301
|
* @param {!Element} element The DOM element to dispatch the event on.
|
|
@@ -68290,35 +67309,30 @@ function _typeof(obj) {
|
|
|
68290
67309
|
* @return {boolean} The return value of `element.dispatchEvent`, which will
|
|
68291
67310
|
* be false if any of the event listeners called `preventDefault`.
|
|
68292
67311
|
*/
|
|
68293
|
-
|
|
68294
|
-
|
|
68295
67312
|
function dispatch(element, eventType, evtName, init_dict) {
|
|
68296
67313
|
if (evtName === void 0) {
|
|
68297
67314
|
evtName = 'Event';
|
|
68298
67315
|
}
|
|
68299
|
-
|
|
68300
67316
|
if (init_dict === void 0) {
|
|
68301
67317
|
init_dict = {};
|
|
68302
67318
|
}
|
|
68303
|
-
|
|
68304
67319
|
var event;
|
|
68305
67320
|
var isCustom;
|
|
68306
67321
|
var initDict = init_dict;
|
|
68307
|
-
var eventName = evtName;
|
|
68308
|
-
|
|
67322
|
+
var eventName = evtName;
|
|
67323
|
+
// eventName is optional
|
|
68309
67324
|
if (_typeof(eventName) === 'object') {
|
|
68310
67325
|
initDict = eventName;
|
|
68311
67326
|
eventName = 'Event';
|
|
68312
67327
|
}
|
|
68313
|
-
|
|
68314
67328
|
initDict['bubbles'] = initDict['bubbles'] || false;
|
|
68315
67329
|
initDict['cancelable'] = initDict['cancelable'] || false;
|
|
68316
|
-
initDict['composed'] = initDict['composed'] || false;
|
|
68317
|
-
|
|
67330
|
+
initDict['composed'] = initDict['composed'] || false;
|
|
67331
|
+
// If a detail property is passed, this is a custom event.
|
|
68318
67332
|
if ('detail' in initDict) isCustom = true;
|
|
68319
|
-
eventName = isCustom ? 'CustomEvent' : eventName;
|
|
67333
|
+
eventName = isCustom ? 'CustomEvent' : eventName;
|
|
67334
|
+
// Tries to create the event using constructors, if that doesn't work,
|
|
68320
67335
|
// fallback to `document.createEvent()`.
|
|
68321
|
-
|
|
68322
67336
|
try {
|
|
68323
67337
|
event = new window[eventName](eventType, initDict);
|
|
68324
67338
|
} catch (err) {
|
|
@@ -68326,7 +67340,6 @@ function dispatch(element, eventType, evtName, init_dict) {
|
|
|
68326
67340
|
var initMethod = 'init' + (isCustom ? 'Custom' : '') + 'Event';
|
|
68327
67341
|
event[initMethod](eventType, initDict['bubbles'], initDict['cancelable'], initDict['detail']);
|
|
68328
67342
|
}
|
|
68329
|
-
|
|
68330
67343
|
return element.dispatchEvent(event);
|
|
68331
67344
|
}
|
|
68332
67345
|
|
|
@@ -68345,7 +67358,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68345
67358
|
/**
|
|
68346
67359
|
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
68347
67360
|
*/
|
|
68348
|
-
|
|
68349
67361
|
/**
|
|
68350
67362
|
* Gets all attributes of an element as a plain JavaScriot object.
|
|
68351
67363
|
* @param {Element} element The element whose attributes to get.
|
|
@@ -68354,17 +67366,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68354
67366
|
* object is returned.
|
|
68355
67367
|
*/
|
|
68356
67368
|
function getAttributes(element) {
|
|
68357
|
-
var attrs = {};
|
|
68358
|
-
|
|
68359
|
-
if (!(element && element.nodeType === 1)) return attrs;
|
|
68360
|
-
|
|
67369
|
+
var attrs = {};
|
|
67370
|
+
// Validate input.
|
|
67371
|
+
if (!(element && element.nodeType === 1)) return attrs;
|
|
67372
|
+
// Return an empty object if there are no attributes.
|
|
68361
67373
|
var map = element.attributes;
|
|
68362
67374
|
if (map.length === 0) return {};
|
|
68363
|
-
|
|
68364
67375
|
for (var i = 0, attr = void 0; attr = map[i]; i++) {
|
|
68365
67376
|
attrs[attr.name] = attr.value;
|
|
68366
67377
|
}
|
|
68367
|
-
|
|
68368
67378
|
return attrs;
|
|
68369
67379
|
}
|
|
68370
67380
|
|
|
@@ -68427,11 +67437,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68427
67437
|
*/
|
|
68428
67438
|
|
|
68429
67439
|
var proto = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["JS"].browserOrNode().isBrowser && window['Element'] ? window['Element'].prototype : null;
|
|
68430
|
-
var nativeMatches = proto ? proto.matches ||
|
|
68431
|
-
|
|
68432
|
-
proto.
|
|
68433
|
-
|
|
68434
|
-
proto.
|
|
67440
|
+
var nativeMatches = proto ? proto.matches ||
|
|
67441
|
+
// @ts-ignore
|
|
67442
|
+
proto.matchesSelector ||
|
|
67443
|
+
// @ts-ignore
|
|
67444
|
+
proto.webkitMatchesSelector ||
|
|
67445
|
+
// @ts-ignore
|
|
67446
|
+
proto.mozMatchesSelector ||
|
|
67447
|
+
// @ts-ignore
|
|
67448
|
+
proto.msMatchesSelector ||
|
|
67449
|
+
// @ts-ignore
|
|
68435
67450
|
proto.oMatchesSelector : null;
|
|
68436
67451
|
/**
|
|
68437
67452
|
* Tests if a DOM elements matches any of the test DOM elements or selectors.
|
|
@@ -68440,15 +67455,12 @@ proto.oMatchesSelector : null;
|
|
|
68440
67455
|
* selector, or an array of DOM elements or CSS selectors to match against.
|
|
68441
67456
|
* @return {boolean} True of any part of the test matches.
|
|
68442
67457
|
*/
|
|
68443
|
-
|
|
68444
67458
|
function matches(element, test) {
|
|
68445
67459
|
// Validate input.
|
|
68446
67460
|
if (element && element.nodeType === 1 && test) {
|
|
68447
67461
|
// if test is a string or DOM element test it.
|
|
68448
67462
|
if (typeof test === 'string' || test.nodeType === 1) {
|
|
68449
|
-
return element === test || matchesSelector(element,
|
|
68450
|
-
/** @type {string} */
|
|
68451
|
-
test);
|
|
67463
|
+
return element === test || matchesSelector(element, /** @type {string} */test);
|
|
68452
67464
|
} else if ('length' in test) {
|
|
68453
67465
|
// if it has a length property iterate over the items
|
|
68454
67466
|
// and return true if any match.
|
|
@@ -68456,9 +67468,8 @@ function matches(element, test) {
|
|
|
68456
67468
|
if (element === item || matchesSelector(element, item)) return true;
|
|
68457
67469
|
}
|
|
68458
67470
|
}
|
|
68459
|
-
}
|
|
68460
|
-
|
|
68461
|
-
|
|
67471
|
+
}
|
|
67472
|
+
// Still here? Return false
|
|
68462
67473
|
return false;
|
|
68463
67474
|
}
|
|
68464
67475
|
/**
|
|
@@ -68468,16 +67479,13 @@ function matches(element, test) {
|
|
|
68468
67479
|
* @param {string} selector The CSS selector to test element against.
|
|
68469
67480
|
* @return {boolean} True if the selector matches.
|
|
68470
67481
|
*/
|
|
68471
|
-
|
|
68472
67482
|
function matchesSelector(element, selector) {
|
|
68473
67483
|
if (typeof selector !== 'string') return false;
|
|
68474
67484
|
if (nativeMatches) return nativeMatches.call(element, selector);
|
|
68475
67485
|
var nodes = element.parentNode.querySelectorAll(selector);
|
|
68476
|
-
|
|
68477
67486
|
for (var i = 0, node = void 0; node = nodes[i]; i++) {
|
|
68478
67487
|
if (node === element) return true;
|
|
68479
67488
|
}
|
|
68480
|
-
|
|
68481
67489
|
return false;
|
|
68482
67490
|
}
|
|
68483
67491
|
|
|
@@ -68496,7 +67504,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68496
67504
|
/**
|
|
68497
67505
|
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
68498
67506
|
*/
|
|
68499
|
-
|
|
68500
67507
|
/**
|
|
68501
67508
|
* Returns an array of a DOM element's parent elements.
|
|
68502
67509
|
* @param {!Element} element The DOM element whose parents to get.
|
|
@@ -68506,14 +67513,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
68506
67513
|
function parents(ele) {
|
|
68507
67514
|
var list = [];
|
|
68508
67515
|
var element = ele;
|
|
68509
|
-
|
|
68510
67516
|
while (element && element.parentNode && element.parentNode.nodeType === 1) {
|
|
68511
|
-
element =
|
|
68512
|
-
/** @type {!Element} */
|
|
68513
|
-
element.parentNode;
|
|
67517
|
+
element = /** @type {!Element} */element.parentNode;
|
|
68514
67518
|
list.push(element);
|
|
68515
67519
|
}
|
|
68516
|
-
|
|
68517
67520
|
return list;
|
|
68518
67521
|
}
|
|
68519
67522
|
|
|
@@ -68545,33 +67548,32 @@ var cache = {};
|
|
|
68545
67548
|
* @param {string} url The url to parse.
|
|
68546
67549
|
* @return {!Object} An object with the same properties as a `Location`.
|
|
68547
67550
|
*/
|
|
68548
|
-
|
|
68549
67551
|
function parseUrl(u) {
|
|
68550
|
-
var url = u;
|
|
68551
|
-
|
|
67552
|
+
var url = u;
|
|
67553
|
+
// All falsy values (as well as ".") should map to the current URL.
|
|
68552
67554
|
url = !url || url === '.' ? location.href : url;
|
|
68553
67555
|
if (cache[url]) return cache[url];
|
|
68554
|
-
a.href = url;
|
|
67556
|
+
a.href = url;
|
|
67557
|
+
// When parsing file relative paths (e.g. `../index.html`), IE will correctly
|
|
68555
67558
|
// resolve the `href` property but will keep the `..` in the `path` property.
|
|
68556
67559
|
// It will also not include the `host` or `hostname` properties. Furthermore,
|
|
68557
67560
|
// IE will sometimes return no protocol or just a colon, especially for things
|
|
68558
67561
|
// like relative protocol URLs (e.g. "//google.com").
|
|
68559
67562
|
// To workaround all of these issues, we reparse with the full URL from the
|
|
68560
67563
|
// `href` property.
|
|
68561
|
-
|
|
68562
|
-
|
|
68563
|
-
|
|
68564
|
-
|
|
68565
|
-
|
|
68566
|
-
|
|
67564
|
+
if (url.charAt(0) === '.' || url.charAt(0) === '/') return parseUrl(a.href);
|
|
67565
|
+
// Don't include default ports.
|
|
67566
|
+
var port = a.port === HTTP_PORT || a.port === HTTPS_PORT ? '' : a.port;
|
|
67567
|
+
// PhantomJS sets the port to "0" when using the file: protocol.
|
|
67568
|
+
port = port === '0' ? '' : port;
|
|
67569
|
+
// Sometimes IE incorrectly includes a port for default ports
|
|
68567
67570
|
// (e.g. `:80` or `:443`) even when no port is specified in the URL.
|
|
68568
67571
|
// http://bit.ly/1rQNoMg
|
|
68569
|
-
|
|
68570
|
-
|
|
68571
|
-
|
|
68572
|
-
|
|
67572
|
+
var host = a.host.replace(DEFAULT_PORT, '');
|
|
67573
|
+
// Not all browser support `origin` so we have to build it.
|
|
67574
|
+
var origin = a['origin'] ? a['origin'] : a.protocol + '//' + host;
|
|
67575
|
+
// Sometimes IE doesn't include the leading slash for pathname.
|
|
68573
67576
|
// http://bit.ly/1rQNoMg
|
|
68574
|
-
|
|
68575
67577
|
var pathname = a.pathname.charAt(0) === '/' ? a.pathname : '/' + a.pathname;
|
|
68576
67578
|
return cache[url] = {
|
|
68577
67579
|
hash: a.hash,
|