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