@mparticle/web-sdk 2.52.0 → 2.53.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 +25 -10
- package/dist/mparticle.esm.js +25 -10
- package/dist/mparticle.js +128 -74
- package/package.json +1 -1
- package/src/batchUploader.ts +3 -3
- package/src/cookieConsentManager.ts +64 -0
- package/src/cookieSyncManager.ts +6 -0
- package/src/identityApiClient.ts +11 -12
- package/src/logger.ts +66 -0
- package/src/mp-instance.ts +8 -1
- package/src/roktManager.ts +19 -17
- package/src/sdkRuntimeModels.ts +9 -1
- package/src/logger.js +0 -61
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.53.1";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -1251,6 +1251,12 @@ var mParticle = (function () {
|
|
|
1251
1251
|
SDKProductActionType[SDKProductActionType["AddToWishlist"] = 9] = "AddToWishlist";
|
|
1252
1252
|
SDKProductActionType[SDKProductActionType["RemoveFromWishlist"] = 10] = "RemoveFromWishlist";
|
|
1253
1253
|
})(SDKProductActionType || (SDKProductActionType = {}));
|
|
1254
|
+
var LogLevelType = {
|
|
1255
|
+
None: 'none',
|
|
1256
|
+
Verbose: 'verbose',
|
|
1257
|
+
Warning: 'warning',
|
|
1258
|
+
Error: 'error'
|
|
1259
|
+
};
|
|
1254
1260
|
|
|
1255
1261
|
function getDefaultExportFromCjs (x) {
|
|
1256
1262
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -2529,13 +2535,13 @@ var mParticle = (function () {
|
|
|
2529
2535
|
if (isEmpty(event)) {
|
|
2530
2536
|
return;
|
|
2531
2537
|
}
|
|
2532
|
-
var
|
|
2538
|
+
var Logger = this.mpInstance.Logger;
|
|
2533
2539
|
this.eventsQueuedForProcessing.push(event);
|
|
2534
2540
|
if (this.offlineStorageEnabled && this.eventVault) {
|
|
2535
2541
|
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
2536
2542
|
}
|
|
2537
|
-
verbose("Queuing event: ".concat(JSON.stringify(event)));
|
|
2538
|
-
verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));
|
|
2543
|
+
Logger.verbose("Queuing event: ".concat(JSON.stringify(event)));
|
|
2544
|
+
Logger.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));
|
|
2539
2545
|
if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
|
|
2540
2546
|
this.prepareAndUpload(false, false);
|
|
2541
2547
|
}
|
|
@@ -3486,7 +3492,8 @@ var mParticle = (function () {
|
|
|
3486
3492
|
AppNexus: 50,
|
|
3487
3493
|
Lotame: 58,
|
|
3488
3494
|
TradeDesk: 103,
|
|
3489
|
-
VerizonMedia: 155
|
|
3495
|
+
VerizonMedia: 155,
|
|
3496
|
+
Rokt: 1277
|
|
3490
3497
|
};
|
|
3491
3498
|
function CookieSyncManager(mpInstance) {
|
|
3492
3499
|
var self = this;
|
|
@@ -3527,6 +3534,10 @@ var mParticle = (function () {
|
|
|
3527
3534
|
if (requiresConsent && mpidIsNotInCookies) {
|
|
3528
3535
|
return;
|
|
3529
3536
|
}
|
|
3537
|
+
// For Rokt, block cookie sync when noTargeting privacy flag is true
|
|
3538
|
+
if (moduleId === PARTNER_MODULE_IDS.Rokt && mpInstance._CookieConsentManager.getNoTargeting()) {
|
|
3539
|
+
return;
|
|
3540
|
+
}
|
|
3530
3541
|
var isEnabledForUserConsent = mpInstance._Consent.isEnabledForUserConsent;
|
|
3531
3542
|
if (!isEnabledForUserConsent(filteringConsentRuleValues, mpInstance.Identity.getCurrentUser())) {
|
|
3532
3543
|
return;
|
|
@@ -4864,56 +4875,54 @@ var mParticle = (function () {
|
|
|
4864
4875
|
return directBaseUrls;
|
|
4865
4876
|
}
|
|
4866
4877
|
|
|
4867
|
-
function
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
this.logger = config.logger;
|
|
4872
|
-
} else {
|
|
4873
|
-
this.logger = new ConsoleLogger();
|
|
4878
|
+
var Logger = /** @class */function () {
|
|
4879
|
+
function Logger(config) {
|
|
4880
|
+
var _a, _b;
|
|
4881
|
+
this.logLevel = (_a = config.logLevel) !== null && _a !== void 0 ? _a : LogLevelType.Warning;
|
|
4882
|
+
this.logger = (_b = config.logger) !== null && _b !== void 0 ? _b : new ConsoleLogger();
|
|
4874
4883
|
}
|
|
4875
|
-
|
|
4876
|
-
if (logLevel
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
}
|
|
4884
|
+
Logger.prototype.verbose = function (msg) {
|
|
4885
|
+
if (this.logLevel === LogLevelType.None) return;
|
|
4886
|
+
if (this.logger.verbose && this.logLevel === LogLevelType.Verbose) {
|
|
4887
|
+
this.logger.verbose(msg);
|
|
4880
4888
|
}
|
|
4881
4889
|
};
|
|
4882
|
-
|
|
4883
|
-
if (logLevel
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
}
|
|
4890
|
+
Logger.prototype.warning = function (msg) {
|
|
4891
|
+
if (this.logLevel === LogLevelType.None) return;
|
|
4892
|
+
if (this.logger.warning && (this.logLevel === LogLevelType.Verbose || this.logLevel === LogLevelType.Warning)) {
|
|
4893
|
+
this.logger.warning(msg);
|
|
4887
4894
|
}
|
|
4888
4895
|
};
|
|
4889
|
-
|
|
4890
|
-
if (logLevel
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
}
|
|
4896
|
+
Logger.prototype.error = function (msg) {
|
|
4897
|
+
if (this.logLevel === LogLevelType.None) return;
|
|
4898
|
+
if (this.logger.error) {
|
|
4899
|
+
this.logger.error(msg);
|
|
4894
4900
|
}
|
|
4895
4901
|
};
|
|
4896
|
-
|
|
4897
|
-
logLevel = newLogLevel;
|
|
4902
|
+
Logger.prototype.setLogLevel = function (newLogLevel) {
|
|
4903
|
+
this.logLevel = newLogLevel;
|
|
4898
4904
|
};
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4905
|
+
return Logger;
|
|
4906
|
+
}();
|
|
4907
|
+
var ConsoleLogger = /** @class */function () {
|
|
4908
|
+
function ConsoleLogger() {}
|
|
4909
|
+
ConsoleLogger.prototype.verbose = function (msg) {
|
|
4902
4910
|
if (console && console.info) {
|
|
4903
4911
|
console.info(msg);
|
|
4904
4912
|
}
|
|
4905
4913
|
};
|
|
4906
|
-
|
|
4914
|
+
ConsoleLogger.prototype.error = function (msg) {
|
|
4907
4915
|
if (console && console.error) {
|
|
4908
4916
|
console.error(msg);
|
|
4909
4917
|
}
|
|
4910
4918
|
};
|
|
4911
|
-
|
|
4919
|
+
ConsoleLogger.prototype.warning = function (msg) {
|
|
4912
4920
|
if (console && console.warn) {
|
|
4913
4921
|
console.warn(msg);
|
|
4914
4922
|
}
|
|
4915
4923
|
};
|
|
4916
|
-
|
|
4924
|
+
return ConsoleLogger;
|
|
4925
|
+
}();
|
|
4917
4926
|
|
|
4918
4927
|
var Base64 = Polyfill.Base64,
|
|
4919
4928
|
Messages$4 = Constants.Messages,
|
|
@@ -9156,15 +9165,15 @@ var mParticle = (function () {
|
|
|
9156
9165
|
function IdentityAPIClient(mpInstance) {
|
|
9157
9166
|
this.sendAliasRequest = function (aliasRequest, aliasCallback) {
|
|
9158
9167
|
return __awaiter(this, void 0, void 0, function () {
|
|
9159
|
-
var
|
|
9160
|
-
return __generator(this, function (
|
|
9161
|
-
switch (
|
|
9168
|
+
var Logger, invokeAliasCallback, aliasUrl, apiKey, uploadUrl, uploader, uploadPayload, response, aliasResponseBody, message, errorMessage, _a, xhrResponse, errorResponse, e_2, errorMessage;
|
|
9169
|
+
return __generator(this, function (_b) {
|
|
9170
|
+
switch (_b.label) {
|
|
9162
9171
|
case 0:
|
|
9163
|
-
|
|
9172
|
+
Logger = mpInstance.Logger;
|
|
9164
9173
|
invokeAliasCallback = mpInstance._Helpers.invokeAliasCallback;
|
|
9165
9174
|
aliasUrl = mpInstance._Store.SDKConfig.aliasUrl;
|
|
9166
9175
|
apiKey = mpInstance._Store.devToken;
|
|
9167
|
-
verbose(Messages$1.InformationMessages.SendAliasHttp);
|
|
9176
|
+
Logger.verbose(Messages$1.InformationMessages.SendAliasHttp);
|
|
9168
9177
|
uploadUrl = "https://".concat(aliasUrl).concat(apiKey, "/Alias");
|
|
9169
9178
|
uploader = window.fetch ? new FetchUploader(uploadUrl) : new XHRUploader(uploadUrl);
|
|
9170
9179
|
uploadPayload = {
|
|
@@ -9175,17 +9184,17 @@ var mParticle = (function () {
|
|
|
9175
9184
|
},
|
|
9176
9185
|
body: JSON.stringify(aliasRequest)
|
|
9177
9186
|
};
|
|
9178
|
-
|
|
9187
|
+
_b.label = 1;
|
|
9179
9188
|
case 1:
|
|
9180
|
-
|
|
9189
|
+
_b.trys.push([1, 13,, 14]);
|
|
9181
9190
|
return [4 /*yield*/, uploader.upload(uploadPayload)];
|
|
9182
9191
|
case 2:
|
|
9183
|
-
response =
|
|
9192
|
+
response = _b.sent();
|
|
9184
9193
|
aliasResponseBody = void 0;
|
|
9185
9194
|
message = void 0;
|
|
9186
9195
|
errorMessage = void 0;
|
|
9187
|
-
|
|
9188
|
-
switch (
|
|
9196
|
+
_a = response.status;
|
|
9197
|
+
switch (_a) {
|
|
9189
9198
|
case HTTP_ACCEPTED:
|
|
9190
9199
|
return [3 /*break*/, 3];
|
|
9191
9200
|
case HTTP_OK:
|
|
@@ -9200,23 +9209,23 @@ var mParticle = (function () {
|
|
|
9200
9209
|
return [3 /*break*/, 12];
|
|
9201
9210
|
case 4:
|
|
9202
9211
|
if (!response.json) return [3 /*break*/, 9];
|
|
9203
|
-
|
|
9212
|
+
_b.label = 5;
|
|
9204
9213
|
case 5:
|
|
9205
|
-
|
|
9214
|
+
_b.trys.push([5, 7,, 8]);
|
|
9206
9215
|
return [4 /*yield*/, response.json()];
|
|
9207
9216
|
case 6:
|
|
9208
|
-
aliasResponseBody =
|
|
9217
|
+
aliasResponseBody = _b.sent();
|
|
9209
9218
|
return [3 /*break*/, 8];
|
|
9210
9219
|
case 7:
|
|
9211
|
-
|
|
9212
|
-
verbose('The request has no response body');
|
|
9220
|
+
_b.sent();
|
|
9221
|
+
Logger.verbose('The request has no response body');
|
|
9213
9222
|
return [3 /*break*/, 8];
|
|
9214
9223
|
case 8:
|
|
9215
9224
|
return [3 /*break*/, 10];
|
|
9216
9225
|
case 9:
|
|
9217
9226
|
xhrResponse = response;
|
|
9218
9227
|
aliasResponseBody = xhrResponse.responseText ? JSON.parse(xhrResponse.responseText) : '';
|
|
9219
|
-
|
|
9228
|
+
_b.label = 10;
|
|
9220
9229
|
case 10:
|
|
9221
9230
|
errorResponse = aliasResponseBody;
|
|
9222
9231
|
if (errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.message) {
|
|
@@ -9232,13 +9241,13 @@ var mParticle = (function () {
|
|
|
9232
9241
|
throw new Error('Received HTTP Code of ' + response.status);
|
|
9233
9242
|
}
|
|
9234
9243
|
case 12:
|
|
9235
|
-
verbose(message);
|
|
9244
|
+
Logger.verbose(message);
|
|
9236
9245
|
invokeAliasCallback(aliasCallback, response.status, errorMessage);
|
|
9237
9246
|
return [3 /*break*/, 14];
|
|
9238
9247
|
case 13:
|
|
9239
|
-
e_2 =
|
|
9248
|
+
e_2 = _b.sent();
|
|
9240
9249
|
errorMessage = e_2.message || e_2.toString();
|
|
9241
|
-
error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
9250
|
+
Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
9242
9251
|
invokeAliasCallback(aliasCallback, HTTPCodes$1.noHttpCoverage, errorMessage);
|
|
9243
9252
|
return [3 /*break*/, 14];
|
|
9244
9253
|
case 14:
|
|
@@ -9250,19 +9259,19 @@ var mParticle = (function () {
|
|
|
9250
9259
|
|
|
9251
9260
|
this.sendIdentityRequest = function (identityApiRequest, method, callback, originalIdentityApiData, parseIdentityResponse, mpid, knownIdentities) {
|
|
9252
9261
|
return __awaiter(this, void 0, void 0, function () {
|
|
9253
|
-
var
|
|
9254
|
-
return __generator(this, function (
|
|
9255
|
-
switch (
|
|
9262
|
+
var invokeCallback, Logger, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message, _a, responseBody, errorResponse, errorMessage, err_1, errorMessage;
|
|
9263
|
+
return __generator(this, function (_b) {
|
|
9264
|
+
switch (_b.label) {
|
|
9256
9265
|
case 0:
|
|
9257
|
-
_a = mpInstance.Logger, verbose = _a.verbose, error = _a.error;
|
|
9258
9266
|
invokeCallback = mpInstance._Helpers.invokeCallback;
|
|
9259
|
-
|
|
9267
|
+
Logger = mpInstance.Logger;
|
|
9268
|
+
Logger.verbose(Messages$1.InformationMessages.SendIdentityBegin);
|
|
9260
9269
|
if (!identityApiRequest) {
|
|
9261
|
-
error(Messages$1.ErrorMessages.APIRequestEmpty);
|
|
9270
|
+
Logger.error(Messages$1.ErrorMessages.APIRequestEmpty);
|
|
9262
9271
|
return [2 /*return*/];
|
|
9263
9272
|
}
|
|
9264
9273
|
|
|
9265
|
-
verbose(Messages$1.InformationMessages.SendIdentityHttp);
|
|
9274
|
+
Logger.verbose(Messages$1.InformationMessages.SendIdentityHttp);
|
|
9266
9275
|
if (mpInstance._Store.identityCallInFlight) {
|
|
9267
9276
|
invokeCallback(callback, HTTPCodes$1.activeIdentityRequest, 'There is currently an Identity request processing. Please wait for this to return before requesting again');
|
|
9268
9277
|
return [2 /*return*/];
|
|
@@ -9281,16 +9290,16 @@ var mParticle = (function () {
|
|
|
9281
9290
|
body: JSON.stringify(identityApiRequest)
|
|
9282
9291
|
};
|
|
9283
9292
|
mpInstance._Store.identityCallInFlight = true;
|
|
9284
|
-
|
|
9293
|
+
_b.label = 1;
|
|
9285
9294
|
case 1:
|
|
9286
|
-
|
|
9295
|
+
_b.trys.push([1, 9,, 10]);
|
|
9287
9296
|
return [4 /*yield*/, uploader.upload(fetchPayload)];
|
|
9288
9297
|
case 2:
|
|
9289
|
-
response =
|
|
9298
|
+
response = _b.sent();
|
|
9290
9299
|
identityResponse = void 0;
|
|
9291
9300
|
message = void 0;
|
|
9292
|
-
|
|
9293
|
-
switch (
|
|
9301
|
+
_a = response.status;
|
|
9302
|
+
switch (_a) {
|
|
9294
9303
|
case HTTP_ACCEPTED:
|
|
9295
9304
|
return [3 /*break*/, 3];
|
|
9296
9305
|
case HTTP_OK:
|
|
@@ -9303,12 +9312,12 @@ var mParticle = (function () {
|
|
|
9303
9312
|
if (!response.json) return [3 /*break*/, 5];
|
|
9304
9313
|
return [4 /*yield*/, response.json()];
|
|
9305
9314
|
case 4:
|
|
9306
|
-
responseBody =
|
|
9315
|
+
responseBody = _b.sent();
|
|
9307
9316
|
identityResponse = this.getIdentityResponseFromFetch(response, responseBody);
|
|
9308
9317
|
return [3 /*break*/, 6];
|
|
9309
9318
|
case 5:
|
|
9310
9319
|
identityResponse = this.getIdentityResponseFromXHR(response);
|
|
9311
|
-
|
|
9320
|
+
_b.label = 6;
|
|
9312
9321
|
case 6:
|
|
9313
9322
|
if (identityResponse.status === HTTP_BAD_REQUEST) {
|
|
9314
9323
|
errorResponse = identityResponse.responseText;
|
|
@@ -9330,14 +9339,14 @@ var mParticle = (function () {
|
|
|
9330
9339
|
}
|
|
9331
9340
|
case 8:
|
|
9332
9341
|
mpInstance._Store.identityCallInFlight = false;
|
|
9333
|
-
verbose(message);
|
|
9342
|
+
Logger.verbose(message);
|
|
9334
9343
|
parseIdentityResponse(identityResponse, previousMPID, callback, originalIdentityApiData, method, knownIdentities, false);
|
|
9335
9344
|
return [3 /*break*/, 10];
|
|
9336
9345
|
case 9:
|
|
9337
|
-
err_1 =
|
|
9346
|
+
err_1 = _b.sent();
|
|
9338
9347
|
mpInstance._Store.identityCallInFlight = false;
|
|
9339
9348
|
errorMessage = err_1.message || err_1.toString();
|
|
9340
|
-
error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
9349
|
+
Logger.error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
9341
9350
|
invokeCallback(callback, HTTPCodes$1.noHttpCoverage, errorMessage);
|
|
9342
9351
|
return [3 /*break*/, 10];
|
|
9343
9352
|
case 10:
|
|
@@ -9835,8 +9844,8 @@ var mParticle = (function () {
|
|
|
9835
9844
|
* with Rokt-compatible key names (like emailsha256, mobilesha256)
|
|
9836
9845
|
*
|
|
9837
9846
|
*
|
|
9838
|
-
* @param {
|
|
9839
|
-
* @returns {Promise<
|
|
9847
|
+
* @param {RoktAttributes} attributes - Attributes to hash
|
|
9848
|
+
* @returns {Promise<RoktAttributes>} Object with both original and hashed attributes
|
|
9840
9849
|
*
|
|
9841
9850
|
*/
|
|
9842
9851
|
RoktManager.prototype.hashAttributes = function (attributes) {
|
|
@@ -9970,7 +9979,8 @@ var mParticle = (function () {
|
|
|
9970
9979
|
var filteredAttributes = {};
|
|
9971
9980
|
for (var key in attributes) {
|
|
9972
9981
|
if (attributes.hasOwnProperty(key) && reservedAttributes.indexOf(key) === -1) {
|
|
9973
|
-
|
|
9982
|
+
var value = attributes[key];
|
|
9983
|
+
filteredAttributes[key] = Array.isArray(value) ? JSON.stringify(value) : value;
|
|
9974
9984
|
}
|
|
9975
9985
|
}
|
|
9976
9986
|
try {
|
|
@@ -10114,6 +10124,40 @@ var mParticle = (function () {
|
|
|
10114
10124
|
return RoktManager;
|
|
10115
10125
|
}();
|
|
10116
10126
|
|
|
10127
|
+
/**
|
|
10128
|
+
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
10129
|
+
* that are passed via launcherOptions during SDK initialization.
|
|
10130
|
+
*
|
|
10131
|
+
* These flags allow Rokt integration to respect user privacy choices.
|
|
10132
|
+
*
|
|
10133
|
+
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
10134
|
+
* unless explicitly opted out by the user.
|
|
10135
|
+
*/
|
|
10136
|
+
var CookieConsentManager = /** @class */function () {
|
|
10137
|
+
function CookieConsentManager(flags) {
|
|
10138
|
+
this.flags = flags;
|
|
10139
|
+
this.flags = {
|
|
10140
|
+
noFunctional: flags.noFunctional === true,
|
|
10141
|
+
noTargeting: flags.noTargeting === true
|
|
10142
|
+
};
|
|
10143
|
+
}
|
|
10144
|
+
/**
|
|
10145
|
+
* Returns true if third-party targeting is disabled.
|
|
10146
|
+
* Targeting is allowed when noTargeting is false (default).
|
|
10147
|
+
*/
|
|
10148
|
+
CookieConsentManager.prototype.getNoTargeting = function () {
|
|
10149
|
+
return this.flags.noTargeting;
|
|
10150
|
+
};
|
|
10151
|
+
/**
|
|
10152
|
+
* Returns true if functional tracking is disabled.
|
|
10153
|
+
* Functional tracking is allowed when noFunctional is false (default).
|
|
10154
|
+
*/
|
|
10155
|
+
CookieConsentManager.prototype.getNoFunctional = function () {
|
|
10156
|
+
return this.flags.noFunctional;
|
|
10157
|
+
};
|
|
10158
|
+
return CookieConsentManager;
|
|
10159
|
+
}();
|
|
10160
|
+
|
|
10117
10161
|
var Messages = Constants.Messages,
|
|
10118
10162
|
HTTPCodes = Constants.HTTPCodes,
|
|
10119
10163
|
FeatureFlags = Constants.FeatureFlags,
|
|
@@ -10226,6 +10270,7 @@ var mParticle = (function () {
|
|
|
10226
10270
|
if (instance._Store) {
|
|
10227
10271
|
delete instance._Store;
|
|
10228
10272
|
}
|
|
10273
|
+
instance.Logger = new Logger(config);
|
|
10229
10274
|
instance._Store = new Store(config, instance);
|
|
10230
10275
|
instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(window.localStorage);
|
|
10231
10276
|
instance._Events.stopTracking();
|
|
@@ -11190,10 +11235,19 @@ var mParticle = (function () {
|
|
|
11190
11235
|
});
|
|
11191
11236
|
}
|
|
11192
11237
|
function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
|
|
11238
|
+
var _a;
|
|
11193
11239
|
mpInstance.Logger = new Logger(config);
|
|
11194
11240
|
mpInstance._Store = new Store(config, mpInstance, apiKey);
|
|
11195
11241
|
window.mParticle.Store = mpInstance._Store;
|
|
11196
11242
|
mpInstance.Logger.verbose(StartingInitialization);
|
|
11243
|
+
// Initialize CookieConsentManager with privacy flags from launcherOptions
|
|
11244
|
+
var _b = (_a = config === null || config === void 0 ? void 0 : config.launcherOptions) !== null && _a !== void 0 ? _a : {},
|
|
11245
|
+
noFunctional = _b.noFunctional,
|
|
11246
|
+
noTargeting = _b.noTargeting;
|
|
11247
|
+
mpInstance._CookieConsentManager = new CookieConsentManager({
|
|
11248
|
+
noFunctional: noFunctional,
|
|
11249
|
+
noTargeting: noTargeting
|
|
11250
|
+
});
|
|
11197
11251
|
// Check to see if localStorage is available before main configuration runs
|
|
11198
11252
|
// since we will need this for the current implementation of user persistence
|
|
11199
11253
|
// TODO: Refactor this when we refactor User Identity Persistence
|
package/package.json
CHANGED
package/src/batchUploader.ts
CHANGED
|
@@ -257,15 +257,15 @@ export class BatchUploader {
|
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
const {
|
|
260
|
+
const { Logger } = this.mpInstance;
|
|
261
261
|
|
|
262
262
|
this.eventsQueuedForProcessing.push(event);
|
|
263
263
|
if (this.offlineStorageEnabled && this.eventVault) {
|
|
264
264
|
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
verbose(`Queuing event: ${JSON.stringify(event)}`);
|
|
268
|
-
verbose(`Queued event count: ${this.eventsQueuedForProcessing.length}`);
|
|
267
|
+
Logger.verbose(`Queuing event: ${JSON.stringify(event)}`);
|
|
268
|
+
Logger.verbose(`Queued event count: ${this.eventsQueuedForProcessing.length}`);
|
|
269
269
|
|
|
270
270
|
if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
|
|
271
271
|
this.prepareAndUpload(false, false);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie consent flags control SDK behavior based on user consent preferences for Rokt integration.
|
|
3
|
+
* @see https://docs.rokt.com/developers/integration-guides/web/cookie-consent-flags/
|
|
4
|
+
*/
|
|
5
|
+
export interface ICookieConsentFlags {
|
|
6
|
+
/**
|
|
7
|
+
* When true, indicates the user has opted out of functional cookies/tracking.
|
|
8
|
+
* Default: false (functional tracking is allowed)
|
|
9
|
+
*/
|
|
10
|
+
noFunctional: boolean;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* When true, indicates the user has opted out of targeting cookies/tracking.
|
|
14
|
+
* This flag is used to block cookie syncs and other targeting-related features.
|
|
15
|
+
* Default: false (targeting is allowed)
|
|
16
|
+
*/
|
|
17
|
+
noTargeting: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ICookieConsentManager {
|
|
21
|
+
/**
|
|
22
|
+
* Targeting is allowed when noTargeting is false (default)
|
|
23
|
+
*/
|
|
24
|
+
getNoTargeting: () => boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Functional tracking is allowed when noFunctional is false (default)
|
|
28
|
+
*/
|
|
29
|
+
getNoFunctional: () => boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
34
|
+
* that are passed via launcherOptions during SDK initialization.
|
|
35
|
+
*
|
|
36
|
+
* These flags allow Rokt integration to respect user privacy choices.
|
|
37
|
+
*
|
|
38
|
+
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
39
|
+
* unless explicitly opted out by the user.
|
|
40
|
+
*/
|
|
41
|
+
export default class CookieConsentManager implements ICookieConsentManager {
|
|
42
|
+
constructor(private flags: ICookieConsentFlags) {
|
|
43
|
+
this.flags = {
|
|
44
|
+
noFunctional: flags.noFunctional === true,
|
|
45
|
+
noTargeting: flags.noTargeting === true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns true if third-party targeting is disabled.
|
|
51
|
+
* Targeting is allowed when noTargeting is false (default).
|
|
52
|
+
*/
|
|
53
|
+
getNoTargeting(): boolean {
|
|
54
|
+
return this.flags.noTargeting;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns true if functional tracking is disabled.
|
|
59
|
+
* Functional tracking is allowed when noFunctional is false (default).
|
|
60
|
+
*/
|
|
61
|
+
getNoFunctional(): boolean {
|
|
62
|
+
return this.flags.noFunctional;
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/cookieSyncManager.ts
CHANGED
|
@@ -21,6 +21,7 @@ export const PARTNER_MODULE_IDS = {
|
|
|
21
21
|
Lotame: 58,
|
|
22
22
|
TradeDesk: 103,
|
|
23
23
|
VerizonMedia: 155,
|
|
24
|
+
Rokt: 1277,
|
|
24
25
|
} as const;
|
|
25
26
|
|
|
26
27
|
export type CookieSyncDates = Dictionary<number>;
|
|
@@ -108,6 +109,11 @@ export default function CookieSyncManager(
|
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
// For Rokt, block cookie sync when noTargeting privacy flag is true
|
|
113
|
+
if (moduleId === PARTNER_MODULE_IDS.Rokt && mpInstance._CookieConsentManager.getNoTargeting()) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
const { isEnabledForUserConsent } = mpInstance._Consent;
|
|
112
118
|
|
|
113
119
|
if (!isEnabledForUserConsent(filteringConsentRuleValues, mpInstance.Identity.getCurrentUser())) {
|
package/src/identityApiClient.ts
CHANGED
|
@@ -88,12 +88,12 @@ export default function IdentityAPIClient(
|
|
|
88
88
|
aliasRequest: IAliasRequest,
|
|
89
89
|
aliasCallback: IAliasCallback
|
|
90
90
|
) {
|
|
91
|
-
const {
|
|
91
|
+
const { Logger } = mpInstance;
|
|
92
92
|
const { invokeAliasCallback } = mpInstance._Helpers;
|
|
93
93
|
const { aliasUrl } = mpInstance._Store.SDKConfig;
|
|
94
94
|
const { devToken: apiKey } = mpInstance._Store;
|
|
95
95
|
|
|
96
|
-
verbose(Messages.InformationMessages.SendAliasHttp);
|
|
96
|
+
Logger.verbose(Messages.InformationMessages.SendAliasHttp);
|
|
97
97
|
|
|
98
98
|
// https://go.mparticle.com/work/SQDSDKS-6750
|
|
99
99
|
const uploadUrl = `https://${aliasUrl}${apiKey}/Alias`;
|
|
@@ -136,7 +136,7 @@ export default function IdentityAPIClient(
|
|
|
136
136
|
try {
|
|
137
137
|
aliasResponseBody = await response.json();
|
|
138
138
|
} catch (e) {
|
|
139
|
-
verbose('The request has no response body');
|
|
139
|
+
Logger.verbose('The request has no response body');
|
|
140
140
|
}
|
|
141
141
|
} else {
|
|
142
142
|
// https://go.mparticle.com/work/SQDSDKS-6568
|
|
@@ -171,11 +171,11 @@ export default function IdentityAPIClient(
|
|
|
171
171
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
verbose(message);
|
|
174
|
+
Logger.verbose(message);
|
|
175
175
|
invokeAliasCallback(aliasCallback, response.status, errorMessage);
|
|
176
176
|
} catch (e) {
|
|
177
177
|
const errorMessage = (e as Error).message || e.toString();
|
|
178
|
-
error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
178
|
+
Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
179
179
|
invokeAliasCallback(
|
|
180
180
|
aliasCallback,
|
|
181
181
|
HTTPCodes.noHttpCoverage,
|
|
@@ -193,15 +193,14 @@ export default function IdentityAPIClient(
|
|
|
193
193
|
mpid: MPID,
|
|
194
194
|
knownIdentities: UserIdentities
|
|
195
195
|
) {
|
|
196
|
-
const { verbose, error } = mpInstance.Logger;
|
|
197
196
|
const { invokeCallback } = mpInstance._Helpers;
|
|
198
|
-
|
|
199
|
-
verbose(Messages.InformationMessages.SendIdentityBegin);
|
|
197
|
+
const { Logger } = mpInstance;
|
|
198
|
+
Logger.verbose(Messages.InformationMessages.SendIdentityBegin);
|
|
200
199
|
if (!identityApiRequest) {
|
|
201
|
-
error(Messages.ErrorMessages.APIRequestEmpty);
|
|
200
|
+
Logger.error(Messages.ErrorMessages.APIRequestEmpty);
|
|
202
201
|
return;
|
|
203
202
|
}
|
|
204
|
-
verbose(Messages.InformationMessages.SendIdentityHttp);
|
|
203
|
+
Logger.verbose(Messages.InformationMessages.SendIdentityHttp);
|
|
205
204
|
|
|
206
205
|
if (mpInstance._Store.identityCallInFlight) {
|
|
207
206
|
invokeCallback(
|
|
@@ -289,7 +288,7 @@ export default function IdentityAPIClient(
|
|
|
289
288
|
|
|
290
289
|
mpInstance._Store.identityCallInFlight = false;
|
|
291
290
|
|
|
292
|
-
verbose(message);
|
|
291
|
+
Logger.verbose(message);
|
|
293
292
|
parseIdentityResponse(
|
|
294
293
|
identityResponse,
|
|
295
294
|
previousMPID,
|
|
@@ -304,7 +303,7 @@ export default function IdentityAPIClient(
|
|
|
304
303
|
|
|
305
304
|
const errorMessage = (err as Error).message || err.toString();
|
|
306
305
|
|
|
307
|
-
error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
306
|
+
Logger.error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
308
307
|
invokeCallback(
|
|
309
308
|
callback,
|
|
310
309
|
HTTPCodes.noHttpCoverage,
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LogLevelType, SDKInitConfig, SDKLoggerApi } from './sdkRuntimeModels';
|
|
2
|
+
|
|
3
|
+
export type ILoggerConfig = Pick<SDKInitConfig, 'logLevel' | 'logger'>;
|
|
4
|
+
export type IConsoleLogger = Partial<Pick<SDKLoggerApi, 'error' | 'warning' | 'verbose'>>;
|
|
5
|
+
|
|
6
|
+
export class Logger {
|
|
7
|
+
private logLevel: LogLevelType;
|
|
8
|
+
private logger: IConsoleLogger;
|
|
9
|
+
|
|
10
|
+
constructor(config: ILoggerConfig) {
|
|
11
|
+
this.logLevel = config.logLevel ?? LogLevelType.Warning;
|
|
12
|
+
this.logger = config.logger ?? new ConsoleLogger();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public verbose(msg: string): void {
|
|
16
|
+
if(this.logLevel === LogLevelType.None)
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
if (this.logger.verbose && this.logLevel === LogLevelType.Verbose) {
|
|
20
|
+
this.logger.verbose(msg);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public warning(msg: string): void {
|
|
25
|
+
if(this.logLevel === LogLevelType.None)
|
|
26
|
+
return;
|
|
27
|
+
|
|
28
|
+
if (this.logger.warning &&
|
|
29
|
+
(this.logLevel === LogLevelType.Verbose || this.logLevel === LogLevelType.Warning)) {
|
|
30
|
+
this.logger.warning(msg);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public error(msg: string): void {
|
|
35
|
+
if(this.logLevel === LogLevelType.None)
|
|
36
|
+
return;
|
|
37
|
+
|
|
38
|
+
if (this.logger.error) {
|
|
39
|
+
this.logger.error(msg);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public setLogLevel(newLogLevel: LogLevelType): void {
|
|
44
|
+
this.logLevel = newLogLevel;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class ConsoleLogger implements IConsoleLogger {
|
|
49
|
+
public verbose(msg: string): void {
|
|
50
|
+
if (console && console.info) {
|
|
51
|
+
console.info(msg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public error(msg: string): void {
|
|
56
|
+
if (console && console.error) {
|
|
57
|
+
console.error(msg);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public warning(msg: string): void {
|
|
62
|
+
if (console && console.warn) {
|
|
63
|
+
console.warn(msg);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|