@mparticle/web-sdk 2.46.0 → 2.47.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 +71 -79
- package/dist/mparticle.esm.js +71 -79
- package/dist/mparticle.js +98 -247
- package/package.json +1 -1
- package/src/batchUploader.ts +3 -1
- package/src/constants.ts +14 -2
- package/src/helpers.js +0 -10
- package/src/identity-user-interfaces.ts +2 -2
- package/src/identity.interfaces.ts +1 -1
- package/src/identity.js +29 -138
- package/src/mp-instance.ts +25 -30
- package/src/persistence.interfaces.ts +0 -5
- package/src/persistence.js +15 -166
- package/src/roktManager.ts +6 -3
- package/src/sdkRuntimeModels.ts +0 -1
- package/src/sessionManager.ts +1 -1
- package/src/store.ts +26 -15
- package/src/utils.ts +16 -9
- package/src/vault.ts +16 -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.47.1";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -211,7 +211,8 @@ var mParticle = (function () {
|
|
|
211
211
|
platform: 'web',
|
|
212
212
|
Messages: {
|
|
213
213
|
DeprecationMessages: {
|
|
214
|
-
|
|
214
|
+
MethodHasBeenDeprecated: 'has been deprecated.',
|
|
215
|
+
MethodMarkedForDeprecationPostfix: 'is a deprecated method and will be removed in future releases.',
|
|
215
216
|
AlternativeMethodPrefix: 'Please use the alternate method:'
|
|
216
217
|
},
|
|
217
218
|
ErrorMessages: {
|
|
@@ -409,6 +410,12 @@ var mParticle = (function () {
|
|
|
409
410
|
var HTTP_OK = 200;
|
|
410
411
|
var HTTP_ACCEPTED = 202;
|
|
411
412
|
var HTTP_BAD_REQUEST = 400;
|
|
413
|
+
var StoragePrivacyMap = {
|
|
414
|
+
SDKState: 'functional',
|
|
415
|
+
OfflineEvents: 'functional',
|
|
416
|
+
IdentityCache: 'functional',
|
|
417
|
+
TimeOnSite: 'targeting'
|
|
418
|
+
};
|
|
412
419
|
|
|
413
420
|
/******************************************************************************
|
|
414
421
|
Copyright (c) Microsoft Corporation.
|
|
@@ -538,11 +545,19 @@ var mParticle = (function () {
|
|
|
538
545
|
}
|
|
539
546
|
return null;
|
|
540
547
|
};
|
|
541
|
-
var generateDeprecationMessage = function generateDeprecationMessage(methodName, alternateMethod) {
|
|
542
|
-
var messageArray = [methodName
|
|
548
|
+
var generateDeprecationMessage = function generateDeprecationMessage(methodName, isDeprecated, alternateMethod, docsUrl) {
|
|
549
|
+
var messageArray = [methodName];
|
|
550
|
+
if (isDeprecated) {
|
|
551
|
+
messageArray.push(Messages$9.DeprecationMessages.MethodHasBeenDeprecated);
|
|
552
|
+
} else {
|
|
553
|
+
messageArray.push(Messages$9.DeprecationMessages.MethodMarkedForDeprecationPostfix);
|
|
554
|
+
}
|
|
543
555
|
if (alternateMethod) {
|
|
544
|
-
messageArray.push(
|
|
545
|
-
messageArray.push(
|
|
556
|
+
messageArray.push(Messages$9.DeprecationMessages.AlternativeMethodPrefix);
|
|
557
|
+
messageArray.push(alternateMethod + ".");
|
|
558
|
+
}
|
|
559
|
+
if (docsUrl) {
|
|
560
|
+
messageArray.push("See - " + docsUrl);
|
|
546
561
|
}
|
|
547
562
|
return messageArray.join(' ');
|
|
548
563
|
};
|
|
@@ -2179,6 +2194,22 @@ var mParticle = (function () {
|
|
|
2179
2194
|
}
|
|
2180
2195
|
return SessionStorageVault;
|
|
2181
2196
|
}(BaseVault);
|
|
2197
|
+
// DisabledVault is used when persistence is disabled by privacy flags.
|
|
2198
|
+
var DisabledVault = /** @class */function (_super) {
|
|
2199
|
+
__extends(DisabledVault, _super);
|
|
2200
|
+
function DisabledVault(storageKey, options) {
|
|
2201
|
+
var _this = _super.call(this, storageKey, window.localStorage, options) || this;
|
|
2202
|
+
_this.contents = null;
|
|
2203
|
+
return _this;
|
|
2204
|
+
}
|
|
2205
|
+
DisabledVault.prototype.store = function (_item) {
|
|
2206
|
+
this.contents = null;
|
|
2207
|
+
};
|
|
2208
|
+
DisabledVault.prototype.retrieve = function () {
|
|
2209
|
+
return this.contents;
|
|
2210
|
+
};
|
|
2211
|
+
return DisabledVault;
|
|
2212
|
+
}(BaseVault);
|
|
2182
2213
|
|
|
2183
2214
|
var AsyncUploader = /** @class */function () {
|
|
2184
2215
|
function AsyncUploader(url) {
|
|
@@ -2358,7 +2389,7 @@ var mParticle = (function () {
|
|
|
2358
2389
|
this.batchesQueuedForProcessing = [];
|
|
2359
2390
|
// Cache Offline Storage Availability boolean
|
|
2360
2391
|
// so that we don't have to check it every time
|
|
2361
|
-
this.offlineStorageEnabled = this.isOfflineStorageAvailable();
|
|
2392
|
+
this.offlineStorageEnabled = this.isOfflineStorageAvailable() && !mpInstance._Store.getPrivacyFlag('OfflineEvents');
|
|
2362
2393
|
if (this.offlineStorageEnabled) {
|
|
2363
2394
|
this.eventVault = new SessionStorageVault("".concat(mpInstance._Store.storageName, "-events"), {
|
|
2364
2395
|
logger: mpInstance.Logger
|
|
@@ -3300,13 +3331,6 @@ var mParticle = (function () {
|
|
|
3300
3331
|
return StorageNames$1.currentStorageName;
|
|
3301
3332
|
}
|
|
3302
3333
|
};
|
|
3303
|
-
this.createProductStorageName = function (workspaceToken) {
|
|
3304
|
-
if (workspaceToken) {
|
|
3305
|
-
return StorageNames$1.currentStorageProductsName + '_' + workspaceToken;
|
|
3306
|
-
} else {
|
|
3307
|
-
return StorageNames$1.currentStorageProductsName;
|
|
3308
|
-
}
|
|
3309
|
-
};
|
|
3310
3334
|
|
|
3311
3335
|
// TODO: Refactor SDK to directly use these methods
|
|
3312
3336
|
// https://go.mparticle.com/work/SQDSDKS-5239
|
|
@@ -3712,7 +3736,7 @@ var mParticle = (function () {
|
|
|
3712
3736
|
}
|
|
3713
3737
|
};
|
|
3714
3738
|
this.getSession = function () {
|
|
3715
|
-
mpInstance.Logger.warning(generateDeprecationMessage('SessionManager.getSession()', 'SessionManager.getSessionId()'));
|
|
3739
|
+
mpInstance.Logger.warning(generateDeprecationMessage('SessionManager.getSession()', false, 'SessionManager.getSessionId()'));
|
|
3716
3740
|
return this.getSessionId();
|
|
3717
3741
|
};
|
|
3718
3742
|
this.getSessionId = function () {
|
|
@@ -4368,9 +4392,7 @@ var mParticle = (function () {
|
|
|
4368
4392
|
// TODO: Merge this with SDKStoreApi in sdkRuntimeModels
|
|
4369
4393
|
function Store(config, mpInstance, apiKey) {
|
|
4370
4394
|
var _this = this;
|
|
4371
|
-
var
|
|
4372
|
-
createMainStorageName = _a.createMainStorageName,
|
|
4373
|
-
createProductStorageName = _a.createProductStorageName;
|
|
4395
|
+
var createMainStorageName = mpInstance._Helpers.createMainStorageName;
|
|
4374
4396
|
var isWebviewEnabled = mpInstance._NativeSdkHelpers.isWebviewEnabled;
|
|
4375
4397
|
var defaultStore = {
|
|
4376
4398
|
isEnabled: true,
|
|
@@ -4407,7 +4429,6 @@ var mParticle = (function () {
|
|
|
4407
4429
|
requireDelay: true,
|
|
4408
4430
|
isLocalStorageAvailable: null,
|
|
4409
4431
|
storageName: null,
|
|
4410
|
-
prodStorageName: null,
|
|
4411
4432
|
activeForwarders: [],
|
|
4412
4433
|
kits: {},
|
|
4413
4434
|
sideloadedKits: [],
|
|
@@ -4626,6 +4647,16 @@ var mParticle = (function () {
|
|
|
4626
4647
|
this.setNoTargeting = function (noTargeting) {
|
|
4627
4648
|
_this.noTargeting = noTargeting;
|
|
4628
4649
|
};
|
|
4650
|
+
this.getPrivacyFlag = function (storageType) {
|
|
4651
|
+
var privacyControl = StoragePrivacyMap[storageType];
|
|
4652
|
+
if (privacyControl === 'functional') {
|
|
4653
|
+
return _this.getNoFunctional();
|
|
4654
|
+
}
|
|
4655
|
+
if (privacyControl === 'targeting') {
|
|
4656
|
+
return _this.getNoTargeting();
|
|
4657
|
+
}
|
|
4658
|
+
return false;
|
|
4659
|
+
};
|
|
4629
4660
|
this.getDeviceId = function () {
|
|
4630
4661
|
return _this.deviceId;
|
|
4631
4662
|
};
|
|
@@ -4706,6 +4737,7 @@ var mParticle = (function () {
|
|
|
4706
4737
|
mpInstance._Persistence.update();
|
|
4707
4738
|
};
|
|
4708
4739
|
this.processConfig = function (config) {
|
|
4740
|
+
var _a;
|
|
4709
4741
|
var workspaceToken = config.workspaceToken,
|
|
4710
4742
|
requiredWebviewBridgeName = config.requiredWebviewBridgeName;
|
|
4711
4743
|
// We should reprocess the flags and baseUrls in case they have changed when we request an updated config
|
|
@@ -4716,22 +4748,25 @@ var mParticle = (function () {
|
|
|
4716
4748
|
for (var baseUrlKeys in baseUrls) {
|
|
4717
4749
|
_this.SDKConfig[baseUrlKeys] = baseUrls[baseUrlKeys];
|
|
4718
4750
|
}
|
|
4751
|
+
var _b = (_a = config === null || config === void 0 ? void 0 : config.launcherOptions) !== null && _a !== void 0 ? _a : {},
|
|
4752
|
+
noFunctional = _b.noFunctional,
|
|
4753
|
+
noTargeting = _b.noTargeting;
|
|
4754
|
+
if (noFunctional != null) {
|
|
4755
|
+
_this.setNoFunctional(noFunctional);
|
|
4756
|
+
}
|
|
4757
|
+
if (noTargeting != null) {
|
|
4758
|
+
_this.setNoTargeting(noTargeting);
|
|
4759
|
+
}
|
|
4719
4760
|
if (workspaceToken) {
|
|
4720
4761
|
_this.SDKConfig.workspaceToken = workspaceToken;
|
|
4721
|
-
|
|
4762
|
+
if (!_this.getPrivacyFlag('TimeOnSite')) {
|
|
4763
|
+
mpInstance._timeOnSiteTimer = new ForegroundTimeTracker(workspaceToken);
|
|
4764
|
+
}
|
|
4722
4765
|
} else {
|
|
4723
4766
|
mpInstance.Logger.warning('You should have a workspaceToken on your config object for security purposes.');
|
|
4724
4767
|
}
|
|
4725
4768
|
// add a new function to apply items to the store that require config to be returned
|
|
4726
4769
|
_this.storageName = createMainStorageName(workspaceToken);
|
|
4727
|
-
_this.prodStorageName = createProductStorageName(workspaceToken);
|
|
4728
|
-
// Extract privacy flags directly from config into Store
|
|
4729
|
-
if (config.hasOwnProperty('noFunctional')) {
|
|
4730
|
-
_this.setNoFunctional(config.noFunctional);
|
|
4731
|
-
}
|
|
4732
|
-
if (config.hasOwnProperty('noTargeting')) {
|
|
4733
|
-
_this.setNoTargeting(config.noTargeting);
|
|
4734
|
-
}
|
|
4735
4770
|
_this.SDKConfig.requiredWebviewBridgeName = requiredWebviewBridgeName || workspaceToken;
|
|
4736
4771
|
_this.webviewBridgeEnabled = isWebviewEnabled(_this.SDKConfig.requiredWebviewBridgeName, _this.SDKConfig.minWebviewBridgeVersion);
|
|
4737
4772
|
_this.configurationLoaded = true;
|
|
@@ -4911,6 +4946,9 @@ var mParticle = (function () {
|
|
|
4911
4946
|
} else {
|
|
4912
4947
|
mpInstance._Store.isFirstRun = false;
|
|
4913
4948
|
}
|
|
4949
|
+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
|
|
4950
|
+
return;
|
|
4951
|
+
}
|
|
4914
4952
|
|
|
4915
4953
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
4916
4954
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
@@ -4955,25 +4993,6 @@ var mParticle = (function () {
|
|
|
4955
4993
|
self.storeDataInMemory(cookies);
|
|
4956
4994
|
}
|
|
4957
4995
|
|
|
4958
|
-
// https://go.mparticle.com/work/SQDSDKS-6048
|
|
4959
|
-
try {
|
|
4960
|
-
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
4961
|
-
var encodedProducts = localStorage.getItem(mpInstance._Store.prodStorageName);
|
|
4962
|
-
if (encodedProducts) {
|
|
4963
|
-
var decodedProducts = JSON.parse(Base64.decode(encodedProducts));
|
|
4964
|
-
}
|
|
4965
|
-
if (mpInstance._Store.mpid) {
|
|
4966
|
-
self.storeProductsInMemory(decodedProducts, mpInstance._Store.mpid);
|
|
4967
|
-
}
|
|
4968
|
-
}
|
|
4969
|
-
} catch (e) {
|
|
4970
|
-
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
4971
|
-
localStorage.removeItem(mpInstance._Store.prodStorageName);
|
|
4972
|
-
}
|
|
4973
|
-
mpInstance._Store.cartProducts = [];
|
|
4974
|
-
mpInstance.Logger.error('Error loading products in initialization: ' + e);
|
|
4975
|
-
}
|
|
4976
|
-
|
|
4977
4996
|
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
4978
4997
|
// Stores all non-current user MPID information into the store
|
|
4979
4998
|
for (var key in allData) {
|
|
@@ -4996,22 +5015,13 @@ var mParticle = (function () {
|
|
|
4996
5015
|
}
|
|
4997
5016
|
};
|
|
4998
5017
|
this.update = function () {
|
|
4999
|
-
if (!mpInstance._Store.webviewBridgeEnabled) {
|
|
5018
|
+
if (!mpInstance._Store.webviewBridgeEnabled && !mpInstance._Store.getPrivacyFlag('SDKState')) {
|
|
5000
5019
|
if (mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
5001
5020
|
self.setCookie();
|
|
5002
5021
|
}
|
|
5003
5022
|
self.setLocalStorage();
|
|
5004
5023
|
}
|
|
5005
5024
|
};
|
|
5006
|
-
this.storeProductsInMemory = function (products, mpid) {
|
|
5007
|
-
if (products) {
|
|
5008
|
-
try {
|
|
5009
|
-
mpInstance._Store.cartProducts = products[mpid] && products[mpid].cp ? products[mpid].cp : [];
|
|
5010
|
-
} catch (e) {
|
|
5011
|
-
mpInstance.Logger.error(Messages$4.ErrorMessages.CookieParseError);
|
|
5012
|
-
}
|
|
5013
|
-
}
|
|
5014
|
-
};
|
|
5015
5025
|
|
|
5016
5026
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5017
5027
|
this.storeDataInMemory = function (obj, currentMPID) {
|
|
@@ -5082,51 +5092,6 @@ var mParticle = (function () {
|
|
|
5082
5092
|
return false;
|
|
5083
5093
|
}
|
|
5084
5094
|
};
|
|
5085
|
-
this.getUserProductsFromLS = function (mpid) {
|
|
5086
|
-
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5087
|
-
return [];
|
|
5088
|
-
}
|
|
5089
|
-
var decodedProducts,
|
|
5090
|
-
userProducts,
|
|
5091
|
-
parsedProducts,
|
|
5092
|
-
encodedProducts = localStorage.getItem(mpInstance._Store.prodStorageName);
|
|
5093
|
-
if (encodedProducts) {
|
|
5094
|
-
decodedProducts = Base64.decode(encodedProducts);
|
|
5095
|
-
}
|
|
5096
|
-
// if there is an MPID, we are retrieving the user's products, which is an array
|
|
5097
|
-
if (mpid) {
|
|
5098
|
-
try {
|
|
5099
|
-
if (decodedProducts) {
|
|
5100
|
-
parsedProducts = JSON.parse(decodedProducts);
|
|
5101
|
-
}
|
|
5102
|
-
if (decodedProducts && parsedProducts[mpid] && parsedProducts[mpid].cp && Array.isArray(parsedProducts[mpid].cp)) {
|
|
5103
|
-
userProducts = parsedProducts[mpid].cp;
|
|
5104
|
-
} else {
|
|
5105
|
-
userProducts = [];
|
|
5106
|
-
}
|
|
5107
|
-
return userProducts;
|
|
5108
|
-
} catch (e) {
|
|
5109
|
-
return [];
|
|
5110
|
-
}
|
|
5111
|
-
} else {
|
|
5112
|
-
return [];
|
|
5113
|
-
}
|
|
5114
|
-
};
|
|
5115
|
-
this.getAllUserProductsFromLS = function () {
|
|
5116
|
-
var decodedProducts,
|
|
5117
|
-
encodedProducts = localStorage.getItem(mpInstance._Store.prodStorageName),
|
|
5118
|
-
parsedDecodedProducts;
|
|
5119
|
-
if (encodedProducts) {
|
|
5120
|
-
decodedProducts = Base64.decode(encodedProducts);
|
|
5121
|
-
}
|
|
5122
|
-
// returns an object with keys of MPID and values of array of products
|
|
5123
|
-
try {
|
|
5124
|
-
parsedDecodedProducts = JSON.parse(decodedProducts);
|
|
5125
|
-
} catch (e) {
|
|
5126
|
-
parsedDecodedProducts = {};
|
|
5127
|
-
}
|
|
5128
|
-
return parsedDecodedProducts;
|
|
5129
|
-
};
|
|
5130
5095
|
|
|
5131
5096
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
5132
5097
|
this.setLocalStorage = function () {
|
|
@@ -5134,22 +5099,9 @@ var mParticle = (function () {
|
|
|
5134
5099
|
return;
|
|
5135
5100
|
}
|
|
5136
5101
|
var key = mpInstance._Store.storageName,
|
|
5137
|
-
allLocalStorageProducts = self.getAllUserProductsFromLS(),
|
|
5138
5102
|
localStorageData = self.getLocalStorage() || {},
|
|
5139
5103
|
currentUser = mpInstance.Identity.getCurrentUser(),
|
|
5140
|
-
mpid = currentUser ? currentUser.getMPID() : null
|
|
5141
|
-
currentUserProducts = {
|
|
5142
|
-
cp: allLocalStorageProducts[mpid] ? allLocalStorageProducts[mpid].cp : []
|
|
5143
|
-
};
|
|
5144
|
-
if (mpid) {
|
|
5145
|
-
allLocalStorageProducts = allLocalStorageProducts || {};
|
|
5146
|
-
allLocalStorageProducts[mpid] = currentUserProducts;
|
|
5147
|
-
try {
|
|
5148
|
-
window.localStorage.setItem(encodeURIComponent(mpInstance._Store.prodStorageName), Base64.encode(JSON.stringify(allLocalStorageProducts)));
|
|
5149
|
-
} catch (e) {
|
|
5150
|
-
mpInstance.Logger.error('Error with setting products on localStorage.');
|
|
5151
|
-
}
|
|
5152
|
-
}
|
|
5104
|
+
mpid = currentUser ? currentUser.getMPID() : null;
|
|
5153
5105
|
if (!mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
5154
5106
|
localStorageData.gs = localStorageData.gs || {};
|
|
5155
5107
|
localStorageData.l = mpInstance._Store.isLoggedIn ? 1 : 0;
|
|
@@ -5518,27 +5470,6 @@ var mParticle = (function () {
|
|
|
5518
5470
|
}
|
|
5519
5471
|
return '';
|
|
5520
5472
|
};
|
|
5521
|
-
this.getCartProducts = function (mpid) {
|
|
5522
|
-
var allCartProducts,
|
|
5523
|
-
cartProductsString = localStorage.getItem(mpInstance._Store.prodStorageName);
|
|
5524
|
-
if (cartProductsString) {
|
|
5525
|
-
allCartProducts = JSON.parse(Base64.decode(cartProductsString));
|
|
5526
|
-
if (allCartProducts && allCartProducts[mpid] && allCartProducts[mpid].cp) {
|
|
5527
|
-
return allCartProducts[mpid].cp;
|
|
5528
|
-
}
|
|
5529
|
-
}
|
|
5530
|
-
return [];
|
|
5531
|
-
};
|
|
5532
|
-
this.setCartProducts = function (allProducts) {
|
|
5533
|
-
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5534
|
-
return;
|
|
5535
|
-
}
|
|
5536
|
-
try {
|
|
5537
|
-
window.localStorage.setItem(encodeURIComponent(mpInstance._Store.prodStorageName), Base64.encode(JSON.stringify(allProducts)));
|
|
5538
|
-
} catch (e) {
|
|
5539
|
-
mpInstance.Logger.error('Error with setting products on localStorage.');
|
|
5540
|
-
}
|
|
5541
|
-
};
|
|
5542
5473
|
this.saveUserCookieSyncDatesToPersistence = function (mpid, csd) {
|
|
5543
5474
|
if (csd) {
|
|
5544
5475
|
var persistence = self.getPersistence();
|
|
@@ -5567,6 +5498,9 @@ var mParticle = (function () {
|
|
|
5567
5498
|
|
|
5568
5499
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
5569
5500
|
this.savePersistence = function (persistence) {
|
|
5501
|
+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
|
|
5502
|
+
return;
|
|
5503
|
+
}
|
|
5570
5504
|
var encodedPersistence = self.encodePersistence(JSON.stringify(persistence)),
|
|
5571
5505
|
date = new Date(),
|
|
5572
5506
|
key = mpInstance._Store.storageName,
|
|
@@ -5588,6 +5522,9 @@ var mParticle = (function () {
|
|
|
5588
5522
|
}
|
|
5589
5523
|
};
|
|
5590
5524
|
this.getPersistence = function () {
|
|
5525
|
+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
|
|
5526
|
+
return null;
|
|
5527
|
+
}
|
|
5591
5528
|
var persistence = this.useLocalStorage() ? this.getLocalStorage() : this.getCookie();
|
|
5592
5529
|
return persistence;
|
|
5593
5530
|
};
|
|
@@ -5672,20 +5609,17 @@ var mParticle = (function () {
|
|
|
5672
5609
|
removeLocalStorage(StorageNames.localStorageName);
|
|
5673
5610
|
removeLocalStorage(StorageNames.localStorageNameV3);
|
|
5674
5611
|
removeLocalStorage(StorageNames.localStorageNameV4);
|
|
5675
|
-
removeLocalStorage(mpInstance._Store.prodStorageName);
|
|
5676
5612
|
removeLocalStorage(mpInstance._Store.storageName);
|
|
5677
5613
|
removeLocalStorage(StorageNames.localStorageProductsV4);
|
|
5678
5614
|
self.expireCookies(StorageNames.cookieName);
|
|
5679
5615
|
self.expireCookies(StorageNames.cookieNameV2);
|
|
5680
5616
|
self.expireCookies(StorageNames.cookieNameV3);
|
|
5681
5617
|
self.expireCookies(StorageNames.cookieNameV4);
|
|
5682
|
-
self.expireCookies(mpInstance._Store.prodStorageName);
|
|
5683
5618
|
self.expireCookies(mpInstance._Store.storageName);
|
|
5684
5619
|
if (mParticle._isTestEnv) {
|
|
5685
5620
|
var testWorkspaceToken = 'abcdef';
|
|
5686
5621
|
removeLocalStorage(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
5687
5622
|
self.expireCookies(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
5688
|
-
removeLocalStorage(mpInstance._Helpers.createProductStorageName(testWorkspaceToken));
|
|
5689
5623
|
}
|
|
5690
5624
|
};
|
|
5691
5625
|
|
|
@@ -8104,7 +8038,7 @@ var mParticle = (function () {
|
|
|
8104
8038
|
*/
|
|
8105
8039
|
getCart: function getCart() {
|
|
8106
8040
|
mpInstance.Logger.warning('Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases');
|
|
8107
|
-
return self.mParticleUserCart(
|
|
8041
|
+
return self.mParticleUserCart();
|
|
8108
8042
|
},
|
|
8109
8043
|
/**
|
|
8110
8044
|
* Returns the Consent State stored locally for this user.
|
|
@@ -8159,84 +8093,23 @@ var mParticle = (function () {
|
|
|
8159
8093
|
* @class mParticle.Identity.getCurrentUser().getCart()
|
|
8160
8094
|
* @deprecated
|
|
8161
8095
|
*/
|
|
8162
|
-
this.mParticleUserCart = function (
|
|
8096
|
+
this.mParticleUserCart = function () {
|
|
8163
8097
|
return {
|
|
8164
8098
|
/**
|
|
8165
8099
|
* Adds a cart product to the user cart
|
|
8166
8100
|
* @method add
|
|
8167
|
-
* @param {Object} product the product
|
|
8168
|
-
* @param {Boolean} [logEvent] a boolean to log adding of the cart object. If blank, no logging occurs.
|
|
8169
8101
|
* @deprecated
|
|
8170
8102
|
*/
|
|
8171
|
-
add: function add(
|
|
8172
|
-
mpInstance.Logger.warning('
|
|
8173
|
-
var allProducts, userProducts, arrayCopy;
|
|
8174
|
-
arrayCopy = Array.isArray(product) ? product.slice() : [product];
|
|
8175
|
-
arrayCopy.forEach(function (product) {
|
|
8176
|
-
product.Attributes = mpInstance._Helpers.sanitizeAttributes(product.Attributes);
|
|
8177
|
-
});
|
|
8178
|
-
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8179
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.AddToCart, JSON.stringify(arrayCopy));
|
|
8180
|
-
} else {
|
|
8181
|
-
mpInstance._SessionManager.resetSessionTimer();
|
|
8182
|
-
userProducts = mpInstance._Persistence.getUserProductsFromLS(mpid);
|
|
8183
|
-
userProducts = userProducts.concat(arrayCopy);
|
|
8184
|
-
if (logEvent === true) {
|
|
8185
|
-
mpInstance._Events.logProductActionEvent(Types.ProductActionType.AddToCart, arrayCopy);
|
|
8186
|
-
}
|
|
8187
|
-
var productsForMemory = {};
|
|
8188
|
-
productsForMemory[mpid] = {
|
|
8189
|
-
cp: userProducts
|
|
8190
|
-
};
|
|
8191
|
-
if (userProducts.length > mpInstance._Store.SDKConfig.maxProducts) {
|
|
8192
|
-
mpInstance.Logger.verbose('The cart contains ' + userProducts.length + ' items. Only ' + mpInstance._Store.SDKConfig.maxProducts + ' can currently be saved in cookies.');
|
|
8193
|
-
userProducts = userProducts.slice(-mpInstance._Store.SDKConfig.maxProducts);
|
|
8194
|
-
}
|
|
8195
|
-
allProducts = mpInstance._Persistence.getAllUserProductsFromLS();
|
|
8196
|
-
allProducts[mpid].cp = userProducts;
|
|
8197
|
-
mpInstance._Persistence.setCartProducts(allProducts);
|
|
8198
|
-
}
|
|
8103
|
+
add: function add() {
|
|
8104
|
+
mpInstance.Logger.warning(generateDeprecationMessage('Identity.getCurrentUser().getCart().add()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
8199
8105
|
},
|
|
8200
8106
|
/**
|
|
8201
8107
|
* Removes a cart product from the current user cart
|
|
8202
8108
|
* @method remove
|
|
8203
|
-
* @param {Object} product the product
|
|
8204
|
-
* @param {Boolean} [logEvent] a boolean to log adding of the cart object. If blank, no logging occurs.
|
|
8205
8109
|
* @deprecated
|
|
8206
8110
|
*/
|
|
8207
|
-
remove: function remove(
|
|
8208
|
-
mpInstance.Logger.warning('
|
|
8209
|
-
var allProducts,
|
|
8210
|
-
userProducts,
|
|
8211
|
-
cartIndex = -1,
|
|
8212
|
-
cartItem = null;
|
|
8213
|
-
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8214
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.RemoveFromCart, JSON.stringify(product));
|
|
8215
|
-
} else {
|
|
8216
|
-
mpInstance._SessionManager.resetSessionTimer();
|
|
8217
|
-
userProducts = mpInstance._Persistence.getUserProductsFromLS(mpid);
|
|
8218
|
-
if (userProducts) {
|
|
8219
|
-
userProducts.forEach(function (cartProduct, i) {
|
|
8220
|
-
if (cartProduct.Sku === product.Sku) {
|
|
8221
|
-
cartIndex = i;
|
|
8222
|
-
cartItem = cartProduct;
|
|
8223
|
-
}
|
|
8224
|
-
});
|
|
8225
|
-
if (cartIndex > -1) {
|
|
8226
|
-
userProducts.splice(cartIndex, 1);
|
|
8227
|
-
if (logEvent === true) {
|
|
8228
|
-
mpInstance._Events.logProductActionEvent(Types.ProductActionType.RemoveFromCart, cartItem);
|
|
8229
|
-
}
|
|
8230
|
-
}
|
|
8231
|
-
}
|
|
8232
|
-
var productsForMemory = {};
|
|
8233
|
-
productsForMemory[mpid] = {
|
|
8234
|
-
cp: userProducts
|
|
8235
|
-
};
|
|
8236
|
-
allProducts = mpInstance._Persistence.getAllUserProductsFromLS();
|
|
8237
|
-
allProducts[mpid].cp = userProducts;
|
|
8238
|
-
mpInstance._Persistence.setCartProducts(allProducts);
|
|
8239
|
-
}
|
|
8111
|
+
remove: function remove() {
|
|
8112
|
+
mpInstance.Logger.warning(generateDeprecationMessage('Identity.getCurrentUser().getCart().remove()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
8240
8113
|
},
|
|
8241
8114
|
/**
|
|
8242
8115
|
* Clears the user's cart
|
|
@@ -8244,19 +8117,7 @@ var mParticle = (function () {
|
|
|
8244
8117
|
* @deprecated
|
|
8245
8118
|
*/
|
|
8246
8119
|
clear: function clear() {
|
|
8247
|
-
mpInstance.Logger.warning('
|
|
8248
|
-
var allProducts;
|
|
8249
|
-
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8250
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.ClearCart);
|
|
8251
|
-
} else {
|
|
8252
|
-
mpInstance._SessionManager.resetSessionTimer();
|
|
8253
|
-
allProducts = mpInstance._Persistence.getAllUserProductsFromLS();
|
|
8254
|
-
if (allProducts && allProducts[mpid] && allProducts[mpid].cp) {
|
|
8255
|
-
allProducts[mpid].cp = [];
|
|
8256
|
-
allProducts[mpid].cp = [];
|
|
8257
|
-
mpInstance._Persistence.setCartProducts(allProducts);
|
|
8258
|
-
}
|
|
8259
|
-
}
|
|
8120
|
+
mpInstance.Logger.warning(generateDeprecationMessage('Identity.getCurrentUser().getCart().clear()', true, '', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
8260
8121
|
},
|
|
8261
8122
|
/**
|
|
8262
8123
|
* Returns all cart products
|
|
@@ -8265,8 +8126,8 @@ var mParticle = (function () {
|
|
|
8265
8126
|
* @deprecated
|
|
8266
8127
|
*/
|
|
8267
8128
|
getCartProducts: function getCartProducts() {
|
|
8268
|
-
mpInstance.Logger.warning('
|
|
8269
|
-
return
|
|
8129
|
+
mpInstance.Logger.warning(generateDeprecationMessage('Identity.getCurrentUser().getCart().getCartProducts()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
8130
|
+
return [];
|
|
8270
8131
|
}
|
|
8271
8132
|
};
|
|
8272
8133
|
};
|
|
@@ -10040,13 +9901,13 @@ var mParticle = (function () {
|
|
|
10040
9901
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.verbose("RoktManager: Processing ".concat(this.messageQueue.size, " queued messages"));
|
|
10041
9902
|
this.messageQueue.forEach(function (message) {
|
|
10042
9903
|
var _a, _b, _c;
|
|
10043
|
-
if (!(message.methodName in _this
|
|
10044
|
-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found
|
|
9904
|
+
if (!(message.methodName in _this) || !isFunction(_this[message.methodName])) {
|
|
9905
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found"));
|
|
10045
9906
|
return;
|
|
10046
9907
|
}
|
|
10047
9908
|
(_b = _this.logger) === null || _b === void 0 ? void 0 : _b.verbose("RoktManager: Processing queued message: ".concat(message.methodName, " with payload: ").concat(JSON.stringify(message.payload)));
|
|
10048
9909
|
try {
|
|
10049
|
-
var result = _this
|
|
9910
|
+
var result = _this[message.methodName](message.payload);
|
|
10050
9911
|
_this.completePendingPromise(message.messageId, result);
|
|
10051
9912
|
} catch (error) {
|
|
10052
9913
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -10054,6 +9915,8 @@ var mParticle = (function () {
|
|
|
10054
9915
|
_this.completePendingPromise(message.messageId, Promise.reject(error));
|
|
10055
9916
|
}
|
|
10056
9917
|
});
|
|
9918
|
+
// Clear the queue after processing all messages
|
|
9919
|
+
this.messageQueue.clear();
|
|
10057
9920
|
};
|
|
10058
9921
|
RoktManager.prototype.queueMessage = function (message) {
|
|
10059
9922
|
this.messageQueue.set(message.messageId, message);
|
|
@@ -10598,13 +10461,7 @@ var mParticle = (function () {
|
|
|
10598
10461
|
* @deprecated
|
|
10599
10462
|
*/
|
|
10600
10463
|
add: function add(product, logEventBoolean) {
|
|
10601
|
-
self.Logger.warning('
|
|
10602
|
-
var mpid;
|
|
10603
|
-
var currentUser = self.Identity.getCurrentUser();
|
|
10604
|
-
if (currentUser) {
|
|
10605
|
-
mpid = currentUser.getMPID();
|
|
10606
|
-
}
|
|
10607
|
-
self._Identity.mParticleUserCart(mpid).add(product, logEventBoolean);
|
|
10464
|
+
self.Logger.warning(generateDeprecationMessage('eCommerce.Cart.add()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
10608
10465
|
},
|
|
10609
10466
|
/**
|
|
10610
10467
|
* Removes a product from the cart
|
|
@@ -10614,13 +10471,7 @@ var mParticle = (function () {
|
|
|
10614
10471
|
* @deprecated
|
|
10615
10472
|
*/
|
|
10616
10473
|
remove: function remove(product, logEventBoolean) {
|
|
10617
|
-
self.Logger.warning('
|
|
10618
|
-
var mpid;
|
|
10619
|
-
var currentUser = self.Identity.getCurrentUser();
|
|
10620
|
-
if (currentUser) {
|
|
10621
|
-
mpid = currentUser.getMPID();
|
|
10622
|
-
}
|
|
10623
|
-
self._Identity.mParticleUserCart(mpid).remove(product, logEventBoolean);
|
|
10474
|
+
self.Logger.warning(generateDeprecationMessage('eCommerce.Cart.remove()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
10624
10475
|
},
|
|
10625
10476
|
/**
|
|
10626
10477
|
* Clears the cart
|
|
@@ -10628,13 +10479,7 @@ var mParticle = (function () {
|
|
|
10628
10479
|
* @deprecated
|
|
10629
10480
|
*/
|
|
10630
10481
|
clear: function clear() {
|
|
10631
|
-
self.Logger.warning('
|
|
10632
|
-
var mpid;
|
|
10633
|
-
var currentUser = self.Identity.getCurrentUser();
|
|
10634
|
-
if (currentUser) {
|
|
10635
|
-
mpid = currentUser.getMPID();
|
|
10636
|
-
}
|
|
10637
|
-
self._Identity.mParticleUserCart(mpid).clear();
|
|
10482
|
+
self.Logger.warning(generateDeprecationMessage('eCommerce.Cart.clear()', true, '', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
10638
10483
|
}
|
|
10639
10484
|
},
|
|
10640
10485
|
/**
|
|
@@ -11165,7 +11010,13 @@ var mParticle = (function () {
|
|
|
11165
11010
|
return kitBlocker;
|
|
11166
11011
|
}
|
|
11167
11012
|
function createIdentityCache(mpInstance) {
|
|
11168
|
-
|
|
11013
|
+
var cacheKey = "".concat(mpInstance._Store.storageName, "-id-cache");
|
|
11014
|
+
if (mpInstance._Store.getPrivacyFlag('IdentityCache')) {
|
|
11015
|
+
return new DisabledVault(cacheKey, {
|
|
11016
|
+
logger: mpInstance.Logger
|
|
11017
|
+
});
|
|
11018
|
+
}
|
|
11019
|
+
return new LocalStorageVault(cacheKey, {
|
|
11169
11020
|
logger: mpInstance.Logger
|
|
11170
11021
|
});
|
|
11171
11022
|
}
|
package/package.json
CHANGED
package/src/batchUploader.ts
CHANGED
|
@@ -72,7 +72,9 @@ export class BatchUploader {
|
|
|
72
72
|
|
|
73
73
|
// Cache Offline Storage Availability boolean
|
|
74
74
|
// so that we don't have to check it every time
|
|
75
|
-
this.offlineStorageEnabled =
|
|
75
|
+
this.offlineStorageEnabled =
|
|
76
|
+
this.isOfflineStorageAvailable() &&
|
|
77
|
+
!mpInstance._Store.getPrivacyFlag('OfflineEvents');
|
|
76
78
|
|
|
77
79
|
if (this.offlineStorageEnabled) {
|
|
78
80
|
this.eventVault = new SessionStorageVault<SDKEvent[]>(
|
package/src/constants.ts
CHANGED
|
@@ -6,8 +6,9 @@ const Constants = {
|
|
|
6
6
|
platform: 'web',
|
|
7
7
|
Messages: {
|
|
8
8
|
DeprecationMessages: {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
MethodHasBeenDeprecated: 'has been deprecated.',
|
|
10
|
+
MethodMarkedForDeprecationPostfix:
|
|
11
|
+
'is a deprecated method and will be removed in future releases.',
|
|
11
12
|
AlternativeMethodPrefix: 'Please use the alternate method:',
|
|
12
13
|
},
|
|
13
14
|
ErrorMessages: {
|
|
@@ -229,3 +230,14 @@ export const HTTP_UNAUTHORIZED = 401 as const;
|
|
|
229
230
|
export const HTTP_FORBIDDEN = 403 as const;
|
|
230
231
|
export const HTTP_NOT_FOUND = 404 as const;
|
|
231
232
|
export const HTTP_SERVER_ERROR = 500 as const;
|
|
233
|
+
|
|
234
|
+
export type PrivacyControl = 'functional' | 'targeting';
|
|
235
|
+
|
|
236
|
+
export type StorageTypes = 'SDKState' | 'OfflineEvents' | 'IdentityCache' | 'TimeOnSite';
|
|
237
|
+
|
|
238
|
+
export const StoragePrivacyMap: Record<StorageTypes, PrivacyControl> = {
|
|
239
|
+
SDKState: 'functional',
|
|
240
|
+
OfflineEvents: 'functional',
|
|
241
|
+
IdentityCache: 'functional',
|
|
242
|
+
TimeOnSite: 'targeting',
|
|
243
|
+
};
|
package/src/helpers.js
CHANGED
|
@@ -376,16 +376,6 @@ export default function Helpers(mpInstance) {
|
|
|
376
376
|
}
|
|
377
377
|
};
|
|
378
378
|
|
|
379
|
-
this.createProductStorageName = function(workspaceToken) {
|
|
380
|
-
if (workspaceToken) {
|
|
381
|
-
return (
|
|
382
|
-
StorageNames.currentStorageProductsName + '_' + workspaceToken
|
|
383
|
-
);
|
|
384
|
-
} else {
|
|
385
|
-
return StorageNames.currentStorageProductsName;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
|
|
389
379
|
// TODO: Refactor SDK to directly use these methods
|
|
390
380
|
// https://go.mparticle.com/work/SQDSDKS-5239
|
|
391
381
|
// Utility Functions
|