@@ -4,7 +4,7 @@ var v1ServiceUrl = 'jssdk.mparticle.com/v1/JS/',
44 v2ServiceUrl = 'jssdk.mparticle.com/v2/JS/' ,
55 v2SecureServiceUrl = 'jssdks.mparticle.com/v2/JS/' ,
66 identityUrl = 'https://identity.mparticle.com/v1/' , //prod
7- sdkVersion = '2.1.5 ' ,
7+ sdkVersion = '2.2.0 ' ,
88 sdkVendor = 'mparticle' ,
99 platform = 'web' ,
1010 Messages = {
@@ -57,9 +57,6 @@ var v1ServiceUrl = 'jssdk.mparticle.com/v1/JS/',
5757 SetUserAttribute : 'setUserAttribute' ,
5858 RemoveUserAttribute : 'removeUserAttribute' ,
5959 SetSessionAttribute : 'setSessionAttribute' ,
60- AddToProductBag : 'addToProductBag' ,
61- RemoveFromProductBag : 'removeFromProductBag' ,
62- ClearProductBag : 'clearProductBag' ,
6360 AddToCart : 'addToCart' ,
6461 RemoveFromCart : 'removeFromCart' ,
6562 ClearCart : 'clearCart' ,
@@ -718,7 +715,7 @@ function send(event) {
718715 if ( xhr ) {
719716 try {
720717 xhr . open ( 'post' , Helpers . createServiceUrl ( Constants . v2SecureServiceUrl , Constants . v2ServiceUrl , MP . devToken ) + '/Events' ) ;
721- xhr . send ( JSON . stringify ( ServerModel . convertEventToDTO ( event , MP . isFirstRun , MP . productBags , MP . currencyCode ) ) ) ;
718+ xhr . send ( JSON . stringify ( ServerModel . convertEventToDTO ( event , MP . isFirstRun , MP . currencyCode ) ) ) ;
722719
723720 if ( event . EventName !== Types . MessageType . AppStateTransition ) {
724721 Forwarders . sendEventToForwarders ( event ) ;
@@ -934,7 +931,6 @@ function logCommerceEvent(commerceEvent, attrs) {
934931 if ( Helpers . isWebViewEmbedded ( ) ) {
935932 // Don't send shopping cart or product bags to parent sdks
936933 commerceEvent . ShoppingCart = { } ;
937- commerceEvent . ProductBags = { } ;
938934 }
939935
940936 if ( attrs ) {
@@ -2708,12 +2704,10 @@ function checkCookieForMPID(currentMPID) {
27082704 if ( cookies && ! cookies [ currentMPID ] ) {
27092705 Persistence . storeDataInMemory ( null , currentMPID ) ;
27102706 MP . cartProducts = [ ] ;
2711- MP . productBags = { } ;
27122707 } else if ( cookies ) {
27132708 var products = Persistence . decodeProducts ( ) ;
27142709 if ( products && products [ currentMPID ] ) {
27152710 MP . cartProducts = products [ currentMPID ] . cp ;
2716- MP . productBags = products [ currentMPID ] . pb ;
27172711 }
27182712 MP . userIdentities = cookies [ currentMPID ] . ui ? cookies [ currentMPID ] . ui : MP . userIdentities ;
27192713 MP . userAttributes = cookies [ currentMPID ] . ua ? cookies [ currentMPID ] . ua : MP . userAttributes ;
@@ -2908,7 +2902,6 @@ var Polyfill = require('./polyfill'),
29082902 MP . forwarders = [ ] ;
29092903 MP . forwarderConstructors = [ ] ;
29102904 MP . pixelConfigurations = [ ] ;
2911- MP . productBags = { } ;
29122905 MP . cartProducts = [ ] ;
29132906 MP . serverSettings = null ;
29142907 MP . mpid = null ;
@@ -3147,77 +3140,9 @@ var Polyfill = require('./polyfill'),
31473140 * @class mParticle.eCommerce
31483141 */
31493142 eCommerce : {
3150- /**
3151- * Invoke these methods on the mParticle.eCommerce.ProductBags object.
3152- * Example: mParticle.eCommerce.ProductBags.clear('exampleBag')
3153- * @class mParticle.eCommerce.ProductBags
3154- */
3155- ProductBags : {
3156- /**
3157- * Adds a product to a product bag
3158- * @method add
3159- * @param {String } productBagName The name of the product bag
3160- * @param {Object } product The product you'd like to add
3161- */
3162- add : function ( productBagName , product ) {
3163- if ( ! Validators . isStringOrNumber ( productBagName ) ) {
3164- Helpers . logDebug ( 'ProductBagName is required and must be a string or number' ) ;
3165- return ;
3166- }
3167- mParticle . sessionManager . resetSessionTimer ( ) ;
3168- if ( ! MP . productBags [ productBagName ] ) {
3169- MP . productBags [ productBagName ] = [ ] ;
3170- }
3171-
3172- MP . productBags [ productBagName ] . push ( product ) ;
3173-
3174- if ( MP . productBags [ productBagName ] . length > mParticle . maxProducts ) {
3175- Helpers . logDebug ( productBagName + ' contains ' + MP . productBags [ productBagName ] . length + ' items. Only mParticle.maxProducts = ' + mParticle . maxProducts + ' can currently be saved in cookies.' ) ;
3176- }
3177- Persistence . update ( ) ;
3178-
3179- Helpers . tryNativeSdk ( Constants . NativeSdkPaths . AddToProductBag , JSON . stringify ( product ) ) ;
3180- } ,
3181- /**
3182- * Removes a product from a product bag
3183- * @method remove
3184- * @param {String } productBagName The name of the product bag
3185- * @param {Object } product The product you'd like to remove
3186- */
3187- remove : function ( productBagName , product ) {
3188- mParticle . sessionManager . resetSessionTimer ( ) ;
3189- var productIndex = - 1 ;
3190-
3191- if ( MP . productBags [ productBagName ] ) {
3192- MP . productBags [ productBagName ] . forEach ( function ( productBagItem , i ) {
3193- if ( productBagItem . sku === product . sku ) {
3194- productIndex = i ;
3195- }
3196- } ) ;
3197-
3198- if ( productIndex > - 1 ) {
3199- MP . productBags [ productBagName ] . splice ( productIndex , 1 ) ;
3200- }
3201- Persistence . update ( ) ;
3202- }
3203- Helpers . tryNativeSdk ( Constants . NativeSdkPaths . RemoveFromProductBag , JSON . stringify ( product ) ) ;
3204- } ,
3205- /**
3206- * Removes all products from a product bag
3207- * @method clear
3208- * @param {String } productBagName The name of the product bag you'd like to clear
3209- */
3210- clear : function ( productBagName ) {
3211- mParticle . sessionManager . resetSessionTimer ( ) ;
3212- MP . productBags [ productBagName ] = [ ] ;
3213- Persistence . update ( ) ;
3214-
3215- Helpers . tryNativeSdk ( Constants . NativeSdkPaths . ClearProductBag , productBagName ) ;
3216- }
3217- } ,
32183143 /**
32193144 * Invoke these methods on the mParticle.eCommerce.Cart object.
3220- * Example: mParticle.eCommerce.ProductBags .add(...)
3145+ * Example: mParticle.eCommerce.Cart .add(...)
32213146 * @class mParticle.eCommerce.Cart
32223147 */
32233148 Cart : {
@@ -3758,8 +3683,7 @@ function convertSDKv2CookiesV1ToSDKv2DecodedCookiesV4(SDKv2CookiesV1) {
37583683 }
37593684
37603685 localStorageProducts [ mpid ] = {
3761- cp : SDKv2CookiesV1 [ mpid ] . cp ,
3762- pb : SDKv2CookiesV1 [ mpid ] . pb
3686+ cp : SDKv2CookiesV1 [ mpid ] . cp
37633687 } ;
37643688 }
37653689 }
@@ -3837,14 +3761,6 @@ function migrateProductsFromSDKv1ToSDKv2CookiesV4(cookies, mpid) {
38373761 localStorageProducts [ mpid ] . cp = cookies . cp ;
38383762 }
38393763 }
3840- if ( cookies . pb ) {
3841- try {
3842- localStorageProducts [ mpid ] . pb = JSON . parse ( Base64 . decode ( cookies . pb ) ) ;
3843- }
3844- catch ( e ) {
3845- localStorageProducts [ mpid ] . pb = cookies . pb ;
3846- }
3847- }
38483764
38493765 localStorage . setItem ( Config . LocalStorageProductsV4 , Base64 . encode ( JSON . stringify ( localStorageProducts ) ) ) ;
38503766}
@@ -3977,7 +3893,6 @@ module.exports = {
39773893 watchPositionId : null ,
39783894 readyQueue : [ ] ,
39793895 isInitialized : false ,
3980- productBags : { } ,
39813896 cartProducts : [ ] ,
39823897 eventQueue : [ ] ,
39833898 currencyCode : null ,
@@ -4089,7 +4004,6 @@ function update() {
40894004function storeProductsInMemory ( products , mpid ) {
40904005 try {
40914006 MP . cartProducts = products [ mpid ] && products [ mpid ] . cp ? products [ mpid ] . cp : [ ] ;
4092- MP . productBags = products [ mpid ] && products [ mpid ] . pb ? products [ mpid ] . pb : { } ;
40934007 }
40944008 catch ( e ) {
40954009 Helpers . logDebug ( Messages . ErrorMessages . CookieParseError ) ;
@@ -4189,18 +4103,9 @@ function convertInMemoryDataForCookies() {
41894103
41904104function convertProductsForLocalStorage ( ) {
41914105 var inMemoryDataForLocalStorage = {
4192- cp : MP . cartProducts ? MP . cartProducts . length <= mParticle . maxProducts ? MP . cartProducts : MP . cartProducts . slice ( 0 , mParticle . maxProducts ) : [ ] ,
4193- pb : { }
4106+ cp : MP . cartProducts ? MP . cartProducts . length <= mParticle . maxProducts ? MP . cartProducts : MP . cartProducts . slice ( 0 , mParticle . maxProducts ) : [ ]
41944107 } ;
41954108
4196- for ( var bag in MP . productBags ) {
4197- if ( MP . productBags [ bag ] . length > mParticle . maxProducts ) {
4198- inMemoryDataForLocalStorage . pb [ bag ] = MP . productBags [ bag ] . slice ( 0 , mParticle . maxProducts ) ;
4199- } else {
4200- inMemoryDataForLocalStorage . pb [ bag ] = MP . productBags [ bag ] ;
4201- }
4202- }
4203-
42044109 return inMemoryDataForLocalStorage ;
42054110}
42064111
@@ -4998,8 +4903,7 @@ var Types = require('./types'),
49984903 Constants = require ( './constants' ) ,
49994904 Helpers = require ( './helpers' ) ,
50004905 MP = require ( './mp' ) ,
5001- parseNumber = require ( './helpers' ) . parseNumber ,
5002- isWebViewEmbedded = require ( './helpers' ) . isWebViewEmbedded ;
4906+ parseNumber = require ( './helpers' ) . parseNumber ;
50034907
50044908function convertCustomFlags ( event , dto ) {
50054909 var valueArray = [ ] ;
@@ -5057,34 +4961,6 @@ function convertProductToDTO(product) {
50574961 } ;
50584962}
50594963
5060- function convertProductBagToDTO ( productBags ) {
5061- var convertedBag = { } ,
5062- list ;
5063-
5064- for ( var prop in productBags ) {
5065- if ( ! productBags . hasOwnProperty ( prop ) ) {
5066- continue ;
5067- }
5068-
5069- list = productBags [ prop ] . map ( function ( item ) {
5070- return convertProductToDTO ( item ) ;
5071- } ) ;
5072-
5073- if ( isWebViewEmbedded ( ) ) {
5074- convertedBag [ prop ] = {
5075- ProductList : list
5076- } ;
5077- }
5078- else {
5079- convertedBag [ prop ] = {
5080- pl : list
5081- } ;
5082- }
5083- }
5084-
5085- return convertedBag ;
5086- }
5087-
50884964function createEventObject ( messageType , name , data , eventType , customFlags ) {
50894965 var eventObject ,
50904966 optOut = ( messageType === Types . MessageType . OptOut ? ! MP . isEnabled : null ) ;
@@ -5109,7 +4985,6 @@ function createEventObject(messageType, name, data, eventType, customFlags) {
51094985 Debug : mParticle . isDevelopmentMode ,
51104986 Location : MP . currentPosition ,
51114987 OptOut : optOut ,
5112- ProductBags : MP . productBags ,
51134988 ExpandedEventCount : 0 ,
51144989 CustomFlags : customFlags ,
51154990 AppVersion : MP . appVersion ,
@@ -5132,7 +5007,7 @@ function createEventObject(messageType, name, data, eventType, customFlags) {
51325007 return null ;
51335008}
51345009
5135- function convertEventToDTO ( event , isFirstRun , productBags , currencyCode ) {
5010+ function convertEventToDTO ( event , isFirstRun , currencyCode ) {
51365011 var dto = {
51375012 n : event . EventName ,
51385013 et : event . EventCategory ,
@@ -5169,8 +5044,6 @@ function convertEventToDTO(event, isFirstRun, productBags, currencyCode) {
51695044 convertCustomFlags ( event , dto ) ;
51705045 }
51715046
5172- dto . pb = convertProductBagToDTO ( productBags ) ;
5173-
51745047 if ( event . EventDataType === MessageType . Commerce ) {
51755048 dto . cu = currencyCode ;
51765049
0 commit comments