@aws-amplify/analytics 5.2.23-unstable.2 → 5.2.23

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