Skip to content

Commit 5a8b470

Browse files
authored
breaking: remove deprecated cart API (#1240)
1 parent af285fa commit 5a8b470

21 files changed

Lines changed: 71 additions & 675 deletions

src/constants.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ const Constants = {
8989
SetUserAttribute: 'setUserAttribute',
9090
RemoveUserAttribute: 'removeUserAttribute',
9191
SetSessionAttribute: 'setSessionAttribute',
92-
AddToCart: 'addToCart',
93-
RemoveFromCart: 'removeFromCart',
94-
ClearCart: 'clearCart',
9592
LogOut: 'logOut',
9693
SetUserAttributeList: 'setUserAttributeList',
9794
RemoveAllUserAttributes: 'removeAllUserAttributes',
@@ -111,18 +108,15 @@ const Constants = {
111108
cookieNameV2: 'mprtcl-v2', // v2 Name of the cookie stored on the user's machine. Removed keys with no values, moved cartProducts and productBags to localStorage.
112109
cookieNameV3: 'mprtcl-v3', // v3 Name of the cookie stored on the user's machine. Base64 encoded keys in Base64CookieKeys object, final version on SDKv1
113110
localStorageNameV4: 'mprtcl-v4', // v4 Name of the mP localstorage, Current Version
114-
localStorageProductsV4: 'mprtcl-prodv4', // The name for mP localstorage that contains products for cartProducs and productBags
115111
cookieNameV4: 'mprtcl-v4', // v4 Name of the cookie stored on the user's machine. Base64 encoded keys in Base64CookieKeys object, current version on SDK v2
116112
currentStorageName: 'mprtcl-v4',
117-
currentStorageProductsName: 'mprtcl-prodv4',
118113
},
119114
DefaultConfig: {
120115
cookieDomain: null, // If null, defaults to current location.host
121116
cookieExpiration: 365, // Cookie expiration time in days
122117
logLevel: null, // What logging will be provided in the console
123118
timeout: 300, // timeout in milliseconds for logging functions
124119
sessionTimeout: 30, // Session timeout in minutes
125-
maxProducts: 20, // Number of products persisted in cartProducts and productBags
126120
forwarderStatsTimeout: 5000, // Milliseconds for forwarderStats timeout
127121
integrationDelayTimeout: 5000, // Milliseconds for forcing the integration delay to un-suspend event queueing due to integration partner errors
128122
maxCookieSize: 3000, // Number of bytes for cookie size to not exceed

src/ecommerce.interfaces.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ interface IECommerceShared {
5656
expandCommerceEvent(event: CommerceEvent): SDKEvent[] | null;
5757
}
5858

59-
export interface SDKCart {
60-
add(product: SDKProduct | SDKProduct[], logEvent?: boolean): void;
61-
remove(product: SDKProduct | SDKProduct[], logEvent?: boolean): void;
62-
clear(): void;
63-
}
6459

6560
// Used for the public `eCommerce` namespace
6661
export interface SDKECommerceAPI extends IECommerceShared {
@@ -90,8 +85,6 @@ export interface SDKECommerceAPI extends IECommerceShared {
9085
/*
9186
* @deprecated
9287
*/
93-
Cart: SDKCart;
94-
9588
}
9689

9790
interface ExtractedActionAttributes {
@@ -128,7 +121,6 @@ interface ExtractedTransactionId {
128121

129122
// Used for the private `_Ecommerce` namespace
130123
export interface IECommerce extends IECommerceShared {
131-
buildProductList(event: SDKEvent, product: Product | Product[]): Product[];
132124
convertProductActionToEventType(
133125
productActionType: valueof<typeof ProductActionType>
134126
): // https://go.mparticle.com/work/SQDSDKS-4801

src/ecommerce.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,6 @@ export default function Ecommerce(mpInstance) {
235235
}
236236
};
237237

238-
this.buildProductList = function(event, product) {
239-
if (product) {
240-
if (Array.isArray(product)) {
241-
return product;
242-
}
243-
244-
return [product];
245-
}
246-
247-
return event.ShoppingCart.ProductList;
248-
};
249-
250238
this.createProduct = function(
251239
name,
252240
sku,
@@ -549,7 +537,6 @@ export default function Ecommerce(mpInstance) {
549537
baseEvent.EventName = 'eCommerce - ';
550538

551539
baseEvent.CurrencyCode = mpInstance._Store.currencyCode;
552-
baseEvent.ShoppingCart = [];
553540
baseEvent.CustomFlags = extend(baseEvent.CustomFlags, customFlags);
554541

555542
return baseEvent;

src/events.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,6 @@ export default function Events(mpInstance) {
250250
);
251251

252252
if (mpInstance._Helpers.canLog()) {
253-
if (mpInstance._Store.webviewBridgeEnabled) {
254-
// Don't send shopping cart to parent sdks
255-
commerceEvent.ShoppingCart = {};
256-
}
257-
258253
if (attrs) {
259254
commerceEvent.EventAttributes = attrs;
260255
}

src/identity-user-interfaces.ts

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
11
import { AllUserAttributes, MPID, User } from '@mparticle/web-sdk';
22
import { SDKIdentityTypeEnum } from './identity.interfaces';
33
import { MessageType } from './types';
4-
import { BaseEvent, SDKProduct } from './sdkRuntimeModels';
4+
import { BaseEvent } from './sdkRuntimeModels';
55
import Constants from './constants';
66
const { HTTPCodes } = Constants;
77

8-
// Cart is Deprecated and private to mParticle user in @mparticle/web-sdk
9-
// but we need to expose it here for type safety in some of our tests
10-
interface ICart {
11-
/**
12-
* @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.AddToCart, [products])
13-
*/
14-
add: (product: SDKProduct, logEventBoolean?: boolean) => void;
15-
/**
16-
* @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.RemoveFromCart, [products])
17-
*/
18-
remove: (product: SDKProduct, logEventBoolean?: boolean) => void;
19-
/**
20-
* @deprecated Cart persistence in mParticle has been deprecated.
21-
*/
22-
clear: () => void;
23-
/**
24-
* @deprecated Cart Products have been deprecated
25-
*/
26-
getCartProducts: () => SDKProduct[];
27-
}
288

299
// https://go.mparticle.com/work/SQDSDKS-5033
3010
// https://go.mparticle.com/work/SQDSDKS-6354
@@ -33,10 +13,6 @@ export interface IMParticleUser extends User {
3313
setUserTag(tagName: string, value?: any): void;
3414
setUserAttribute(key: string, value: any): void;
3515
getUserAudiences?(callback?: IdentityCallback): void;
36-
/*
37-
* @deprecated
38-
*/
39-
getCart(): ICart;
4016
}
4117

4218
export interface ISDKUserIdentity {
@@ -114,12 +90,5 @@ export interface IdentityModifyResultBody {
11490
};
11591
}
11692

117-
export interface mParticleUserCart {
118-
add(): void;
119-
remove(): void;
120-
clear(): void;
121-
getCartProducts(): SDKProduct[];
122-
}
123-
12493
// https://go.mparticle.com/work/SQDSDKS-5196
12594
export type UserAttributes = AllUserAttributes;

src/identity.interfaces.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
IUserAttributeChangeEvent,
1010
IUserIdentityChangeEvent,
1111
IMParticleUser,
12-
mParticleUserCart,
1312
IIdentityResponse,
1413
} from './identity-user-interfaces';
1514
const { platform, sdkVendor, sdkVersion, HTTPCodes } = Constants;
@@ -205,9 +204,4 @@ export interface IIdentity {
205204
mpid: MPID,
206205
prevUserIdentities: UserIdentities
207206
): void;
208-
209-
/**
210-
* @deprecated
211-
*/
212-
mParticleUserCart(): mParticleUserCart;
213207
}

src/identity.js

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,18 +1208,6 @@ export default function Identity(mpInstance) {
12081208

12091209
return userAttributesCopy;
12101210
},
1211-
/**
1212-
* Returns the cart object for the current user
1213-
* @method getCart
1214-
* @return a cart object
1215-
*/
1216-
getCart: function() {
1217-
mpInstance.Logger.warning(
1218-
'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases'
1219-
);
1220-
return self.mParticleUserCart();
1221-
},
1222-
12231211
/**
12241212
* Returns the Consent State stored locally for this user.
12251213
* @method getConsentState
@@ -1282,79 +1270,6 @@ export default function Identity(mpInstance) {
12821270
};
12831271
};
12841272

1285-
/**
1286-
* Invoke these methods on the mParticle.Identity.getCurrentUser().getCart() object.
1287-
* Example: mParticle.Identity.getCurrentUser().getCart().add(...);
1288-
* @class mParticle.Identity.getCurrentUser().getCart()
1289-
* @deprecated
1290-
*/
1291-
this.mParticleUserCart = function() {
1292-
return {
1293-
/**
1294-
* Adds a cart product to the user cart
1295-
* @method add
1296-
* @deprecated
1297-
*/
1298-
add: function() {
1299-
mpInstance.Logger.warning(
1300-
generateDeprecationMessage(
1301-
'Identity.getCurrentUser().getCart().add()',
1302-
true,
1303-
'eCommerce.logProductAction()',
1304-
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1305-
)
1306-
);
1307-
},
1308-
/**
1309-
* Removes a cart product from the current user cart
1310-
* @method remove
1311-
* @deprecated
1312-
*/
1313-
remove: function() {
1314-
mpInstance.Logger.warning(
1315-
generateDeprecationMessage(
1316-
'Identity.getCurrentUser().getCart().remove()',
1317-
true,
1318-
'eCommerce.logProductAction()',
1319-
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1320-
)
1321-
);
1322-
},
1323-
/**
1324-
* Clears the user's cart
1325-
* @method clear
1326-
* @deprecated
1327-
*/
1328-
clear: function() {
1329-
mpInstance.Logger.warning(
1330-
generateDeprecationMessage(
1331-
'Identity.getCurrentUser().getCart().clear()',
1332-
true,
1333-
'',
1334-
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1335-
)
1336-
);
1337-
},
1338-
/**
1339-
* Returns all cart products
1340-
* @method getCartProducts
1341-
* @return {Array} array of cart products
1342-
* @deprecated
1343-
*/
1344-
getCartProducts: function() {
1345-
mpInstance.Logger.warning(
1346-
generateDeprecationMessage(
1347-
'Identity.getCurrentUser().getCart().getCartProducts()',
1348-
true,
1349-
'eCommerce.logProductAction()',
1350-
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
1351-
)
1352-
);
1353-
return [];
1354-
},
1355-
};
1356-
};
1357-
13581273
// https://go.mparticle.com/work/SQDSDKS-6355
13591274
this.parseIdentityResponse = function(
13601275
identityResponse,

src/mp-instance.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -749,63 +749,6 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
749749
* @class mParticle.eCommerce
750750
*/
751751
this.eCommerce = {
752-
/**
753-
* Invoke these methods on the mParticle.eCommerce.Cart object.
754-
* Example: mParticle.eCommerce.Cart.add(...)
755-
* @class mParticle.eCommerce.Cart
756-
* @deprecated
757-
*/
758-
Cart: {
759-
/**
760-
* Adds a product to the cart
761-
* @method add
762-
* @param {Object} product The product you want to add to the cart
763-
* @param {Boolean} [logEventBoolean] Option to log the event to mParticle's servers. If blank, no logging occurs.
764-
* @deprecated
765-
*/
766-
add: function(product, logEventBoolean) {
767-
self.Logger.warning(
768-
generateDeprecationMessage(
769-
'eCommerce.Cart.add()',
770-
true,
771-
'eCommerce.logProductAction()',
772-
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
773-
)
774-
);
775-
},
776-
/**
777-
* Removes a product from the cart
778-
* @method remove
779-
* @param {Object} product The product you want to add to the cart
780-
* @param {Boolean} [logEventBoolean] Option to log the event to mParticle's servers. If blank, no logging occurs.
781-
* @deprecated
782-
*/
783-
remove: function(product, logEventBoolean) {
784-
self.Logger.warning(
785-
generateDeprecationMessage(
786-
'eCommerce.Cart.remove()',
787-
true,
788-
'eCommerce.logProductAction()',
789-
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
790-
)
791-
);
792-
},
793-
/**
794-
* Clears the cart
795-
* @method clear
796-
* @deprecated
797-
*/
798-
clear: function() {
799-
self.Logger.warning(
800-
generateDeprecationMessage(
801-
'eCommerce.Cart.clear()',
802-
true,
803-
'',
804-
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
805-
)
806-
);
807-
},
808-
},
809752
/**
810753
* Sets the currency code
811754
* @for mParticle.eCommerce

src/mparticle-instance-manager.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,6 @@ function mParticleInstanceManager(this: IMParticleInstanceManager) {
197197
self.getInstance().upload();
198198
};
199199
this.eCommerce = {
200-
Cart: {
201-
add: function(product, logEventBoolean) {
202-
self.getInstance().eCommerce.Cart.add(product, logEventBoolean);
203-
},
204-
remove: function(product, logEventBoolean) {
205-
self.getInstance().eCommerce.Cart.remove(
206-
product,
207-
logEventBoolean
208-
);
209-
},
210-
clear: function() {
211-
self.getInstance().eCommerce.Cart.clear();
212-
},
213-
},
214200
setCurrencyCode: function(code) {
215201
self.getInstance().eCommerce.setCurrencyCode(code);
216202
},

src/sdkRuntimeModels.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export interface SDKEvent {
8585
ProductAction?: SDKProductAction;
8686
PromotionAction?: SDKPromotionAction;
8787
ProductImpressions?: SDKProductImpression[];
88-
ShoppingCart?: SDKShoppingCart;
8988
UserIdentityChanges?: ISDKUserIdentityChanges;
9089
UserAttributeChanges?: ISDKUserAttributeChangeData;
9190
CurrencyCode: string;
@@ -107,10 +106,6 @@ export interface SDKDataPlan {
107106
PlanId?: string | null;
108107
}
109108

110-
export interface SDKShoppingCart {
111-
ProductList?: SDKProduct[];
112-
}
113-
114109
export interface SDKPromotionAction {
115110
PromotionActionType: string;
116111
PromotionList?: SDKPromotion[];
@@ -323,7 +318,6 @@ export interface SDKInitConfig
323318
identityUrl?: string;
324319
integrationDelayTimeout?: number;
325320
isIOS?: boolean;
326-
maxProducts?: number;
327321
requestConfig?: boolean;
328322
sessionTimeout?: number;
329323
useNativeSdk?: boolean;

0 commit comments

Comments
 (0)