@mparticle/web-sdk 2.27.0 → 2.28.1
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.common.js +428 -43
- package/dist/mparticle.esm.js +428 -43
- package/dist/mparticle.js +552 -94
- package/package.json +1 -1
- package/src/apiClient.ts +43 -42
- package/src/configAPIClient.ts +85 -72
- package/src/forwarders.js +32 -0
- package/src/identity.js +8 -7
- package/src/mp-instance.js +11 -2
- package/src/persistence.interfaces.ts +2 -2
- package/src/sdkRuntimeModels.ts +2 -1
- package/src/uploaders.ts +17 -4
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.
|
|
396
|
+
var version = "2.28.1";
|
|
397
397
|
|
|
398
398
|
var Constants = {
|
|
399
399
|
sdkVersion: version,
|
|
@@ -1146,6 +1146,10 @@ var mParticle = (function () {
|
|
|
1146
1146
|
SDKProductActionType[SDKProductActionType["RemoveFromWishlist"] = 10] = "RemoveFromWishlist";
|
|
1147
1147
|
})(SDKProductActionType || (SDKProductActionType = {}));
|
|
1148
1148
|
|
|
1149
|
+
function getDefaultExportFromCjs (x) {
|
|
1150
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1149
1153
|
var dist = {};
|
|
1150
1154
|
|
|
1151
1155
|
(function (exports) {
|
|
@@ -2101,7 +2105,7 @@ var mParticle = (function () {
|
|
|
2101
2105
|
return __generator(this, function (_a) {
|
|
2102
2106
|
switch (_a.label) {
|
|
2103
2107
|
case 0:
|
|
2104
|
-
return [4 /*yield*/, this.makeRequest(this.url, fetchPayload.body)];
|
|
2108
|
+
return [4 /*yield*/, this.makeRequest(this.url, fetchPayload.body, fetchPayload.method)];
|
|
2105
2109
|
case 1:
|
|
2106
2110
|
response = _a.sent();
|
|
2107
2111
|
return [2 /*return*/, response];
|
|
@@ -2109,7 +2113,17 @@ var mParticle = (function () {
|
|
|
2109
2113
|
});
|
|
2110
2114
|
});
|
|
2111
2115
|
};
|
|
2112
|
-
|
|
2116
|
+
// XHR Ready States
|
|
2117
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState
|
|
2118
|
+
// 0 UNSENT open() has not been called yet.
|
|
2119
|
+
// 1 OPENED send() has been called.
|
|
2120
|
+
// 2 HEADERS_RECEIVED send() has been called, and headers and status are available.
|
|
2121
|
+
// 3 LOADING Downloading; responseText holds partial data.
|
|
2122
|
+
// 4 DONE The operation is complete.
|
|
2123
|
+
XHRUploader.prototype.makeRequest = function (url, data, method) {
|
|
2124
|
+
if (method === void 0) {
|
|
2125
|
+
method = 'post';
|
|
2126
|
+
}
|
|
2113
2127
|
return __awaiter(this, void 0, void 0, function () {
|
|
2114
2128
|
var xhr;
|
|
2115
2129
|
return __generator(this, function (_a) {
|
|
@@ -2124,7 +2138,7 @@ var mParticle = (function () {
|
|
|
2124
2138
|
reject(xhr);
|
|
2125
2139
|
}
|
|
2126
2140
|
};
|
|
2127
|
-
xhr.open(
|
|
2141
|
+
xhr.open(method, url);
|
|
2128
2142
|
xhr.send(data);
|
|
2129
2143
|
})];
|
|
2130
2144
|
});
|
|
@@ -2553,27 +2567,12 @@ var mParticle = (function () {
|
|
|
2553
2567
|
mpInstance.Logger.error('Error sending forwarding stats to mParticle servers.');
|
|
2554
2568
|
}
|
|
2555
2569
|
};
|
|
2556
|
-
this.
|
|
2557
|
-
var
|
|
2558
|
-
var
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
if (xhr_1.status === 202) {
|
|
2563
|
-
mpInstance.Logger.verbose('Successfully sent ' + xhr_1.statusText + ' from server');
|
|
2564
|
-
}
|
|
2565
|
-
}
|
|
2566
|
-
};
|
|
2567
|
-
var xhr_1 = mpInstance._Helpers.createXHR(xhrCallback);
|
|
2568
|
-
url = mpInstance._Helpers.createServiceUrl(mpInstance._Store.SDKConfig.v1SecureServiceUrl, mpInstance._Store.devToken);
|
|
2569
|
-
data = forwardingStatsData;
|
|
2570
|
-
if (xhr_1) {
|
|
2571
|
-
xhr_1.open('post', url + '/Forwarding');
|
|
2572
|
-
xhr_1.send(JSON.stringify(data));
|
|
2573
|
-
}
|
|
2574
|
-
} catch (e) {
|
|
2575
|
-
mpInstance.Logger.error('Error sending forwarding stats to mParticle servers.');
|
|
2576
|
-
}
|
|
2570
|
+
this.initializeForwarderStatsUploader = function () {
|
|
2571
|
+
var forwardingDomain = mpInstance._Store.SDKConfig.v1SecureServiceUrl;
|
|
2572
|
+
var devToken = mpInstance._Store.devToken;
|
|
2573
|
+
var uploadUrl = "https://".concat(forwardingDomain).concat(devToken, "/Forwarding");
|
|
2574
|
+
var uploader = window.fetch ? new FetchUploader(uploadUrl) : new XHRUploader(uploadUrl);
|
|
2575
|
+
return uploader;
|
|
2577
2576
|
};
|
|
2578
2577
|
this.prepareForwardingStats = function (forwarder, event) {
|
|
2579
2578
|
var forwardingStatsData;
|
|
@@ -2592,11 +2591,14 @@ var mParticle = (function () {
|
|
|
2592
2591
|
eec: event.ExpandedEventCount,
|
|
2593
2592
|
dp: event.DataPlan
|
|
2594
2593
|
};
|
|
2594
|
+
var _a = mpInstance._Forwarders,
|
|
2595
|
+
sendSingleForwardingStatsToServer = _a.sendSingleForwardingStatsToServer,
|
|
2596
|
+
setForwarderStatsQueue = _a.setForwarderStatsQueue;
|
|
2595
2597
|
if (mpInstance._Helpers.getFeatureFlag(Constants.FeatureFlags.ReportBatching)) {
|
|
2596
2598
|
queue.push(forwardingStatsData);
|
|
2597
|
-
|
|
2599
|
+
setForwarderStatsQueue(queue);
|
|
2598
2600
|
} else {
|
|
2599
|
-
|
|
2601
|
+
sendSingleForwardingStatsToServer(forwardingStatsData);
|
|
2600
2602
|
}
|
|
2601
2603
|
}
|
|
2602
2604
|
};
|
|
@@ -2855,7 +2857,7 @@ var mParticle = (function () {
|
|
|
2855
2857
|
}
|
|
2856
2858
|
|
|
2857
2859
|
// Handle case when target is a string or something (possible in deep copy)
|
|
2858
|
-
if (_typeof(target) !== 'object' && !objectHelper.isFunction(target)) {
|
|
2860
|
+
if (_typeof$1(target) !== 'object' && !objectHelper.isFunction(target)) {
|
|
2859
2861
|
target = {};
|
|
2860
2862
|
}
|
|
2861
2863
|
|
|
@@ -3831,7 +3833,7 @@ var mParticle = (function () {
|
|
|
3831
3833
|
// sanitizes any non number, non string value to 0
|
|
3832
3834
|
this.sanitizeAmount = function (amount, category) {
|
|
3833
3835
|
if (!mpInstance._Helpers.Validators.isStringOrNumber(amount)) {
|
|
3834
|
-
var message = [category, 'must be of type number. A', _typeof(amount), 'was passed. Converting to 0'].join(' ');
|
|
3836
|
+
var message = [category, 'must be of type number. A', _typeof$1(amount), 'was passed. Converting to 0'].join(' ');
|
|
3835
3837
|
mpInstance.Logger.warning(message);
|
|
3836
3838
|
return 0;
|
|
3837
3839
|
}
|
|
@@ -3989,7 +3991,7 @@ var mParticle = (function () {
|
|
|
3989
3991
|
if (mpInstance._Helpers.Validators.isFunction(callback)) {
|
|
3990
3992
|
this.SDKConfig.identityCallback = config.identityCallback;
|
|
3991
3993
|
} else {
|
|
3992
|
-
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.');
|
|
3994
|
+
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.');
|
|
3993
3995
|
}
|
|
3994
3996
|
}
|
|
3995
3997
|
if (config.hasOwnProperty('appVersion')) {
|
|
@@ -5403,6 +5405,386 @@ var mParticle = (function () {
|
|
|
5403
5405
|
};
|
|
5404
5406
|
}
|
|
5405
5407
|
|
|
5408
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
5409
|
+
try {
|
|
5410
|
+
var info = gen[key](arg);
|
|
5411
|
+
var value = info.value;
|
|
5412
|
+
} catch (error) {
|
|
5413
|
+
reject(error);
|
|
5414
|
+
return;
|
|
5415
|
+
}
|
|
5416
|
+
if (info.done) {
|
|
5417
|
+
resolve(value);
|
|
5418
|
+
} else {
|
|
5419
|
+
Promise.resolve(value).then(_next, _throw);
|
|
5420
|
+
}
|
|
5421
|
+
}
|
|
5422
|
+
function _asyncToGenerator(fn) {
|
|
5423
|
+
return function () {
|
|
5424
|
+
var self = this,
|
|
5425
|
+
args = arguments;
|
|
5426
|
+
return new Promise(function (resolve, reject) {
|
|
5427
|
+
var gen = fn.apply(self, args);
|
|
5428
|
+
function _next(value) {
|
|
5429
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
5430
|
+
}
|
|
5431
|
+
function _throw(err) {
|
|
5432
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
5433
|
+
}
|
|
5434
|
+
_next(undefined);
|
|
5435
|
+
});
|
|
5436
|
+
};
|
|
5437
|
+
}
|
|
5438
|
+
|
|
5439
|
+
var regeneratorRuntime$1 = {exports: {}};
|
|
5440
|
+
|
|
5441
|
+
var _typeof = {exports: {}};
|
|
5442
|
+
|
|
5443
|
+
_typeof.exports;
|
|
5444
|
+
|
|
5445
|
+
(function (module) {
|
|
5446
|
+
function _typeof(o) {
|
|
5447
|
+
"@babel/helpers - typeof";
|
|
5448
|
+
|
|
5449
|
+
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
5450
|
+
return typeof o;
|
|
5451
|
+
} : function (o) {
|
|
5452
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
5453
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
5454
|
+
}
|
|
5455
|
+
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5456
|
+
} (_typeof));
|
|
5457
|
+
|
|
5458
|
+
var _typeofExports = _typeof.exports;
|
|
5459
|
+
|
|
5460
|
+
regeneratorRuntime$1.exports;
|
|
5461
|
+
|
|
5462
|
+
(function (module) {
|
|
5463
|
+
var _typeof = _typeofExports["default"];
|
|
5464
|
+
function _regeneratorRuntime() {
|
|
5465
|
+
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
5466
|
+
return e;
|
|
5467
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5468
|
+
var t,
|
|
5469
|
+
e = {},
|
|
5470
|
+
r = Object.prototype,
|
|
5471
|
+
n = r.hasOwnProperty,
|
|
5472
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
5473
|
+
t[e] = r.value;
|
|
5474
|
+
},
|
|
5475
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
5476
|
+
a = i.iterator || "@@iterator",
|
|
5477
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
5478
|
+
u = i.toStringTag || "@@toStringTag";
|
|
5479
|
+
function define(t, e, r) {
|
|
5480
|
+
return Object.defineProperty(t, e, {
|
|
5481
|
+
value: r,
|
|
5482
|
+
enumerable: !0,
|
|
5483
|
+
configurable: !0,
|
|
5484
|
+
writable: !0
|
|
5485
|
+
}), t[e];
|
|
5486
|
+
}
|
|
5487
|
+
try {
|
|
5488
|
+
define({}, "");
|
|
5489
|
+
} catch (t) {
|
|
5490
|
+
define = function define(t, e, r) {
|
|
5491
|
+
return t[e] = r;
|
|
5492
|
+
};
|
|
5493
|
+
}
|
|
5494
|
+
function wrap(t, e, r, n) {
|
|
5495
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
5496
|
+
a = Object.create(i.prototype),
|
|
5497
|
+
c = new Context(n || []);
|
|
5498
|
+
return o(a, "_invoke", {
|
|
5499
|
+
value: makeInvokeMethod(t, r, c)
|
|
5500
|
+
}), a;
|
|
5501
|
+
}
|
|
5502
|
+
function tryCatch(t, e, r) {
|
|
5503
|
+
try {
|
|
5504
|
+
return {
|
|
5505
|
+
type: "normal",
|
|
5506
|
+
arg: t.call(e, r)
|
|
5507
|
+
};
|
|
5508
|
+
} catch (t) {
|
|
5509
|
+
return {
|
|
5510
|
+
type: "throw",
|
|
5511
|
+
arg: t
|
|
5512
|
+
};
|
|
5513
|
+
}
|
|
5514
|
+
}
|
|
5515
|
+
e.wrap = wrap;
|
|
5516
|
+
var h = "suspendedStart",
|
|
5517
|
+
l = "suspendedYield",
|
|
5518
|
+
f = "executing",
|
|
5519
|
+
s = "completed",
|
|
5520
|
+
y = {};
|
|
5521
|
+
function Generator() {}
|
|
5522
|
+
function GeneratorFunction() {}
|
|
5523
|
+
function GeneratorFunctionPrototype() {}
|
|
5524
|
+
var p = {};
|
|
5525
|
+
define(p, a, function () {
|
|
5526
|
+
return this;
|
|
5527
|
+
});
|
|
5528
|
+
var d = Object.getPrototypeOf,
|
|
5529
|
+
v = d && d(d(values([])));
|
|
5530
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
5531
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
5532
|
+
function defineIteratorMethods(t) {
|
|
5533
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
5534
|
+
define(t, e, function (t) {
|
|
5535
|
+
return this._invoke(e, t);
|
|
5536
|
+
});
|
|
5537
|
+
});
|
|
5538
|
+
}
|
|
5539
|
+
function AsyncIterator(t, e) {
|
|
5540
|
+
function invoke(r, o, i, a) {
|
|
5541
|
+
var c = tryCatch(t[r], t, o);
|
|
5542
|
+
if ("throw" !== c.type) {
|
|
5543
|
+
var u = c.arg,
|
|
5544
|
+
h = u.value;
|
|
5545
|
+
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
5546
|
+
invoke("next", t, i, a);
|
|
5547
|
+
}, function (t) {
|
|
5548
|
+
invoke("throw", t, i, a);
|
|
5549
|
+
}) : e.resolve(h).then(function (t) {
|
|
5550
|
+
u.value = t, i(u);
|
|
5551
|
+
}, function (t) {
|
|
5552
|
+
return invoke("throw", t, i, a);
|
|
5553
|
+
});
|
|
5554
|
+
}
|
|
5555
|
+
a(c.arg);
|
|
5556
|
+
}
|
|
5557
|
+
var r;
|
|
5558
|
+
o(this, "_invoke", {
|
|
5559
|
+
value: function value(t, n) {
|
|
5560
|
+
function callInvokeWithMethodAndArg() {
|
|
5561
|
+
return new e(function (e, r) {
|
|
5562
|
+
invoke(t, n, e, r);
|
|
5563
|
+
});
|
|
5564
|
+
}
|
|
5565
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
5566
|
+
}
|
|
5567
|
+
});
|
|
5568
|
+
}
|
|
5569
|
+
function makeInvokeMethod(e, r, n) {
|
|
5570
|
+
var o = h;
|
|
5571
|
+
return function (i, a) {
|
|
5572
|
+
if (o === f) throw new Error("Generator is already running");
|
|
5573
|
+
if (o === s) {
|
|
5574
|
+
if ("throw" === i) throw a;
|
|
5575
|
+
return {
|
|
5576
|
+
value: t,
|
|
5577
|
+
done: !0
|
|
5578
|
+
};
|
|
5579
|
+
}
|
|
5580
|
+
for (n.method = i, n.arg = a;;) {
|
|
5581
|
+
var c = n.delegate;
|
|
5582
|
+
if (c) {
|
|
5583
|
+
var u = maybeInvokeDelegate(c, n);
|
|
5584
|
+
if (u) {
|
|
5585
|
+
if (u === y) continue;
|
|
5586
|
+
return u;
|
|
5587
|
+
}
|
|
5588
|
+
}
|
|
5589
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
5590
|
+
if (o === h) throw o = s, n.arg;
|
|
5591
|
+
n.dispatchException(n.arg);
|
|
5592
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
5593
|
+
o = f;
|
|
5594
|
+
var p = tryCatch(e, r, n);
|
|
5595
|
+
if ("normal" === p.type) {
|
|
5596
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
5597
|
+
return {
|
|
5598
|
+
value: p.arg,
|
|
5599
|
+
done: n.done
|
|
5600
|
+
};
|
|
5601
|
+
}
|
|
5602
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
5603
|
+
}
|
|
5604
|
+
};
|
|
5605
|
+
}
|
|
5606
|
+
function maybeInvokeDelegate(e, r) {
|
|
5607
|
+
var n = r.method,
|
|
5608
|
+
o = e.iterator[n];
|
|
5609
|
+
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;
|
|
5610
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
5611
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
5612
|
+
var a = i.arg;
|
|
5613
|
+
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);
|
|
5614
|
+
}
|
|
5615
|
+
function pushTryEntry(t) {
|
|
5616
|
+
var e = {
|
|
5617
|
+
tryLoc: t[0]
|
|
5618
|
+
};
|
|
5619
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
5620
|
+
}
|
|
5621
|
+
function resetTryEntry(t) {
|
|
5622
|
+
var e = t.completion || {};
|
|
5623
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
5624
|
+
}
|
|
5625
|
+
function Context(t) {
|
|
5626
|
+
this.tryEntries = [{
|
|
5627
|
+
tryLoc: "root"
|
|
5628
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
5629
|
+
}
|
|
5630
|
+
function values(e) {
|
|
5631
|
+
if (e || "" === e) {
|
|
5632
|
+
var r = e[a];
|
|
5633
|
+
if (r) return r.call(e);
|
|
5634
|
+
if ("function" == typeof e.next) return e;
|
|
5635
|
+
if (!isNaN(e.length)) {
|
|
5636
|
+
var o = -1,
|
|
5637
|
+
i = function next() {
|
|
5638
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
5639
|
+
return next.value = t, next.done = !0, next;
|
|
5640
|
+
};
|
|
5641
|
+
return i.next = i;
|
|
5642
|
+
}
|
|
5643
|
+
}
|
|
5644
|
+
throw new TypeError(_typeof(e) + " is not iterable");
|
|
5645
|
+
}
|
|
5646
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
5647
|
+
value: GeneratorFunctionPrototype,
|
|
5648
|
+
configurable: !0
|
|
5649
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
5650
|
+
value: GeneratorFunction,
|
|
5651
|
+
configurable: !0
|
|
5652
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
5653
|
+
var e = "function" == typeof t && t.constructor;
|
|
5654
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
5655
|
+
}, e.mark = function (t) {
|
|
5656
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
5657
|
+
}, e.awrap = function (t) {
|
|
5658
|
+
return {
|
|
5659
|
+
__await: t
|
|
5660
|
+
};
|
|
5661
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
5662
|
+
return this;
|
|
5663
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
5664
|
+
void 0 === i && (i = Promise);
|
|
5665
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
5666
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
5667
|
+
return t.done ? t.value : a.next();
|
|
5668
|
+
});
|
|
5669
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
5670
|
+
return this;
|
|
5671
|
+
}), define(g, "toString", function () {
|
|
5672
|
+
return "[object Generator]";
|
|
5673
|
+
}), e.keys = function (t) {
|
|
5674
|
+
var e = Object(t),
|
|
5675
|
+
r = [];
|
|
5676
|
+
for (var n in e) r.push(n);
|
|
5677
|
+
return r.reverse(), function next() {
|
|
5678
|
+
for (; r.length;) {
|
|
5679
|
+
var t = r.pop();
|
|
5680
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
5681
|
+
}
|
|
5682
|
+
return next.done = !0, next;
|
|
5683
|
+
};
|
|
5684
|
+
}, e.values = values, Context.prototype = {
|
|
5685
|
+
constructor: Context,
|
|
5686
|
+
reset: function reset(e) {
|
|
5687
|
+
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);
|
|
5688
|
+
},
|
|
5689
|
+
stop: function stop() {
|
|
5690
|
+
this.done = !0;
|
|
5691
|
+
var t = this.tryEntries[0].completion;
|
|
5692
|
+
if ("throw" === t.type) throw t.arg;
|
|
5693
|
+
return this.rval;
|
|
5694
|
+
},
|
|
5695
|
+
dispatchException: function dispatchException(e) {
|
|
5696
|
+
if (this.done) throw e;
|
|
5697
|
+
var r = this;
|
|
5698
|
+
function handle(n, o) {
|
|
5699
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
5700
|
+
}
|
|
5701
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
5702
|
+
var i = this.tryEntries[o],
|
|
5703
|
+
a = i.completion;
|
|
5704
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
5705
|
+
if (i.tryLoc <= this.prev) {
|
|
5706
|
+
var c = n.call(i, "catchLoc"),
|
|
5707
|
+
u = n.call(i, "finallyLoc");
|
|
5708
|
+
if (c && u) {
|
|
5709
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
5710
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
5711
|
+
} else if (c) {
|
|
5712
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
5713
|
+
} else {
|
|
5714
|
+
if (!u) throw new Error("try statement without catch or finally");
|
|
5715
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
5716
|
+
}
|
|
5717
|
+
}
|
|
5718
|
+
}
|
|
5719
|
+
},
|
|
5720
|
+
abrupt: function abrupt(t, e) {
|
|
5721
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
5722
|
+
var o = this.tryEntries[r];
|
|
5723
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
5724
|
+
var i = o;
|
|
5725
|
+
break;
|
|
5726
|
+
}
|
|
5727
|
+
}
|
|
5728
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
5729
|
+
var a = i ? i.completion : {};
|
|
5730
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
5731
|
+
},
|
|
5732
|
+
complete: function complete(t, e) {
|
|
5733
|
+
if ("throw" === t.type) throw t.arg;
|
|
5734
|
+
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;
|
|
5735
|
+
},
|
|
5736
|
+
finish: function finish(t) {
|
|
5737
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
5738
|
+
var r = this.tryEntries[e];
|
|
5739
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
5740
|
+
}
|
|
5741
|
+
},
|
|
5742
|
+
"catch": function _catch(t) {
|
|
5743
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
5744
|
+
var r = this.tryEntries[e];
|
|
5745
|
+
if (r.tryLoc === t) {
|
|
5746
|
+
var n = r.completion;
|
|
5747
|
+
if ("throw" === n.type) {
|
|
5748
|
+
var o = n.arg;
|
|
5749
|
+
resetTryEntry(r);
|
|
5750
|
+
}
|
|
5751
|
+
return o;
|
|
5752
|
+
}
|
|
5753
|
+
}
|
|
5754
|
+
throw new Error("illegal catch attempt");
|
|
5755
|
+
},
|
|
5756
|
+
delegateYield: function delegateYield(e, r, n) {
|
|
5757
|
+
return this.delegate = {
|
|
5758
|
+
iterator: values(e),
|
|
5759
|
+
resultName: r,
|
|
5760
|
+
nextLoc: n
|
|
5761
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
5762
|
+
}
|
|
5763
|
+
}, e;
|
|
5764
|
+
}
|
|
5765
|
+
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
5766
|
+
} (regeneratorRuntime$1));
|
|
5767
|
+
|
|
5768
|
+
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
5769
|
+
|
|
5770
|
+
// TODO(Babel 8): Remove this file.
|
|
5771
|
+
|
|
5772
|
+
var runtime = regeneratorRuntimeExports();
|
|
5773
|
+
var regenerator = runtime;
|
|
5774
|
+
|
|
5775
|
+
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
5776
|
+
try {
|
|
5777
|
+
regeneratorRuntime = runtime;
|
|
5778
|
+
} catch (accidentalStrictMode) {
|
|
5779
|
+
if (typeof globalThis === "object") {
|
|
5780
|
+
globalThis.regeneratorRuntime = runtime;
|
|
5781
|
+
} else {
|
|
5782
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
5783
|
+
}
|
|
5784
|
+
}
|
|
5785
|
+
|
|
5786
|
+
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
5787
|
+
|
|
5406
5788
|
function filteredMparticleUser(mpid, forwarder, mpInstance, kitBlocker) {
|
|
5407
5789
|
var self = this;
|
|
5408
5790
|
return {
|
|
@@ -5467,7 +5849,9 @@ var mParticle = (function () {
|
|
|
5467
5849
|
Login$2 = _Constants$IdentityMe.Login,
|
|
5468
5850
|
Logout$2 = _Constants$IdentityMe.Logout;
|
|
5469
5851
|
function Forwarders(mpInstance, kitBlocker) {
|
|
5852
|
+
var _this = this;
|
|
5470
5853
|
var self = this;
|
|
5854
|
+
this.forwarderStatsUploader = new APIClient(mpInstance, kitBlocker).initializeForwarderStatsUploader();
|
|
5471
5855
|
var UserAttributeActionTypes = {
|
|
5472
5856
|
setUserAttribute: 'setUserAttribute',
|
|
5473
5857
|
removeUserAttribute: 'removeUserAttribute'
|
|
@@ -5936,6 +6320,44 @@ var mParticle = (function () {
|
|
|
5936
6320
|
mpInstance.Logger.error('Cookie Sync configs not configured propertly. Cookie Sync may not be initialized. ' + e);
|
|
5937
6321
|
}
|
|
5938
6322
|
};
|
|
6323
|
+
this.sendSingleForwardingStatsToServer = /*#__PURE__*/function () {
|
|
6324
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(forwardingStatsData) {
|
|
6325
|
+
var _mpInstance$Logger;
|
|
6326
|
+
var fetchPayload, response, message;
|
|
6327
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
6328
|
+
while (1) switch (_context.prev = _context.next) {
|
|
6329
|
+
case 0:
|
|
6330
|
+
// https://go.mparticle.com/work/SQDSDKS-6568
|
|
6331
|
+
fetchPayload = {
|
|
6332
|
+
method: 'post',
|
|
6333
|
+
body: JSON.stringify(forwardingStatsData),
|
|
6334
|
+
headers: {
|
|
6335
|
+
Accept: 'text/plain;charset=UTF-8',
|
|
6336
|
+
'Content-Type': 'text/plain;charset=UTF-8'
|
|
6337
|
+
}
|
|
6338
|
+
};
|
|
6339
|
+
_context.next = 3;
|
|
6340
|
+
return _this.forwarderStatsUploader.upload(fetchPayload);
|
|
6341
|
+
case 3:
|
|
6342
|
+
response = _context.sent;
|
|
6343
|
+
// This is a fire and forget, so we only need to log the response based on the code, and not return any response body
|
|
6344
|
+
if (response.status === 202) {
|
|
6345
|
+
// https://go.mparticle.com/work/SQDSDKS-6670
|
|
6346
|
+
message = 'Successfully sent forwarding stats to mParticle Servers';
|
|
6347
|
+
} else {
|
|
6348
|
+
message = 'Issue with forwarding stats to mParticle Servers, received HTTP Code of ' + response.statusText;
|
|
6349
|
+
}
|
|
6350
|
+
mpInstance === null || mpInstance === void 0 || (_mpInstance$Logger = mpInstance.Logger) === null || _mpInstance$Logger === void 0 || _mpInstance$Logger.verbose(message);
|
|
6351
|
+
case 6:
|
|
6352
|
+
case "end":
|
|
6353
|
+
return _context.stop();
|
|
6354
|
+
}
|
|
6355
|
+
}, _callee);
|
|
6356
|
+
}));
|
|
6357
|
+
return function (_x) {
|
|
6358
|
+
return _ref.apply(this, arguments);
|
|
6359
|
+
};
|
|
6360
|
+
}();
|
|
5939
6361
|
}
|
|
5940
6362
|
|
|
5941
6363
|
// TODO: This file is no longer the server model because the web SDK payload
|
|
@@ -6533,7 +6955,7 @@ var mParticle = (function () {
|
|
|
6533
6955
|
};
|
|
6534
6956
|
}
|
|
6535
6957
|
if (callback && !mpInstance._Helpers.Validators.isFunction(callback)) {
|
|
6536
|
-
var error = 'The optional callback must be a function. You tried entering a(n) ' + _typeof(callback);
|
|
6958
|
+
var error = 'The optional callback must be a function. You tried entering a(n) ' + _typeof$1(callback);
|
|
6537
6959
|
mpInstance.Logger.error(error);
|
|
6538
6960
|
return {
|
|
6539
6961
|
valid: false,
|
|
@@ -7077,7 +7499,7 @@ var mParticle = (function () {
|
|
|
7077
7499
|
}
|
|
7078
7500
|
}
|
|
7079
7501
|
} else {
|
|
7080
|
-
mpInstance.Logger.error('Must pass an object into setUserAttributes. You passed a ' + _typeof(userAttributes));
|
|
7502
|
+
mpInstance.Logger.error('Must pass an object into setUserAttributes. You passed a ' + _typeof$1(userAttributes));
|
|
7081
7503
|
}
|
|
7082
7504
|
},
|
|
7083
7505
|
/**
|
|
@@ -7129,7 +7551,7 @@ var mParticle = (function () {
|
|
|
7129
7551
|
return;
|
|
7130
7552
|
}
|
|
7131
7553
|
if (!Array.isArray(newValue)) {
|
|
7132
|
-
mpInstance.Logger.error('The value you passed in to setUserAttributeList must be an array. You passed in a ' + (typeof value === "undefined" ? "undefined" : _typeof(value)));
|
|
7554
|
+
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)));
|
|
7133
7555
|
return;
|
|
7134
7556
|
}
|
|
7135
7557
|
var arrayCopy = newValue.slice();
|
|
@@ -7421,7 +7843,7 @@ var mParticle = (function () {
|
|
|
7421
7843
|
var newIdentitiesByType = {};
|
|
7422
7844
|
mpInstance._Store.identityCallInFlight = false;
|
|
7423
7845
|
try {
|
|
7424
|
-
var _identityApiResult;
|
|
7846
|
+
var _identityApiResult, _mpInstance$_APIClien;
|
|
7425
7847
|
mpInstance.Logger.verbose('Parsing "' + method + '" identity response from server');
|
|
7426
7848
|
identityApiResult = xhr.responseText ? JSON.parse(xhr.responseText) : null;
|
|
7427
7849
|
mpInstance._Store.isLoggedIn = ((_identityApiResult = identityApiResult) === null || _identityApiResult === void 0 ? void 0 : _identityApiResult.is_logged_in) || false;
|
|
@@ -7497,7 +7919,9 @@ var mParticle = (function () {
|
|
|
7497
7919
|
mpInstance.Logger.error('Received HTTP response code of ' + xhr.status + ' - ' + identityApiResult.errors[0].message);
|
|
7498
7920
|
}
|
|
7499
7921
|
mpInstance.Logger.verbose('Successfully parsed Identity Response');
|
|
7500
|
-
|
|
7922
|
+
|
|
7923
|
+
// https://go.mparticle.com/work/SQDSDKS-6654
|
|
7924
|
+
(_mpInstance$_APIClien = mpInstance._APIClient) === null || _mpInstance$_APIClien === void 0 || _mpInstance$_APIClien.processQueuedEvents();
|
|
7501
7925
|
} catch (e) {
|
|
7502
7926
|
if (callback) {
|
|
7503
7927
|
mpInstance._Helpers.invokeCallback(callback, xhr.status, identityApiResult || null);
|
|
@@ -7522,12 +7946,13 @@ var mParticle = (function () {
|
|
|
7522
7946
|
for (var identityType in newUserIdentities) {
|
|
7523
7947
|
// Verifies a change actually happened
|
|
7524
7948
|
if (prevUserIdentities[identityType] !== newUserIdentities[identityType]) {
|
|
7949
|
+
var _mpInstance$_APIClien2;
|
|
7525
7950
|
// If a new identity type was introduced when the identity changes
|
|
7526
7951
|
// we need to notify the server so that the user profile is updated in
|
|
7527
7952
|
// the mParticle UI.
|
|
7528
7953
|
var isNewUserIdentityType = !prevUserIdentities[identityType];
|
|
7529
7954
|
var userIdentityChangeEvent = self.createUserIdentityChange(identityType, newUserIdentities[identityType], prevUserIdentities[identityType], isNewUserIdentityType, currentUserInMemory);
|
|
7530
|
-
mpInstance._APIClient.sendEventToServer(userIdentityChangeEvent);
|
|
7955
|
+
(_mpInstance$_APIClien2 = mpInstance._APIClient) === null || _mpInstance$_APIClien2 === void 0 || _mpInstance$_APIClien2.sendEventToServer(userIdentityChangeEvent);
|
|
7531
7956
|
}
|
|
7532
7957
|
}
|
|
7533
7958
|
};
|
|
@@ -7556,7 +7981,8 @@ var mParticle = (function () {
|
|
|
7556
7981
|
this.sendUserAttributeChangeEvent = function (attributeKey, newUserAttributeValue, previousUserAttributeValue, isNewAttribute, deleted, user) {
|
|
7557
7982
|
var userAttributeChangeEvent = self.createUserAttributeChange(attributeKey, newUserAttributeValue, previousUserAttributeValue, isNewAttribute, deleted, user);
|
|
7558
7983
|
if (userAttributeChangeEvent) {
|
|
7559
|
-
|
|
7984
|
+
var _mpInstance$_APIClien3;
|
|
7985
|
+
(_mpInstance$_APIClien3 = mpInstance._APIClient) === null || _mpInstance$_APIClien3 === void 0 || _mpInstance$_APIClien3.sendEventToServer(userAttributeChangeEvent);
|
|
7560
7986
|
}
|
|
7561
7987
|
};
|
|
7562
7988
|
this.createUserAttributeChange = function (key, newValue, previousUserAttributeValue, isNewAttribute, deleted, user) {
|
|
@@ -7581,14 +8007,16 @@ var mParticle = (function () {
|
|
|
7581
8007
|
};
|
|
7582
8008
|
this.reinitForwardersOnUserChange = function (prevUser, newUser) {
|
|
7583
8009
|
if (hasMPIDAndUserLoginChanged(prevUser, newUser)) {
|
|
7584
|
-
|
|
8010
|
+
var _mpInstance$_Forwarde;
|
|
8011
|
+
(_mpInstance$_Forwarde = mpInstance._Forwarders) === null || _mpInstance$_Forwarde === void 0 || _mpInstance$_Forwarde.initForwarders(newUser.getUserIdentities().userIdentities, mpInstance._APIClient.prepareForwardingStats);
|
|
7585
8012
|
}
|
|
7586
8013
|
};
|
|
7587
8014
|
this.setForwarderCallbacks = function (user, method) {
|
|
8015
|
+
var _mpInstance$_Forwarde2, _mpInstance$_Forwarde3, _mpInstance$_Forwarde4;
|
|
7588
8016
|
// https://go.mparticle.com/work/SQDSDKS-6036
|
|
7589
|
-
mpInstance._Forwarders.setForwarderUserIdentities(user.getUserIdentities().userIdentities);
|
|
7590
|
-
mpInstance._Forwarders.setForwarderOnIdentityComplete(user, method);
|
|
7591
|
-
mpInstance._Forwarders.setForwarderOnUserIdentified(user);
|
|
8017
|
+
(_mpInstance$_Forwarde2 = mpInstance._Forwarders) === null || _mpInstance$_Forwarde2 === void 0 || _mpInstance$_Forwarde2.setForwarderUserIdentities(user.getUserIdentities().userIdentities);
|
|
8018
|
+
(_mpInstance$_Forwarde3 = mpInstance._Forwarders) === null || _mpInstance$_Forwarde3 === void 0 || _mpInstance$_Forwarde3.setForwarderOnIdentityComplete(user, method);
|
|
8019
|
+
(_mpInstance$_Forwarde4 = mpInstance._Forwarders) === null || _mpInstance$_Forwarde4 === void 0 || _mpInstance$_Forwarde4.setForwarderOnUserIdentified(user);
|
|
7592
8020
|
};
|
|
7593
8021
|
}
|
|
7594
8022
|
|
|
@@ -8355,48 +8783,73 @@ var mParticle = (function () {
|
|
|
8355
8783
|
return KitBlocker;
|
|
8356
8784
|
}();
|
|
8357
8785
|
|
|
8358
|
-
function
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
var
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8786
|
+
var buildUrl = function buildUrl(configUrl, apiKey, dataPlanConfig, isDevelopmentMode) {
|
|
8787
|
+
var url = configUrl + apiKey + '/config';
|
|
8788
|
+
var env = isDevelopmentMode ? '1' : '0';
|
|
8789
|
+
var queryParams = ["env=".concat(env)];
|
|
8790
|
+
var _a = dataPlanConfig || {},
|
|
8791
|
+
planId = _a.planId,
|
|
8792
|
+
planVersion = _a.planVersion;
|
|
8793
|
+
if (planId) {
|
|
8794
|
+
queryParams.push("plan_id=".concat(planId));
|
|
8795
|
+
}
|
|
8796
|
+
if (planVersion) {
|
|
8797
|
+
queryParams.push("plan_version=".concat(planVersion));
|
|
8798
|
+
}
|
|
8799
|
+
return "".concat(url, "?").concat(queryParams.join('&'));
|
|
8800
|
+
};
|
|
8801
|
+
function ConfigAPIClient(apiKey, config, mpInstance) {
|
|
8802
|
+
var _this = this;
|
|
8803
|
+
var baseUrl = 'https://' + mpInstance._Store.SDKConfig.configUrl;
|
|
8804
|
+
var isDevelopmentMode = config.isDevelopmentMode;
|
|
8805
|
+
var dataPlan = config.dataPlan;
|
|
8806
|
+
var uploadUrl = buildUrl(baseUrl, apiKey, dataPlan, isDevelopmentMode);
|
|
8807
|
+
var uploader = window.fetch ? new FetchUploader(uploadUrl) : new XHRUploader(uploadUrl);
|
|
8808
|
+
this.getSDKConfiguration = function () {
|
|
8809
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
8810
|
+
var configResponse, fetchPayload, response, xhrResponse;
|
|
8811
|
+
var _a, _b, _c;
|
|
8812
|
+
return __generator(this, function (_d) {
|
|
8813
|
+
switch (_d.label) {
|
|
8814
|
+
case 0:
|
|
8815
|
+
fetchPayload = {
|
|
8816
|
+
method: 'get',
|
|
8817
|
+
headers: {
|
|
8818
|
+
Accept: 'text/plain;charset=UTF-8',
|
|
8819
|
+
'Content-Type': 'text/plain;charset=UTF-8'
|
|
8820
|
+
},
|
|
8821
|
+
body: null
|
|
8822
|
+
};
|
|
8823
|
+
_d.label = 1;
|
|
8824
|
+
case 1:
|
|
8825
|
+
_d.trys.push([1, 6,, 7]);
|
|
8826
|
+
return [4 /*yield*/, uploader.upload(fetchPayload)];
|
|
8827
|
+
case 2:
|
|
8828
|
+
response = _d.sent();
|
|
8829
|
+
if (!(response.status === 200)) return [3 /*break*/, 5];
|
|
8830
|
+
(_a = mpInstance === null || mpInstance === void 0 ? void 0 : mpInstance.Logger) === null || _a === void 0 ? void 0 : _a.verbose('Successfully received configuration from server');
|
|
8831
|
+
if (!response.json) return [3 /*break*/, 4];
|
|
8832
|
+
return [4 /*yield*/, response.json()];
|
|
8833
|
+
case 3:
|
|
8834
|
+
configResponse = _d.sent();
|
|
8835
|
+
return [2 /*return*/, configResponse];
|
|
8836
|
+
case 4:
|
|
8837
|
+
xhrResponse = response;
|
|
8838
|
+
configResponse = JSON.parse(xhrResponse.responseText);
|
|
8839
|
+
return [2 /*return*/, configResponse];
|
|
8840
|
+
case 5:
|
|
8841
|
+
(_b = mpInstance === null || mpInstance === void 0 ? void 0 : mpInstance.Logger) === null || _b === void 0 ? void 0 : _b.verbose('Issue with receiving configuration from server, received HTTP Code of ' + response.statusText);
|
|
8842
|
+
return [3 /*break*/, 7];
|
|
8843
|
+
case 6:
|
|
8844
|
+
_d.sent();
|
|
8845
|
+
(_c = mpInstance === null || mpInstance === void 0 ? void 0 : mpInstance.Logger) === null || _c === void 0 ? void 0 : _c.error('Error getting forwarder configuration from mParticle servers.');
|
|
8846
|
+
return [3 /*break*/, 7];
|
|
8847
|
+
case 7:
|
|
8848
|
+
// Returns the original config object if we cannot retrieve the remote config
|
|
8849
|
+
return [2 /*return*/, config];
|
|
8390
8850
|
}
|
|
8391
|
-
}
|
|
8392
|
-
|
|
8393
|
-
xhr_1.open('get', url);
|
|
8394
|
-
xhr_1.send(null);
|
|
8395
|
-
}
|
|
8396
|
-
} catch (e) {
|
|
8397
|
-
completeSDKInitialization(apiKey, config, mpInstance);
|
|
8398
|
-
mpInstance.Logger.error('Error getting forwarder configuration from mParticle servers.');
|
|
8399
|
-
}
|
|
8851
|
+
});
|
|
8852
|
+
});
|
|
8400
8853
|
};
|
|
8401
8854
|
}
|
|
8402
8855
|
|
|
@@ -8539,6 +8992,7 @@ var mParticle = (function () {
|
|
|
8539
8992
|
}
|
|
8540
8993
|
}
|
|
8541
8994
|
this.init = function (apiKey, config) {
|
|
8995
|
+
var _this = this;
|
|
8542
8996
|
if (!config) {
|
|
8543
8997
|
console.warn('You did not pass a config object to init(). mParticle will not initialize properly');
|
|
8544
8998
|
}
|
|
@@ -8549,7 +9003,11 @@ var mParticle = (function () {
|
|
|
8549
9003
|
// to it for it to be run after fetched
|
|
8550
9004
|
if (config) {
|
|
8551
9005
|
if (!config.hasOwnProperty('requestConfig') || config.requestConfig) {
|
|
8552
|
-
new ConfigAPIClient(
|
|
9006
|
+
var configApiClient = new ConfigAPIClient(apiKey, config, this);
|
|
9007
|
+
configApiClient.getSDKConfiguration().then(function (result) {
|
|
9008
|
+
var mergedConfig = _this._Helpers.extend({}, config, result);
|
|
9009
|
+
completeSDKInitialization(apiKey, mergedConfig, _this);
|
|
9010
|
+
});
|
|
8553
9011
|
} else {
|
|
8554
9012
|
completeSDKInitialization(apiKey, config, this);
|
|
8555
9013
|
}
|
|
@@ -8897,11 +9355,11 @@ var mParticle = (function () {
|
|
|
8897
9355
|
title: window.document.title
|
|
8898
9356
|
};
|
|
8899
9357
|
} else if (!self._Helpers.isObject(attrs)) {
|
|
8900
|
-
self.Logger.error('The attributes argument must be an object. A ' + _typeof(attrs) + ' was entered. Please correct and retry.');
|
|
9358
|
+
self.Logger.error('The attributes argument must be an object. A ' + _typeof$1(attrs) + ' was entered. Please correct and retry.');
|
|
8901
9359
|
return;
|
|
8902
9360
|
}
|
|
8903
9361
|
if (customFlags && !self._Helpers.isObject(customFlags)) {
|
|
8904
|
-
self.Logger.error('The customFlags argument must be an object. A ' + _typeof(customFlags) + ' was entered. Please correct and retry.');
|
|
9362
|
+
self.Logger.error('The customFlags argument must be an object. A ' + _typeof$1(customFlags) + ' was entered. Please correct and retry.');
|
|
8905
9363
|
return;
|
|
8906
9364
|
}
|
|
8907
9365
|
}
|
|
@@ -9327,17 +9785,17 @@ var mParticle = (function () {
|
|
|
9327
9785
|
self._Store.integrationAttributes[integrationId][key] = attrs[key];
|
|
9328
9786
|
}
|
|
9329
9787
|
} else {
|
|
9330
|
-
self.Logger.error('Values for integration attributes must be strings. You entered a ' + _typeof(attrs[key]));
|
|
9788
|
+
self.Logger.error('Values for integration attributes must be strings. You entered a ' + _typeof$1(attrs[key]));
|
|
9331
9789
|
continue;
|
|
9332
9790
|
}
|
|
9333
9791
|
} else {
|
|
9334
|
-
self.Logger.error('Keys must be strings, you entered a ' + _typeof(key));
|
|
9792
|
+
self.Logger.error('Keys must be strings, you entered a ' + _typeof$1(key));
|
|
9335
9793
|
continue;
|
|
9336
9794
|
}
|
|
9337
9795
|
}
|
|
9338
9796
|
}
|
|
9339
9797
|
} else {
|
|
9340
|
-
self.Logger.error('Attrs must be an object with keys and values. You entered a ' + _typeof(attrs));
|
|
9798
|
+
self.Logger.error('Attrs must be an object with keys and values. You entered a ' + _typeof$1(attrs));
|
|
9341
9799
|
return;
|
|
9342
9800
|
}
|
|
9343
9801
|
self._Persistence.update();
|