@mparticle/web-sdk 2.47.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 +64 -71
- package/dist/mparticle.esm.js +64 -71
- package/dist/mparticle.js +30 -234
- package/package.json +1 -1
- package/src/constants.ts +4 -4
- 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 +19 -26
- package/src/persistence.interfaces.ts +0 -5
- package/src/persistence.js +1 -165
- package/src/sdkRuntimeModels.ts +0 -1
- package/src/sessionManager.ts +1 -1
- package/src/store.ts +0 -4
- package/src/utils.ts +16 -9
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.47.
|
|
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: {
|
|
@@ -411,7 +412,6 @@ var mParticle = (function () {
|
|
|
411
412
|
var HTTP_BAD_REQUEST = 400;
|
|
412
413
|
var StoragePrivacyMap = {
|
|
413
414
|
SDKState: 'functional',
|
|
414
|
-
Products: 'targeting',
|
|
415
415
|
OfflineEvents: 'functional',
|
|
416
416
|
IdentityCache: 'functional',
|
|
417
417
|
TimeOnSite: 'targeting'
|
|
@@ -545,11 +545,19 @@ var mParticle = (function () {
|
|
|
545
545
|
}
|
|
546
546
|
return null;
|
|
547
547
|
};
|
|
548
|
-
var generateDeprecationMessage = function generateDeprecationMessage(methodName, alternateMethod) {
|
|
549
|
-
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
|
+
}
|
|
550
555
|
if (alternateMethod) {
|
|
551
|
-
messageArray.push(
|
|
552
|
-
messageArray.push(
|
|
556
|
+
messageArray.push(Messages$9.DeprecationMessages.AlternativeMethodPrefix);
|
|
557
|
+
messageArray.push(alternateMethod + ".");
|
|
558
|
+
}
|
|
559
|
+
if (docsUrl) {
|
|
560
|
+
messageArray.push("See - " + docsUrl);
|
|
553
561
|
}
|
|
554
562
|
return messageArray.join(' ');
|
|
555
563
|
};
|
|
@@ -3323,13 +3331,6 @@ var mParticle = (function () {
|
|
|
3323
3331
|
return StorageNames$1.currentStorageName;
|
|
3324
3332
|
}
|
|
3325
3333
|
};
|
|
3326
|
-
this.createProductStorageName = function (workspaceToken) {
|
|
3327
|
-
if (workspaceToken) {
|
|
3328
|
-
return StorageNames$1.currentStorageProductsName + '_' + workspaceToken;
|
|
3329
|
-
} else {
|
|
3330
|
-
return StorageNames$1.currentStorageProductsName;
|
|
3331
|
-
}
|
|
3332
|
-
};
|
|
3333
3334
|
|
|
3334
3335
|
// TODO: Refactor SDK to directly use these methods
|
|
3335
3336
|
// https://go.mparticle.com/work/SQDSDKS-5239
|
|
@@ -3735,7 +3736,7 @@ var mParticle = (function () {
|
|
|
3735
3736
|
}
|
|
3736
3737
|
};
|
|
3737
3738
|
this.getSession = function () {
|
|
3738
|
-
mpInstance.Logger.warning(generateDeprecationMessage('SessionManager.getSession()', 'SessionManager.getSessionId()'));
|
|
3739
|
+
mpInstance.Logger.warning(generateDeprecationMessage('SessionManager.getSession()', false, 'SessionManager.getSessionId()'));
|
|
3739
3740
|
return this.getSessionId();
|
|
3740
3741
|
};
|
|
3741
3742
|
this.getSessionId = function () {
|
|
@@ -4391,9 +4392,7 @@ var mParticle = (function () {
|
|
|
4391
4392
|
// TODO: Merge this with SDKStoreApi in sdkRuntimeModels
|
|
4392
4393
|
function Store(config, mpInstance, apiKey) {
|
|
4393
4394
|
var _this = this;
|
|
4394
|
-
var
|
|
4395
|
-
createMainStorageName = _a.createMainStorageName,
|
|
4396
|
-
createProductStorageName = _a.createProductStorageName;
|
|
4395
|
+
var createMainStorageName = mpInstance._Helpers.createMainStorageName;
|
|
4397
4396
|
var isWebviewEnabled = mpInstance._NativeSdkHelpers.isWebviewEnabled;
|
|
4398
4397
|
var defaultStore = {
|
|
4399
4398
|
isEnabled: true,
|
|
@@ -4430,7 +4429,6 @@ var mParticle = (function () {
|
|
|
4430
4429
|
requireDelay: true,
|
|
4431
4430
|
isLocalStorageAvailable: null,
|
|
4432
4431
|
storageName: null,
|
|
4433
|
-
prodStorageName: null,
|
|
4434
4432
|
activeForwarders: [],
|
|
4435
4433
|
kits: {},
|
|
4436
4434
|
sideloadedKits: [],
|
|
@@ -4769,7 +4767,6 @@ var mParticle = (function () {
|
|
|
4769
4767
|
}
|
|
4770
4768
|
// add a new function to apply items to the store that require config to be returned
|
|
4771
4769
|
_this.storageName = createMainStorageName(workspaceToken);
|
|
4772
|
-
_this.prodStorageName = createProductStorageName(workspaceToken);
|
|
4773
4770
|
_this.SDKConfig.requiredWebviewBridgeName = requiredWebviewBridgeName || workspaceToken;
|
|
4774
4771
|
_this.webviewBridgeEnabled = isWebviewEnabled(_this.SDKConfig.requiredWebviewBridgeName, _this.SDKConfig.minWebviewBridgeVersion);
|
|
4775
4772
|
_this.configurationLoaded = true;
|
|
@@ -4996,25 +4993,6 @@ var mParticle = (function () {
|
|
|
4996
4993
|
self.storeDataInMemory(cookies);
|
|
4997
4994
|
}
|
|
4998
4995
|
|
|
4999
|
-
// https://go.mparticle.com/work/SQDSDKS-6048
|
|
5000
|
-
try {
|
|
5001
|
-
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
5002
|
-
var encodedProducts = localStorage.getItem(mpInstance._Store.prodStorageName);
|
|
5003
|
-
if (encodedProducts) {
|
|
5004
|
-
var decodedProducts = JSON.parse(Base64.decode(encodedProducts));
|
|
5005
|
-
}
|
|
5006
|
-
if (mpInstance._Store.mpid) {
|
|
5007
|
-
self.storeProductsInMemory(decodedProducts, mpInstance._Store.mpid);
|
|
5008
|
-
}
|
|
5009
|
-
}
|
|
5010
|
-
} catch (e) {
|
|
5011
|
-
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
5012
|
-
localStorage.removeItem(mpInstance._Store.prodStorageName);
|
|
5013
|
-
}
|
|
5014
|
-
mpInstance._Store.cartProducts = [];
|
|
5015
|
-
mpInstance.Logger.error('Error loading products in initialization: ' + e);
|
|
5016
|
-
}
|
|
5017
|
-
|
|
5018
4996
|
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
5019
4997
|
// Stores all non-current user MPID information into the store
|
|
5020
4998
|
for (var key in allData) {
|
|
@@ -5044,15 +5022,6 @@ var mParticle = (function () {
|
|
|
5044
5022
|
self.setLocalStorage();
|
|
5045
5023
|
}
|
|
5046
5024
|
};
|
|
5047
|
-
this.storeProductsInMemory = function (products, mpid) {
|
|
5048
|
-
if (products) {
|
|
5049
|
-
try {
|
|
5050
|
-
mpInstance._Store.cartProducts = products[mpid] && products[mpid].cp ? products[mpid].cp : [];
|
|
5051
|
-
} catch (e) {
|
|
5052
|
-
mpInstance.Logger.error(Messages$4.ErrorMessages.CookieParseError);
|
|
5053
|
-
}
|
|
5054
|
-
}
|
|
5055
|
-
};
|
|
5056
5025
|
|
|
5057
5026
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5058
5027
|
this.storeDataInMemory = function (obj, currentMPID) {
|
|
@@ -5123,51 +5092,6 @@ var mParticle = (function () {
|
|
|
5123
5092
|
return false;
|
|
5124
5093
|
}
|
|
5125
5094
|
};
|
|
5126
|
-
this.getUserProductsFromLS = function (mpid) {
|
|
5127
|
-
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5128
|
-
return [];
|
|
5129
|
-
}
|
|
5130
|
-
var decodedProducts,
|
|
5131
|
-
userProducts,
|
|
5132
|
-
parsedProducts,
|
|
5133
|
-
encodedProducts = localStorage.getItem(mpInstance._Store.prodStorageName);
|
|
5134
|
-
if (encodedProducts) {
|
|
5135
|
-
decodedProducts = Base64.decode(encodedProducts);
|
|
5136
|
-
}
|
|
5137
|
-
// if there is an MPID, we are retrieving the user's products, which is an array
|
|
5138
|
-
if (mpid) {
|
|
5139
|
-
try {
|
|
5140
|
-
if (decodedProducts) {
|
|
5141
|
-
parsedProducts = JSON.parse(decodedProducts);
|
|
5142
|
-
}
|
|
5143
|
-
if (decodedProducts && parsedProducts[mpid] && parsedProducts[mpid].cp && Array.isArray(parsedProducts[mpid].cp)) {
|
|
5144
|
-
userProducts = parsedProducts[mpid].cp;
|
|
5145
|
-
} else {
|
|
5146
|
-
userProducts = [];
|
|
5147
|
-
}
|
|
5148
|
-
return userProducts;
|
|
5149
|
-
} catch (e) {
|
|
5150
|
-
return [];
|
|
5151
|
-
}
|
|
5152
|
-
} else {
|
|
5153
|
-
return [];
|
|
5154
|
-
}
|
|
5155
|
-
};
|
|
5156
|
-
this.getAllUserProductsFromLS = function () {
|
|
5157
|
-
var decodedProducts,
|
|
5158
|
-
encodedProducts = localStorage.getItem(mpInstance._Store.prodStorageName),
|
|
5159
|
-
parsedDecodedProducts;
|
|
5160
|
-
if (encodedProducts) {
|
|
5161
|
-
decodedProducts = Base64.decode(encodedProducts);
|
|
5162
|
-
}
|
|
5163
|
-
// returns an object with keys of MPID and values of array of products
|
|
5164
|
-
try {
|
|
5165
|
-
parsedDecodedProducts = JSON.parse(decodedProducts);
|
|
5166
|
-
} catch (e) {
|
|
5167
|
-
parsedDecodedProducts = {};
|
|
5168
|
-
}
|
|
5169
|
-
return parsedDecodedProducts;
|
|
5170
|
-
};
|
|
5171
5095
|
|
|
5172
5096
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
5173
5097
|
this.setLocalStorage = function () {
|
|
@@ -5175,22 +5099,9 @@ var mParticle = (function () {
|
|
|
5175
5099
|
return;
|
|
5176
5100
|
}
|
|
5177
5101
|
var key = mpInstance._Store.storageName,
|
|
5178
|
-
allLocalStorageProducts = self.getAllUserProductsFromLS(),
|
|
5179
5102
|
localStorageData = self.getLocalStorage() || {},
|
|
5180
5103
|
currentUser = mpInstance.Identity.getCurrentUser(),
|
|
5181
|
-
mpid = currentUser ? currentUser.getMPID() : null
|
|
5182
|
-
currentUserProducts = {
|
|
5183
|
-
cp: allLocalStorageProducts[mpid] ? allLocalStorageProducts[mpid].cp : []
|
|
5184
|
-
};
|
|
5185
|
-
if (mpid) {
|
|
5186
|
-
allLocalStorageProducts = allLocalStorageProducts || {};
|
|
5187
|
-
allLocalStorageProducts[mpid] = currentUserProducts;
|
|
5188
|
-
try {
|
|
5189
|
-
window.localStorage.setItem(encodeURIComponent(mpInstance._Store.prodStorageName), Base64.encode(JSON.stringify(allLocalStorageProducts)));
|
|
5190
|
-
} catch (e) {
|
|
5191
|
-
mpInstance.Logger.error('Error with setting products on localStorage.');
|
|
5192
|
-
}
|
|
5193
|
-
}
|
|
5104
|
+
mpid = currentUser ? currentUser.getMPID() : null;
|
|
5194
5105
|
if (!mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
5195
5106
|
localStorageData.gs = localStorageData.gs || {};
|
|
5196
5107
|
localStorageData.l = mpInstance._Store.isLoggedIn ? 1 : 0;
|
|
@@ -5559,27 +5470,6 @@ var mParticle = (function () {
|
|
|
5559
5470
|
}
|
|
5560
5471
|
return '';
|
|
5561
5472
|
};
|
|
5562
|
-
this.getCartProducts = function (mpid) {
|
|
5563
|
-
var allCartProducts,
|
|
5564
|
-
cartProductsString = localStorage.getItem(mpInstance._Store.prodStorageName);
|
|
5565
|
-
if (cartProductsString) {
|
|
5566
|
-
allCartProducts = JSON.parse(Base64.decode(cartProductsString));
|
|
5567
|
-
if (allCartProducts && allCartProducts[mpid] && allCartProducts[mpid].cp) {
|
|
5568
|
-
return allCartProducts[mpid].cp;
|
|
5569
|
-
}
|
|
5570
|
-
}
|
|
5571
|
-
return [];
|
|
5572
|
-
};
|
|
5573
|
-
this.setCartProducts = function (allProducts) {
|
|
5574
|
-
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5575
|
-
return;
|
|
5576
|
-
}
|
|
5577
|
-
try {
|
|
5578
|
-
window.localStorage.setItem(encodeURIComponent(mpInstance._Store.prodStorageName), Base64.encode(JSON.stringify(allProducts)));
|
|
5579
|
-
} catch (e) {
|
|
5580
|
-
mpInstance.Logger.error('Error with setting products on localStorage.');
|
|
5581
|
-
}
|
|
5582
|
-
};
|
|
5583
5473
|
this.saveUserCookieSyncDatesToPersistence = function (mpid, csd) {
|
|
5584
5474
|
if (csd) {
|
|
5585
5475
|
var persistence = self.getPersistence();
|
|
@@ -5719,20 +5609,17 @@ var mParticle = (function () {
|
|
|
5719
5609
|
removeLocalStorage(StorageNames.localStorageName);
|
|
5720
5610
|
removeLocalStorage(StorageNames.localStorageNameV3);
|
|
5721
5611
|
removeLocalStorage(StorageNames.localStorageNameV4);
|
|
5722
|
-
removeLocalStorage(mpInstance._Store.prodStorageName);
|
|
5723
5612
|
removeLocalStorage(mpInstance._Store.storageName);
|
|
5724
5613
|
removeLocalStorage(StorageNames.localStorageProductsV4);
|
|
5725
5614
|
self.expireCookies(StorageNames.cookieName);
|
|
5726
5615
|
self.expireCookies(StorageNames.cookieNameV2);
|
|
5727
5616
|
self.expireCookies(StorageNames.cookieNameV3);
|
|
5728
5617
|
self.expireCookies(StorageNames.cookieNameV4);
|
|
5729
|
-
self.expireCookies(mpInstance._Store.prodStorageName);
|
|
5730
5618
|
self.expireCookies(mpInstance._Store.storageName);
|
|
5731
5619
|
if (mParticle._isTestEnv) {
|
|
5732
5620
|
var testWorkspaceToken = 'abcdef';
|
|
5733
5621
|
removeLocalStorage(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
5734
5622
|
self.expireCookies(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
5735
|
-
removeLocalStorage(mpInstance._Helpers.createProductStorageName(testWorkspaceToken));
|
|
5736
5623
|
}
|
|
5737
5624
|
};
|
|
5738
5625
|
|
|
@@ -8151,7 +8038,7 @@ var mParticle = (function () {
|
|
|
8151
8038
|
*/
|
|
8152
8039
|
getCart: function getCart() {
|
|
8153
8040
|
mpInstance.Logger.warning('Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases');
|
|
8154
|
-
return self.mParticleUserCart(
|
|
8041
|
+
return self.mParticleUserCart();
|
|
8155
8042
|
},
|
|
8156
8043
|
/**
|
|
8157
8044
|
* Returns the Consent State stored locally for this user.
|
|
@@ -8206,84 +8093,23 @@ var mParticle = (function () {
|
|
|
8206
8093
|
* @class mParticle.Identity.getCurrentUser().getCart()
|
|
8207
8094
|
* @deprecated
|
|
8208
8095
|
*/
|
|
8209
|
-
this.mParticleUserCart = function (
|
|
8096
|
+
this.mParticleUserCart = function () {
|
|
8210
8097
|
return {
|
|
8211
8098
|
/**
|
|
8212
8099
|
* Adds a cart product to the user cart
|
|
8213
8100
|
* @method add
|
|
8214
|
-
* @param {Object} product the product
|
|
8215
|
-
* @param {Boolean} [logEvent] a boolean to log adding of the cart object. If blank, no logging occurs.
|
|
8216
8101
|
* @deprecated
|
|
8217
8102
|
*/
|
|
8218
|
-
add: function add(
|
|
8219
|
-
mpInstance.Logger.warning('
|
|
8220
|
-
var allProducts, userProducts, arrayCopy;
|
|
8221
|
-
arrayCopy = Array.isArray(product) ? product.slice() : [product];
|
|
8222
|
-
arrayCopy.forEach(function (product) {
|
|
8223
|
-
product.Attributes = mpInstance._Helpers.sanitizeAttributes(product.Attributes);
|
|
8224
|
-
});
|
|
8225
|
-
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8226
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.AddToCart, JSON.stringify(arrayCopy));
|
|
8227
|
-
} else {
|
|
8228
|
-
mpInstance._SessionManager.resetSessionTimer();
|
|
8229
|
-
userProducts = mpInstance._Persistence.getUserProductsFromLS(mpid);
|
|
8230
|
-
userProducts = userProducts.concat(arrayCopy);
|
|
8231
|
-
if (logEvent === true) {
|
|
8232
|
-
mpInstance._Events.logProductActionEvent(Types.ProductActionType.AddToCart, arrayCopy);
|
|
8233
|
-
}
|
|
8234
|
-
var productsForMemory = {};
|
|
8235
|
-
productsForMemory[mpid] = {
|
|
8236
|
-
cp: userProducts
|
|
8237
|
-
};
|
|
8238
|
-
if (userProducts.length > mpInstance._Store.SDKConfig.maxProducts) {
|
|
8239
|
-
mpInstance.Logger.verbose('The cart contains ' + userProducts.length + ' items. Only ' + mpInstance._Store.SDKConfig.maxProducts + ' can currently be saved in cookies.');
|
|
8240
|
-
userProducts = userProducts.slice(-mpInstance._Store.SDKConfig.maxProducts);
|
|
8241
|
-
}
|
|
8242
|
-
allProducts = mpInstance._Persistence.getAllUserProductsFromLS();
|
|
8243
|
-
allProducts[mpid].cp = userProducts;
|
|
8244
|
-
mpInstance._Persistence.setCartProducts(allProducts);
|
|
8245
|
-
}
|
|
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'));
|
|
8246
8105
|
},
|
|
8247
8106
|
/**
|
|
8248
8107
|
* Removes a cart product from the current user cart
|
|
8249
8108
|
* @method remove
|
|
8250
|
-
* @param {Object} product the product
|
|
8251
|
-
* @param {Boolean} [logEvent] a boolean to log adding of the cart object. If blank, no logging occurs.
|
|
8252
8109
|
* @deprecated
|
|
8253
8110
|
*/
|
|
8254
|
-
remove: function remove(
|
|
8255
|
-
mpInstance.Logger.warning('
|
|
8256
|
-
var allProducts,
|
|
8257
|
-
userProducts,
|
|
8258
|
-
cartIndex = -1,
|
|
8259
|
-
cartItem = null;
|
|
8260
|
-
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8261
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.RemoveFromCart, JSON.stringify(product));
|
|
8262
|
-
} else {
|
|
8263
|
-
mpInstance._SessionManager.resetSessionTimer();
|
|
8264
|
-
userProducts = mpInstance._Persistence.getUserProductsFromLS(mpid);
|
|
8265
|
-
if (userProducts) {
|
|
8266
|
-
userProducts.forEach(function (cartProduct, i) {
|
|
8267
|
-
if (cartProduct.Sku === product.Sku) {
|
|
8268
|
-
cartIndex = i;
|
|
8269
|
-
cartItem = cartProduct;
|
|
8270
|
-
}
|
|
8271
|
-
});
|
|
8272
|
-
if (cartIndex > -1) {
|
|
8273
|
-
userProducts.splice(cartIndex, 1);
|
|
8274
|
-
if (logEvent === true) {
|
|
8275
|
-
mpInstance._Events.logProductActionEvent(Types.ProductActionType.RemoveFromCart, cartItem);
|
|
8276
|
-
}
|
|
8277
|
-
}
|
|
8278
|
-
}
|
|
8279
|
-
var productsForMemory = {};
|
|
8280
|
-
productsForMemory[mpid] = {
|
|
8281
|
-
cp: userProducts
|
|
8282
|
-
};
|
|
8283
|
-
allProducts = mpInstance._Persistence.getAllUserProductsFromLS();
|
|
8284
|
-
allProducts[mpid].cp = userProducts;
|
|
8285
|
-
mpInstance._Persistence.setCartProducts(allProducts);
|
|
8286
|
-
}
|
|
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'));
|
|
8287
8113
|
},
|
|
8288
8114
|
/**
|
|
8289
8115
|
* Clears the user's cart
|
|
@@ -8291,19 +8117,7 @@ var mParticle = (function () {
|
|
|
8291
8117
|
* @deprecated
|
|
8292
8118
|
*/
|
|
8293
8119
|
clear: function clear() {
|
|
8294
|
-
mpInstance.Logger.warning('
|
|
8295
|
-
var allProducts;
|
|
8296
|
-
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8297
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.ClearCart);
|
|
8298
|
-
} else {
|
|
8299
|
-
mpInstance._SessionManager.resetSessionTimer();
|
|
8300
|
-
allProducts = mpInstance._Persistence.getAllUserProductsFromLS();
|
|
8301
|
-
if (allProducts && allProducts[mpid] && allProducts[mpid].cp) {
|
|
8302
|
-
allProducts[mpid].cp = [];
|
|
8303
|
-
allProducts[mpid].cp = [];
|
|
8304
|
-
mpInstance._Persistence.setCartProducts(allProducts);
|
|
8305
|
-
}
|
|
8306
|
-
}
|
|
8120
|
+
mpInstance.Logger.warning(generateDeprecationMessage('Identity.getCurrentUser().getCart().clear()', true, '', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
8307
8121
|
},
|
|
8308
8122
|
/**
|
|
8309
8123
|
* Returns all cart products
|
|
@@ -8312,8 +8126,8 @@ var mParticle = (function () {
|
|
|
8312
8126
|
* @deprecated
|
|
8313
8127
|
*/
|
|
8314
8128
|
getCartProducts: function getCartProducts() {
|
|
8315
|
-
mpInstance.Logger.warning('
|
|
8316
|
-
return
|
|
8129
|
+
mpInstance.Logger.warning(generateDeprecationMessage('Identity.getCurrentUser().getCart().getCartProducts()', true, 'eCommerce.logProductAction()', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
8130
|
+
return [];
|
|
8317
8131
|
}
|
|
8318
8132
|
};
|
|
8319
8133
|
};
|
|
@@ -10647,13 +10461,7 @@ var mParticle = (function () {
|
|
|
10647
10461
|
* @deprecated
|
|
10648
10462
|
*/
|
|
10649
10463
|
add: function add(product, logEventBoolean) {
|
|
10650
|
-
self.Logger.warning('
|
|
10651
|
-
var mpid;
|
|
10652
|
-
var currentUser = self.Identity.getCurrentUser();
|
|
10653
|
-
if (currentUser) {
|
|
10654
|
-
mpid = currentUser.getMPID();
|
|
10655
|
-
}
|
|
10656
|
-
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'));
|
|
10657
10465
|
},
|
|
10658
10466
|
/**
|
|
10659
10467
|
* Removes a product from the cart
|
|
@@ -10663,13 +10471,7 @@ var mParticle = (function () {
|
|
|
10663
10471
|
* @deprecated
|
|
10664
10472
|
*/
|
|
10665
10473
|
remove: function remove(product, logEventBoolean) {
|
|
10666
|
-
self.Logger.warning('
|
|
10667
|
-
var mpid;
|
|
10668
|
-
var currentUser = self.Identity.getCurrentUser();
|
|
10669
|
-
if (currentUser) {
|
|
10670
|
-
mpid = currentUser.getMPID();
|
|
10671
|
-
}
|
|
10672
|
-
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'));
|
|
10673
10475
|
},
|
|
10674
10476
|
/**
|
|
10675
10477
|
* Clears the cart
|
|
@@ -10677,13 +10479,7 @@ var mParticle = (function () {
|
|
|
10677
10479
|
* @deprecated
|
|
10678
10480
|
*/
|
|
10679
10481
|
clear: function clear() {
|
|
10680
|
-
self.Logger.warning('
|
|
10681
|
-
var mpid;
|
|
10682
|
-
var currentUser = self.Identity.getCurrentUser();
|
|
10683
|
-
if (currentUser) {
|
|
10684
|
-
mpid = currentUser.getMPID();
|
|
10685
|
-
}
|
|
10686
|
-
self._Identity.mParticleUserCart(mpid).clear();
|
|
10482
|
+
self.Logger.warning(generateDeprecationMessage('eCommerce.Cart.clear()', true, '', 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'));
|
|
10687
10483
|
}
|
|
10688
10484
|
},
|
|
10689
10485
|
/**
|
package/package.json
CHANGED
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: {
|
|
@@ -232,11 +233,10 @@ export const HTTP_SERVER_ERROR = 500 as const;
|
|
|
232
233
|
|
|
233
234
|
export type PrivacyControl = 'functional' | 'targeting';
|
|
234
235
|
|
|
235
|
-
export type StorageTypes = 'SDKState' | '
|
|
236
|
+
export type StorageTypes = 'SDKState' | 'OfflineEvents' | 'IdentityCache' | 'TimeOnSite';
|
|
236
237
|
|
|
237
238
|
export const StoragePrivacyMap: Record<StorageTypes, PrivacyControl> = {
|
|
238
239
|
SDKState: 'functional',
|
|
239
|
-
Products: 'targeting',
|
|
240
240
|
OfflineEvents: 'functional',
|
|
241
241
|
IdentityCache: 'functional',
|
|
242
242
|
TimeOnSite: 'targeting',
|
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
|
|
@@ -115,8 +115,8 @@ export interface IdentityModifyResultBody {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export interface mParticleUserCart {
|
|
118
|
-
add(
|
|
119
|
-
remove(
|
|
118
|
+
add(): void;
|
|
119
|
+
remove(): void;
|
|
120
120
|
clear(): void;
|
|
121
121
|
getCartProducts(): SDKProduct[];
|
|
122
122
|
}
|