@mparticle/web-sdk 2.72.0 → 2.73.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 +33 -19
- package/dist/mparticle.esm.js +33 -19
- package/dist/mparticle.js +80 -43
- package/dist/types/src/pre-init-utils.d.ts +2 -1
- package/dist/types/src/reporting/types.d.ts +0 -1
- package/dist/types/src/roktManager.d.ts +3 -1
- package/dist/types/src/utils.d.ts +2 -1
- package/package.json +1 -1
- package/src/identity/search.ts +3 -4
- package/src/identity-utils.ts +2 -3
- package/src/identity.js +2 -1
- package/src/identityApiClient.ts +3 -3
- package/src/mp-instance.ts +12 -4
- package/src/pre-init-utils.ts +39 -7
- package/src/reporting/types.ts +0 -1
- package/src/roktManager.ts +37 -18
- package/src/utils.ts +22 -0
package/dist/mparticle.js
CHANGED
|
@@ -203,7 +203,7 @@ var mParticle = (function () {
|
|
|
203
203
|
Base64: Base64$1
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
var version = "2.
|
|
206
|
+
var version = "2.73.1";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -1013,6 +1013,22 @@ var mParticle = (function () {
|
|
|
1013
1013
|
}
|
|
1014
1014
|
return target;
|
|
1015
1015
|
}
|
|
1016
|
+
var getErrorMessage = function getErrorMessage(e, fallback) {
|
|
1017
|
+
if (fallback === void 0) {
|
|
1018
|
+
fallback = 'unknown error';
|
|
1019
|
+
}
|
|
1020
|
+
if (e instanceof Error) {
|
|
1021
|
+
return e.message;
|
|
1022
|
+
}
|
|
1023
|
+
if (typeof e === 'string') {
|
|
1024
|
+
return e;
|
|
1025
|
+
}
|
|
1026
|
+
// fetch-mock and some network libs reject with { message } rather than Error
|
|
1027
|
+
if (e && _typeof$1(e) === 'object' && typeof e.message === 'string') {
|
|
1028
|
+
return e.message;
|
|
1029
|
+
}
|
|
1030
|
+
return fallback;
|
|
1031
|
+
};
|
|
1016
1032
|
|
|
1017
1033
|
var MessageType$1 = {
|
|
1018
1034
|
SessionStart: 1,
|
|
@@ -3086,7 +3102,6 @@ var mParticle = (function () {
|
|
|
3086
3102
|
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
3087
3103
|
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
3088
3104
|
IDENTITY_MISMATCH: 'IDENTITY_MISMATCH',
|
|
3089
|
-
ROKT_KIT_ATTACHED: 'ROKT_KIT_ATTACHED',
|
|
3090
3105
|
MP_DEPRECATED_METHOD_USAGE: 'MP_DEPRECATED_METHOD_USAGE'
|
|
3091
3106
|
};
|
|
3092
3107
|
var WSDKErrorSeverity = {
|
|
@@ -3235,7 +3250,7 @@ var mParticle = (function () {
|
|
|
3235
3250
|
try {
|
|
3236
3251
|
callback(result);
|
|
3237
3252
|
} catch (e) {
|
|
3238
|
-
logger.error('Error invoking search callback: ' + (
|
|
3253
|
+
logger.error('Error invoking search callback: ' + getErrorMessage(e));
|
|
3239
3254
|
}
|
|
3240
3255
|
};
|
|
3241
3256
|
cleanedKnownIdentities = Validators.removeFalsyIdentityValues({
|
|
@@ -3324,7 +3339,7 @@ var mParticle = (function () {
|
|
|
3324
3339
|
return [3 /*break*/, 10];
|
|
3325
3340
|
case 9:
|
|
3326
3341
|
e_2 = _a.sent();
|
|
3327
|
-
message = (e_2
|
|
3342
|
+
message = getErrorMessage(e_2);
|
|
3328
3343
|
reportMessage = 'Error sending search request: ' + message;
|
|
3329
3344
|
logger.error(reportMessage);
|
|
3330
3345
|
// Mirror the identity-route pattern in identityApiClient.ts: log to
|
|
@@ -3590,7 +3605,7 @@ var mParticle = (function () {
|
|
|
3590
3605
|
httpCode: HTTPCodes$3.loggingDisabledOrMissingAPIKey
|
|
3591
3606
|
});
|
|
3592
3607
|
} catch (e) {
|
|
3593
|
-
Logger.error('Error invoking search callback: ' + (
|
|
3608
|
+
Logger.error('Error invoking search callback: ' + getErrorMessage(e));
|
|
3594
3609
|
}
|
|
3595
3610
|
}
|
|
3596
3611
|
return;
|
|
@@ -7912,21 +7927,43 @@ var mParticle = (function () {
|
|
|
7912
7927
|
return AudienceManager;
|
|
7913
7928
|
}();
|
|
7914
7929
|
|
|
7915
|
-
var processReadyQueue = function processReadyQueue(readyQueue) {
|
|
7916
|
-
if (
|
|
7917
|
-
|
|
7930
|
+
var processReadyQueue = function processReadyQueue(readyQueue, logger) {
|
|
7931
|
+
if (isEmpty(readyQueue)) {
|
|
7932
|
+
return [];
|
|
7933
|
+
}
|
|
7934
|
+
// Without draining first, sync re-entry (cache-hit identify →
|
|
7935
|
+
// parseIdentityResponse → processReadyQueue) re-iterates the same array:
|
|
7936
|
+
// callers only replace `_preInit.readyQueue` with [] after we return, so the
|
|
7937
|
+
// nested call still sees every entry. That duplicates Identity/event calls
|
|
7938
|
+
// and can nest "Unable to compute proper mParticle function" wraps.
|
|
7939
|
+
// Splice the queue empty up front so a nested call observes [].
|
|
7940
|
+
var items = readyQueue.splice(0, readyQueue.length);
|
|
7941
|
+
// Isolate each item so one throw cannot abort the rest of this pass.
|
|
7942
|
+
// Drain-first already removed siblings from the shared queue; without a
|
|
7943
|
+
// per-item catch they would be lost forever when forEach aborts.
|
|
7944
|
+
items.forEach(function (readyQueueItem) {
|
|
7945
|
+
try {
|
|
7918
7946
|
if (isFunction(readyQueueItem)) {
|
|
7919
7947
|
readyQueueItem();
|
|
7920
7948
|
} else if (Array.isArray(readyQueueItem)) {
|
|
7921
7949
|
processPreloadedItem(readyQueueItem);
|
|
7922
7950
|
}
|
|
7923
|
-
})
|
|
7924
|
-
|
|
7951
|
+
} catch (e) {
|
|
7952
|
+
logger.error('Error processing ready queue item: ' + getErrorMessage(e));
|
|
7953
|
+
}
|
|
7954
|
+
});
|
|
7925
7955
|
return [];
|
|
7926
7956
|
};
|
|
7927
7957
|
var processPreloadedItem = function processPreloadedItem(readyQueueItem) {
|
|
7928
|
-
|
|
7958
|
+
// Operate on a copy so processPreloadedItem never mutates the caller's
|
|
7959
|
+
// queued item array (defensive; the queue itself is drained above).
|
|
7960
|
+
var args = readyQueueItem.slice();
|
|
7929
7961
|
var method = args.splice(0, 1)[0];
|
|
7962
|
+
// Skip malformed queue entries (empty array or non-string method) instead of
|
|
7963
|
+
// throwing an uncaught TypeError from method.split() below.
|
|
7964
|
+
if (typeof method !== 'string' || method.length === 0) {
|
|
7965
|
+
return;
|
|
7966
|
+
}
|
|
7930
7967
|
// if the first argument is a method on the base mParticle object, run it
|
|
7931
7968
|
if (typeof window !== 'undefined' && window.mParticle && window.mParticle[args[0]]) {
|
|
7932
7969
|
window.mParticle[method].apply(window.mParticle, args);
|
|
@@ -8939,7 +8976,7 @@ var mParticle = (function () {
|
|
|
8939
8976
|
}
|
|
8940
8977
|
mpInstance._Store.isInitialized = true;
|
|
8941
8978
|
mpInstance._RoktManager.onIdentityComplete();
|
|
8942
|
-
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
|
|
8979
|
+
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue, mpInstance.Logger);
|
|
8943
8980
|
};
|
|
8944
8981
|
|
|
8945
8982
|
// send a user identity change request on identify, login, logout, modify when any values change.
|
|
@@ -9965,7 +10002,7 @@ var mParticle = (function () {
|
|
|
9965
10002
|
return [3 /*break*/, 14];
|
|
9966
10003
|
case 13:
|
|
9967
10004
|
e_2 = _b.sent();
|
|
9968
|
-
errorMessage = e_2
|
|
10005
|
+
errorMessage = getErrorMessage(e_2);
|
|
9969
10006
|
Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
9970
10007
|
invokeAliasCallback(aliasCallback, HTTPCodes$1.noHttpCoverage, errorMessage);
|
|
9971
10008
|
return [3 /*break*/, 14];
|
|
@@ -10097,7 +10134,7 @@ var mParticle = (function () {
|
|
|
10097
10134
|
requestCount = mpInstance._Store.identifyRequestCount;
|
|
10098
10135
|
mpInstance.captureTiming("".concat(requestCount, "-identityRequestEnd"));
|
|
10099
10136
|
}
|
|
10100
|
-
errorMessage = err_1
|
|
10137
|
+
errorMessage = getErrorMessage(err_1);
|
|
10101
10138
|
msg = 'Error sending identity request to servers' + ' - ' + errorMessage;
|
|
10102
10139
|
Logger.error(msg);
|
|
10103
10140
|
errorReporter === null || errorReporter === void 0 ? void 0 : errorReporter.report({
|
|
@@ -10436,6 +10473,7 @@ var mParticle = (function () {
|
|
|
10436
10473
|
return IntegrationCapture;
|
|
10437
10474
|
}();
|
|
10438
10475
|
|
|
10476
|
+
var PASSBACK_CONVERSION_TRACKING_ID = 'passbackconversiontrackingid';
|
|
10439
10477
|
var ON_SHOPPABLE_ADS_READY_METHOD = 'onShoppableAdsReady';
|
|
10440
10478
|
// The purpose of this class is to create a link between the Core mParticle SDK and the
|
|
10441
10479
|
// Rokt Web SDK via a Web Kit.
|
|
@@ -10478,7 +10516,7 @@ var mParticle = (function () {
|
|
|
10478
10516
|
*
|
|
10479
10517
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
10480
10518
|
*/
|
|
10481
|
-
RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, store, logger, options, captureTiming, errorReporter, loggingService) {
|
|
10519
|
+
RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, store, logger, options, captureTiming, errorReporter, loggingService, integrationCapture) {
|
|
10482
10520
|
var _a, _b;
|
|
10483
10521
|
var _c = roktConfig || {},
|
|
10484
10522
|
userAttributeFilters = _c.userAttributeFilters,
|
|
@@ -10493,6 +10531,7 @@ var mParticle = (function () {
|
|
|
10493
10531
|
this.errorReporter = errorReporter;
|
|
10494
10532
|
this.loggingService = loggingService;
|
|
10495
10533
|
this.captureTiming = captureTiming;
|
|
10534
|
+
this.integrationCapture = integrationCapture;
|
|
10496
10535
|
(_b = this.captureTiming) === null || _b === void 0 ? void 0 : _b.call(this, PerformanceMarkType.JointSdkRoktKitInit);
|
|
10497
10536
|
this.filters = {
|
|
10498
10537
|
userAttributeFilters: userAttributeFilters,
|
|
@@ -10531,7 +10570,7 @@ var mParticle = (function () {
|
|
|
10531
10570
|
configurable: true
|
|
10532
10571
|
});
|
|
10533
10572
|
RoktManager.prototype.attachKit = function (kit) {
|
|
10534
|
-
var _a, _b, _c, _d
|
|
10573
|
+
var _a, _b, _c, _d;
|
|
10535
10574
|
this.kit = kit;
|
|
10536
10575
|
if ((_a = kit.settings) === null || _a === void 0 ? void 0 : _a.accountId) {
|
|
10537
10576
|
this.store.setRoktAccountId(kit.settings.accountId);
|
|
@@ -10539,15 +10578,11 @@ var mParticle = (function () {
|
|
|
10539
10578
|
if (kit.integrationName) {
|
|
10540
10579
|
(_b = this.store) === null || _b === void 0 ? void 0 : _b.setIntegrationName(kit.integrationName);
|
|
10541
10580
|
}
|
|
10542
|
-
(_c = this.loggingService) === null || _c === void 0 ? void 0 : _c.log({
|
|
10543
|
-
message: 'RoktManager: Kit attached, Rokt is ready',
|
|
10544
|
-
code: ErrorCodes.ROKT_KIT_ATTACHED
|
|
10545
|
-
});
|
|
10546
10581
|
this.processMessageQueue();
|
|
10547
10582
|
try {
|
|
10548
|
-
(
|
|
10583
|
+
(_c = this.onReadyCallback) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
10549
10584
|
} catch (e) {
|
|
10550
|
-
(
|
|
10585
|
+
(_d = this.logger) === null || _d === void 0 ? void 0 : _d.error('RoktManager: Error in onReadyCallback: ' + e);
|
|
10551
10586
|
}
|
|
10552
10587
|
};
|
|
10553
10588
|
/**
|
|
@@ -10566,11 +10601,11 @@ var mParticle = (function () {
|
|
|
10566
10601
|
* });
|
|
10567
10602
|
*/
|
|
10568
10603
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
10569
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10604
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
10570
10605
|
return __awaiter(this, void 0, void 0, function () {
|
|
10571
|
-
var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg,
|
|
10606
|
+
var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg, finalUserIdentities, enrichedAttributes, hashedEmail, capturedAttrs, passbackId, enrichedOptions;
|
|
10572
10607
|
var _this = this;
|
|
10573
|
-
return __generator(this, function (
|
|
10608
|
+
return __generator(this, function (_o) {
|
|
10574
10609
|
(_a = this.captureTiming) === null || _a === void 0 ? void 0 : _a.call(this, PerformanceMarkType.JointSdkSelectPlacements);
|
|
10575
10610
|
// Queue if kit isn't ready OR if identity is in flight
|
|
10576
10611
|
if (!this.isReady() || ((_b = this.store) === null || _b === void 0 ? void 0 : _b.identityCallInFlight)) {
|
|
@@ -10636,8 +10671,7 @@ var mParticle = (function () {
|
|
|
10636
10671
|
_this.processMessageQueue();
|
|
10637
10672
|
});
|
|
10638
10673
|
} catch (error) {
|
|
10639
|
-
|
|
10640
|
-
this.logger.error('Background identify threw an error: ' + errorMessage);
|
|
10674
|
+
this.logger.error('Background identify threw an error: ' + getErrorMessage(error));
|
|
10641
10675
|
}
|
|
10642
10676
|
}
|
|
10643
10677
|
finalUserIdentities = __assign(__assign({}, currentUserIdentities), newIdentities);
|
|
@@ -10656,6 +10690,14 @@ var mParticle = (function () {
|
|
|
10656
10690
|
enrichedAttributes.emailsha256 = hashedEmail;
|
|
10657
10691
|
}
|
|
10658
10692
|
}
|
|
10693
|
+
if (!enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID]) {
|
|
10694
|
+
(_k = this.integrationCapture) === null || _k === void 0 ? void 0 : _k.capture();
|
|
10695
|
+
capturedAttrs = (_l = this.integrationCapture) === null || _l === void 0 ? void 0 : _l.getClickIdsAsIntegrationAttributes();
|
|
10696
|
+
passbackId = (_m = capturedAttrs === null || capturedAttrs === void 0 ? void 0 : capturedAttrs[PARTNER_MODULE_IDS.Rokt]) === null || _m === void 0 ? void 0 : _m[PASSBACK_CONVERSION_TRACKING_ID];
|
|
10697
|
+
if (passbackId) {
|
|
10698
|
+
enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID] = passbackId;
|
|
10699
|
+
}
|
|
10700
|
+
}
|
|
10659
10701
|
this.filters.filteredUser = this.currentUser || this.filters.filteredUser || null;
|
|
10660
10702
|
enrichedOptions = __assign(__assign({}, options), {
|
|
10661
10703
|
attributes: enrichedAttributes
|
|
@@ -10679,7 +10721,7 @@ var mParticle = (function () {
|
|
|
10679
10721
|
*/
|
|
10680
10722
|
RoktManager.prototype.hashAttributes = function (attributes) {
|
|
10681
10723
|
return __awaiter(this, void 0, void 0, function () {
|
|
10682
|
-
var keys, hashPromises, results, hashedAttributes, _i, results_1, _a, key, attributeValue, hashedValue, error_1
|
|
10724
|
+
var keys, hashPromises, results, hashedAttributes, _i, results_1, _a, key, attributeValue, hashedValue, error_1;
|
|
10683
10725
|
var _this = this;
|
|
10684
10726
|
return __generator(this, function (_b) {
|
|
10685
10727
|
switch (_b.label) {
|
|
@@ -10725,8 +10767,7 @@ var mParticle = (function () {
|
|
|
10725
10767
|
return [2 /*return*/, hashedAttributes];
|
|
10726
10768
|
case 2:
|
|
10727
10769
|
error_1 = _b.sent();
|
|
10728
|
-
|
|
10729
|
-
this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(errorMessage));
|
|
10770
|
+
this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(getErrorMessage(error_1)));
|
|
10730
10771
|
return [2 /*return*/, {}];
|
|
10731
10772
|
case 3:
|
|
10732
10773
|
return [2 /*return*/];
|
|
@@ -10743,8 +10784,7 @@ var mParticle = (function () {
|
|
|
10743
10784
|
try {
|
|
10744
10785
|
this.kit.setExtensionData(extensionData);
|
|
10745
10786
|
} catch (error) {
|
|
10746
|
-
|
|
10747
|
-
throw new Error('Error setting extension data: ' + errorMessage);
|
|
10787
|
+
throw new Error('Error setting extension data: ' + getErrorMessage(error));
|
|
10748
10788
|
}
|
|
10749
10789
|
};
|
|
10750
10790
|
RoktManager.prototype.use = function (name) {
|
|
@@ -10765,8 +10805,7 @@ var mParticle = (function () {
|
|
|
10765
10805
|
try {
|
|
10766
10806
|
this.kit.onShoppableAdsReady(callback);
|
|
10767
10807
|
} catch (error) {
|
|
10768
|
-
|
|
10769
|
-
this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(errorMessage));
|
|
10808
|
+
this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(getErrorMessage(error)));
|
|
10770
10809
|
}
|
|
10771
10810
|
};
|
|
10772
10811
|
RoktManager.prototype.flushOnShoppableAdsReadyMessageQueue = function (kit) {
|
|
@@ -10794,7 +10833,7 @@ var mParticle = (function () {
|
|
|
10794
10833
|
*/
|
|
10795
10834
|
RoktManager.prototype.hashSha256 = function (attribute) {
|
|
10796
10835
|
return __awaiter(this, void 0, void 0, function () {
|
|
10797
|
-
var normalizedValue, error_2
|
|
10836
|
+
var normalizedValue, error_2;
|
|
10798
10837
|
return __generator(this, function (_a) {
|
|
10799
10838
|
switch (_a.label) {
|
|
10800
10839
|
case 0:
|
|
@@ -10811,8 +10850,7 @@ var mParticle = (function () {
|
|
|
10811
10850
|
return [2 /*return*/, _a.sent()];
|
|
10812
10851
|
case 3:
|
|
10813
10852
|
error_2 = _a.sent();
|
|
10814
|
-
|
|
10815
|
-
this.logger.error("Failed to hashSha256, returning undefined: ".concat(errorMessage));
|
|
10853
|
+
this.logger.error("Failed to hashSha256, returning undefined: ".concat(getErrorMessage(error_2)));
|
|
10816
10854
|
return [2 /*return*/, undefined];
|
|
10817
10855
|
case 4:
|
|
10818
10856
|
return [2 /*return*/];
|
|
@@ -10893,8 +10931,7 @@ var mParticle = (function () {
|
|
|
10893
10931
|
var reject = message.reject;
|
|
10894
10932
|
var handleError = function handleError(error) {
|
|
10895
10933
|
var _a;
|
|
10896
|
-
|
|
10897
|
-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(errorMessage));
|
|
10934
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(getErrorMessage(error)));
|
|
10898
10935
|
if (reject) {
|
|
10899
10936
|
reject(error);
|
|
10900
10937
|
}
|
|
@@ -11132,7 +11169,7 @@ var mParticle = (function () {
|
|
|
11132
11169
|
}
|
|
11133
11170
|
if (((_b = self._Store) === null || _b === void 0 ? void 0 : _b.identityCallFailed) && ((_c = self._RoktManager) === null || _c === void 0 ? void 0 : _c.isReady())) {
|
|
11134
11171
|
self._RoktManager.processMessageQueue();
|
|
11135
|
-
self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
|
|
11172
|
+
self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue, self.Logger);
|
|
11136
11173
|
}
|
|
11137
11174
|
};
|
|
11138
11175
|
/**
|
|
@@ -11145,7 +11182,7 @@ var mParticle = (function () {
|
|
|
11145
11182
|
}
|
|
11146
11183
|
var noFunctionalWithoutId = ((_b = self._CookieConsentManager) === null || _b === void 0 ? void 0 : _b.getNoFunctional()) && !hasExplicitIdentifier(self._Store);
|
|
11147
11184
|
if (noFunctionalWithoutId) {
|
|
11148
|
-
self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
|
|
11185
|
+
self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue, self.Logger);
|
|
11149
11186
|
}
|
|
11150
11187
|
};
|
|
11151
11188
|
// required for forwarders once they reference the mparticle instance
|
|
@@ -12145,7 +12182,7 @@ var mParticle = (function () {
|
|
|
12145
12182
|
domain: config === null || config === void 0 ? void 0 : config.domain
|
|
12146
12183
|
};
|
|
12147
12184
|
// https://go.mparticle.com/work/SQDSDKS-7339
|
|
12148
|
-
mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance._Store, mpInstance.Logger, roktOptions, mpInstance.captureTiming, mpInstance._ErrorReportingDispatcher, mpInstance._LoggingDispatcher);
|
|
12185
|
+
mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance._Store, mpInstance.Logger, roktOptions, mpInstance.captureTiming, mpInstance._ErrorReportingDispatcher, mpInstance._LoggingDispatcher, mpInstance._IntegrationCapture);
|
|
12149
12186
|
}
|
|
12150
12187
|
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
12151
12188
|
mpInstance._Forwarders.processPixelConfigs(config);
|
|
@@ -12162,7 +12199,7 @@ var mParticle = (function () {
|
|
|
12162
12199
|
// Sync $NoTargeting user attribute on re-init when no identity call is made
|
|
12163
12200
|
// if for some reason there was a change in boolean between init calls
|
|
12164
12201
|
(_c = mpInstance._CookieConsentManager) === null || _c === void 0 ? void 0 : _c.syncNoTargetingAttribute(mpInstance.Identity.getCurrentUser());
|
|
12165
|
-
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
|
|
12202
|
+
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue, mpInstance.Logger);
|
|
12166
12203
|
}
|
|
12167
12204
|
// For noFunctional sessions with no identity, drain any pre-init ready callbacks
|
|
12168
12205
|
// that were queued before _CookieConsentManager was available to evaluate the condition.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IPixelConfiguration } from './cookieSyncManager';
|
|
2
2
|
import { MPForwarder } from './forwarders.interfaces';
|
|
3
3
|
import { IntegrationDelays } from './mp-instance';
|
|
4
|
+
import { SDKLoggerApi } from './sdkRuntimeModels';
|
|
4
5
|
export interface IPreInit {
|
|
5
6
|
readyQueue: Function[] | any[];
|
|
6
7
|
integrationDelays: IntegrationDelays;
|
|
@@ -8,4 +9,4 @@ export interface IPreInit {
|
|
|
8
9
|
pixelConfigurations?: IPixelConfiguration[];
|
|
9
10
|
isDevelopmentMode?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare const processReadyQueue: (readyQueue: any) => Function[];
|
|
12
|
+
export declare const processReadyQueue: (readyQueue: any, logger: SDKLoggerApi) => Function[];
|
|
@@ -4,7 +4,6 @@ export declare const ErrorCodes: {
|
|
|
4
4
|
readonly UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION";
|
|
5
5
|
readonly IDENTITY_REQUEST: "IDENTITY_REQUEST";
|
|
6
6
|
readonly IDENTITY_MISMATCH: "IDENTITY_MISMATCH";
|
|
7
|
-
readonly ROKT_KIT_ATTACHED: "ROKT_KIT_ATTACHED";
|
|
8
7
|
readonly MP_DEPRECATED_METHOD_USAGE: "MP_DEPRECATED_METHOD_USAGE";
|
|
9
8
|
};
|
|
10
9
|
export type ErrorCodes = valueof<typeof ErrorCodes>;
|
|
@@ -7,6 +7,7 @@ import { SDKLoggerApi } from "./sdkRuntimeModels";
|
|
|
7
7
|
import { IStore, LocalSessionAttributes } from "./store";
|
|
8
8
|
import { IErrorReportingService, ILoggingService } from "./reporting/types";
|
|
9
9
|
import { IRoktLauncherOptions } from "./roktLauncherOptions";
|
|
10
|
+
import IntegrationCapture from "./integrationCapture";
|
|
10
11
|
export type RoktAttributeValueArray = Array<string | number | boolean>;
|
|
11
12
|
export type RoktAttributeValueType = string | number | boolean | undefined | null;
|
|
12
13
|
export type RoktAttributeValue = RoktAttributeValueType | RoktAttributeValueArray;
|
|
@@ -82,6 +83,7 @@ export default class RoktManager {
|
|
|
82
83
|
private domain?;
|
|
83
84
|
private mappedEmailShaIdentityType?;
|
|
84
85
|
private captureTiming?;
|
|
86
|
+
private integrationCapture?;
|
|
85
87
|
private onReadyCallback;
|
|
86
88
|
private initialized;
|
|
87
89
|
private isShoppableAdsLoaded;
|
|
@@ -103,7 +105,7 @@ export default class RoktManager {
|
|
|
103
105
|
*
|
|
104
106
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
105
107
|
*/
|
|
106
|
-
init(roktConfig: IKitConfigs, filteredUser: IMParticleUser, identityService: SDKIdentityApi, store: IStore, logger?: SDKLoggerApi, options?: IRoktOptions, captureTiming?: (metricsName: string) => void, errorReporter?: IErrorReportingService, loggingService?: ILoggingService): void;
|
|
108
|
+
init(roktConfig: IKitConfigs, filteredUser: IMParticleUser, identityService: SDKIdentityApi, store: IStore, logger?: SDKLoggerApi, options?: IRoktOptions, captureTiming?: (metricsName: string) => void, errorReporter?: IErrorReportingService, loggingService?: ILoggingService, integrationCapture?: IntegrationCapture): void;
|
|
107
109
|
get isInitialized(): boolean;
|
|
108
110
|
attachKit(kit: IRoktKit): void;
|
|
109
111
|
/**
|
|
@@ -80,4 +80,5 @@ declare const obfuscateData: (value: any) => any;
|
|
|
80
80
|
*/
|
|
81
81
|
declare const obfuscateDevData: (data: any, isDevelopmentMode?: boolean) => any;
|
|
82
82
|
declare function extend(...args: any[]): any;
|
|
83
|
-
|
|
83
|
+
declare const getErrorMessage: (e: unknown, fallback?: string) => string;
|
|
84
|
+
export { createCookieString, revertCookieString, createCookieSyncUrl, valueof, AttributeValue, converted, decoded, obfuscateDevData, filterDictionaryWithHash, findKeyInObject, generateDeprecationMessage, generateHash, generateUniqueId, getErrorMessage, getRampNumber, inArray, isObject, isStringOrNumber, obfuscateData, parseConfig, parseNumber, parseSettingsString, parseStringOrNumber, replaceCommasWithPipes, replacePipesWithCommas, replaceApostrophesWithQuotes, replaceQuotesWithApostrophes, returnConvertedBoolean, toDataPlanSlug, isString, isNumber, isFunction, isDataPlanSlug, isEmpty, isValidAttributeValue, isValidCustomFlagProperty, mergeObjects, moveElementToEnd, queryStringParser, getCookies, getHref, replaceMPID, replaceAmpWithAmpersand, extend, };
|
package/package.json
CHANGED
package/src/identity/search.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Constants, { HTTP_OK, HTTP_NOT_FOUND } from '../constants';
|
|
2
2
|
import { SDKLoggerApi } from '../sdkRuntimeModels';
|
|
3
|
-
import { Environment, isFunction } from '../utils';
|
|
3
|
+
import { Environment, isFunction, getErrorMessage } from '../utils';
|
|
4
4
|
import {
|
|
5
5
|
AsyncUploader,
|
|
6
6
|
FetchUploader,
|
|
@@ -111,8 +111,7 @@ export const sendSearchRequest = async (
|
|
|
111
111
|
callback(result);
|
|
112
112
|
} catch (e) {
|
|
113
113
|
logger.error(
|
|
114
|
-
'Error invoking search callback: ' +
|
|
115
|
-
((e as Error)?.message || String(e)),
|
|
114
|
+
'Error invoking search callback: ' + getErrorMessage(e),
|
|
116
115
|
);
|
|
117
116
|
}
|
|
118
117
|
};
|
|
@@ -216,7 +215,7 @@ export const sendSearchRequest = async (
|
|
|
216
215
|
|
|
217
216
|
safeInvoke({ httpCode: response.status, body });
|
|
218
217
|
} catch (e) {
|
|
219
|
-
const message = (e
|
|
218
|
+
const message = getErrorMessage(e);
|
|
220
219
|
const reportMessage = 'Error sending search request: ' + message;
|
|
221
220
|
logger.error(reportMessage);
|
|
222
221
|
// Mirror the identity-route pattern in identityApiClient.ts: log to
|
package/src/identity-utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Constants, { ONE_DAY_IN_SECONDS, MILLIS_IN_ONE_SEC } from './constants';
|
|
2
|
-
import { Dictionary, Environment, parseNumber, isObject, generateHash, generateUniqueId, isEmpty, isFunction } from './utils';
|
|
2
|
+
import { Dictionary, Environment, parseNumber, isObject, generateHash, generateUniqueId, isEmpty, isFunction, getErrorMessage } from './utils';
|
|
3
3
|
import { BaseVault } from './vault';
|
|
4
4
|
import Types from './types';
|
|
5
5
|
import {
|
|
@@ -414,8 +414,7 @@ export const executeSearchRequest = (
|
|
|
414
414
|
});
|
|
415
415
|
} catch (e) {
|
|
416
416
|
Logger.error(
|
|
417
|
-
'Error invoking search callback: ' +
|
|
418
|
-
((e as Error)?.message || String(e)),
|
|
417
|
+
'Error invoking search callback: ' + getErrorMessage(e),
|
|
419
418
|
);
|
|
420
419
|
}
|
|
421
420
|
}
|
package/src/identity.js
CHANGED
|
@@ -1657,7 +1657,8 @@ export default function Identity(mpInstance) {
|
|
|
1657
1657
|
mpInstance._RoktManager.onIdentityComplete();
|
|
1658
1658
|
|
|
1659
1659
|
mpInstance._preInit.readyQueue = processReadyQueue(
|
|
1660
|
-
mpInstance._preInit.readyQueue
|
|
1660
|
+
mpInstance._preInit.readyQueue,
|
|
1661
|
+
mpInstance.Logger
|
|
1661
1662
|
);
|
|
1662
1663
|
};
|
|
1663
1664
|
|
package/src/identityApiClient.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
IFetchPayload,
|
|
7
7
|
} from './uploaders';
|
|
8
8
|
import { CACHE_HEADER } from './identity-utils';
|
|
9
|
-
import { obfuscateData, parseNumber, valueof } from './utils';
|
|
9
|
+
import { obfuscateData, parseNumber, valueof, getErrorMessage } from './utils';
|
|
10
10
|
import {
|
|
11
11
|
IAliasCallback,
|
|
12
12
|
IAliasRequest,
|
|
@@ -175,7 +175,7 @@ export default function IdentityAPIClient(
|
|
|
175
175
|
Logger.verbose(message);
|
|
176
176
|
invokeAliasCallback(aliasCallback, response.status, errorMessage);
|
|
177
177
|
} catch (e) {
|
|
178
|
-
const errorMessage = (e
|
|
178
|
+
const errorMessage = getErrorMessage(e);
|
|
179
179
|
Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
180
180
|
invokeAliasCallback(
|
|
181
181
|
aliasCallback,
|
|
@@ -338,7 +338,7 @@ export default function IdentityAPIClient(
|
|
|
338
338
|
mpInstance.captureTiming(`${requestCount}-identityRequestEnd`);
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
const errorMessage = (err
|
|
341
|
+
const errorMessage = getErrorMessage(err);
|
|
342
342
|
const msg = 'Error sending identity request to servers' + ' - ' + errorMessage;
|
|
343
343
|
Logger.error(msg);
|
|
344
344
|
errorReporter?.report({
|
package/src/mp-instance.ts
CHANGED
|
@@ -162,7 +162,10 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
162
162
|
|
|
163
163
|
if (self._Store?.identityCallFailed && self._RoktManager?.isReady()) {
|
|
164
164
|
self._RoktManager.processMessageQueue();
|
|
165
|
-
self._preInit.readyQueue = processReadyQueue(
|
|
165
|
+
self._preInit.readyQueue = processReadyQueue(
|
|
166
|
+
self._preInit.readyQueue,
|
|
167
|
+
self.Logger
|
|
168
|
+
);
|
|
166
169
|
}
|
|
167
170
|
};
|
|
168
171
|
|
|
@@ -179,7 +182,10 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
179
182
|
!hasExplicitIdentifier(self._Store);
|
|
180
183
|
|
|
181
184
|
if (noFunctionalWithoutId) {
|
|
182
|
-
self._preInit.readyQueue = processReadyQueue(
|
|
185
|
+
self._preInit.readyQueue = processReadyQueue(
|
|
186
|
+
self._preInit.readyQueue,
|
|
187
|
+
self.Logger
|
|
188
|
+
);
|
|
183
189
|
}
|
|
184
190
|
};
|
|
185
191
|
|
|
@@ -1560,7 +1566,8 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1560
1566
|
roktOptions,
|
|
1561
1567
|
mpInstance.captureTiming,
|
|
1562
1568
|
mpInstance._ErrorReportingDispatcher,
|
|
1563
|
-
mpInstance._LoggingDispatcher
|
|
1569
|
+
mpInstance._LoggingDispatcher,
|
|
1570
|
+
mpInstance._IntegrationCapture,
|
|
1564
1571
|
);
|
|
1565
1572
|
}
|
|
1566
1573
|
|
|
@@ -1598,7 +1605,8 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1598
1605
|
);
|
|
1599
1606
|
|
|
1600
1607
|
mpInstance._preInit.readyQueue = processReadyQueue(
|
|
1601
|
-
mpInstance._preInit.readyQueue
|
|
1608
|
+
mpInstance._preInit.readyQueue,
|
|
1609
|
+
mpInstance.Logger
|
|
1602
1610
|
);
|
|
1603
1611
|
}
|
|
1604
1612
|
|
package/src/pre-init-utils.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IPixelConfiguration } from './cookieSyncManager';
|
|
2
2
|
import { MPForwarder } from './forwarders.interfaces';
|
|
3
3
|
import { IntegrationDelays } from './mp-instance';
|
|
4
|
-
import {
|
|
4
|
+
import { SDKLoggerApi } from './sdkRuntimeModels';
|
|
5
|
+
import { isEmpty, isFunction, getErrorMessage } from './utils';
|
|
5
6
|
|
|
6
7
|
export interface IPreInit {
|
|
7
8
|
readyQueue: Function[] | any[];
|
|
@@ -11,23 +12,54 @@ export interface IPreInit {
|
|
|
11
12
|
isDevelopmentMode?: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export const processReadyQueue = (
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export const processReadyQueue = (
|
|
16
|
+
readyQueue,
|
|
17
|
+
logger: SDKLoggerApi
|
|
18
|
+
): Function[] => {
|
|
19
|
+
if (isEmpty(readyQueue)) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Without draining first, sync re-entry (cache-hit identify →
|
|
24
|
+
// parseIdentityResponse → processReadyQueue) re-iterates the same array:
|
|
25
|
+
// callers only replace `_preInit.readyQueue` with [] after we return, so the
|
|
26
|
+
// nested call still sees every entry. That duplicates Identity/event calls
|
|
27
|
+
// and can nest "Unable to compute proper mParticle function" wraps.
|
|
28
|
+
// Splice the queue empty up front so a nested call observes [].
|
|
29
|
+
const items = readyQueue.splice(0, readyQueue.length);
|
|
30
|
+
|
|
31
|
+
// Isolate each item so one throw cannot abort the rest of this pass.
|
|
32
|
+
// Drain-first already removed siblings from the shared queue; without a
|
|
33
|
+
// per-item catch they would be lost forever when forEach aborts.
|
|
34
|
+
items.forEach(readyQueueItem => {
|
|
35
|
+
try {
|
|
17
36
|
if (isFunction(readyQueueItem)) {
|
|
18
37
|
readyQueueItem();
|
|
19
38
|
} else if (Array.isArray(readyQueueItem)) {
|
|
20
39
|
processPreloadedItem(readyQueueItem);
|
|
21
40
|
}
|
|
22
|
-
})
|
|
23
|
-
|
|
41
|
+
} catch (e) {
|
|
42
|
+
logger.error(
|
|
43
|
+
'Error processing ready queue item: ' + getErrorMessage(e)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
24
48
|
return [];
|
|
25
49
|
};
|
|
26
50
|
|
|
27
51
|
const processPreloadedItem = (readyQueueItem): void => {
|
|
28
|
-
|
|
52
|
+
// Operate on a copy so processPreloadedItem never mutates the caller's
|
|
53
|
+
// queued item array (defensive; the queue itself is drained above).
|
|
54
|
+
const args = readyQueueItem.slice();
|
|
29
55
|
const method = args.splice(0, 1)[0];
|
|
30
56
|
|
|
57
|
+
// Skip malformed queue entries (empty array or non-string method) instead of
|
|
58
|
+
// throwing an uncaught TypeError from method.split() below.
|
|
59
|
+
if (typeof method !== 'string' || method.length === 0) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
31
63
|
// if the first argument is a method on the base mParticle object, run it
|
|
32
64
|
if (typeof window !== 'undefined' && window.mParticle && window.mParticle[args[0]]) {
|
|
33
65
|
window.mParticle[method].apply(window.mParticle, args);
|
package/src/reporting/types.ts
CHANGED
|
@@ -5,7 +5,6 @@ export const ErrorCodes = {
|
|
|
5
5
|
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
6
6
|
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
7
7
|
IDENTITY_MISMATCH: 'IDENTITY_MISMATCH',
|
|
8
|
-
ROKT_KIT_ATTACHED: 'ROKT_KIT_ATTACHED',
|
|
9
8
|
MP_DEPRECATED_METHOD_USAGE: 'MP_DEPRECATED_METHOD_USAGE',
|
|
10
9
|
} as const;
|
|
11
10
|
|