@mparticle/web-sdk 2.28.0 → 2.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mparticle.js CHANGED
@@ -203,22 +203,22 @@ var mParticle = (function () {
203
203
  Base64: Base64$1
204
204
  };
205
205
 
206
- function _typeof(o) {
206
+ function _typeof$1(o) {
207
207
  "@babel/helpers - typeof";
208
208
 
209
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
209
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
210
210
  return typeof o;
211
211
  } : function (o) {
212
212
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
213
- }, _typeof(o);
213
+ }, _typeof$1(o);
214
214
  }
215
215
 
216
216
  function _toPrimitive(input, hint) {
217
- if (_typeof(input) !== "object" || input === null) return input;
217
+ if (_typeof$1(input) !== "object" || input === null) return input;
218
218
  var prim = input[Symbol.toPrimitive];
219
219
  if (prim !== undefined) {
220
220
  var res = prim.call(input, hint || "default");
221
- if (_typeof(res) !== "object") return res;
221
+ if (_typeof$1(res) !== "object") return res;
222
222
  throw new TypeError("@@toPrimitive must return a primitive value.");
223
223
  }
224
224
  return (hint === "string" ? String : Number)(input);
@@ -226,7 +226,7 @@ var mParticle = (function () {
226
226
 
227
227
  function _toPropertyKey(arg) {
228
228
  var key = _toPrimitive(arg, "string");
229
- return _typeof(key) === "symbol" ? key : String(key);
229
+ return _typeof$1(key) === "symbol" ? key : String(key);
230
230
  }
231
231
 
232
232
  function _defineProperty(obj, key, value) {
@@ -393,7 +393,7 @@ var mParticle = (function () {
393
393
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
394
394
  };
395
395
 
396
- var version = "2.28.0";
396
+ var version = "2.28.2";
397
397
 
398
398
  var Constants = {
399
399
  sdkVersion: version,
@@ -568,6 +568,7 @@ var mParticle = (function () {
568
568
  var MILLIS_IN_ONE_SEC = 1000;
569
569
 
570
570
  var Messages$9 = Constants.Messages;
571
+ var HTTP_SUCCESS = 200;
571
572
  var createCookieString = function createCookieString(value) {
572
573
  return replaceCommasWithPipes(replaceQuotesWithApostrophes(value));
573
574
  };
@@ -1146,6 +1147,10 @@ var mParticle = (function () {
1146
1147
  SDKProductActionType[SDKProductActionType["RemoveFromWishlist"] = 10] = "RemoveFromWishlist";
1147
1148
  })(SDKProductActionType || (SDKProductActionType = {}));
1148
1149
 
1150
+ function getDefaultExportFromCjs (x) {
1151
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1152
+ }
1153
+
1149
1154
  var dist = {};
1150
1155
 
1151
1156
  (function (exports) {
@@ -2563,27 +2568,12 @@ var mParticle = (function () {
2563
2568
  mpInstance.Logger.error('Error sending forwarding stats to mParticle servers.');
2564
2569
  }
2565
2570
  };
2566
- this.sendSingleForwardingStatsToServer = function (forwardingStatsData) {
2567
- var url;
2568
- var data;
2569
- try {
2570
- var xhrCallback = function xhrCallback() {
2571
- if (xhr_1.readyState === 4) {
2572
- if (xhr_1.status === 202) {
2573
- mpInstance.Logger.verbose('Successfully sent ' + xhr_1.statusText + ' from server');
2574
- }
2575
- }
2576
- };
2577
- var xhr_1 = mpInstance._Helpers.createXHR(xhrCallback);
2578
- url = mpInstance._Helpers.createServiceUrl(mpInstance._Store.SDKConfig.v1SecureServiceUrl, mpInstance._Store.devToken);
2579
- data = forwardingStatsData;
2580
- if (xhr_1) {
2581
- xhr_1.open('post', url + '/Forwarding');
2582
- xhr_1.send(JSON.stringify(data));
2583
- }
2584
- } catch (e) {
2585
- mpInstance.Logger.error('Error sending forwarding stats to mParticle servers.');
2586
- }
2571
+ this.initializeForwarderStatsUploader = function () {
2572
+ var forwardingDomain = mpInstance._Store.SDKConfig.v1SecureServiceUrl;
2573
+ var devToken = mpInstance._Store.devToken;
2574
+ var uploadUrl = "https://".concat(forwardingDomain).concat(devToken, "/Forwarding");
2575
+ var uploader = window.fetch ? new FetchUploader(uploadUrl) : new XHRUploader(uploadUrl);
2576
+ return uploader;
2587
2577
  };
2588
2578
  this.prepareForwardingStats = function (forwarder, event) {
2589
2579
  var forwardingStatsData;
@@ -2602,11 +2592,14 @@ var mParticle = (function () {
2602
2592
  eec: event.ExpandedEventCount,
2603
2593
  dp: event.DataPlan
2604
2594
  };
2595
+ var _a = mpInstance._Forwarders,
2596
+ sendSingleForwardingStatsToServer = _a.sendSingleForwardingStatsToServer,
2597
+ setForwarderStatsQueue = _a.setForwarderStatsQueue;
2605
2598
  if (mpInstance._Helpers.getFeatureFlag(Constants.FeatureFlags.ReportBatching)) {
2606
2599
  queue.push(forwardingStatsData);
2607
- mpInstance._Forwarders.setForwarderStatsQueue(queue);
2600
+ setForwarderStatsQueue(queue);
2608
2601
  } else {
2609
- self.sendSingleForwardingStatsToServer(forwardingStatsData);
2602
+ sendSingleForwardingStatsToServer(forwardingStatsData);
2610
2603
  }
2611
2604
  }
2612
2605
  };
@@ -2865,7 +2858,7 @@ var mParticle = (function () {
2865
2858
  }
2866
2859
 
2867
2860
  // Handle case when target is a string or something (possible in deep copy)
2868
- if (_typeof(target) !== 'object' && !objectHelper.isFunction(target)) {
2861
+ if (_typeof$1(target) !== 'object' && !objectHelper.isFunction(target)) {
2869
2862
  target = {};
2870
2863
  }
2871
2864
 
@@ -3841,7 +3834,7 @@ var mParticle = (function () {
3841
3834
  // sanitizes any non number, non string value to 0
3842
3835
  this.sanitizeAmount = function (amount, category) {
3843
3836
  if (!mpInstance._Helpers.Validators.isStringOrNumber(amount)) {
3844
- var message = [category, 'must be of type number. A', _typeof(amount), 'was passed. Converting to 0'].join(' ');
3837
+ var message = [category, 'must be of type number. A', _typeof$1(amount), 'was passed. Converting to 0'].join(' ');
3845
3838
  mpInstance.Logger.warning(message);
3846
3839
  return 0;
3847
3840
  }
@@ -3999,7 +3992,7 @@ var mParticle = (function () {
3999
3992
  if (mpInstance._Helpers.Validators.isFunction(callback)) {
4000
3993
  this.SDKConfig.identityCallback = config.identityCallback;
4001
3994
  } else {
4002
- mpInstance.Logger.warning('The optional callback must be a function. You tried entering a(n) ' + _typeof(callback) + ' . Callback not set. Please set your callback again.');
3995
+ mpInstance.Logger.warning('The optional callback must be a function. You tried entering a(n) ' + _typeof$1(callback) + ' . Callback not set. Please set your callback again.');
4003
3996
  }
4004
3997
  }
4005
3998
  if (config.hasOwnProperty('appVersion')) {
@@ -5413,6 +5406,386 @@ var mParticle = (function () {
5413
5406
  };
5414
5407
  }
5415
5408
 
5409
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
5410
+ try {
5411
+ var info = gen[key](arg);
5412
+ var value = info.value;
5413
+ } catch (error) {
5414
+ reject(error);
5415
+ return;
5416
+ }
5417
+ if (info.done) {
5418
+ resolve(value);
5419
+ } else {
5420
+ Promise.resolve(value).then(_next, _throw);
5421
+ }
5422
+ }
5423
+ function _asyncToGenerator(fn) {
5424
+ return function () {
5425
+ var self = this,
5426
+ args = arguments;
5427
+ return new Promise(function (resolve, reject) {
5428
+ var gen = fn.apply(self, args);
5429
+ function _next(value) {
5430
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
5431
+ }
5432
+ function _throw(err) {
5433
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
5434
+ }
5435
+ _next(undefined);
5436
+ });
5437
+ };
5438
+ }
5439
+
5440
+ var regeneratorRuntime$1 = {exports: {}};
5441
+
5442
+ var _typeof = {exports: {}};
5443
+
5444
+ _typeof.exports;
5445
+
5446
+ (function (module) {
5447
+ function _typeof(o) {
5448
+ "@babel/helpers - typeof";
5449
+
5450
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
5451
+ return typeof o;
5452
+ } : function (o) {
5453
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
5454
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
5455
+ }
5456
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
5457
+ } (_typeof));
5458
+
5459
+ var _typeofExports = _typeof.exports;
5460
+
5461
+ regeneratorRuntime$1.exports;
5462
+
5463
+ (function (module) {
5464
+ var _typeof = _typeofExports["default"];
5465
+ function _regeneratorRuntime() {
5466
+ module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
5467
+ return e;
5468
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
5469
+ var t,
5470
+ e = {},
5471
+ r = Object.prototype,
5472
+ n = r.hasOwnProperty,
5473
+ o = Object.defineProperty || function (t, e, r) {
5474
+ t[e] = r.value;
5475
+ },
5476
+ i = "function" == typeof Symbol ? Symbol : {},
5477
+ a = i.iterator || "@@iterator",
5478
+ c = i.asyncIterator || "@@asyncIterator",
5479
+ u = i.toStringTag || "@@toStringTag";
5480
+ function define(t, e, r) {
5481
+ return Object.defineProperty(t, e, {
5482
+ value: r,
5483
+ enumerable: !0,
5484
+ configurable: !0,
5485
+ writable: !0
5486
+ }), t[e];
5487
+ }
5488
+ try {
5489
+ define({}, "");
5490
+ } catch (t) {
5491
+ define = function define(t, e, r) {
5492
+ return t[e] = r;
5493
+ };
5494
+ }
5495
+ function wrap(t, e, r, n) {
5496
+ var i = e && e.prototype instanceof Generator ? e : Generator,
5497
+ a = Object.create(i.prototype),
5498
+ c = new Context(n || []);
5499
+ return o(a, "_invoke", {
5500
+ value: makeInvokeMethod(t, r, c)
5501
+ }), a;
5502
+ }
5503
+ function tryCatch(t, e, r) {
5504
+ try {
5505
+ return {
5506
+ type: "normal",
5507
+ arg: t.call(e, r)
5508
+ };
5509
+ } catch (t) {
5510
+ return {
5511
+ type: "throw",
5512
+ arg: t
5513
+ };
5514
+ }
5515
+ }
5516
+ e.wrap = wrap;
5517
+ var h = "suspendedStart",
5518
+ l = "suspendedYield",
5519
+ f = "executing",
5520
+ s = "completed",
5521
+ y = {};
5522
+ function Generator() {}
5523
+ function GeneratorFunction() {}
5524
+ function GeneratorFunctionPrototype() {}
5525
+ var p = {};
5526
+ define(p, a, function () {
5527
+ return this;
5528
+ });
5529
+ var d = Object.getPrototypeOf,
5530
+ v = d && d(d(values([])));
5531
+ v && v !== r && n.call(v, a) && (p = v);
5532
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
5533
+ function defineIteratorMethods(t) {
5534
+ ["next", "throw", "return"].forEach(function (e) {
5535
+ define(t, e, function (t) {
5536
+ return this._invoke(e, t);
5537
+ });
5538
+ });
5539
+ }
5540
+ function AsyncIterator(t, e) {
5541
+ function invoke(r, o, i, a) {
5542
+ var c = tryCatch(t[r], t, o);
5543
+ if ("throw" !== c.type) {
5544
+ var u = c.arg,
5545
+ h = u.value;
5546
+ return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
5547
+ invoke("next", t, i, a);
5548
+ }, function (t) {
5549
+ invoke("throw", t, i, a);
5550
+ }) : e.resolve(h).then(function (t) {
5551
+ u.value = t, i(u);
5552
+ }, function (t) {
5553
+ return invoke("throw", t, i, a);
5554
+ });
5555
+ }
5556
+ a(c.arg);
5557
+ }
5558
+ var r;
5559
+ o(this, "_invoke", {
5560
+ value: function value(t, n) {
5561
+ function callInvokeWithMethodAndArg() {
5562
+ return new e(function (e, r) {
5563
+ invoke(t, n, e, r);
5564
+ });
5565
+ }
5566
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
5567
+ }
5568
+ });
5569
+ }
5570
+ function makeInvokeMethod(e, r, n) {
5571
+ var o = h;
5572
+ return function (i, a) {
5573
+ if (o === f) throw new Error("Generator is already running");
5574
+ if (o === s) {
5575
+ if ("throw" === i) throw a;
5576
+ return {
5577
+ value: t,
5578
+ done: !0
5579
+ };
5580
+ }
5581
+ for (n.method = i, n.arg = a;;) {
5582
+ var c = n.delegate;
5583
+ if (c) {
5584
+ var u = maybeInvokeDelegate(c, n);
5585
+ if (u) {
5586
+ if (u === y) continue;
5587
+ return u;
5588
+ }
5589
+ }
5590
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
5591
+ if (o === h) throw o = s, n.arg;
5592
+ n.dispatchException(n.arg);
5593
+ } else "return" === n.method && n.abrupt("return", n.arg);
5594
+ o = f;
5595
+ var p = tryCatch(e, r, n);
5596
+ if ("normal" === p.type) {
5597
+ if (o = n.done ? s : l, p.arg === y) continue;
5598
+ return {
5599
+ value: p.arg,
5600
+ done: n.done
5601
+ };
5602
+ }
5603
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
5604
+ }
5605
+ };
5606
+ }
5607
+ function maybeInvokeDelegate(e, r) {
5608
+ var n = r.method,
5609
+ o = e.iterator[n];
5610
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
5611
+ var i = tryCatch(o, e.iterator, r.arg);
5612
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
5613
+ var a = i.arg;
5614
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
5615
+ }
5616
+ function pushTryEntry(t) {
5617
+ var e = {
5618
+ tryLoc: t[0]
5619
+ };
5620
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
5621
+ }
5622
+ function resetTryEntry(t) {
5623
+ var e = t.completion || {};
5624
+ e.type = "normal", delete e.arg, t.completion = e;
5625
+ }
5626
+ function Context(t) {
5627
+ this.tryEntries = [{
5628
+ tryLoc: "root"
5629
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
5630
+ }
5631
+ function values(e) {
5632
+ if (e || "" === e) {
5633
+ var r = e[a];
5634
+ if (r) return r.call(e);
5635
+ if ("function" == typeof e.next) return e;
5636
+ if (!isNaN(e.length)) {
5637
+ var o = -1,
5638
+ i = function next() {
5639
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
5640
+ return next.value = t, next.done = !0, next;
5641
+ };
5642
+ return i.next = i;
5643
+ }
5644
+ }
5645
+ throw new TypeError(_typeof(e) + " is not iterable");
5646
+ }
5647
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
5648
+ value: GeneratorFunctionPrototype,
5649
+ configurable: !0
5650
+ }), o(GeneratorFunctionPrototype, "constructor", {
5651
+ value: GeneratorFunction,
5652
+ configurable: !0
5653
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
5654
+ var e = "function" == typeof t && t.constructor;
5655
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
5656
+ }, e.mark = function (t) {
5657
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
5658
+ }, e.awrap = function (t) {
5659
+ return {
5660
+ __await: t
5661
+ };
5662
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
5663
+ return this;
5664
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
5665
+ void 0 === i && (i = Promise);
5666
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
5667
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
5668
+ return t.done ? t.value : a.next();
5669
+ });
5670
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
5671
+ return this;
5672
+ }), define(g, "toString", function () {
5673
+ return "[object Generator]";
5674
+ }), e.keys = function (t) {
5675
+ var e = Object(t),
5676
+ r = [];
5677
+ for (var n in e) r.push(n);
5678
+ return r.reverse(), function next() {
5679
+ for (; r.length;) {
5680
+ var t = r.pop();
5681
+ if (t in e) return next.value = t, next.done = !1, next;
5682
+ }
5683
+ return next.done = !0, next;
5684
+ };
5685
+ }, e.values = values, Context.prototype = {
5686
+ constructor: Context,
5687
+ reset: function reset(e) {
5688
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
5689
+ },
5690
+ stop: function stop() {
5691
+ this.done = !0;
5692
+ var t = this.tryEntries[0].completion;
5693
+ if ("throw" === t.type) throw t.arg;
5694
+ return this.rval;
5695
+ },
5696
+ dispatchException: function dispatchException(e) {
5697
+ if (this.done) throw e;
5698
+ var r = this;
5699
+ function handle(n, o) {
5700
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
5701
+ }
5702
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
5703
+ var i = this.tryEntries[o],
5704
+ a = i.completion;
5705
+ if ("root" === i.tryLoc) return handle("end");
5706
+ if (i.tryLoc <= this.prev) {
5707
+ var c = n.call(i, "catchLoc"),
5708
+ u = n.call(i, "finallyLoc");
5709
+ if (c && u) {
5710
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
5711
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
5712
+ } else if (c) {
5713
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
5714
+ } else {
5715
+ if (!u) throw new Error("try statement without catch or finally");
5716
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
5717
+ }
5718
+ }
5719
+ }
5720
+ },
5721
+ abrupt: function abrupt(t, e) {
5722
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
5723
+ var o = this.tryEntries[r];
5724
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
5725
+ var i = o;
5726
+ break;
5727
+ }
5728
+ }
5729
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
5730
+ var a = i ? i.completion : {};
5731
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
5732
+ },
5733
+ complete: function complete(t, e) {
5734
+ if ("throw" === t.type) throw t.arg;
5735
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
5736
+ },
5737
+ finish: function finish(t) {
5738
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
5739
+ var r = this.tryEntries[e];
5740
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
5741
+ }
5742
+ },
5743
+ "catch": function _catch(t) {
5744
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
5745
+ var r = this.tryEntries[e];
5746
+ if (r.tryLoc === t) {
5747
+ var n = r.completion;
5748
+ if ("throw" === n.type) {
5749
+ var o = n.arg;
5750
+ resetTryEntry(r);
5751
+ }
5752
+ return o;
5753
+ }
5754
+ }
5755
+ throw new Error("illegal catch attempt");
5756
+ },
5757
+ delegateYield: function delegateYield(e, r, n) {
5758
+ return this.delegate = {
5759
+ iterator: values(e),
5760
+ resultName: r,
5761
+ nextLoc: n
5762
+ }, "next" === this.method && (this.arg = t), y;
5763
+ }
5764
+ }, e;
5765
+ }
5766
+ module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
5767
+ } (regeneratorRuntime$1));
5768
+
5769
+ var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
5770
+
5771
+ // TODO(Babel 8): Remove this file.
5772
+
5773
+ var runtime = regeneratorRuntimeExports();
5774
+ var regenerator = runtime;
5775
+
5776
+ // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
5777
+ try {
5778
+ regeneratorRuntime = runtime;
5779
+ } catch (accidentalStrictMode) {
5780
+ if (typeof globalThis === "object") {
5781
+ globalThis.regeneratorRuntime = runtime;
5782
+ } else {
5783
+ Function("r", "regeneratorRuntime = r")(runtime);
5784
+ }
5785
+ }
5786
+
5787
+ var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
5788
+
5416
5789
  function filteredMparticleUser(mpid, forwarder, mpInstance, kitBlocker) {
5417
5790
  var self = this;
5418
5791
  return {
@@ -5477,7 +5850,9 @@ var mParticle = (function () {
5477
5850
  Login$2 = _Constants$IdentityMe.Login,
5478
5851
  Logout$2 = _Constants$IdentityMe.Logout;
5479
5852
  function Forwarders(mpInstance, kitBlocker) {
5853
+ var _this = this;
5480
5854
  var self = this;
5855
+ this.forwarderStatsUploader = new APIClient(mpInstance, kitBlocker).initializeForwarderStatsUploader();
5481
5856
  var UserAttributeActionTypes = {
5482
5857
  setUserAttribute: 'setUserAttribute',
5483
5858
  removeUserAttribute: 'removeUserAttribute'
@@ -5946,6 +6321,44 @@ var mParticle = (function () {
5946
6321
  mpInstance.Logger.error('Cookie Sync configs not configured propertly. Cookie Sync may not be initialized. ' + e);
5947
6322
  }
5948
6323
  };
6324
+ this.sendSingleForwardingStatsToServer = /*#__PURE__*/function () {
6325
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(forwardingStatsData) {
6326
+ var _mpInstance$Logger;
6327
+ var fetchPayload, response, message;
6328
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
6329
+ while (1) switch (_context.prev = _context.next) {
6330
+ case 0:
6331
+ // https://go.mparticle.com/work/SQDSDKS-6568
6332
+ fetchPayload = {
6333
+ method: 'post',
6334
+ body: JSON.stringify(forwardingStatsData),
6335
+ headers: {
6336
+ Accept: 'text/plain;charset=UTF-8',
6337
+ 'Content-Type': 'text/plain;charset=UTF-8'
6338
+ }
6339
+ };
6340
+ _context.next = 3;
6341
+ return _this.forwarderStatsUploader.upload(fetchPayload);
6342
+ case 3:
6343
+ response = _context.sent;
6344
+ // This is a fire and forget, so we only need to log the response based on the code, and not return any response body
6345
+ if (response.status === 202) {
6346
+ // https://go.mparticle.com/work/SQDSDKS-6670
6347
+ message = 'Successfully sent forwarding stats to mParticle Servers';
6348
+ } else {
6349
+ message = 'Issue with forwarding stats to mParticle Servers, received HTTP Code of ' + response.statusText;
6350
+ }
6351
+ mpInstance === null || mpInstance === void 0 || (_mpInstance$Logger = mpInstance.Logger) === null || _mpInstance$Logger === void 0 || _mpInstance$Logger.verbose(message);
6352
+ case 6:
6353
+ case "end":
6354
+ return _context.stop();
6355
+ }
6356
+ }, _callee);
6357
+ }));
6358
+ return function (_x) {
6359
+ return _ref.apply(this, arguments);
6360
+ };
6361
+ }();
5949
6362
  }
5950
6363
 
5951
6364
  // TODO: This file is no longer the server model because the web SDK payload
@@ -6303,22 +6716,35 @@ var mParticle = (function () {
6303
6716
  Modify$2 = _a.Modify,
6304
6717
  Login$1 = _a.Login,
6305
6718
  Logout$1 = _a.Logout;
6306
- var cacheOrClearIdCache = function cacheOrClearIdCache(method, knownIdentities, idCache, xhr, parsingCachedResponse) {
6719
+ var CACHE_HEADER = 'x-mp-max-age';
6720
+ // https://go.mparticle.com/work/SQDSDKS-6568
6721
+ // Temporary adapter to convert the XMLHttpRequest response to the IIdentityResponse interface
6722
+ var xhrIdentityResponseAdapter = function xhrIdentityResponseAdapter(possiblyXhr) {
6723
+ if (possiblyXhr.hasOwnProperty('expireTimestamp')) {
6724
+ // If there is an `expireTimestamp`, it is an IIdentityResponse object, so just return it. This indicates it was a previously cached value.
6725
+ return possiblyXhr;
6726
+ } else {
6727
+ // If there is no `expireTimestamp`, then it is an XHR object and needs to be parsed.
6728
+ return {
6729
+ status: possiblyXhr.status,
6730
+ // Sometimes responseText can be an empty string, such as a 404 response
6731
+ responseText: possiblyXhr.responseText ? JSON.parse(possiblyXhr.responseText) : {},
6732
+ cacheMaxAge: parseNumber((possiblyXhr === null || possiblyXhr === void 0 ? void 0 : possiblyXhr.getResponseHeader(CACHE_HEADER)) || ''),
6733
+ expireTimestamp: 0
6734
+ };
6735
+ }
6736
+ };
6737
+ var cacheOrClearIdCache = function cacheOrClearIdCache(method, knownIdentities, idCache, identityResponse, parsingCachedResponse) {
6307
6738
  // when parsing a response that has already been cached, simply return instead of attempting another cache
6308
6739
  if (parsingCachedResponse) {
6309
6740
  return;
6310
6741
  }
6311
- var CACHE_HEADER = 'x-mp-max-age';
6312
6742
  // default the expire timestamp to one day in milliseconds unless a header comes back
6313
- var now = new Date().getTime();
6314
- var expireTimestamp = now + ONE_DAY_IN_SECONDS * MILLIS_IN_ONE_SEC;
6315
- if (xhr.getAllResponseHeaders().includes(CACHE_HEADER)) {
6316
- expireTimestamp = now + parseNumber(xhr.getResponseHeader(CACHE_HEADER)) * MILLIS_IN_ONE_SEC;
6317
- }
6743
+ var expireTimestamp = getExpireTimestamp(identityResponse === null || identityResponse === void 0 ? void 0 : identityResponse.cacheMaxAge);
6318
6744
  switch (method) {
6319
6745
  case Login$1:
6320
6746
  case Identify$1:
6321
- cacheIdentityRequest(method, knownIdentities, expireTimestamp, idCache, xhr);
6747
+ cacheIdentityRequest(method, knownIdentities, expireTimestamp, idCache, identityResponse);
6322
6748
  break;
6323
6749
  case Modify$2:
6324
6750
  case Logout$1:
@@ -6326,20 +6752,21 @@ var mParticle = (function () {
6326
6752
  break;
6327
6753
  }
6328
6754
  };
6329
- var cacheIdentityRequest = function cacheIdentityRequest(method, identities, expireTimestamp, idCache, xhr) {
6755
+ var cacheIdentityRequest = function cacheIdentityRequest(method, identities, expireTimestamp, idCache, identityResponse) {
6756
+ var responseText = identityResponse.responseText,
6757
+ status = identityResponse.status;
6330
6758
  var cache = idCache.retrieve() || {};
6331
6759
  var cacheKey = concatenateIdentities(method, identities);
6332
6760
  var hashedKey = generateHash(cacheKey);
6333
- var _a = JSON.parse(xhr.responseText),
6334
- mpid = _a.mpid,
6335
- is_logged_in = _a.is_logged_in;
6336
- var cachedResponseText = {
6761
+ var mpid = responseText.mpid,
6762
+ is_logged_in = responseText.is_logged_in;
6763
+ var cachedResponseBody = {
6337
6764
  mpid: mpid,
6338
6765
  is_logged_in: is_logged_in
6339
6766
  };
6340
6767
  cache[hashedKey] = {
6341
- responseText: JSON.stringify(cachedResponseText),
6342
- status: xhr.status,
6768
+ responseText: JSON.stringify(cachedResponseBody),
6769
+ status: status,
6343
6770
  expireTimestamp: expireTimestamp
6344
6771
  };
6345
6772
  idCache.store(cache);
@@ -6371,10 +6798,10 @@ var mParticle = (function () {
6371
6798
  return concatenatedIdentities;
6372
6799
  };
6373
6800
  var hasValidCachedIdentity = function hasValidCachedIdentity(method, proposedUserIdentities, idCache) {
6374
- // There is an edge case where multiple identity calls are taking place
6375
- // before identify fires, so there may not be a cache. See what happens when
6801
+ // There is an edge case where multiple identity calls are taking place
6802
+ // before identify fires, so there may not be a cache. See what happens when
6376
6803
  // the ? in idCache is removed to the following test
6377
- // "queued events contain login mpid instead of identify mpid when calling
6804
+ // "queued events contain login mpid instead of identify mpid when calling
6378
6805
  // login immediately after mParticle initializes"
6379
6806
  var cache = idCache === null || idCache === void 0 ? void 0 : idCache.retrieve();
6380
6807
  // if there is no cache, then there is no valid cached identity
@@ -6402,7 +6829,11 @@ var mParticle = (function () {
6402
6829
  var hashedKey = generateHash(cacheKey);
6403
6830
  var cache = idCache.retrieve();
6404
6831
  var cachedIdentity = cache ? cache[hashedKey] : null;
6405
- return cachedIdentity;
6832
+ return {
6833
+ responseText: parseIdentityResponse(cachedIdentity.responseText),
6834
+ expireTimestamp: cachedIdentity.expireTimestamp,
6835
+ status: cachedIdentity.status
6836
+ };
6406
6837
  };
6407
6838
  // https://go.mparticle.com/work/SQDSDKS-6079
6408
6839
  var createKnownIdentities = function createKnownIdentities(identityApiData, deviceId) {
@@ -6437,6 +6868,15 @@ var mParticle = (function () {
6437
6868
  }
6438
6869
  return false;
6439
6870
  };
6871
+ var getExpireTimestamp = function getExpireTimestamp(maxAge) {
6872
+ if (maxAge === void 0) {
6873
+ maxAge = ONE_DAY_IN_SECONDS;
6874
+ }
6875
+ return new Date().getTime() + maxAge * MILLIS_IN_ONE_SEC;
6876
+ };
6877
+ var parseIdentityResponse = function parseIdentityResponse(responseText) {
6878
+ return responseText ? JSON.parse(responseText) : {};
6879
+ };
6440
6880
 
6441
6881
  var AudienceManager = /** @class */function () {
6442
6882
  function AudienceManager(userAudienceUrl, apiKey, logger) {
@@ -6543,7 +6983,7 @@ var mParticle = (function () {
6543
6983
  };
6544
6984
  }
6545
6985
  if (callback && !mpInstance._Helpers.Validators.isFunction(callback)) {
6546
- var error = 'The optional callback must be a function. You tried entering a(n) ' + _typeof(callback);
6986
+ var error = 'The optional callback must be a function. You tried entering a(n) ' + _typeof$1(callback);
6547
6987
  mpInstance.Logger.error(error);
6548
6988
  return {
6549
6989
  valid: false,
@@ -7087,7 +7527,7 @@ var mParticle = (function () {
7087
7527
  }
7088
7528
  }
7089
7529
  } else {
7090
- mpInstance.Logger.error('Must pass an object into setUserAttributes. You passed a ' + _typeof(userAttributes));
7530
+ mpInstance.Logger.error('Must pass an object into setUserAttributes. You passed a ' + _typeof$1(userAttributes));
7091
7531
  }
7092
7532
  },
7093
7533
  /**
@@ -7139,7 +7579,7 @@ var mParticle = (function () {
7139
7579
  return;
7140
7580
  }
7141
7581
  if (!Array.isArray(newValue)) {
7142
- mpInstance.Logger.error('The value you passed in to setUserAttributeList must be an array. You passed in a ' + (typeof value === "undefined" ? "undefined" : _typeof(value)));
7582
+ mpInstance.Logger.error('The value you passed in to setUserAttributeList must be an array. You passed in a ' + (typeof value === "undefined" ? "undefined" : _typeof$1(value)));
7143
7583
  return;
7144
7584
  }
7145
7585
  var arrayCopy = newValue.slice();
@@ -7421,7 +7861,7 @@ var mParticle = (function () {
7421
7861
  };
7422
7862
 
7423
7863
  // https://go.mparticle.com/work/SQDSDKS-6355
7424
- this.parseIdentityResponse = function (xhr, previousMPID, callback, identityApiData, method, knownIdentities, parsingCachedResponse) {
7864
+ this.parseIdentityResponse = function (identityResponse, previousMPID, callback, identityApiData, method, knownIdentities, parsingCachedResponse) {
7425
7865
  var prevUser = mpInstance.Identity.getUser(previousMPID);
7426
7866
  var prevUserMPID = prevUser ? prevUser.getMPID() : null;
7427
7867
  var previousUIByName = prevUser ? prevUser.getUserIdentities().userIdentities : {};
@@ -7431,9 +7871,9 @@ var mParticle = (function () {
7431
7871
  var newIdentitiesByType = {};
7432
7872
  mpInstance._Store.identityCallInFlight = false;
7433
7873
  try {
7434
- var _identityApiResult, _mpInstance$_APIClien;
7874
+ var _identityResponse$res, _identityApiResult, _mpInstance$_APIClien;
7435
7875
  mpInstance.Logger.verbose('Parsing "' + method + '" identity response from server');
7436
- identityApiResult = xhr.responseText ? JSON.parse(xhr.responseText) : null;
7876
+ identityApiResult = (_identityResponse$res = identityResponse.responseText) !== null && _identityResponse$res !== void 0 ? _identityResponse$res : null;
7437
7877
  mpInstance._Store.isLoggedIn = ((_identityApiResult = identityApiResult) === null || _identityApiResult === void 0 ? void 0 : _identityApiResult.is_logged_in) || false;
7438
7878
 
7439
7879
  // https://go.mparticle.com/work/SQDSDKS-6504
@@ -7449,9 +7889,10 @@ var mParticle = (function () {
7449
7889
  // https://go.mparticle.com/work/SQDSDKS-6329
7450
7890
  mpInstance._Persistence.setFirstSeenTime(identityApiResult.mpid);
7451
7891
  }
7452
- if (xhr.status === 200) {
7892
+ if (identityResponse.status === HTTP_SUCCESS) {
7453
7893
  if (getFeatureFlag(CacheIdentity)) {
7454
- cacheOrClearIdCache(method, knownIdentities, self.idCache, xhr, parsingCachedResponse);
7894
+ var identityResponseForCache = xhrIdentityResponseAdapter(identityResponse);
7895
+ cacheOrClearIdCache(method, knownIdentities, self.idCache, identityResponseForCache, parsingCachedResponse);
7455
7896
  }
7456
7897
  var incomingUser = self.IdentityAPI.getUser(identityApiResult.mpid);
7457
7898
  var incomingUIByName = incomingUser ? incomingUser.getUserIdentities().userIdentities : {};
@@ -7500,11 +7941,11 @@ var mParticle = (function () {
7500
7941
  self.sendUserIdentityChangeEvent(newIdentitiesByName, method, identityApiResult.mpid, uiByName);
7501
7942
  }
7502
7943
  if (callback) {
7503
- var callbackCode = xhr.status === 0 ? HTTPCodes$2.noHttpCoverage : xhr.status;
7944
+ var callbackCode = identityResponse.status === 0 ? HTTPCodes$2.noHttpCoverage : identityResponse.status;
7504
7945
  mpInstance._Helpers.invokeCallback(callback, callbackCode, identityApiResult || null, newUser);
7505
7946
  } else if (identityApiResult && !isEmpty(identityApiResult.errors)) {
7506
7947
  // https://go.mparticle.com/work/SQDSDKS-6500
7507
- mpInstance.Logger.error('Received HTTP response code of ' + xhr.status + ' - ' + identityApiResult.errors[0].message);
7948
+ mpInstance.Logger.error('Received HTTP response code of ' + identityResponse.status + ' - ' + identityApiResult.errors[0].message);
7508
7949
  }
7509
7950
  mpInstance.Logger.verbose('Successfully parsed Identity Response');
7510
7951
 
@@ -7512,7 +7953,7 @@ var mParticle = (function () {
7512
7953
  (_mpInstance$_APIClien = mpInstance._APIClient) === null || _mpInstance$_APIClien === void 0 || _mpInstance$_APIClien.processQueuedEvents();
7513
7954
  } catch (e) {
7514
7955
  if (callback) {
7515
- mpInstance._Helpers.invokeCallback(callback, xhr.status, identityApiResult || null);
7956
+ mpInstance._Helpers.invokeCallback(callback, identityResponse.status, identityApiResult || null);
7516
7957
  }
7517
7958
  mpInstance.Logger.error('Error parsing JSON response from Identity server: ' + e);
7518
7959
  }
@@ -8484,7 +8925,10 @@ var mParticle = (function () {
8484
8925
  if (xhr.readyState === 4) {
8485
8926
  // https://go.mparticle.com/work/SQDSDKS-6368
8486
8927
  mpInstance.Logger.verbose('Received ' + xhr.statusText + ' from server');
8487
- parseIdentityResponse(xhr, previousMPID, callback, originalIdentityApiData, method, knownIdentities, false);
8928
+
8929
+ // https://go.mparticle.com/work/SQDSDKS-6565
8930
+ var identityResponse = xhrIdentityResponseAdapter(xhr);
8931
+ parseIdentityResponse(identityResponse, previousMPID, callback, originalIdentityApiData, method, knownIdentities, false);
8488
8932
  }
8489
8933
  };
8490
8934
  mpInstance.Logger.verbose(Messages$1.InformationMessages.SendIdentityBegin);
@@ -8943,11 +9387,11 @@ var mParticle = (function () {
8943
9387
  title: window.document.title
8944
9388
  };
8945
9389
  } else if (!self._Helpers.isObject(attrs)) {
8946
- self.Logger.error('The attributes argument must be an object. A ' + _typeof(attrs) + ' was entered. Please correct and retry.');
9390
+ self.Logger.error('The attributes argument must be an object. A ' + _typeof$1(attrs) + ' was entered. Please correct and retry.');
8947
9391
  return;
8948
9392
  }
8949
9393
  if (customFlags && !self._Helpers.isObject(customFlags)) {
8950
- self.Logger.error('The customFlags argument must be an object. A ' + _typeof(customFlags) + ' was entered. Please correct and retry.');
9394
+ self.Logger.error('The customFlags argument must be an object. A ' + _typeof$1(customFlags) + ' was entered. Please correct and retry.');
8951
9395
  return;
8952
9396
  }
8953
9397
  }
@@ -9373,17 +9817,17 @@ var mParticle = (function () {
9373
9817
  self._Store.integrationAttributes[integrationId][key] = attrs[key];
9374
9818
  }
9375
9819
  } else {
9376
- self.Logger.error('Values for integration attributes must be strings. You entered a ' + _typeof(attrs[key]));
9820
+ self.Logger.error('Values for integration attributes must be strings. You entered a ' + _typeof$1(attrs[key]));
9377
9821
  continue;
9378
9822
  }
9379
9823
  } else {
9380
- self.Logger.error('Keys must be strings, you entered a ' + _typeof(key));
9824
+ self.Logger.error('Keys must be strings, you entered a ' + _typeof$1(key));
9381
9825
  continue;
9382
9826
  }
9383
9827
  }
9384
9828
  }
9385
9829
  } else {
9386
- self.Logger.error('Attrs must be an object with keys and values. You entered a ' + _typeof(attrs));
9830
+ self.Logger.error('Attrs must be an object with keys and values. You entered a ' + _typeof$1(attrs));
9387
9831
  return;
9388
9832
  }
9389
9833
  self._Persistence.update();