@mparticle/web-sdk 2.59.0 → 2.60.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 +34 -31
- package/dist/mparticle.esm.js +34 -31
- package/dist/mparticle.js +141 -84
- package/package.json +1 -1
- package/src/batchUploader.ts +19 -25
- package/src/identityApiClient.ts +15 -5
- package/src/logger.ts +4 -0
- package/src/mp-instance.ts +3 -7
- package/src/mparticle-instance-manager.ts +1 -1
- package/src/roktManager.ts +12 -4
- package/src/sdkRuntimeModels.ts +1 -0
- package/src/utils.ts +63 -2
- package/src/vault.ts +9 -37
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.60.1";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -419,6 +419,16 @@ var mParticle = (function () {
|
|
|
419
419
|
var HTTP_BAD_REQUEST = 400;
|
|
420
420
|
var HTTP_SERVER_ERROR = 500;
|
|
421
421
|
|
|
422
|
+
function _typeof$1(o) {
|
|
423
|
+
"@babel/helpers - typeof";
|
|
424
|
+
|
|
425
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
426
|
+
return typeof o;
|
|
427
|
+
} : function (o) {
|
|
428
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
429
|
+
}, _typeof$1(o);
|
|
430
|
+
}
|
|
431
|
+
|
|
422
432
|
/******************************************************************************
|
|
423
433
|
Copyright (c) Microsoft Corporation.
|
|
424
434
|
|
|
@@ -855,6 +865,63 @@ var mParticle = (function () {
|
|
|
855
865
|
return kitConfig.name === moduleName && kitConfig.moduleId === moduleId;
|
|
856
866
|
})) || null;
|
|
857
867
|
};
|
|
868
|
+
/**
|
|
869
|
+
* Obfuscates an object by replacing all primitive values with their type names,
|
|
870
|
+
* while preserving the structure of nested objects and arrays.
|
|
871
|
+
* This is useful for logging data structures without exposing PII.
|
|
872
|
+
*
|
|
873
|
+
* @param value - The value to obfuscate
|
|
874
|
+
* @returns The obfuscated value with types instead of actual values
|
|
875
|
+
*
|
|
876
|
+
* @example
|
|
877
|
+
* obfuscateData({ email: 'user@email.com', age: 30 })
|
|
878
|
+
* // Returns: { email: 'string', age: 'number' }
|
|
879
|
+
*
|
|
880
|
+
* obfuscateData({ tags: ['premium', 'verified'] })
|
|
881
|
+
* // Returns: { tags: ['string', 'string'] }
|
|
882
|
+
*/
|
|
883
|
+
var obfuscateData = function obfuscateData(value) {
|
|
884
|
+
// Preserve null and undefined
|
|
885
|
+
if (value === null || value === undefined) {
|
|
886
|
+
return value;
|
|
887
|
+
}
|
|
888
|
+
// Handle arrays - recursively obfuscate each element
|
|
889
|
+
if (Array.isArray(value)) {
|
|
890
|
+
return value.map(function (item) {
|
|
891
|
+
return obfuscateData(item);
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
// Handle objects - recursively obfuscate each property
|
|
895
|
+
if (isObject(value)) {
|
|
896
|
+
var obfuscated = {};
|
|
897
|
+
for (var key in value) {
|
|
898
|
+
if (value.hasOwnProperty(key)) {
|
|
899
|
+
obfuscated[key] = obfuscateData(value[key]);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return obfuscated;
|
|
903
|
+
}
|
|
904
|
+
// For primitives and other types, return the type as a string
|
|
905
|
+
return _typeof$1(value);
|
|
906
|
+
};
|
|
907
|
+
/**
|
|
908
|
+
* For verbose logging: returns raw data when isDevelopmentMode is true, else obfuscated data.
|
|
909
|
+
* Used when logging payloads so PII is not exposed in production.
|
|
910
|
+
*
|
|
911
|
+
* @param data - The value to log
|
|
912
|
+
* @param isDevelopmentMode - When true, returns data unchanged, when false or undefined, returns obfuscated data
|
|
913
|
+
* @returns Raw data when isDevelopmentMode is true, otherwise obfuscated structure
|
|
914
|
+
*
|
|
915
|
+
* @example
|
|
916
|
+
* obfuscateDevData({ email: 'user@email.com' }, true)
|
|
917
|
+
* // Returns: { email: 'user@email.com' }
|
|
918
|
+
*
|
|
919
|
+
* obfuscateDevData({ email: 'user@email.com' }, false)
|
|
920
|
+
* // Returns: { email: 'string' }
|
|
921
|
+
*/
|
|
922
|
+
var obfuscateDevData = function obfuscateDevData(data, isDevelopmentMode) {
|
|
923
|
+
return isDevelopmentMode ? data : obfuscateData(data);
|
|
924
|
+
};
|
|
858
925
|
|
|
859
926
|
var MessageType$1 = {
|
|
860
927
|
SessionStart: 1,
|
|
@@ -1234,16 +1301,6 @@ var mParticle = (function () {
|
|
|
1234
1301
|
Environment: Constants.Environment
|
|
1235
1302
|
};
|
|
1236
1303
|
|
|
1237
|
-
function _typeof$1(o) {
|
|
1238
|
-
"@babel/helpers - typeof";
|
|
1239
|
-
|
|
1240
|
-
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
1241
|
-
return typeof o;
|
|
1242
|
-
} : function (o) {
|
|
1243
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
1244
|
-
}, _typeof$1(o);
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
1304
|
var SDKProductActionType;
|
|
1248
1305
|
(function (SDKProductActionType) {
|
|
1249
1306
|
SDKProductActionType[SDKProductActionType["Unknown"] = 0] = "Unknown";
|
|
@@ -2138,18 +2195,11 @@ var mParticle = (function () {
|
|
|
2138
2195
|
/**
|
|
2139
2196
|
*
|
|
2140
2197
|
* @param {string} storageKey the local storage key string
|
|
2141
|
-
* @param {Storage} Web API Storage object that is being used
|
|
2142
|
-
* @param {IVaultOptions} options A Dictionary of IVaultOptions
|
|
2198
|
+
* @param {Storage} storageObject Web API Storage object that is being used
|
|
2143
2199
|
*/
|
|
2144
|
-
function BaseVault(storageKey, storageObject
|
|
2200
|
+
function BaseVault(storageKey, storageObject) {
|
|
2145
2201
|
this._storageKey = storageKey;
|
|
2146
2202
|
this.storageObject = storageObject;
|
|
2147
|
-
// Add a fake logger in case one is not provided or needed
|
|
2148
|
-
this.logger = (options === null || options === void 0 ? void 0 : options.logger) || {
|
|
2149
|
-
verbose: function verbose() {},
|
|
2150
|
-
warning: function warning() {},
|
|
2151
|
-
error: function error() {}
|
|
2152
|
-
};
|
|
2153
2203
|
this.contents = this.retrieve();
|
|
2154
2204
|
}
|
|
2155
2205
|
/**
|
|
@@ -2165,13 +2215,7 @@ var mParticle = (function () {
|
|
|
2165
2215
|
} else {
|
|
2166
2216
|
stringifiedItem = '';
|
|
2167
2217
|
}
|
|
2168
|
-
|
|
2169
|
-
this.storageObject.setItem(this._storageKey, stringifiedItem);
|
|
2170
|
-
this.logger.verbose("Saving item to Storage: ".concat(stringifiedItem));
|
|
2171
|
-
} catch (error) {
|
|
2172
|
-
this.logger.error("Cannot Save items to Storage: ".concat(stringifiedItem));
|
|
2173
|
-
this.logger.error(error);
|
|
2174
|
-
}
|
|
2218
|
+
this.storageObject.setItem(this._storageKey, stringifiedItem);
|
|
2175
2219
|
};
|
|
2176
2220
|
/**
|
|
2177
2221
|
* Retrieve StorableItem from Storage
|
|
@@ -2183,7 +2227,6 @@ var mParticle = (function () {
|
|
|
2183
2227
|
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
2184
2228
|
var item = this.storageObject.getItem(this._storageKey);
|
|
2185
2229
|
this.contents = item ? JSON.parse(item) : null;
|
|
2186
|
-
this.logger.verbose("Retrieving item from Storage: ".concat(item));
|
|
2187
2230
|
return this.contents;
|
|
2188
2231
|
};
|
|
2189
2232
|
/**
|
|
@@ -2192,7 +2235,6 @@ var mParticle = (function () {
|
|
|
2192
2235
|
* @method purge
|
|
2193
2236
|
*/
|
|
2194
2237
|
BaseVault.prototype.purge = function () {
|
|
2195
|
-
this.logger.verbose('Purging Storage');
|
|
2196
2238
|
this.contents = null;
|
|
2197
2239
|
this.storageObject.removeItem(this._storageKey);
|
|
2198
2240
|
};
|
|
@@ -2200,23 +2242,23 @@ var mParticle = (function () {
|
|
|
2200
2242
|
}();
|
|
2201
2243
|
var LocalStorageVault = /** @class */function (_super) {
|
|
2202
2244
|
__extends(LocalStorageVault, _super);
|
|
2203
|
-
function LocalStorageVault(storageKey
|
|
2204
|
-
return _super.call(this, storageKey, window.localStorage
|
|
2245
|
+
function LocalStorageVault(storageKey) {
|
|
2246
|
+
return _super.call(this, storageKey, window.localStorage) || this;
|
|
2205
2247
|
}
|
|
2206
2248
|
return LocalStorageVault;
|
|
2207
2249
|
}(BaseVault);
|
|
2208
2250
|
var SessionStorageVault = /** @class */function (_super) {
|
|
2209
2251
|
__extends(SessionStorageVault, _super);
|
|
2210
|
-
function SessionStorageVault(storageKey
|
|
2211
|
-
return _super.call(this, storageKey, window.sessionStorage
|
|
2252
|
+
function SessionStorageVault(storageKey) {
|
|
2253
|
+
return _super.call(this, storageKey, window.sessionStorage) || this;
|
|
2212
2254
|
}
|
|
2213
2255
|
return SessionStorageVault;
|
|
2214
2256
|
}(BaseVault);
|
|
2215
2257
|
// DisabledVault is used when persistence is disabled by privacy flags.
|
|
2216
2258
|
var DisabledVault = /** @class */function (_super) {
|
|
2217
2259
|
__extends(DisabledVault, _super);
|
|
2218
|
-
function DisabledVault(storageKey
|
|
2219
|
-
var _this = _super.call(this, storageKey, window.localStorage
|
|
2260
|
+
function DisabledVault(storageKey) {
|
|
2261
|
+
var _this = _super.call(this, storageKey, window.localStorage) || this;
|
|
2220
2262
|
_this.contents = null;
|
|
2221
2263
|
_this.storageObject.removeItem(_this._storageKey);
|
|
2222
2264
|
return _this;
|
|
@@ -2416,12 +2458,8 @@ var mParticle = (function () {
|
|
|
2416
2458
|
// When noFunctional is true, prevent events/batches storage
|
|
2417
2459
|
var noFunctional = (_b = mpInstance._CookieConsentManager) === null || _b === void 0 ? void 0 : _b.getNoFunctional();
|
|
2418
2460
|
if (this.offlineStorageEnabled && !noFunctional) {
|
|
2419
|
-
this.eventVault = new SessionStorageVault("".concat(mpInstance._Store.storageName, "-events")
|
|
2420
|
-
|
|
2421
|
-
});
|
|
2422
|
-
this.batchVault = new LocalStorageVault("".concat(mpInstance._Store.storageName, "-batches"), {
|
|
2423
|
-
logger: mpInstance.Logger
|
|
2424
|
-
});
|
|
2461
|
+
this.eventVault = new SessionStorageVault("".concat(mpInstance._Store.storageName, "-events"));
|
|
2462
|
+
this.batchVault = new LocalStorageVault("".concat(mpInstance._Store.storageName, "-batches"));
|
|
2425
2463
|
// Load Events from Session Storage in case we have any in storage
|
|
2426
2464
|
(_a = this.eventsQueuedForProcessing).push.apply(_a, this.eventVault.retrieve());
|
|
2427
2465
|
}
|
|
@@ -2565,13 +2603,15 @@ var mParticle = (function () {
|
|
|
2565
2603
|
if (isEmpty(event)) {
|
|
2566
2604
|
return;
|
|
2567
2605
|
}
|
|
2568
|
-
var Logger = this.mpInstance.Logger;
|
|
2569
2606
|
this.eventsQueuedForProcessing.push(event);
|
|
2570
2607
|
if (this.offlineStorageEnabled && this.eventVault) {
|
|
2571
2608
|
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
2572
2609
|
}
|
|
2573
|
-
|
|
2574
|
-
|
|
2610
|
+
if (this.mpInstance.Logger.isVerbose()) {
|
|
2611
|
+
var eventToLog = obfuscateDevData(event, this.mpInstance._Store.SDKConfig.isDevelopmentMode);
|
|
2612
|
+
this.mpInstance.Logger.verbose("Queuing event: ".concat(JSON.stringify(eventToLog)));
|
|
2613
|
+
this.mpInstance.Logger.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));
|
|
2614
|
+
}
|
|
2575
2615
|
if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
|
|
2576
2616
|
this.prepareAndUpload(false, false);
|
|
2577
2617
|
}
|
|
@@ -2687,7 +2727,7 @@ var mParticle = (function () {
|
|
|
2687
2727
|
}
|
|
2688
2728
|
batchesToUpload = this.batchesQueuedForProcessing;
|
|
2689
2729
|
this.batchesQueuedForProcessing = [];
|
|
2690
|
-
return [4 /*yield*/, this.uploadBatches(
|
|
2730
|
+
return [4 /*yield*/, this.uploadBatches(batchesToUpload, useBeacon)];
|
|
2691
2731
|
case 1:
|
|
2692
2732
|
batchesThatDidNotUpload = _d.sent();
|
|
2693
2733
|
// Batches that do not successfully upload are added back to the process queue
|
|
@@ -2716,11 +2756,10 @@ var mParticle = (function () {
|
|
|
2716
2756
|
});
|
|
2717
2757
|
});
|
|
2718
2758
|
};
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
BatchUploader.prototype.uploadBatches = function (logger, batches, useBeacon) {
|
|
2759
|
+
|
|
2760
|
+
BatchUploader.prototype.uploadBatches = function (batches, useBeacon) {
|
|
2722
2761
|
return __awaiter(this, void 0, void 0, function () {
|
|
2723
|
-
var uploads, i, fetchPayload, blob, response, e_1;
|
|
2762
|
+
var uploads, uploadsToLog, i, fetchPayload, blob, response, e_1;
|
|
2724
2763
|
return __generator(this, function (_a) {
|
|
2725
2764
|
switch (_a.label) {
|
|
2726
2765
|
case 0:
|
|
@@ -2730,8 +2769,11 @@ var mParticle = (function () {
|
|
|
2730
2769
|
if (isEmpty(uploads)) {
|
|
2731
2770
|
return [2 /*return*/, null];
|
|
2732
2771
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2772
|
+
if (this.mpInstance.Logger.isVerbose()) {
|
|
2773
|
+
uploadsToLog = obfuscateDevData(uploads, this.mpInstance._Store.SDKConfig.isDevelopmentMode);
|
|
2774
|
+
this.mpInstance.Logger.verbose("Uploading batches: ".concat(JSON.stringify(uploadsToLog)));
|
|
2775
|
+
this.mpInstance.Logger.verbose("Batch count: ".concat(uploads.length));
|
|
2776
|
+
}
|
|
2735
2777
|
i = 0;
|
|
2736
2778
|
_a.label = 1;
|
|
2737
2779
|
case 1:
|
|
@@ -2756,13 +2798,13 @@ var mParticle = (function () {
|
|
|
2756
2798
|
case 3:
|
|
2757
2799
|
response = _a.sent();
|
|
2758
2800
|
if (response.status >= 200 && response.status < 300) {
|
|
2759
|
-
|
|
2801
|
+
this.mpInstance.Logger.verbose("Upload success for request ID: ".concat(uploads[i].source_request_id));
|
|
2760
2802
|
} else if (response.status >= 500 || response.status === 429) {
|
|
2761
|
-
|
|
2803
|
+
this.mpInstance.Logger.error("HTTP error status ".concat(response.status, " received"));
|
|
2762
2804
|
// Server error, add back current batches and try again later
|
|
2763
2805
|
return [2 /*return*/, uploads.slice(i, uploads.length)];
|
|
2764
2806
|
} else if (response.status >= 401) {
|
|
2765
|
-
|
|
2807
|
+
this.mpInstance.Logger.error("HTTP error status ".concat(response.status, " while uploading - please verify your API key."));
|
|
2766
2808
|
//if we're getting a 401, assume we'll keep getting a 401 and clear the uploads.
|
|
2767
2809
|
return [2 /*return*/, null];
|
|
2768
2810
|
} else {
|
|
@@ -2773,7 +2815,7 @@ var mParticle = (function () {
|
|
|
2773
2815
|
return [3 /*break*/, 5];
|
|
2774
2816
|
case 4:
|
|
2775
2817
|
e_1 = _a.sent();
|
|
2776
|
-
|
|
2818
|
+
this.mpInstance.Logger.error("Error sending event to mParticle servers. ".concat(e_1));
|
|
2777
2819
|
return [2 /*return*/, uploads.slice(i, uploads.length)];
|
|
2778
2820
|
case 5:
|
|
2779
2821
|
i++;
|
|
@@ -5011,6 +5053,9 @@ var mParticle = (function () {
|
|
|
5011
5053
|
}
|
|
5012
5054
|
}
|
|
5013
5055
|
};
|
|
5056
|
+
Logger.prototype.isVerbose = function () {
|
|
5057
|
+
return this.logLevel === LogLevelType.Verbose;
|
|
5058
|
+
};
|
|
5014
5059
|
Logger.prototype.setLogLevel = function (newLogLevel) {
|
|
5015
5060
|
this.logLevel = newLogLevel;
|
|
5016
5061
|
};
|
|
@@ -9397,7 +9442,7 @@ var mParticle = (function () {
|
|
|
9397
9442
|
this.sendIdentityRequest = function (identityApiRequest, method, callback, originalIdentityApiData, parseIdentityResponse, mpid, knownIdentities) {
|
|
9398
9443
|
var _a, _b, _c, _d;
|
|
9399
9444
|
return __awaiter(this, void 0, void 0, function () {
|
|
9400
|
-
var requestCount, invokeCallback, Logger, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message, _e, responseBody, errorResponse, errorMessage, errorMessage, requestCount, err_1, requestCount, errorMessage;
|
|
9445
|
+
var requestCount, invokeCallback, Logger, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message, _e, responseBody, errorResponse, errorMessage, responseText, isDevelopmentMode, responseToLog, errorMessage, requestCount, err_1, requestCount, errorMessage;
|
|
9401
9446
|
return __generator(this, function (_f) {
|
|
9402
9447
|
switch (_f.label) {
|
|
9403
9448
|
case 0:
|
|
@@ -9471,9 +9516,16 @@ var mParticle = (function () {
|
|
|
9471
9516
|
}).join(', ');
|
|
9472
9517
|
message += ' - ' + errorMessage;
|
|
9473
9518
|
}
|
|
9474
|
-
} else {
|
|
9475
|
-
|
|
9476
|
-
|
|
9519
|
+
} else if (Logger.isVerbose()) {
|
|
9520
|
+
responseText = identityResponse.responseText;
|
|
9521
|
+
isDevelopmentMode = mpInstance._Store.SDKConfig.isDevelopmentMode;
|
|
9522
|
+
responseToLog = responseText;
|
|
9523
|
+
if (!isDevelopmentMode && (responseText === null || responseText === void 0 ? void 0 : responseText.matched_identities)) {
|
|
9524
|
+
responseToLog = __assign(__assign({}, responseText), {
|
|
9525
|
+
matched_identities: obfuscateData(responseText.matched_identities)
|
|
9526
|
+
});
|
|
9527
|
+
}
|
|
9528
|
+
message = 'Received Identity Response from server: ' + JSON.stringify(responseToLog);
|
|
9477
9529
|
}
|
|
9478
9530
|
return [3 /*break*/, 8];
|
|
9479
9531
|
case 7:
|
|
@@ -9491,7 +9543,9 @@ var mParticle = (function () {
|
|
|
9491
9543
|
case 8:
|
|
9492
9544
|
mpInstance._Store.identityCallInFlight = false;
|
|
9493
9545
|
mpInstance._Store.identityCallFailed = false;
|
|
9494
|
-
|
|
9546
|
+
if (message) {
|
|
9547
|
+
Logger.verbose(message);
|
|
9548
|
+
}
|
|
9495
9549
|
if ((_b = mpInstance._RoktManager) === null || _b === void 0 ? void 0 : _b.isInitialized) {
|
|
9496
9550
|
requestCount = mpInstance._Store.identifyRequestCount;
|
|
9497
9551
|
mpInstance.captureTiming("".concat(requestCount, "-identityRequestEnd"));
|
|
@@ -9958,27 +10012,30 @@ var mParticle = (function () {
|
|
|
9958
10012
|
* });
|
|
9959
10013
|
*/
|
|
9960
10014
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
9961
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
10015
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
9962
10016
|
return __awaiter(this, void 0, void 0, function () {
|
|
9963
|
-
var attributes, sandboxValue, mappedAttributes, currentUserIdentities_1, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities_1, error_1, finalUserIdentities, enrichedAttributes, hashedEmail, enrichedOptions, error_2;
|
|
10017
|
+
var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities_1, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities_1, error_1, errorMessage, finalUserIdentities, enrichedAttributes, hashedEmail, enrichedOptions, error_2;
|
|
9964
10018
|
var _this = this;
|
|
9965
|
-
return __generator(this, function (
|
|
9966
|
-
switch (
|
|
10019
|
+
return __generator(this, function (_k) {
|
|
10020
|
+
switch (_k.label) {
|
|
9967
10021
|
case 0:
|
|
9968
10022
|
(_a = this.captureTiming) === null || _a === void 0 ? void 0 : _a.call(this, PerformanceMarkType.JointSdkSelectPlacements);
|
|
9969
10023
|
// Queue if kit isn't ready OR if identity is in flight
|
|
9970
10024
|
if (!this.isReady() || ((_b = this.store) === null || _b === void 0 ? void 0 : _b.identityCallInFlight)) {
|
|
9971
10025
|
return [2 /*return*/, this.deferredCall('selectPlacements', options)];
|
|
9972
10026
|
}
|
|
9973
|
-
|
|
10027
|
+
_k.label = 1;
|
|
9974
10028
|
case 1:
|
|
9975
|
-
|
|
10029
|
+
_k.trys.push([1, 6,, 7]);
|
|
9976
10030
|
attributes = options.attributes;
|
|
9977
10031
|
sandboxValue = (attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) || null;
|
|
9978
10032
|
mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
9979
|
-
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.
|
|
10033
|
+
if ((_c = this.logger) === null || _c === void 0 ? void 0 : _c.isVerbose()) {
|
|
10034
|
+
attributesToLog = obfuscateDevData(attributes, (_e = (_d = this.store) === null || _d === void 0 ? void 0 : _d.SDKConfig) === null || _e === void 0 ? void 0 : _e.isDevelopmentMode);
|
|
10035
|
+
this.logger.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(attributesToLog, null, 2)));
|
|
10036
|
+
}
|
|
9980
10037
|
this.currentUser = this.identityService.getCurrentUser();
|
|
9981
|
-
currentUserIdentities_1 = ((
|
|
10038
|
+
currentUserIdentities_1 = ((_g = (_f = this.currentUser) === null || _f === void 0 ? void 0 : _f.getUserIdentities()) === null || _g === void 0 ? void 0 : _g.userIdentities) || {};
|
|
9982
10039
|
currentEmail = currentUserIdentities_1.email;
|
|
9983
10040
|
newEmail = mappedAttributes.email;
|
|
9984
10041
|
currentHashedEmail = void 0;
|
|
@@ -10002,9 +10059,9 @@ var mParticle = (function () {
|
|
|
10002
10059
|
this.logger.warning("emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.");
|
|
10003
10060
|
}
|
|
10004
10061
|
if (!!isEmpty(newIdentities_1)) return [3 /*break*/, 5];
|
|
10005
|
-
|
|
10062
|
+
_k.label = 2;
|
|
10006
10063
|
case 2:
|
|
10007
|
-
|
|
10064
|
+
_k.trys.push([2, 4,, 5]);
|
|
10008
10065
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
10009
10066
|
_this.identityService.identify({
|
|
10010
10067
|
userIdentities: __assign(__assign({}, currentUserIdentities_1), newIdentities_1)
|
|
@@ -10013,16 +10070,17 @@ var mParticle = (function () {
|
|
|
10013
10070
|
});
|
|
10014
10071
|
})];
|
|
10015
10072
|
case 3:
|
|
10016
|
-
|
|
10073
|
+
_k.sent();
|
|
10017
10074
|
return [3 /*break*/, 5];
|
|
10018
10075
|
case 4:
|
|
10019
|
-
error_1 =
|
|
10020
|
-
|
|
10076
|
+
error_1 = _k.sent();
|
|
10077
|
+
errorMessage = error_1 instanceof Error ? error_1.message : JSON.stringify(error_1);
|
|
10078
|
+
this.logger.error('Failed to identify user with updated identities: ' + errorMessage);
|
|
10021
10079
|
return [3 /*break*/, 5];
|
|
10022
10080
|
case 5:
|
|
10023
10081
|
// Refresh current user identities to ensure we have the latest values before building enrichedAttributes
|
|
10024
10082
|
this.currentUser = this.identityService.getCurrentUser();
|
|
10025
|
-
finalUserIdentities = ((
|
|
10083
|
+
finalUserIdentities = ((_j = (_h = this.currentUser) === null || _h === void 0 ? void 0 : _h.getUserIdentities()) === null || _j === void 0 ? void 0 : _j.userIdentities) || {};
|
|
10026
10084
|
this.setUserAttributes(mappedAttributes);
|
|
10027
10085
|
enrichedAttributes = __assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
|
|
10028
10086
|
sandbox: sandboxValue
|
|
@@ -10044,7 +10102,7 @@ var mParticle = (function () {
|
|
|
10044
10102
|
});
|
|
10045
10103
|
return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
|
|
10046
10104
|
case 6:
|
|
10047
|
-
error_2 =
|
|
10105
|
+
error_2 = _k.sent();
|
|
10048
10106
|
return [2 /*return*/, Promise.reject(error_2 instanceof Error ? error_2 : new Error('Unknown error occurred'))];
|
|
10049
10107
|
case 7:
|
|
10050
10108
|
return [2 /*return*/];
|
|
@@ -10235,12 +10293,15 @@ var mParticle = (function () {
|
|
|
10235
10293
|
// Clear the queue immediately to prevent re-processing
|
|
10236
10294
|
this.messageQueue.clear();
|
|
10237
10295
|
messagesToProcess.forEach(function (message) {
|
|
10238
|
-
var _a, _b;
|
|
10296
|
+
var _a, _b, _c, _d;
|
|
10239
10297
|
if (!(message.methodName in _this) || !isFunction(_this[message.methodName])) {
|
|
10240
10298
|
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found"));
|
|
10241
10299
|
return;
|
|
10242
10300
|
}
|
|
10243
|
-
(_b = _this.logger) === null || _b === void 0 ? void 0 : _b.
|
|
10301
|
+
if ((_b = _this.logger) === null || _b === void 0 ? void 0 : _b.isVerbose()) {
|
|
10302
|
+
var payloadToLog = obfuscateDevData(message.payload, (_d = (_c = _this.store) === null || _c === void 0 ? void 0 : _c.SDKConfig) === null || _d === void 0 ? void 0 : _d.isDevelopmentMode);
|
|
10303
|
+
_this.logger.verbose("RoktManager: Processing queued message: ".concat(message.methodName, " with payload: ").concat(JSON.stringify(payloadToLog)));
|
|
10304
|
+
}
|
|
10244
10305
|
// Capture resolve/reject functions before async processing
|
|
10245
10306
|
var resolve = message.resolve;
|
|
10246
10307
|
var reject = message.reject;
|
|
@@ -11635,13 +11696,9 @@ var mParticle = (function () {
|
|
|
11635
11696
|
// Identity expects mpInstance._Identity.idCache to always exist. DisabledVault
|
|
11636
11697
|
// ensures no identity response data is written to localStorage when noFunctional is true
|
|
11637
11698
|
if ((_a = mpInstance._CookieConsentManager) === null || _a === void 0 ? void 0 : _a.getNoFunctional()) {
|
|
11638
|
-
return new DisabledVault("".concat(mpInstance._Store.storageName, "-id-cache")
|
|
11639
|
-
logger: mpInstance.Logger
|
|
11640
|
-
});
|
|
11699
|
+
return new DisabledVault("".concat(mpInstance._Store.storageName, "-id-cache"));
|
|
11641
11700
|
}
|
|
11642
|
-
return new LocalStorageVault("".concat(mpInstance._Store.storageName, "-id-cache")
|
|
11643
|
-
logger: mpInstance.Logger
|
|
11644
|
-
});
|
|
11701
|
+
return new LocalStorageVault("".concat(mpInstance._Store.storageName, "-id-cache"));
|
|
11645
11702
|
}
|
|
11646
11703
|
function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
|
|
11647
11704
|
var _a;
|
|
@@ -12138,7 +12195,7 @@ var mParticle = (function () {
|
|
|
12138
12195
|
};
|
|
12139
12196
|
this.sessionManager = {
|
|
12140
12197
|
getSession: function getSession() {
|
|
12141
|
-
return self.getInstance()._SessionManager.
|
|
12198
|
+
return self.getInstance()._SessionManager.getSessionId();
|
|
12142
12199
|
}
|
|
12143
12200
|
};
|
|
12144
12201
|
this.Consent = {
|
package/package.json
CHANGED
package/src/batchUploader.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Batch } from '@mparticle/event-models';
|
|
2
2
|
import Constants from './constants';
|
|
3
|
-
import { SDKEvent, SDKEventCustomFlags
|
|
3
|
+
import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels';
|
|
4
4
|
import { convertEvents } from './sdkToEventsApiConverter';
|
|
5
5
|
import { MessageType, EventType } from './types';
|
|
6
|
-
import { getRampNumber, isEmpty } from './utils';
|
|
6
|
+
import { getRampNumber, isEmpty, obfuscateDevData } from './utils';
|
|
7
7
|
import { SessionStorageVault, LocalStorageVault } from './vault';
|
|
8
8
|
import {
|
|
9
9
|
AsyncUploader,
|
|
@@ -79,17 +79,11 @@ export class BatchUploader {
|
|
|
79
79
|
|
|
80
80
|
if (this.offlineStorageEnabled && !noFunctional) {
|
|
81
81
|
this.eventVault = new SessionStorageVault<SDKEvent[]>(
|
|
82
|
-
`${mpInstance._Store.storageName}-events
|
|
83
|
-
{
|
|
84
|
-
logger: mpInstance.Logger,
|
|
85
|
-
}
|
|
82
|
+
`${mpInstance._Store.storageName}-events`
|
|
86
83
|
);
|
|
87
84
|
|
|
88
85
|
this.batchVault = new LocalStorageVault<Batch[]>(
|
|
89
|
-
`${mpInstance._Store.storageName}-batches
|
|
90
|
-
{
|
|
91
|
-
logger: mpInstance.Logger,
|
|
92
|
-
}
|
|
86
|
+
`${mpInstance._Store.storageName}-batches`
|
|
93
87
|
);
|
|
94
88
|
|
|
95
89
|
// Load Events from Session Storage in case we have any in storage
|
|
@@ -260,15 +254,16 @@ export class BatchUploader {
|
|
|
260
254
|
return;
|
|
261
255
|
}
|
|
262
256
|
|
|
263
|
-
const { Logger } = this.mpInstance;
|
|
264
|
-
|
|
265
257
|
this.eventsQueuedForProcessing.push(event);
|
|
266
258
|
if (this.offlineStorageEnabled && this.eventVault) {
|
|
267
259
|
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
268
260
|
}
|
|
269
261
|
|
|
270
|
-
Logger.
|
|
271
|
-
|
|
262
|
+
if (this.mpInstance.Logger.isVerbose()) {
|
|
263
|
+
const eventToLog = obfuscateDevData(event, this.mpInstance._Store.SDKConfig.isDevelopmentMode);
|
|
264
|
+
this.mpInstance.Logger.verbose(`Queuing event: ${JSON.stringify(eventToLog)}`);
|
|
265
|
+
this.mpInstance.Logger.verbose(`Queued event count: ${this.eventsQueuedForProcessing.length}`);
|
|
266
|
+
}
|
|
272
267
|
|
|
273
268
|
if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
|
|
274
269
|
this.prepareAndUpload(false, false);
|
|
@@ -412,7 +407,6 @@ export class BatchUploader {
|
|
|
412
407
|
this.batchesQueuedForProcessing = [];
|
|
413
408
|
|
|
414
409
|
const batchesThatDidNotUpload = await this.uploadBatches(
|
|
415
|
-
this.mpInstance.Logger,
|
|
416
410
|
batchesToUpload,
|
|
417
411
|
useBeacon
|
|
418
412
|
);
|
|
@@ -432,8 +426,8 @@ export class BatchUploader {
|
|
|
432
426
|
// therefore NOT overwrite Offline Storage when beacon returns, so that we can retry
|
|
433
427
|
// uploading saved batches at a later time. Batches should only be removed from
|
|
434
428
|
// Local Storage once we can confirm they are successfully uploaded.
|
|
429
|
+
|
|
435
430
|
this.batchVault.store(this.batchesQueuedForProcessing);
|
|
436
|
-
|
|
437
431
|
// Clear batch queue since everything should be in Offline Storage
|
|
438
432
|
this.batchesQueuedForProcessing = [];
|
|
439
433
|
}
|
|
@@ -443,10 +437,7 @@ export class BatchUploader {
|
|
|
443
437
|
}
|
|
444
438
|
}
|
|
445
439
|
|
|
446
|
-
// TODO: Refactor to use logger as a class method
|
|
447
|
-
// https://go.mparticle.com/work/SQDSDKS-5167
|
|
448
440
|
private async uploadBatches(
|
|
449
|
-
logger: SDKLoggerApi,
|
|
450
441
|
batches: Batch[],
|
|
451
442
|
useBeacon: boolean
|
|
452
443
|
): Promise<Batch[] | null> {
|
|
@@ -457,8 +448,11 @@ export class BatchUploader {
|
|
|
457
448
|
return null;
|
|
458
449
|
}
|
|
459
450
|
|
|
460
|
-
|
|
461
|
-
|
|
451
|
+
if (this.mpInstance.Logger.isVerbose()) {
|
|
452
|
+
const uploadsToLog = obfuscateDevData(uploads, this.mpInstance._Store.SDKConfig.isDevelopmentMode);
|
|
453
|
+
this.mpInstance.Logger.verbose(`Uploading batches: ${JSON.stringify(uploadsToLog)}`);
|
|
454
|
+
this.mpInstance.Logger.verbose(`Batch count: ${uploads.length}`);
|
|
455
|
+
}
|
|
462
456
|
|
|
463
457
|
for (let i = 0; i < uploads.length; i++) {
|
|
464
458
|
const fetchPayload: IFetchPayload = {
|
|
@@ -482,20 +476,20 @@ export class BatchUploader {
|
|
|
482
476
|
const response = await this.uploader.upload(fetchPayload);
|
|
483
477
|
|
|
484
478
|
if (response.status >= 200 && response.status < 300) {
|
|
485
|
-
|
|
479
|
+
this.mpInstance.Logger.verbose(
|
|
486
480
|
`Upload success for request ID: ${uploads[i].source_request_id}`
|
|
487
481
|
);
|
|
488
482
|
} else if (
|
|
489
483
|
response.status >= 500 ||
|
|
490
484
|
response.status === 429
|
|
491
485
|
) {
|
|
492
|
-
|
|
486
|
+
this.mpInstance.Logger.error(
|
|
493
487
|
`HTTP error status ${response.status} received`
|
|
494
488
|
);
|
|
495
489
|
// Server error, add back current batches and try again later
|
|
496
490
|
return uploads.slice(i, uploads.length);
|
|
497
491
|
} else if (response.status >= 401) {
|
|
498
|
-
|
|
492
|
+
this.mpInstance.Logger.error(
|
|
499
493
|
`HTTP error status ${response.status} while uploading - please verify your API key.`
|
|
500
494
|
);
|
|
501
495
|
//if we're getting a 401, assume we'll keep getting a 401 and clear the uploads.
|
|
@@ -512,7 +506,7 @@ export class BatchUploader {
|
|
|
512
506
|
);
|
|
513
507
|
}
|
|
514
508
|
} catch (e) {
|
|
515
|
-
|
|
509
|
+
this.mpInstance.Logger.error(
|
|
516
510
|
`Error sending event to mParticle servers. ${e}`
|
|
517
511
|
);
|
|
518
512
|
return uploads.slice(i, uploads.length);
|
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 { parseNumber, valueof } from './utils';
|
|
9
|
+
import { obfuscateData, parseNumber, valueof } from './utils';
|
|
10
10
|
import {
|
|
11
11
|
IAliasCallback,
|
|
12
12
|
IAliasRequest,
|
|
@@ -277,9 +277,17 @@ export default function IdentityAPIClient(
|
|
|
277
277
|
message += ' - ' + errorMessage;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
} else {
|
|
281
|
-
|
|
282
|
-
|
|
280
|
+
} else if (Logger.isVerbose()) {
|
|
281
|
+
const responseText = identityResponse.responseText;
|
|
282
|
+
const { isDevelopmentMode } = mpInstance._Store.SDKConfig;
|
|
283
|
+
let responseToLog = responseText;
|
|
284
|
+
if (!isDevelopmentMode && responseText?.matched_identities) {
|
|
285
|
+
responseToLog = {
|
|
286
|
+
...responseText,
|
|
287
|
+
matched_identities: obfuscateData(responseText.matched_identities)
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
message = 'Received Identity Response from server: ' + JSON.stringify(responseToLog);
|
|
283
291
|
}
|
|
284
292
|
|
|
285
293
|
break;
|
|
@@ -306,7 +314,9 @@ export default function IdentityAPIClient(
|
|
|
306
314
|
mpInstance._Store.identityCallInFlight = false;
|
|
307
315
|
mpInstance._Store.identityCallFailed = false;
|
|
308
316
|
|
|
309
|
-
|
|
317
|
+
if (message) {
|
|
318
|
+
Logger.verbose(message);
|
|
319
|
+
}
|
|
310
320
|
if (mpInstance._RoktManager?.isInitialized) {
|
|
311
321
|
const requestCount = mpInstance._Store.identifyRequestCount;
|
|
312
322
|
mpInstance.captureTiming(`${requestCount}-identityRequestEnd`);
|