diff --git a/src/constants.ts b/src/constants.ts index 38c85d00d..4bfc33ab6 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -89,9 +89,6 @@ const Constants = { SetUserAttribute: 'setUserAttribute', RemoveUserAttribute: 'removeUserAttribute', SetSessionAttribute: 'setSessionAttribute', - AddToCart: 'addToCart', - RemoveFromCart: 'removeFromCart', - ClearCart: 'clearCart', LogOut: 'logOut', SetUserAttributeList: 'setUserAttributeList', RemoveAllUserAttributes: 'removeAllUserAttributes', @@ -111,10 +108,8 @@ const Constants = { 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. cookieNameV3: 'mprtcl-v3', // v3 Name of the cookie stored on the user's machine. Base64 encoded keys in Base64CookieKeys object, final version on SDKv1 localStorageNameV4: 'mprtcl-v4', // v4 Name of the mP localstorage, Current Version - localStorageProductsV4: 'mprtcl-prodv4', // The name for mP localstorage that contains products for cartProducs and productBags 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 currentStorageName: 'mprtcl-v4', - currentStorageProductsName: 'mprtcl-prodv4', }, DefaultConfig: { cookieDomain: null, // If null, defaults to current location.host @@ -122,7 +117,6 @@ const Constants = { logLevel: null, // What logging will be provided in the console timeout: 300, // timeout in milliseconds for logging functions sessionTimeout: 30, // Session timeout in minutes - maxProducts: 20, // Number of products persisted in cartProducts and productBags forwarderStatsTimeout: 5000, // Milliseconds for forwarderStats timeout integrationDelayTimeout: 5000, // Milliseconds for forcing the integration delay to un-suspend event queueing due to integration partner errors maxCookieSize: 3000, // Number of bytes for cookie size to not exceed diff --git a/src/ecommerce.interfaces.ts b/src/ecommerce.interfaces.ts index 89cb34e70..2b9c8289b 100644 --- a/src/ecommerce.interfaces.ts +++ b/src/ecommerce.interfaces.ts @@ -56,11 +56,6 @@ interface IECommerceShared { expandCommerceEvent(event: CommerceEvent): SDKEvent[] | null; } -export interface SDKCart { - add(product: SDKProduct | SDKProduct[], logEvent?: boolean): void; - remove(product: SDKProduct | SDKProduct[], logEvent?: boolean): void; - clear(): void; -} // Used for the public `eCommerce` namespace export interface SDKECommerceAPI extends IECommerceShared { @@ -90,8 +85,6 @@ export interface SDKECommerceAPI extends IECommerceShared { /* * @deprecated */ - Cart: SDKCart; - } interface ExtractedActionAttributes { @@ -128,7 +121,6 @@ interface ExtractedTransactionId { // Used for the private `_Ecommerce` namespace export interface IECommerce extends IECommerceShared { - buildProductList(event: SDKEvent, product: Product | Product[]): Product[]; convertProductActionToEventType( productActionType: valueof ): // https://go.mparticle.com/work/SQDSDKS-4801 diff --git a/src/ecommerce.js b/src/ecommerce.js index c492e102e..91ae5973e 100644 --- a/src/ecommerce.js +++ b/src/ecommerce.js @@ -235,18 +235,6 @@ export default function Ecommerce(mpInstance) { } }; - this.buildProductList = function(event, product) { - if (product) { - if (Array.isArray(product)) { - return product; - } - - return [product]; - } - - return event.ShoppingCart.ProductList; - }; - this.createProduct = function( name, sku, @@ -549,7 +537,6 @@ export default function Ecommerce(mpInstance) { baseEvent.EventName = 'eCommerce - '; baseEvent.CurrencyCode = mpInstance._Store.currencyCode; - baseEvent.ShoppingCart = []; baseEvent.CustomFlags = extend(baseEvent.CustomFlags, customFlags); return baseEvent; diff --git a/src/events.js b/src/events.js index fb916c90e..e5cb6b513 100644 --- a/src/events.js +++ b/src/events.js @@ -250,11 +250,6 @@ export default function Events(mpInstance) { ); if (mpInstance._Helpers.canLog()) { - if (mpInstance._Store.webviewBridgeEnabled) { - // Don't send shopping cart to parent sdks - commerceEvent.ShoppingCart = {}; - } - if (attrs) { commerceEvent.EventAttributes = attrs; } diff --git a/src/identity-user-interfaces.ts b/src/identity-user-interfaces.ts index 9a4b673b6..f18ca146d 100644 --- a/src/identity-user-interfaces.ts +++ b/src/identity-user-interfaces.ts @@ -1,30 +1,10 @@ import { AllUserAttributes, MPID, User } from '@mparticle/web-sdk'; import { SDKIdentityTypeEnum } from './identity.interfaces'; import { MessageType } from './types'; -import { BaseEvent, SDKProduct } from './sdkRuntimeModels'; +import { BaseEvent } from './sdkRuntimeModels'; import Constants from './constants'; const { HTTPCodes } = Constants; -// Cart is Deprecated and private to mParticle user in @mparticle/web-sdk -// but we need to expose it here for type safety in some of our tests -interface ICart { - /** - * @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.AddToCart, [products]) - */ - add: (product: SDKProduct, logEventBoolean?: boolean) => void; - /** - * @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.RemoveFromCart, [products]) - */ - remove: (product: SDKProduct, logEventBoolean?: boolean) => void; - /** - * @deprecated Cart persistence in mParticle has been deprecated. - */ - clear: () => void; - /** - * @deprecated Cart Products have been deprecated - */ - getCartProducts: () => SDKProduct[]; -} // https://go.mparticle.com/work/SQDSDKS-5033 // https://go.mparticle.com/work/SQDSDKS-6354 @@ -33,10 +13,6 @@ export interface IMParticleUser extends User { setUserTag(tagName: string, value?: any): void; setUserAttribute(key: string, value: any): void; getUserAudiences?(callback?: IdentityCallback): void; - /* - * @deprecated - */ - getCart(): ICart; } export interface ISDKUserIdentity { @@ -114,12 +90,5 @@ export interface IdentityModifyResultBody { }; } -export interface mParticleUserCart { - add(): void; - remove(): void; - clear(): void; - getCartProducts(): SDKProduct[]; -} - // https://go.mparticle.com/work/SQDSDKS-5196 export type UserAttributes = AllUserAttributes; diff --git a/src/identity.interfaces.ts b/src/identity.interfaces.ts index 32ad3ea6e..c54c31b3c 100644 --- a/src/identity.interfaces.ts +++ b/src/identity.interfaces.ts @@ -9,7 +9,6 @@ import { IUserAttributeChangeEvent, IUserIdentityChangeEvent, IMParticleUser, - mParticleUserCart, IIdentityResponse, } from './identity-user-interfaces'; const { platform, sdkVendor, sdkVersion, HTTPCodes } = Constants; @@ -205,9 +204,4 @@ export interface IIdentity { mpid: MPID, prevUserIdentities: UserIdentities ): void; - - /** - * @deprecated - */ - mParticleUserCart(): mParticleUserCart; } diff --git a/src/identity.js b/src/identity.js index 0e939b599..1e35ba7d0 100644 --- a/src/identity.js +++ b/src/identity.js @@ -1208,18 +1208,6 @@ export default function Identity(mpInstance) { return userAttributesCopy; }, - /** - * Returns the cart object for the current user - * @method getCart - * @return a cart object - */ - getCart: function() { - mpInstance.Logger.warning( - 'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases' - ); - return self.mParticleUserCart(); - }, - /** * Returns the Consent State stored locally for this user. * @method getConsentState @@ -1282,79 +1270,6 @@ export default function Identity(mpInstance) { }; }; - /** - * Invoke these methods on the mParticle.Identity.getCurrentUser().getCart() object. - * Example: mParticle.Identity.getCurrentUser().getCart().add(...); - * @class mParticle.Identity.getCurrentUser().getCart() - * @deprecated - */ - this.mParticleUserCart = function() { - return { - /** - * Adds a cart product to the user cart - * @method add - * @deprecated - */ - add: function() { - mpInstance.Logger.warning( - generateDeprecationMessage( - 'Identity.getCurrentUser().getCart().add()', - true, - 'eCommerce.logProductAction()', - 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ) - ); - }, - /** - * Removes a cart product from the current user cart - * @method remove - * @deprecated - */ - remove: function() { - mpInstance.Logger.warning( - generateDeprecationMessage( - 'Identity.getCurrentUser().getCart().remove()', - true, - 'eCommerce.logProductAction()', - 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ) - ); - }, - /** - * Clears the user's cart - * @method clear - * @deprecated - */ - clear: function() { - mpInstance.Logger.warning( - generateDeprecationMessage( - 'Identity.getCurrentUser().getCart().clear()', - true, - '', - 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ) - ); - }, - /** - * Returns all cart products - * @method getCartProducts - * @return {Array} array of cart products - * @deprecated - */ - getCartProducts: function() { - mpInstance.Logger.warning( - generateDeprecationMessage( - 'Identity.getCurrentUser().getCart().getCartProducts()', - true, - 'eCommerce.logProductAction()', - 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ) - ); - return []; - }, - }; - }; - // https://go.mparticle.com/work/SQDSDKS-6355 this.parseIdentityResponse = function( identityResponse, diff --git a/src/mp-instance.ts b/src/mp-instance.ts index ee07942ef..71a2605fa 100644 --- a/src/mp-instance.ts +++ b/src/mp-instance.ts @@ -749,63 +749,6 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan * @class mParticle.eCommerce */ this.eCommerce = { - /** - * Invoke these methods on the mParticle.eCommerce.Cart object. - * Example: mParticle.eCommerce.Cart.add(...) - * @class mParticle.eCommerce.Cart - * @deprecated - */ - Cart: { - /** - * Adds a product to the cart - * @method add - * @param {Object} product The product you want to add to the cart - * @param {Boolean} [logEventBoolean] Option to log the event to mParticle's servers. If blank, no logging occurs. - * @deprecated - */ - add: function(product, logEventBoolean) { - self.Logger.warning( - generateDeprecationMessage( - 'eCommerce.Cart.add()', - true, - 'eCommerce.logProductAction()', - 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ) - ); - }, - /** - * Removes a product from the cart - * @method remove - * @param {Object} product The product you want to add to the cart - * @param {Boolean} [logEventBoolean] Option to log the event to mParticle's servers. If blank, no logging occurs. - * @deprecated - */ - remove: function(product, logEventBoolean) { - self.Logger.warning( - generateDeprecationMessage( - 'eCommerce.Cart.remove()', - true, - 'eCommerce.logProductAction()', - 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ) - ); - }, - /** - * Clears the cart - * @method clear - * @deprecated - */ - clear: function() { - self.Logger.warning( - generateDeprecationMessage( - 'eCommerce.Cart.clear()', - true, - '', - 'https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ) - ); - }, - }, /** * Sets the currency code * @for mParticle.eCommerce diff --git a/src/mparticle-instance-manager.ts b/src/mparticle-instance-manager.ts index 9c189f507..db1f8a928 100644 --- a/src/mparticle-instance-manager.ts +++ b/src/mparticle-instance-manager.ts @@ -197,20 +197,6 @@ function mParticleInstanceManager(this: IMParticleInstanceManager) { self.getInstance().upload(); }; this.eCommerce = { - Cart: { - add: function(product, logEventBoolean) { - self.getInstance().eCommerce.Cart.add(product, logEventBoolean); - }, - remove: function(product, logEventBoolean) { - self.getInstance().eCommerce.Cart.remove( - product, - logEventBoolean - ); - }, - clear: function() { - self.getInstance().eCommerce.Cart.clear(); - }, - }, setCurrencyCode: function(code) { self.getInstance().eCommerce.setCurrencyCode(code); }, diff --git a/src/sdkRuntimeModels.ts b/src/sdkRuntimeModels.ts index 8d6c624a9..3a9dfe03d 100644 --- a/src/sdkRuntimeModels.ts +++ b/src/sdkRuntimeModels.ts @@ -85,7 +85,6 @@ export interface SDKEvent { ProductAction?: SDKProductAction; PromotionAction?: SDKPromotionAction; ProductImpressions?: SDKProductImpression[]; - ShoppingCart?: SDKShoppingCart; UserIdentityChanges?: ISDKUserIdentityChanges; UserAttributeChanges?: ISDKUserAttributeChangeData; CurrencyCode: string; @@ -107,10 +106,6 @@ export interface SDKDataPlan { PlanId?: string | null; } -export interface SDKShoppingCart { - ProductList?: SDKProduct[]; -} - export interface SDKPromotionAction { PromotionActionType: string; PromotionList?: SDKPromotion[]; @@ -323,7 +318,6 @@ export interface SDKInitConfig identityUrl?: string; integrationDelayTimeout?: number; isIOS?: boolean; - maxProducts?: number; requestConfig?: boolean; sessionTimeout?: number; useNativeSdk?: boolean; diff --git a/src/sdkToEventsApiConverter.ts b/src/sdkToEventsApiConverter.ts index 827c248e7..4be2111bf 100644 --- a/src/sdkToEventsApiConverter.ts +++ b/src/sdkToEventsApiConverter.ts @@ -433,22 +433,6 @@ export function convertImpressions( return impressions; } -export function convertShoppingCart( - sdkEvent: SDKEvent -): EventsApi.ShoppingCart | null { - if ( - !sdkEvent.ShoppingCart || - !sdkEvent.ShoppingCart.ProductList || - !sdkEvent.ShoppingCart.ProductList.length - ) { - return null; - } - const shoppingCart: EventsApi.ShoppingCart = { - products: convertProducts(sdkEvent.ShoppingCart.ProductList), - }; - return shoppingCart; -} - export function convertCommerceEvent( sdkEvent: SDKEvent ): EventsApi.CommerceEvent { @@ -460,7 +444,6 @@ export function convertCommerceEvent( product_action: convertProductAction(sdkEvent), promotion_action: convertPromotionAction(sdkEvent), product_impressions: convertImpressions(sdkEvent), - shopping_cart: convertShoppingCart(sdkEvent), currency_code: sdkEvent.CurrencyCode, }; diff --git a/src/serverModel.ts b/src/serverModel.ts index ae70599ea..a70c2a3df 100644 --- a/src/serverModel.ts +++ b/src/serverModel.ts @@ -441,15 +441,6 @@ export default function ServerModel( if (event.EventDataType === MessageType.Commerce) { dto.cu = event.CurrencyCode; - // TODO: If Cart is deprecated, we should deprecate this too - if (event.ShoppingCart) { - dto.sc = { - pl: convertProductListToV2DTO( - event.ShoppingCart.ProductList - ), - }; - } - if (event.ProductAction) { dto.pd = { an: event.ProductAction.ProductActionType, diff --git a/src/store.ts b/src/store.ts index 9c4fcc18f..cf23a32e0 100644 --- a/src/store.ts +++ b/src/store.ts @@ -84,7 +84,6 @@ export interface SDKConfig { userAudienceUrl?: string; isIOS?: boolean; maxAliasWindow: number; - maxProducts: number; requestConfig?: boolean; sessionTimeout?: number; useNativeSdk?: boolean; @@ -369,12 +368,6 @@ export default function Store( this.SDKConfig.useCookieStorage = false; } - if (config.hasOwnProperty('maxProducts')) { - this.SDKConfig.maxProducts = config.maxProducts; - } else { - this.SDKConfig.maxProducts = Constants.DefaultConfig.maxProducts; - } - if (config.hasOwnProperty('maxCookieSize')) { this.SDKConfig.maxCookieSize = config.maxCookieSize; } else { diff --git a/src/stub/mparticle.stub.js b/src/stub/mparticle.stub.js index 7a73bb2e2..f90d01f96 100644 --- a/src/stub/mparticle.stub.js +++ b/src/stub/mparticle.stub.js @@ -37,7 +37,6 @@ let mParticle = { logProductAction: voidFunction, logPromotion: voidFunction, setCurrencyCode: voidFunction, - Cart: new Cart(), }, Consent: { createConsentState: createConsentState, @@ -83,7 +82,6 @@ function returnUser() { removeAllUserAttributes: voidFunction, getUserAttributesLists: returnObject, getAllUserAttributes: returnObject, - getCart: Cart, getConsentState: createConsentState, setConsentState: voidFunction, }; @@ -93,17 +91,6 @@ function returnUsers() { return [returnUser()]; } -function Cart() { - return { - add: voidFunction, - clear: voidFunction, - remove: voidFunction, - getCartProducts: function() { - return [returnProduct()]; - }, - }; -} - function returnImpression() { return { Name: 'name', diff --git a/test/src/tests-eCommerce.js b/test/src/tests-eCommerce.js index 726e02515..8585a2758 100644 --- a/test/src/tests-eCommerce.js +++ b/test/src/tests-eCommerce.js @@ -1176,136 +1176,81 @@ describe('eCommerce', function() { impressionEvent.data.custom_flags.interactionEvent.should.equal(true); }); - describe('Cart', function() { - afterEach(function() { - sinon.restore(); - }); - - it('should deprecate add', async () => { - await waitForCondition(hasIdentifyReturned); - mParticle._resetForTests(MPConfig); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); - - const product = mParticle.eCommerce.createProduct( - 'iPhone', - '12345', - 400 - ); + it('should be empty when transactionAttributes is empty', () => { + const mparticle = mParticle.getInstance() + const productAction = {} + mparticle._Ecommerce.convertTransactionAttributesToProductAction({}, productAction) + Object.keys(productAction).length.should.equal(0); + }); - mParticle.eCommerce.Cart.add(product, true); + it('should sanitize certain ecommerce amounts from strings to 0', () => { + mParticle.getInstance()._Ecommerce.sanitizeAmount('$42', 'Price').should.equal(0); + mParticle.getInstance()._Ecommerce.sanitizeAmount('$100', 'TotalAmount').should.equal(0); + mParticle.getInstance()._Ecommerce.sanitizeAmount('first', 'Position').should.equal(0); + mParticle.getInstance()._Ecommerce.sanitizeAmount('two', 'Quantity').should.equal(0); + mParticle.getInstance()._Ecommerce.sanitizeAmount('string', 'Shipping').should.equal(0); + mParticle.getInstance()._Ecommerce.sanitizeAmount('$5.80', 'Tax').should.equal(0); + }); - bond.called.should.eql(true); - bond.getCalls()[0].args[0].should.eql( - 'eCommerce.Cart.add() has been deprecated. Please use the alternate method: eCommerce.logProductAction(). See - https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ); - }); - - it('should deprecate remove', async () => { - await waitForCondition(hasIdentifyReturned); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); + it('should convert transactionAttributes strings to numbers or zero', () => { + const mparticle = mParticle.getInstance() + const transactionAttributes = { + Id: "id", + Affiliation: "affiliation", + CouponCode: "couponCode", + Revenue: "revenue", + Shipping: "shipping", + Tax: "tax" + }; + + const productAction = {}; + mparticle._Ecommerce.convertTransactionAttributesToProductAction(transactionAttributes, productAction) + productAction.TransactionId.should.equal("id") + productAction.Affiliation.should.equal("affiliation") + productAction.CouponCode.should.equal("couponCode") + + // convert strings to 0 + productAction.TotalAmount.should.equal(0) + productAction.ShippingAmount.should.equal(0) + productAction.TaxAmount.should.equal(0) + }); + it('should allow a user to pass in a source_message_id to a commerce event', async () => { + await waitForCondition(hasIdentifyReturned); const product = mParticle.eCommerce.createProduct( - 'iPhone', - '12345', - 400 - ); - - mParticle.eCommerce.Cart.remove(product, true); - - bond.called.should.eql(true); - bond.getCalls()[0].args[0].should.eql( - 'eCommerce.Cart.remove() has been deprecated. Please use the alternate method: eCommerce.logProductAction(). See - https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ); - }); - - it('should deprecate clear', async () => { - await waitForCondition(hasIdentifyReturned); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); - - mParticle.eCommerce.Cart.clear(); - - bond.called.should.eql(true); - bond.getCalls()[0].args[0].should.eql( - 'eCommerce.Cart.clear() has been deprecated. See - https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ); - }); - - it('should be empty when transactionAttributes is empty', () => { - const mparticle = mParticle.getInstance() - const productAction = {} - mparticle._Ecommerce.convertTransactionAttributesToProductAction({}, productAction) - Object.keys(productAction).length.should.equal(0); - }); - - it('should sanitize certain ecommerce amounts from strings to 0', () => { - mParticle.getInstance()._Ecommerce.sanitizeAmount('$42', 'Price').should.equal(0); - mParticle.getInstance()._Ecommerce.sanitizeAmount('$100', 'TotalAmount').should.equal(0); - mParticle.getInstance()._Ecommerce.sanitizeAmount('first', 'Position').should.equal(0); - mParticle.getInstance()._Ecommerce.sanitizeAmount('two', 'Quantity').should.equal(0); - mParticle.getInstance()._Ecommerce.sanitizeAmount('string', 'Shipping').should.equal(0); - mParticle.getInstance()._Ecommerce.sanitizeAmount('$5.80', 'Tax').should.equal(0); - }); - - it('should convert transactionAttributes strings to numbers or zero', () => { - const mparticle = mParticle.getInstance() - const transactionAttributes = { - Id: "id", - Affiliation: "affiliation", - CouponCode: "couponCode", - Revenue: "revenue", - Shipping: "shipping", - Tax: "tax" - }; - - const productAction = {}; - mparticle._Ecommerce.convertTransactionAttributesToProductAction(transactionAttributes, productAction) - productAction.TransactionId.should.equal("id") - productAction.Affiliation.should.equal("affiliation") - productAction.CouponCode.should.equal("couponCode") - - // convert strings to 0 - productAction.TotalAmount.should.equal(0) - productAction.ShippingAmount.should.equal(0) - productAction.TaxAmount.should.equal(0) - }); - - it('should allow a user to pass in a source_message_id to a commerce event', async () => { - await waitForCondition(hasIdentifyReturned); - const product = mParticle.eCommerce.createProduct( - 'iPhone', - '12345', - '400', - 2, - 'Plus', - 'Phones', - 'Apple', - 1, - 'my-coupon-code', - { customkey: 'customvalue' } - ), + 'iPhone', + '12345', + '400', + 2, + 'Plus', + 'Phones', + 'Apple', + 1, + 'my-coupon-code', + { customkey: 'customvalue' } + ), - transactionAttributes = mParticle.eCommerce.createTransactionAttributes( - '12345', - 'test-affiliation', - 'coupon-code', - 44334, - 600, - 200 - ); - - mParticle.eCommerce.logProductAction( - mParticle.ProductActionType.Purchase, - product, - null, - null, - transactionAttributes, - { - sourceMessageId: 'foo-bar' - } - ); + transactionAttributes = mParticle.eCommerce.createTransactionAttributes( + '12345', + 'test-affiliation', + 'coupon-code', + 44334, + 600, + 200 + ); + + mParticle.eCommerce.logProductAction( + mParticle.ProductActionType.Purchase, + product, + null, + null, + transactionAttributes, + { + sourceMessageId: 'foo-bar' + } + ); - const purchaseEvent1 = findEventFromRequest(fetchMock.calls(), 'purchase'); - purchaseEvent1.data.source_message_id.should.equal('foo-bar'); - }); + const purchaseEvent1 = findEventFromRequest(fetchMock.calls(), 'purchase'); + purchaseEvent1.data.source_message_id.should.equal('foo-bar'); }); }); \ No newline at end of file diff --git a/test/src/tests-forwarders.ts b/test/src/tests-forwarders.ts index 176847554..b33e760e8 100644 --- a/test/src/tests-forwarders.ts +++ b/test/src/tests-forwarders.ts @@ -2558,7 +2558,6 @@ describe('forwarders', function() { 123, 1 ); - mParticle.eCommerce.Cart.add(product, true); let result = getForwarderEvent(fetchMock.calls(), 'not in forwarder'); diff --git a/test/src/tests-identity.ts b/test/src/tests-identity.ts index 0d023b0c1..ac69fc0ff 100644 --- a/test/src/tests-identity.ts +++ b/test/src/tests-identity.ts @@ -2527,7 +2527,6 @@ describe('identity', function() { const product1 = mParticle.eCommerce.createProduct('iPhone', 'SKU1', 1), product2 = mParticle.eCommerce.createProduct('Android', 'SKU2', 1); - mParticle.eCommerce.Cart.add([product1, product2]); fetchMockSuccess(urls.login, { mpid: testMPID, @@ -2705,31 +2704,6 @@ describe('identity', function() { }); }); - it('should return an empty array when no cart products exist', async () => { - mParticle.init(apiKey, window.mParticle.config); - await waitForCondition(hasIdentifyReturned); - const user1 = { - userIdentities: { - customerid: 'customerId1', - }, - }; - - fetchMockSuccess(urls.login, { - mpid: testMPID, - is_logged_in: true, - }); - - mParticle.Identity.login(user1); - - await waitForCondition(hasIdentityCallInflightReturned); - - const products = mParticle.Identity.getCurrentUser() - .getCart() - .getCartProducts(); - - expect(products.length).to.not.be.ok; - }); - it('should make a request when copyUserAttributes is included on the identity request', async () => { mParticle.init(apiKey, window.mParticle.config); @@ -4671,130 +4645,4 @@ describe('identity', function() { }) }); - describe('Deprecate Cart', function() { - afterEach(function() { - sinon.restore(); - }); - - it("should deprecate the user's cart", async () => { - mParticle.init(apiKey, window.mParticle.config); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); - await waitForCondition(hasIdentifyReturned); - mParticle - .getInstance() - .Identity.getCurrentUser() - .getCart(); - mParticle.Identity.getCurrentUser().getCart(); - - bond.called.should.eql(true); - bond.callCount.should.equal(2); - - bond.getCalls()[0].args[0].should.eql( - 'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases' - ); - }); - - it('should deprecate add', async () => { - mParticle.init(apiKey, window.mParticle.config); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); - - await waitForCondition(hasIdentifyReturned); - - const product: SDKProduct = mParticle.eCommerce.createProduct( - 'iPhone', - '12345', - 400 - ); - mParticle - .getInstance() - .Identity.getCurrentUser() - .getCart() - .add(product); - - mParticle.Identity.getCurrentUser() - .getCart() - .add(product); - - bond.called.should.eql(true); - // deprecates on both .getCart, then .add - bond.callCount.should.equal(4); - bond.getCalls()[1].args[0].should.eql( - 'Identity.getCurrentUser().getCart().add() has been deprecated. Please use the alternate method: eCommerce.logProductAction(). See - https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ); - }); - - it('should deprecate remove', async () => { - mParticle.init(apiKey, window.mParticle.config); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); - - await waitForCondition(hasIdentifyReturned); - - const product: SDKProduct = mParticle.eCommerce.createProduct( - 'iPhone', - '12345', - 400 - ); - - mParticle - .getInstance() - .Identity.getCurrentUser() - .getCart() - .remove(product, true); - mParticle.Identity.getCurrentUser() - .getCart() - .remove(product, true); - - bond.called.should.eql(true); - // deprecates on both .getCart, then .add - bond.callCount.should.equal(4); - bond.getCalls()[1].args[0].should.eql( - 'Identity.getCurrentUser().getCart().remove() has been deprecated. Please use the alternate method: eCommerce.logProductAction(). See - https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ); - }); - - it('should deprecate clear', async () => { - mParticle.init(apiKey, window.mParticle.config); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); - await waitForCondition(hasIdentifyReturned); - mParticle - .getInstance() - .Identity.getCurrentUser() - .getCart() - .clear(); - mParticle - .Identity.getCurrentUser() - .getCart() - .clear(); - - bond.called.should.eql(true); - // deprecates on both .getCart, then .add - bond.callCount.should.equal(4); - bond.getCalls()[1].args[0].should.eql( - 'Identity.getCurrentUser().getCart().clear() has been deprecated. See - https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ); - }); - - it('should deprecate getCartProducts', async () => { - mParticle.init(apiKey, window.mParticle.config); - const bond = sinon.spy(mParticle.getInstance().Logger, 'warning'); - - await waitForCondition(hasIdentifyReturned); - - mParticle - .getInstance() - .Identity.getCurrentUser() - .getCart() - .getCartProducts(); - mParticle.Identity.getCurrentUser() - .getCart() - .getCartProducts(); - - bond.called.should.eql(true); - // deprecates on both .getCart, then .add - bond.callCount.should.equal(4); - bond.getCalls()[1].args[0].should.eql( - 'Identity.getCurrentUser().getCart().getCartProducts() has been deprecated. Please use the alternate method: eCommerce.logProductAction(). See - https://docs.mparticle.com/developers/sdk/web/commerce-tracking' - ); - }); - }); }); diff --git a/test/src/tests-mparticle-instance-manager.ts b/test/src/tests-mparticle-instance-manager.ts index dd9cf728a..1641e0563 100644 --- a/test/src/tests-mparticle-instance-manager.ts +++ b/test/src/tests-mparticle-instance-manager.ts @@ -135,7 +135,6 @@ describe('mParticle instance manager', () => { 'tooManyRequests', ]); expect(mParticle.eCommerce, 'eCommerce').to.have.keys([ - 'Cart', 'setCurrencyCode', 'createProduct', 'createPromotion', diff --git a/test/src/tests-serverModel.ts b/test/src/tests-serverModel.ts index 5077c3b6a..0278b7201 100644 --- a/test/src/tests-serverModel.ts +++ b/test/src/tests-serverModel.ts @@ -768,104 +768,6 @@ describe('ServerModel', () => { expect(actualDTO.flags).to.eql(expectedFlags); }); - it('should add shopping cart to DTO', () => { - const uploadObject = ({ - CurrencyCode: 'USD', - EventDataType: Types.MessageType.Commerce, - ShoppingCart: { - ProductList: [ - { - Sku: 'SKU-12345', - Name: 'Some Item', - Price: '42', - Quantity: '3', - Brand: 'mParticle', - Variant: 'blue', - Category: 'product', - Position: 1, - CouponCode: 'FIDDY', - TotalAmount: '41.50', - Attributes: { - foo: 'bar', - fizz: 'bizz', - }, - }, - { - Sku: 'SKU-67890', - Name: 'Some Other Item', - Price: '37', - Quantity: '5', - Brand: 'mParticle', - Variant: 'red', - Category: 'not-product', - Position: 2, - CouponCode: 'FIDDY', - TotalAmount: '36.50', - Attributes: { - fizz: 'buzz', - }, - }, - ], - }, - } as unknown) as IUploadObject; - - const expectedShoppingCart = { - pl: [ - { - id: 'SKU-12345', - nm: 'Some Item', - pr: 42, - qt: 3, - br: 'mParticle', - va: 'blue', - ca: 'product', - ps: 1, - cc: 'FIDDY', - tpa: 41.5, - attrs: { - foo: 'bar', - fizz: 'bizz', - }, - }, - { - id: 'SKU-67890', - nm: 'Some Other Item', - pr: 37, - qt: 5, - br: 'mParticle', - va: 'red', - ca: 'not-product', - ps: 2, - cc: 'FIDDY', - tpa: 36.5, - attrs: { - fizz: 'buzz', - }, - }, - ], - }; - const actualDTO = ServerModel.convertEventToV2DTO(uploadObject); - - expect(actualDTO.cu).to.equal('USD'); - expect(actualDTO.sc).to.eql(expectedShoppingCart); - }); - - it('should add empty array to DTO if shopping cart is empty', () => { - const uploadObject = ({ - CurrencyCode: 'USD', - EventDataType: Types.MessageType.Commerce, - ShoppingCart: {}, - } as unknown) as IUploadObject; - - const expectedShoppingCart = { - pl: [], - }; - const actualDTO = ServerModel.convertEventToV2DTO(uploadObject); - - expect(actualDTO.cu).to.equal('USD'); - expect(actualDTO.sc).to.eql(expectedShoppingCart); - }); - it('should add product action to DTO', () => { const uploadObject = ({ CurrencyCode: 'USD', diff --git a/test/src/tests-store.ts b/test/src/tests-store.ts index 3d2a2baa5..20effb9d4 100644 --- a/test/src/tests-store.ts +++ b/test/src/tests-store.ts @@ -235,7 +235,6 @@ describe('Store', () => { expect(store.SDKConfig.logLevel, 'logLevel').to.eq(null); expect(store.SDKConfig.maxCookieSize, 'maxCookieSize').to.eq(3000); - expect(store.SDKConfig.maxProducts, 'maxProducts').to.eq(20); expect( store.SDKConfig.minWebviewBridgeVersion, 'minWebviewBridgeVersion' diff --git a/test/stub/tests-mParticle-stub.js b/test/stub/tests-mParticle-stub.js index 516b22f5f..8620d6bbc 100644 --- a/test/stub/tests-mParticle-stub.js +++ b/test/stub/tests-mParticle-stub.js @@ -58,18 +58,6 @@ describe('mParticle stubs', function() { mParticle.eCommerce.logPromotion(); mParticle.eCommerce.setCurrencyCode(); - var product1 = mParticle.eCommerce.createProduct( - 'iphone', - 'iphoneSKU', - 999 - ); - - mParticle.eCommerce.Cart.add(product1); - mParticle.eCommerce.Cart.remove(product1); - mParticle.eCommerce.Cart.clear(product1); - var products = mParticle.eCommerce.Cart.getCartProducts(); - checkProduct(products[0]); - done(); }); @@ -146,13 +134,6 @@ describe('mParticle stubs', function() { user.removeAllUserAttributes(); (typeof user.getUserAttributesLists()).should.equal('object'); (typeof user.getAllUserAttributes()).should.equal('object'); - var userCart = user.getCart(); - (typeof userCart).should.equal('object'); - userCart.add(); - userCart.clear(); - userCart.remove(); - var cartProducts = userCart.getCartProducts(); - checkProduct(cartProducts[0]); user.setConsentState();