@mparticle/web-sdk 2.26.4 → 2.26.6

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.
@@ -61,7 +61,7 @@ var _TriggerUploadType,MessageType$2={SessionStart:1,SessionEnd:2,PageView:3,Pag
61
61
  // Continuation of enum above, but in seperate object since we don't expose these to end user
62
62
  IdentityType$1.isValid=function(a){if("number"==typeof a)for(var b in IdentityType$1)if(IdentityType$1.hasOwnProperty(b)&&IdentityType$1[b]===a)return !0;return !1},IdentityType$1.getName=function(a){return a===window.mParticle.IdentityType.CustomerId?"Customer ID":a===window.mParticle.IdentityType.Facebook?"Facebook ID":a===window.mParticle.IdentityType.Twitter?"Twitter ID":a===window.mParticle.IdentityType.Google?"Google ID":a===window.mParticle.IdentityType.Microsoft?"Microsoft ID":a===window.mParticle.IdentityType.Yahoo?"Yahoo ID":a===window.mParticle.IdentityType.Email?"Email":a===window.mParticle.IdentityType.FacebookCustomAudienceId?"Facebook App User ID":"Other ID"},IdentityType$1.getIdentityType=function(a){return "other"===a?IdentityType$1.Other:"customerid"===a?IdentityType$1.CustomerId:"facebook"===a?IdentityType$1.Facebook:"twitter"===a?IdentityType$1.Twitter:"google"===a?IdentityType$1.Google:"microsoft"===a?IdentityType$1.Microsoft:"yahoo"===a?IdentityType$1.Yahoo:"email"===a?IdentityType$1.Email:"facebookcustomaudienceid"===a?IdentityType$1.FacebookCustomAudienceId:"other2"===a?IdentityType$1.Other2:"other3"===a?IdentityType$1.Other3:"other4"===a?IdentityType$1.Other4:"other5"===a?IdentityType$1.Other5:"other6"===a?IdentityType$1.Other6:"other7"===a?IdentityType$1.Other7:"other8"===a?IdentityType$1.Other8:"other9"===a?IdentityType$1.Other9:"other10"===a?IdentityType$1.Other10:"mobile_number"===a?IdentityType$1.MobileNumber:"phone_number_2"===a?IdentityType$1.PhoneNumber2:!("phone_number_3"!=a)&&IdentityType$1.PhoneNumber3},IdentityType$1.getIdentityName=function(a){return a===IdentityType$1.Other?"other":a===IdentityType$1.CustomerId?"customerid":a===IdentityType$1.Facebook?"facebook":a===IdentityType$1.Twitter?"twitter":a===IdentityType$1.Google?"google":a===IdentityType$1.Microsoft?"microsoft":a===IdentityType$1.Yahoo?"yahoo":a===IdentityType$1.Email?"email":a===IdentityType$1.FacebookCustomAudienceId?"facebookcustomaudienceid":a===IdentityType$1.Other2?"other2":a===IdentityType$1.Other3?"other3":a===IdentityType$1.Other4?"other4":a===IdentityType$1.Other5?"other5":a===IdentityType$1.Other6?"other6":a===IdentityType$1.Other7?"other7":a===IdentityType$1.Other8?"other8":a===IdentityType$1.Other9?"other9":a===IdentityType$1.Other10?"other10":a===IdentityType$1.MobileNumber?"mobile_number":a===IdentityType$1.PhoneNumber2?"phone_number_2":a===IdentityType$1.PhoneNumber3?"phone_number_3":void 0};var ProductActionType={Unknown:0,AddToCart:1,RemoveFromCart:2,Checkout:3,CheckoutOption:4,Click:5,ViewDetail:6,Purchase:7,Refund:8,AddToWishlist:9,RemoveFromWishlist:10};ProductActionType.getName=function(a){return a===ProductActionType.AddToCart?"Add to Cart":a===ProductActionType.RemoveFromCart?"Remove from Cart":a===ProductActionType.Checkout?"Checkout":a===ProductActionType.CheckoutOption?"Checkout Option":a===ProductActionType.Click?"Click":a===ProductActionType.ViewDetail?"View Detail":a===ProductActionType.Purchase?"Purchase":a===ProductActionType.Refund?"Refund":a===ProductActionType.AddToWishlist?"Add to Wishlist":a===ProductActionType.RemoveFromWishlist?"Remove from Wishlist":"Unknown"},ProductActionType.getExpansionName=function(a){return a===ProductActionType.AddToCart?"add_to_cart":a===ProductActionType.RemoveFromCart?"remove_from_cart":a===ProductActionType.Checkout?"checkout":a===ProductActionType.CheckoutOption?"checkout_option":a===ProductActionType.Click?"click":a===ProductActionType.ViewDetail?"view_detail":a===ProductActionType.Purchase?"purchase":a===ProductActionType.Refund?"refund":a===ProductActionType.AddToWishlist?"add_to_wishlist":a===ProductActionType.RemoveFromWishlist?"remove_from_wishlist":"unknown"};var PromotionActionType={Unknown:0,PromotionView:1,PromotionClick:2};PromotionActionType.getName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"},PromotionActionType.getExpansionName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"};var ProfileMessageType={Logout:3},ApplicationTransitionType$1={AppInit:1},Environment={Production:"production",Development:"development"};var Types = {MessageType:MessageType$2,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType$1,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,TriggerUploadType:TriggerUploadType,Environment:Environment};
63
63
 
64
- var version = "2.26.4";
64
+ var version = "2.26.6";
65
65
 
66
66
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"is a deprecated method and will be removed in future releases",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
67
67
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
@@ -622,8 +622,10 @@ for(var n,o=0;o<h.length&&(g=d(b,c,e),g.length>f);o++)n=h[o],b[n]?(a.Logger.verb
622
622
  // other keys on the cookie are currentSessionMPIDs and currentMPID which should not be searched
623
623
  if(d[g].mpid){var h=d[g].ui;for(var i in h)if(e===i&&b.userIdentities[e]===h[i]){c=g;break}}c&&f.storeDataInMemory(d,c);},this.encodePersistence=function(b){for(var c in b=JSON.parse(b),b.gs)b.gs.hasOwnProperty(c)&&(Base64CookieKeys[c]?b.gs[c]?Array.isArray(b.gs[c])&&b.gs[c].length||a._Helpers.isObject(b.gs[c])&&Object.keys(b.gs[c]).length?b.gs[c]=Base64.encode(JSON.stringify(b.gs[c])):delete b.gs[c]:delete b.gs[c]:"ie"===c?b.gs[c]=b.gs[c]?1:0:!b.gs[c]&&delete b.gs[c]);for(var d in b)if(b.hasOwnProperty(d)&&!SDKv2NonMPIDCookieKeys[d])for(c in b[d])b[d].hasOwnProperty(c)&&Base64CookieKeys[c]&&(a._Helpers.isObject(b[d][c])&&Object.keys(b[d][c]).length?b[d][c]=Base64.encode(JSON.stringify(b[d][c])):delete b[d][c]);return createCookieString(JSON.stringify(b))},this.decodePersistence=function(b){try{if(b){if(b=JSON.parse(revertCookieString(b)),a._Helpers.isObject(b)&&Object.keys(b).length){for(var c in b.gs)b.gs.hasOwnProperty(c)&&(Base64CookieKeys[c]?b.gs[c]=JSON.parse(Base64.decode(b.gs[c])):"ie"===c&&(b.gs[c]=!!b.gs[c]));for(var d in b)if(b.hasOwnProperty(d))if(!SDKv2NonMPIDCookieKeys[d])for(c in b[d])b[d].hasOwnProperty(c)&&Base64CookieKeys[c]&&b[d][c].length&&(b[d][c]=JSON.parse(Base64.decode(b[d][c])));else "l"===d&&(b[d]=!!b[d]);}return JSON.stringify(b)}}catch(b){a.Logger.error("Problem with decoding cookie",b);}},this.getCookieDomain=function(){if(a._Store.SDKConfig.cookieDomain)return a._Store.SDKConfig.cookieDomain;var b=f.getDomain(document,location.hostname);return ""===b?"":"."+b},this.getDomain=function(a,b){var c,d,e=b.split(".");for(c=e.length-1;0<=c;c--)if(d=e.slice(c).join("."),a.cookie="mptest=cookie;domain=."+d+";",-1<a.cookie.indexOf("mptest=cookie"))return a.cookie="mptest=;domain=."+d+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",d;return ""},this.getUserIdentities=function(a){var b=f.getPersistence();return b&&b[a]&&b[a].ui?b[a].ui:{}},this.getAllUserAttributes=function(a){var b=f.getPersistence();return b&&b[a]&&b[a].ua?b[a].ua:{}},this.getCartProducts=function(b){var c,d=localStorage.getItem(a._Store.prodStorageName);return d&&(c=JSON.parse(Base64.decode(d)),c&&c[b]&&c[b].cp)?c[b].cp:[]},this.setCartProducts=function(b){if(a._Store.isLocalStorageAvailable)try{window.localStorage.setItem(encodeURIComponent(a._Store.prodStorageName),Base64.encode(JSON.stringify(b)));}catch(b){a.Logger.error("Error with setting products on localStorage.");}},this.saveUserIdentitiesToPersistence=function(a,b){if(b){var c=f.getPersistence();c&&(c[a]?c[a].ui=b:c[a]={ui:b},f.savePersistence(c));}},this.saveUserAttributesToPersistence=function(a,b){var c=f.getPersistence();b&&(c&&(c[a]?c[a].ui=b:c[a]={ui:b}),f.savePersistence(c));},this.saveUserCookieSyncDatesToPersistence=function(a,b){if(b){var c=f.getPersistence();c&&(c[a]?c[a].csd=b:c[a]={csd:b}),f.savePersistence(c);}},this.saveUserConsentStateToCookies=function(b,c){//it's currently not supported to set persistence
624
624
  //for any MPID that's not the current one.
625
- if(c||null===c){var d=f.getPersistence();d&&(d[b]?d[b].con=a._Consent.ConsentSerialization.toMinifiedJsonObject(c):d[b]={con:a._Consent.ConsentSerialization.toMinifiedJsonObject(c)},f.savePersistence(d));}},this.savePersistence=function(b){var c,d=f.encodePersistence(JSON.stringify(b)),e=new Date,g=a._Store.storageName,h=new Date(e.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toGMTString(),i=f.getCookieDomain();if(c=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=f.reduceAndEncodePersistence(b,h,c,a._Store.SDKConfig.maxCookieSize);window.document.cookie=encodeURIComponent(g)+"="+j;}else a._Store.isLocalStorageAvailable&&localStorage.setItem(a._Store.storageName,d);},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getConsentState=function(b){var c=f.getPersistence();return c&&c[b]&&c[b].con?a._Consent.ConsentSerialization.fromMinifiedJsonObject(c[b].con):null},this.getFirstSeenTime=function(a){if(!a)return null;var b=f.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&(!c[a]&&(c[a]={}),!c[a].fst&&(c[a].fst=b,f.savePersistence(c)));}},this.getLastSeenTime=function(b){if(!b)return null;if(b===a.Identity.getCurrentUser().getMPID())//if the mpid is the current user, its last seen time is the current time
626
- return new Date().getTime();var c=f.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&c[a]&&(c[a].lst=b,f.savePersistence(c));}},this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,f.update();},this.resetPersistence=function(){if(c(StorageNames.localStorageName),c(StorageNames.localStorageNameV3),c(StorageNames.localStorageNameV4),c(a._Store.prodStorageName),c(a._Store.storageName),c(StorageNames.localStorageProductsV4),f.expireCookies(StorageNames.cookieName),f.expireCookies(StorageNames.cookieNameV2),f.expireCookies(StorageNames.cookieNameV3),f.expireCookies(StorageNames.cookieNameV4),f.expireCookies(a._Store.prodStorageName),f.expireCookies(a._Store.storageName),mParticle._isTestEnv){c(a._Helpers.createMainStorageName("abcdef")),f.expireCookies(a._Helpers.createMainStorageName("abcdef")),c(a._Helpers.createProductStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
625
+ if(c||null===c){var d=f.getPersistence();d&&(d[b]?d[b].con=a._Consent.ConsentSerialization.toMinifiedJsonObject(c):d[b]={con:a._Consent.ConsentSerialization.toMinifiedJsonObject(c)},f.savePersistence(d));}},this.swapCurrentUser=function(a,b,c){if(a&&b&&a!==b){var d=f.getPersistence();d&&(d.cu=b,d.gs.csm=c,f.savePersistence(d));}},this.savePersistence=function(b){var c,d=f.encodePersistence(JSON.stringify(b)),e=new Date,g=a._Store.storageName,h=new Date(e.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toGMTString(),i=f.getCookieDomain();if(c=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=f.reduceAndEncodePersistence(b,h,c,a._Store.SDKConfig.maxCookieSize);window.document.cookie=encodeURIComponent(g)+"="+j;}else a._Store.isLocalStorageAvailable&&localStorage.setItem(a._Store.storageName,d);},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getConsentState=function(b){var c=f.getPersistence();return c&&c[b]&&c[b].con?a._Consent.ConsentSerialization.fromMinifiedJsonObject(c[b].con):null},this.getFirstSeenTime=function(a){if(!a)return null;var b=f.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&(!c[a]&&(c[a]={}),!c[a].fst&&(c[a].fst=b,f.savePersistence(c)));}// https://go.mparticle.com/work/SQDSDKS-6329
626
+ },this.getLastSeenTime=function(b){if(!b)return null;if(b===a.Identity.getCurrentUser().getMPID())//if the mpid is the current user, its last seen time is the current time
627
+ return new Date().getTime();var c=f.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&c[a]&&(c[a].lst=b,f.savePersistence(c));}// https://go.mparticle.com/work/SQDSDKS-6329
628
+ },this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,f.update();},this.resetPersistence=function(){if(c(StorageNames.localStorageName),c(StorageNames.localStorageNameV3),c(StorageNames.localStorageNameV4),c(a._Store.prodStorageName),c(a._Store.storageName),c(StorageNames.localStorageProductsV4),f.expireCookies(StorageNames.cookieName),f.expireCookies(StorageNames.cookieNameV2),f.expireCookies(StorageNames.cookieNameV3),f.expireCookies(StorageNames.cookieNameV4),f.expireCookies(a._Store.prodStorageName),f.expireCookies(a._Store.storageName),mParticle._isTestEnv){c(a._Helpers.createMainStorageName("abcdef")),f.expireCookies(a._Helpers.createMainStorageName("abcdef")),c(a._Helpers.createProductStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
627
629
 
628
630
  var Messages$3=Constants.Messages;function Events(a){var b=this;this.logEvent=function(b,c){if(a.Logger.verbose(Messages$3.InformationMessages.StartingLogEvent+": "+b.name),a._Helpers.canLog()){var d=a._ServerModel.createEventObject(b);a._APIClient.sendEventToServer(d,c);}else a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);},this.startTracking=function(b){function c(b,c){if(b)try{c?b(c):b();}catch(b){a.Logger.error("Error invoking the callback passed to startTrackingLocation."),a.Logger.error(b);}}if(!a._Store.isTracking)"geolocation"in navigator&&(a._Store.watchPositionId=navigator.geolocation.watchPosition(function e(d){// prevents callback from being fired multiple times
629
631
  a._Store.currentPosition={lat:d.coords.latitude,lng:d.coords.longitude},c(b,d),b=null,a._Store.isTracking=!0;},function d(){// prevents callback from being fired multiple times
@@ -725,11 +727,13 @@ if(h){var i=getCachedIdentity(g,a,b);return c(i,d,e,f,g,a,!0),!0}return !1};
725
727
  var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
726
728
  throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
727
729
 
728
- var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1=Constants.FeatureFlags,ErrorMessages=Messages$2.ErrorMessages,_Constants$IdentityMe=Constants.IdentityMethods,Identify=_Constants$IdentityMe.Identify,Modify$1=_Constants$IdentityMe.Modify,Login=_Constants$IdentityMe.Login,Logout=_Constants$IdentityMe.Logout;function Identity(t){var r=this;/**
730
+ var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1=Constants.FeatureFlags,ErrorMessages=Messages$2.ErrorMessages,_Constants$IdentityMe=Constants.IdentityMethods,Identify=_Constants$IdentityMe.Identify,Modify$1=_Constants$IdentityMe.Modify,Login=_Constants$IdentityMe.Login,Logout=_Constants$IdentityMe.Logout;function Identity(t){var r=this;// https://go.mparticle.com/work/SQDSDKS-6353
731
+ /**
729
732
  * Invoke these methods on the mParticle.Identity object.
730
733
  * Example: mParticle.Identity.getCurrentUser().
731
734
  * @class mParticle.Identity
732
- */ /**
735
+ */ // https://go.mparticle.com/work/SQDSDKS-6354
736
+ /**
733
737
  * Invoke these methods on the mParticle.Identity.getCurrentUser() object.
734
738
  * Example: mParticle.Identity.getCurrentUser().getAllUserAttributes()
735
739
  * @class mParticle.Identity.getCurrentUser()
@@ -738,32 +742,37 @@ var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1
738
742
  * Example: mParticle.Identity.getCurrentUser().getCart().add(...);
739
743
  * @class mParticle.Identity.getCurrentUser().getCart()
740
744
  * @deprecated
741
- */ // send a user identity change request on identify, login, logout, modify when any values change.
745
+ */ // https://go.mparticle.com/work/SQDSDKS-6355
746
+ // send a user identity change request on identify, login, logout, modify when any values change.
742
747
  // compare what identities exist vs what is previously was for the specific user if they were in memory before.
743
748
  // if it's the first time the user is logging in, send a user identity change request with
744
- this.idCache=null,this.audienceManager=null,this.checkIdentitySwap=function(e,r,s){if(e&&r&&e!==r){var i=t._Persistence.getPersistence();i&&(i.cu=r,i.gs.csm=s,t._Persistence.savePersistence(i));}},this.IdentityRequest={preProcessIdentityRequest:function preProcessIdentityRequest(e,r,s){t.Logger.verbose(Messages$2.InformationMessages.StartingLogEvent+": "+s);var i=t._Helpers.Validators.validateIdentities(e,s);if(!i.valid)return t.Logger.error("ERROR: "+i.error),{valid:!1,error:i.error};if(r&&!t._Helpers.Validators.isFunction(r)){var n="The optional callback must be a function. You tried entering a(n) "+_typeof(r);return t.Logger.error(n),{valid:!1,error:n}}return {valid:!0}},createIdentityRequest:function createIdentityRequest(e,r,s,i,n,a,o){var d={client_sdk:{platform:r,sdk_vendor:s,sdk_version:i},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),previous_mpid:o||null,known_identities:createKnownIdentities(e,n)};return d},createModifyIdentityRequest:function createModifyIdentityRequest(e,r,s,i,n,a){return {client_sdk:{platform:s,sdk_vendor:i,sdk_version:n},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),identity_changes:this.createIdentityChanges(e,r)}},createIdentityChanges:function createIdentityChanges(e,r){var s,i=[];if(r&&t._Helpers.isObject(r)&&e&&t._Helpers.isObject(e))for(s in r)i.push({old_value:e[s]||null,new_value:r[s],identity_type:s});return i},// takes 2 UI objects keyed by name, combines them, returns them keyed by type
749
+ this.idCache=null,this.audienceManager=null,this.IdentityRequest={preProcessIdentityRequest:function preProcessIdentityRequest(e,r,s){t.Logger.verbose(Messages$2.InformationMessages.StartingLogEvent+": "+s);var i=t._Helpers.Validators.validateIdentities(e,s);if(!i.valid)return t.Logger.error("ERROR: "+i.error),{valid:!1,error:i.error};if(r&&!t._Helpers.Validators.isFunction(r)){var n="The optional callback must be a function. You tried entering a(n) "+_typeof(r);return t.Logger.error(n),{valid:!1,error:n}}return {valid:!0}},createIdentityRequest:function createIdentityRequest(e,r,s,i,n,a,o){var d={client_sdk:{platform:r,sdk_vendor:s,sdk_version:i},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),previous_mpid:o||null,known_identities:createKnownIdentities(e,n)};return d},createModifyIdentityRequest:function createModifyIdentityRequest(e,r,s,i,n,a){return {client_sdk:{platform:s,sdk_vendor:i,sdk_version:n},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),identity_changes:this.createIdentityChanges(e,r)}},createIdentityChanges:function createIdentityChanges(e,r){var s,i=[];if(r&&t._Helpers.isObject(r)&&e&&t._Helpers.isObject(e))for(s in r)i.push({old_value:e[s]||null,new_value:r[s],identity_type:s});return i},// takes 2 UI objects keyed by name, combines them, returns them keyed by type
745
750
  combineUserIdentities:function combineUserIdentities(e,r){var s={},i=t._Helpers.extend(e,r);for(var n in i){var a=Types.IdentityType.getIdentityType(n);// this check removes anything that is not whitelisted as an identity type
746
751
  !1!==a&&0<=a&&(s[Types.IdentityType.getIdentityType(n)]=i[n]);}return s},createAliasNetworkRequest:function createAliasNetworkRequest(e){return {request_id:t._Helpers.generateUniqueId(),request_type:"alias",environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",api_key:t._Store.devToken,data:{destination_mpid:e.destinationMpid,source_mpid:e.sourceMpid,start_unixtime_ms:e.startTime,end_unixtime_ms:e.endTime,scope:e.scope,device_application_stamp:t._Store.deviceId}}},convertAliasToNative:function convertAliasToNative(e){return {DestinationMpid:e.destinationMpid,SourceMpid:e.sourceMpid,StartUnixtimeMs:e.startTime,EndUnixtimeMs:e.endTime}},convertToNative:function convertToNative(e){var t=[];if(e&&e.userIdentities){for(var r in e.userIdentities)e.userIdentities.hasOwnProperty(r)&&t.push({Type:Types.IdentityType.getIdentityType(r),Identity:e.userIdentities[r]});return {UserIdentities:t}}}},this.IdentityAPI={HTTPCodes:HTTPCodes$2,/**
747
752
  * Initiate a logout request to the mParticle server
748
753
  * @method identify
749
754
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
750
755
  * @param {Function} [callback] A callback function that is called when the identify request completes
751
- */identify:function identify(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Identify);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Identify);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Identify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Identify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Identify,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
756
+ */identify:function identify(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
757
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Identify);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Identify);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Identify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Identify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Identify,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
752
758
  * Initiate a logout request to the mParticle server
753
759
  * @method logout
754
760
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
755
761
  * @param {Function} [callback] A callback function that is called when the logout request completes
756
- */logout:function logout(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Logout);if(n&&(i=n.getMPID()),a.valid){var o,d=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Logout,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Logout request sent to native sdk")):(t._IdentityAPIClient.sendIdentityRequest(d,Logout,s,e,r.parseIdentityResponse,i),o=t._ServerModel.createEventObject({messageType:Types.MessageType.Profile}),o.ProfileMessageType=Types.ProfileMessageType.Logout,t._Store.activeForwarders.length&&t._Store.activeForwarders.forEach(function(e){e.logOut&&e.logOut(o);})):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
762
+ */logout:function logout(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
763
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Logout);if(n&&(i=n.getMPID()),a.valid){var o,d=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Logout,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Logout request sent to native sdk")):(t._IdentityAPIClient.sendIdentityRequest(d,Logout,s,e,r.parseIdentityResponse,i),o=t._ServerModel.createEventObject({messageType:Types.MessageType.Profile}),o.ProfileMessageType=Types.ProfileMessageType.Logout,t._Store.activeForwarders.length&&t._Store.activeForwarders.forEach(function(e){e.logOut&&e.logOut(o);})):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
757
764
  * Initiate a login request to the mParticle server
758
765
  * @method login
759
766
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
760
767
  * @param {Function} [callback] A callback function that is called when the login request completes
761
- */login:function login(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Login);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Login);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Login,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Login request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Login,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
768
+ */login:function login(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
769
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Login);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Login);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Login,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Login request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Login,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
762
770
  * Initiate a modify request to the mParticle server
763
771
  * @method modify
764
772
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
765
773
  * @param {Function} [callback] A callback function that is called when the modify request completes
766
- */modify:function modify(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Modify$1);n&&(i=n.getMPID());var o=e&&e.userIdentities?e.userIdentities:{};if(a.valid){var d=t._Identity.IdentityRequest.createModifyIdentityRequest(n?n.getUserIdentities().userIdentities:{},o,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.context);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Modify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Modify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(d,Modify$1,s,e,r.parseIdentityResponse,i,d.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
774
+ */modify:function modify(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
775
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Modify$1);n&&(i=n.getMPID());var o=e&&e.userIdentities?e.userIdentities:{};if(a.valid){var d=t._Identity.IdentityRequest.createModifyIdentityRequest(n?n.getUserIdentities().userIdentities:{},o,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.context);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Modify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Modify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(d,Modify$1,s,e,r.parseIdentityResponse,i,d.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
767
776
  * Returns a user object with methods to interact with the current user
768
777
  * @method getCurrentUser
769
778
  * @return {Object} the current user object
@@ -831,10 +840,10 @@ return s<i&&(s=i,n<s&&t.Logger.warning("Source User has not been seen in the las
831
840
  * @method setUserAttributeList
832
841
  * @param {String} key
833
842
  * @param {Array} value an array of values
834
- */setUserAttributeList:function setUserAttributeList(r,n){var a,o,d,g,l;if(t._SessionManager.resetSessionTimer(),!t._Helpers.Validators.isValidKeyValue(r))return void t.Logger.error(Messages$2.ErrorMessages.BadKey);if(!Array.isArray(n))return void t.Logger.error("The value you passed in to setUserAttributeList must be an array. You passed in a "+("undefined"==typeof value?"undefined":_typeof(value)));var u=n.slice();if(t._Store.webviewBridgeEnabled)t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.SetUserAttributeList,JSON.stringify({key:r,value:u}));else {a=t._Persistence.getPersistence(),o=this.getAllUserAttributes();var c=t._Helpers.findKeyInObject(o,r);// If the new attributeList length is different previous, then there is a change event.
843
+ */setUserAttributeList:function setUserAttributeList(r,n){var a,o,d,g,l;if(t._SessionManager.resetSessionTimer(),!t._Helpers.Validators.isValidKeyValue(r))return void t.Logger.error(Messages$2.ErrorMessages.BadKey);if(!Array.isArray(n))return void t.Logger.error("The value you passed in to setUserAttributeList must be an array. You passed in a "+("undefined"==typeof value?"undefined":_typeof(value)));var u=n.slice();if(t._Store.webviewBridgeEnabled)t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.SetUserAttributeList,JSON.stringify({key:r,value:u}));else {a=t._Persistence.getPersistence(),o=this.getAllUserAttributes();var p=t._Helpers.findKeyInObject(o,r);// If the new attributeList length is different previous, then there is a change event.
835
844
  // Loop through new attributes list, see if they are all in the same index as previous user attributes list
836
845
  // If there are any changes, break, and immediately send a userAttributeChangeEvent with full array as a value
837
- if(c?(g=!1,d=o[c],delete o[c]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.savePersistence(a,e)),!d||!Array.isArray(d))l=!0;else if(n.length!==d.length)l=!0;else for(var p=0;p<n.length;p++)if(d[p]!==n[p]){l=!0;break}l&&s.sendUserAttributeChangeEvent(r,n,d,g,!1,this),t._Forwarders.initForwarders(s.IdentityAPI.getCurrentUser().getUserIdentities(),t._APIClient.prepareForwardingStats),t._Forwarders.handleForwarderUserAttributes("setUserAttribute",r,u);}},/**
846
+ if(p?(g=!1,d=o[p],delete o[p]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.savePersistence(a,e)),!d||!Array.isArray(d))l=!0;else if(n.length!==d.length)l=!0;else for(var c=0;c<n.length;c++)if(d[c]!==n[c]){l=!0;break}l&&s.sendUserAttributeChangeEvent(r,n,d,g,!1,this),t._Forwarders.initForwarders(s.IdentityAPI.getCurrentUser().getUserIdentities(),t._APIClient.prepareForwardingStats),t._Forwarders.handleForwarderUserAttributes("setUserAttribute",r,u);}},/**
838
847
  * Removes all user attributes
839
848
  * @method removeAllUserAttributes
840
849
  */removeAllUserAttributes:function removeAllUserAttributes(){var e;if(t._SessionManager.resetSessionTimer(),t._Store.webviewBridgeEnabled)t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.RemoveAllUserAttributes);else if(e=this.getAllUserAttributes(),t._Forwarders.initForwarders(s.IdentityAPI.getCurrentUser().getUserIdentities(),t._APIClient.prepareForwardingStats),e)for(var r in e)e.hasOwnProperty(r)&&t._Forwarders.handleForwarderUserAttributes("removeUserAttribute",r,null),this.removeUserAttribute(r);},/**
@@ -884,7 +893,9 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
884
893
  * @method getCartProducts
885
894
  * @return {Array} array of cart products
886
895
  * @deprecated
887
- */getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,c,p,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(c=JSON.parse(s.responseText),c.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=c.is_logged_in)),(!_||_.getMPID()&&c.mpid&&c.mpid!==_.getMPID())&&(t._Store.mpid=c.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(c.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(c.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(c.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&c.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(c.mpid),p=t._Store.currentSessionMPIDs.indexOf(c.mpid),t._Store.sessionId&&c.mpid&&i!==c.mpid&&0>p&&t._Store.currentSessionMPIDs.push(c.mpid),-1<p&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,p).concat(t._Store.currentSessionMPIDs.slice(p+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(c.mpid)),t._CookieSyncManager.attemptCookieSync(i,c.mpid,u),r.checkIdentitySwap(i,c.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(c.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=c.context||t._Store.context;}if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var k in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(k))]=I[k];r.sendUserIdentityChangeEvent(A,o,c.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,c||null,l):t._Helpers.invokeCallback(n,s.status,c||null,l):c&&c.errors&&c.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+c.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,c||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}},this.createUserIdentityChange=function(e,r,s,i,n){var a;// https://go.mparticle.com/work/SQDSDKS-6439
896
+ */getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,p,c,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(p=JSON.parse(s.responseText),p.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=p.is_logged_in)),(!_||_.getMPID()&&p.mpid&&p.mpid!==_.getMPID())&&(t._Store.mpid=p.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(p.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(p.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(p.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&p.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(p.mpid),c=t._Store.currentSessionMPIDs.indexOf(p.mpid),t._Store.sessionId&&p.mpid&&i!==p.mpid&&0>c&&t._Store.currentSessionMPIDs.push(p.mpid),-1<c&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,c).concat(t._Store.currentSessionMPIDs.slice(c+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(p.mpid)),t._CookieSyncManager.attemptCookieSync(i,p.mpid,u),t._Persistence.swapCurrentUser(i,p.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(p.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=p.context||t._Store.context;}// https://go.mparticle.com/work/SQDSDKS-6359
897
+ if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var U in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(U))]=I[U];r.sendUserIdentityChangeEvent(A,o,p.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,p||null,l):t._Helpers.invokeCallback(n,s.status,p||null,l):p&&p.errors&&p.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+p.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}// https://go.mparticle.com/work/SQDSDKS-6354
898
+ },this.createUserIdentityChange=function(e,r,s,i,n){var a;// https://go.mparticle.com/work/SQDSDKS-6439
888
899
  return a=t._ServerModel.createEventObject({messageType:Types.MessageType.UserIdentityChange,userIdentityChanges:{New:{IdentityType:e,Identity:r,CreatedThisBatch:i},Old:{IdentityType:e,Identity:s,CreatedThisBatch:!1}},userInMemory:n}),a},this.sendUserAttributeChangeEvent=function(e,s,i,n,a,o){var d=r.createUserAttributeChange(e,s,i,n,a,o);d&&t._APIClient.sendEventToServer(d);},this.createUserAttributeChange=function(e,r,s,i,n,a){"undefined"==typeof s&&(s=null);var o;return r!==s&&(o=t._ServerModel.createEventObject({messageType:Types.MessageType.UserAttributeChange,userAttributeChanges:{UserAttributeName:e,New:r,Old:s,Deleted:n,IsNewAttribute:i}},a)),o};}
889
900
 
890
901
  var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){var b=this;// this function is called when consent is required to
@@ -61,7 +61,7 @@ var _TriggerUploadType,MessageType$2={SessionStart:1,SessionEnd:2,PageView:3,Pag
61
61
  // Continuation of enum above, but in seperate object since we don't expose these to end user
62
62
  IdentityType$1.isValid=function(a){if("number"==typeof a)for(var b in IdentityType$1)if(IdentityType$1.hasOwnProperty(b)&&IdentityType$1[b]===a)return !0;return !1},IdentityType$1.getName=function(a){return a===window.mParticle.IdentityType.CustomerId?"Customer ID":a===window.mParticle.IdentityType.Facebook?"Facebook ID":a===window.mParticle.IdentityType.Twitter?"Twitter ID":a===window.mParticle.IdentityType.Google?"Google ID":a===window.mParticle.IdentityType.Microsoft?"Microsoft ID":a===window.mParticle.IdentityType.Yahoo?"Yahoo ID":a===window.mParticle.IdentityType.Email?"Email":a===window.mParticle.IdentityType.FacebookCustomAudienceId?"Facebook App User ID":"Other ID"},IdentityType$1.getIdentityType=function(a){return "other"===a?IdentityType$1.Other:"customerid"===a?IdentityType$1.CustomerId:"facebook"===a?IdentityType$1.Facebook:"twitter"===a?IdentityType$1.Twitter:"google"===a?IdentityType$1.Google:"microsoft"===a?IdentityType$1.Microsoft:"yahoo"===a?IdentityType$1.Yahoo:"email"===a?IdentityType$1.Email:"facebookcustomaudienceid"===a?IdentityType$1.FacebookCustomAudienceId:"other2"===a?IdentityType$1.Other2:"other3"===a?IdentityType$1.Other3:"other4"===a?IdentityType$1.Other4:"other5"===a?IdentityType$1.Other5:"other6"===a?IdentityType$1.Other6:"other7"===a?IdentityType$1.Other7:"other8"===a?IdentityType$1.Other8:"other9"===a?IdentityType$1.Other9:"other10"===a?IdentityType$1.Other10:"mobile_number"===a?IdentityType$1.MobileNumber:"phone_number_2"===a?IdentityType$1.PhoneNumber2:!("phone_number_3"!=a)&&IdentityType$1.PhoneNumber3},IdentityType$1.getIdentityName=function(a){return a===IdentityType$1.Other?"other":a===IdentityType$1.CustomerId?"customerid":a===IdentityType$1.Facebook?"facebook":a===IdentityType$1.Twitter?"twitter":a===IdentityType$1.Google?"google":a===IdentityType$1.Microsoft?"microsoft":a===IdentityType$1.Yahoo?"yahoo":a===IdentityType$1.Email?"email":a===IdentityType$1.FacebookCustomAudienceId?"facebookcustomaudienceid":a===IdentityType$1.Other2?"other2":a===IdentityType$1.Other3?"other3":a===IdentityType$1.Other4?"other4":a===IdentityType$1.Other5?"other5":a===IdentityType$1.Other6?"other6":a===IdentityType$1.Other7?"other7":a===IdentityType$1.Other8?"other8":a===IdentityType$1.Other9?"other9":a===IdentityType$1.Other10?"other10":a===IdentityType$1.MobileNumber?"mobile_number":a===IdentityType$1.PhoneNumber2?"phone_number_2":a===IdentityType$1.PhoneNumber3?"phone_number_3":void 0};var ProductActionType={Unknown:0,AddToCart:1,RemoveFromCart:2,Checkout:3,CheckoutOption:4,Click:5,ViewDetail:6,Purchase:7,Refund:8,AddToWishlist:9,RemoveFromWishlist:10};ProductActionType.getName=function(a){return a===ProductActionType.AddToCart?"Add to Cart":a===ProductActionType.RemoveFromCart?"Remove from Cart":a===ProductActionType.Checkout?"Checkout":a===ProductActionType.CheckoutOption?"Checkout Option":a===ProductActionType.Click?"Click":a===ProductActionType.ViewDetail?"View Detail":a===ProductActionType.Purchase?"Purchase":a===ProductActionType.Refund?"Refund":a===ProductActionType.AddToWishlist?"Add to Wishlist":a===ProductActionType.RemoveFromWishlist?"Remove from Wishlist":"Unknown"},ProductActionType.getExpansionName=function(a){return a===ProductActionType.AddToCart?"add_to_cart":a===ProductActionType.RemoveFromCart?"remove_from_cart":a===ProductActionType.Checkout?"checkout":a===ProductActionType.CheckoutOption?"checkout_option":a===ProductActionType.Click?"click":a===ProductActionType.ViewDetail?"view_detail":a===ProductActionType.Purchase?"purchase":a===ProductActionType.Refund?"refund":a===ProductActionType.AddToWishlist?"add_to_wishlist":a===ProductActionType.RemoveFromWishlist?"remove_from_wishlist":"unknown"};var PromotionActionType={Unknown:0,PromotionView:1,PromotionClick:2};PromotionActionType.getName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"},PromotionActionType.getExpansionName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"};var ProfileMessageType={Logout:3},ApplicationTransitionType$1={AppInit:1},Environment={Production:"production",Development:"development"};var Types = {MessageType:MessageType$2,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType$1,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,TriggerUploadType:TriggerUploadType,Environment:Environment};
63
63
 
64
- var version = "2.26.4";
64
+ var version = "2.26.6";
65
65
 
66
66
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"is a deprecated method and will be removed in future releases",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
67
67
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
@@ -622,8 +622,10 @@ for(var n,o=0;o<h.length&&(g=d(b,c,e),g.length>f);o++)n=h[o],b[n]?(a.Logger.verb
622
622
  // other keys on the cookie are currentSessionMPIDs and currentMPID which should not be searched
623
623
  if(d[g].mpid){var h=d[g].ui;for(var i in h)if(e===i&&b.userIdentities[e]===h[i]){c=g;break}}c&&f.storeDataInMemory(d,c);},this.encodePersistence=function(b){for(var c in b=JSON.parse(b),b.gs)b.gs.hasOwnProperty(c)&&(Base64CookieKeys[c]?b.gs[c]?Array.isArray(b.gs[c])&&b.gs[c].length||a._Helpers.isObject(b.gs[c])&&Object.keys(b.gs[c]).length?b.gs[c]=Base64.encode(JSON.stringify(b.gs[c])):delete b.gs[c]:delete b.gs[c]:"ie"===c?b.gs[c]=b.gs[c]?1:0:!b.gs[c]&&delete b.gs[c]);for(var d in b)if(b.hasOwnProperty(d)&&!SDKv2NonMPIDCookieKeys[d])for(c in b[d])b[d].hasOwnProperty(c)&&Base64CookieKeys[c]&&(a._Helpers.isObject(b[d][c])&&Object.keys(b[d][c]).length?b[d][c]=Base64.encode(JSON.stringify(b[d][c])):delete b[d][c]);return createCookieString(JSON.stringify(b))},this.decodePersistence=function(b){try{if(b){if(b=JSON.parse(revertCookieString(b)),a._Helpers.isObject(b)&&Object.keys(b).length){for(var c in b.gs)b.gs.hasOwnProperty(c)&&(Base64CookieKeys[c]?b.gs[c]=JSON.parse(Base64.decode(b.gs[c])):"ie"===c&&(b.gs[c]=!!b.gs[c]));for(var d in b)if(b.hasOwnProperty(d))if(!SDKv2NonMPIDCookieKeys[d])for(c in b[d])b[d].hasOwnProperty(c)&&Base64CookieKeys[c]&&b[d][c].length&&(b[d][c]=JSON.parse(Base64.decode(b[d][c])));else "l"===d&&(b[d]=!!b[d]);}return JSON.stringify(b)}}catch(b){a.Logger.error("Problem with decoding cookie",b);}},this.getCookieDomain=function(){if(a._Store.SDKConfig.cookieDomain)return a._Store.SDKConfig.cookieDomain;var b=f.getDomain(document,location.hostname);return ""===b?"":"."+b},this.getDomain=function(a,b){var c,d,e=b.split(".");for(c=e.length-1;0<=c;c--)if(d=e.slice(c).join("."),a.cookie="mptest=cookie;domain=."+d+";",-1<a.cookie.indexOf("mptest=cookie"))return a.cookie="mptest=;domain=."+d+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",d;return ""},this.getUserIdentities=function(a){var b=f.getPersistence();return b&&b[a]&&b[a].ui?b[a].ui:{}},this.getAllUserAttributes=function(a){var b=f.getPersistence();return b&&b[a]&&b[a].ua?b[a].ua:{}},this.getCartProducts=function(b){var c,d=localStorage.getItem(a._Store.prodStorageName);return d&&(c=JSON.parse(Base64.decode(d)),c&&c[b]&&c[b].cp)?c[b].cp:[]},this.setCartProducts=function(b){if(a._Store.isLocalStorageAvailable)try{window.localStorage.setItem(encodeURIComponent(a._Store.prodStorageName),Base64.encode(JSON.stringify(b)));}catch(b){a.Logger.error("Error with setting products on localStorage.");}},this.saveUserIdentitiesToPersistence=function(a,b){if(b){var c=f.getPersistence();c&&(c[a]?c[a].ui=b:c[a]={ui:b},f.savePersistence(c));}},this.saveUserAttributesToPersistence=function(a,b){var c=f.getPersistence();b&&(c&&(c[a]?c[a].ui=b:c[a]={ui:b}),f.savePersistence(c));},this.saveUserCookieSyncDatesToPersistence=function(a,b){if(b){var c=f.getPersistence();c&&(c[a]?c[a].csd=b:c[a]={csd:b}),f.savePersistence(c);}},this.saveUserConsentStateToCookies=function(b,c){//it's currently not supported to set persistence
624
624
  //for any MPID that's not the current one.
625
- if(c||null===c){var d=f.getPersistence();d&&(d[b]?d[b].con=a._Consent.ConsentSerialization.toMinifiedJsonObject(c):d[b]={con:a._Consent.ConsentSerialization.toMinifiedJsonObject(c)},f.savePersistence(d));}},this.savePersistence=function(b){var c,d=f.encodePersistence(JSON.stringify(b)),e=new Date,g=a._Store.storageName,h=new Date(e.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toGMTString(),i=f.getCookieDomain();if(c=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=f.reduceAndEncodePersistence(b,h,c,a._Store.SDKConfig.maxCookieSize);window.document.cookie=encodeURIComponent(g)+"="+j;}else a._Store.isLocalStorageAvailable&&localStorage.setItem(a._Store.storageName,d);},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getConsentState=function(b){var c=f.getPersistence();return c&&c[b]&&c[b].con?a._Consent.ConsentSerialization.fromMinifiedJsonObject(c[b].con):null},this.getFirstSeenTime=function(a){if(!a)return null;var b=f.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&(!c[a]&&(c[a]={}),!c[a].fst&&(c[a].fst=b,f.savePersistence(c)));}},this.getLastSeenTime=function(b){if(!b)return null;if(b===a.Identity.getCurrentUser().getMPID())//if the mpid is the current user, its last seen time is the current time
626
- return new Date().getTime();var c=f.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&c[a]&&(c[a].lst=b,f.savePersistence(c));}},this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,f.update();},this.resetPersistence=function(){if(c(StorageNames.localStorageName),c(StorageNames.localStorageNameV3),c(StorageNames.localStorageNameV4),c(a._Store.prodStorageName),c(a._Store.storageName),c(StorageNames.localStorageProductsV4),f.expireCookies(StorageNames.cookieName),f.expireCookies(StorageNames.cookieNameV2),f.expireCookies(StorageNames.cookieNameV3),f.expireCookies(StorageNames.cookieNameV4),f.expireCookies(a._Store.prodStorageName),f.expireCookies(a._Store.storageName),mParticle._isTestEnv){c(a._Helpers.createMainStorageName("abcdef")),f.expireCookies(a._Helpers.createMainStorageName("abcdef")),c(a._Helpers.createProductStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
625
+ if(c||null===c){var d=f.getPersistence();d&&(d[b]?d[b].con=a._Consent.ConsentSerialization.toMinifiedJsonObject(c):d[b]={con:a._Consent.ConsentSerialization.toMinifiedJsonObject(c)},f.savePersistence(d));}},this.swapCurrentUser=function(a,b,c){if(a&&b&&a!==b){var d=f.getPersistence();d&&(d.cu=b,d.gs.csm=c,f.savePersistence(d));}},this.savePersistence=function(b){var c,d=f.encodePersistence(JSON.stringify(b)),e=new Date,g=a._Store.storageName,h=new Date(e.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toGMTString(),i=f.getCookieDomain();if(c=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=f.reduceAndEncodePersistence(b,h,c,a._Store.SDKConfig.maxCookieSize);window.document.cookie=encodeURIComponent(g)+"="+j;}else a._Store.isLocalStorageAvailable&&localStorage.setItem(a._Store.storageName,d);},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getConsentState=function(b){var c=f.getPersistence();return c&&c[b]&&c[b].con?a._Consent.ConsentSerialization.fromMinifiedJsonObject(c[b].con):null},this.getFirstSeenTime=function(a){if(!a)return null;var b=f.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&(!c[a]&&(c[a]={}),!c[a].fst&&(c[a].fst=b,f.savePersistence(c)));}// https://go.mparticle.com/work/SQDSDKS-6329
626
+ },this.getLastSeenTime=function(b){if(!b)return null;if(b===a.Identity.getCurrentUser().getMPID())//if the mpid is the current user, its last seen time is the current time
627
+ return new Date().getTime();var c=f.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(a,b){if(a){b||(b=new Date().getTime());var c=f.getPersistence();c&&c[a]&&(c[a].lst=b,f.savePersistence(c));}// https://go.mparticle.com/work/SQDSDKS-6329
628
+ },this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,f.update();},this.resetPersistence=function(){if(c(StorageNames.localStorageName),c(StorageNames.localStorageNameV3),c(StorageNames.localStorageNameV4),c(a._Store.prodStorageName),c(a._Store.storageName),c(StorageNames.localStorageProductsV4),f.expireCookies(StorageNames.cookieName),f.expireCookies(StorageNames.cookieNameV2),f.expireCookies(StorageNames.cookieNameV3),f.expireCookies(StorageNames.cookieNameV4),f.expireCookies(a._Store.prodStorageName),f.expireCookies(a._Store.storageName),mParticle._isTestEnv){c(a._Helpers.createMainStorageName("abcdef")),f.expireCookies(a._Helpers.createMainStorageName("abcdef")),c(a._Helpers.createProductStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
627
629
 
628
630
  var Messages$3=Constants.Messages;function Events(a){var b=this;this.logEvent=function(b,c){if(a.Logger.verbose(Messages$3.InformationMessages.StartingLogEvent+": "+b.name),a._Helpers.canLog()){var d=a._ServerModel.createEventObject(b);a._APIClient.sendEventToServer(d,c);}else a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);},this.startTracking=function(b){function c(b,c){if(b)try{c?b(c):b();}catch(b){a.Logger.error("Error invoking the callback passed to startTrackingLocation."),a.Logger.error(b);}}if(!a._Store.isTracking)"geolocation"in navigator&&(a._Store.watchPositionId=navigator.geolocation.watchPosition(function e(d){// prevents callback from being fired multiple times
629
631
  a._Store.currentPosition={lat:d.coords.latitude,lng:d.coords.longitude},c(b,d),b=null,a._Store.isTracking=!0;},function d(){// prevents callback from being fired multiple times
@@ -725,11 +727,13 @@ if(h){var i=getCachedIdentity(g,a,b);return c(i,d,e,f,g,a,!0),!0}return !1};
725
727
  var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
726
728
  throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
727
729
 
728
- var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1=Constants.FeatureFlags,ErrorMessages=Messages$2.ErrorMessages,_Constants$IdentityMe=Constants.IdentityMethods,Identify=_Constants$IdentityMe.Identify,Modify$1=_Constants$IdentityMe.Modify,Login=_Constants$IdentityMe.Login,Logout=_Constants$IdentityMe.Logout;function Identity(t){var r=this;/**
730
+ var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1=Constants.FeatureFlags,ErrorMessages=Messages$2.ErrorMessages,_Constants$IdentityMe=Constants.IdentityMethods,Identify=_Constants$IdentityMe.Identify,Modify$1=_Constants$IdentityMe.Modify,Login=_Constants$IdentityMe.Login,Logout=_Constants$IdentityMe.Logout;function Identity(t){var r=this;// https://go.mparticle.com/work/SQDSDKS-6353
731
+ /**
729
732
  * Invoke these methods on the mParticle.Identity object.
730
733
  * Example: mParticle.Identity.getCurrentUser().
731
734
  * @class mParticle.Identity
732
- */ /**
735
+ */ // https://go.mparticle.com/work/SQDSDKS-6354
736
+ /**
733
737
  * Invoke these methods on the mParticle.Identity.getCurrentUser() object.
734
738
  * Example: mParticle.Identity.getCurrentUser().getAllUserAttributes()
735
739
  * @class mParticle.Identity.getCurrentUser()
@@ -738,32 +742,37 @@ var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1
738
742
  * Example: mParticle.Identity.getCurrentUser().getCart().add(...);
739
743
  * @class mParticle.Identity.getCurrentUser().getCart()
740
744
  * @deprecated
741
- */ // send a user identity change request on identify, login, logout, modify when any values change.
745
+ */ // https://go.mparticle.com/work/SQDSDKS-6355
746
+ // send a user identity change request on identify, login, logout, modify when any values change.
742
747
  // compare what identities exist vs what is previously was for the specific user if they were in memory before.
743
748
  // if it's the first time the user is logging in, send a user identity change request with
744
- this.idCache=null,this.audienceManager=null,this.checkIdentitySwap=function(e,r,s){if(e&&r&&e!==r){var i=t._Persistence.getPersistence();i&&(i.cu=r,i.gs.csm=s,t._Persistence.savePersistence(i));}},this.IdentityRequest={preProcessIdentityRequest:function preProcessIdentityRequest(e,r,s){t.Logger.verbose(Messages$2.InformationMessages.StartingLogEvent+": "+s);var i=t._Helpers.Validators.validateIdentities(e,s);if(!i.valid)return t.Logger.error("ERROR: "+i.error),{valid:!1,error:i.error};if(r&&!t._Helpers.Validators.isFunction(r)){var n="The optional callback must be a function. You tried entering a(n) "+_typeof(r);return t.Logger.error(n),{valid:!1,error:n}}return {valid:!0}},createIdentityRequest:function createIdentityRequest(e,r,s,i,n,a,o){var d={client_sdk:{platform:r,sdk_vendor:s,sdk_version:i},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),previous_mpid:o||null,known_identities:createKnownIdentities(e,n)};return d},createModifyIdentityRequest:function createModifyIdentityRequest(e,r,s,i,n,a){return {client_sdk:{platform:s,sdk_vendor:i,sdk_version:n},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),identity_changes:this.createIdentityChanges(e,r)}},createIdentityChanges:function createIdentityChanges(e,r){var s,i=[];if(r&&t._Helpers.isObject(r)&&e&&t._Helpers.isObject(e))for(s in r)i.push({old_value:e[s]||null,new_value:r[s],identity_type:s});return i},// takes 2 UI objects keyed by name, combines them, returns them keyed by type
749
+ this.idCache=null,this.audienceManager=null,this.IdentityRequest={preProcessIdentityRequest:function preProcessIdentityRequest(e,r,s){t.Logger.verbose(Messages$2.InformationMessages.StartingLogEvent+": "+s);var i=t._Helpers.Validators.validateIdentities(e,s);if(!i.valid)return t.Logger.error("ERROR: "+i.error),{valid:!1,error:i.error};if(r&&!t._Helpers.Validators.isFunction(r)){var n="The optional callback must be a function. You tried entering a(n) "+_typeof(r);return t.Logger.error(n),{valid:!1,error:n}}return {valid:!0}},createIdentityRequest:function createIdentityRequest(e,r,s,i,n,a,o){var d={client_sdk:{platform:r,sdk_vendor:s,sdk_version:i},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),previous_mpid:o||null,known_identities:createKnownIdentities(e,n)};return d},createModifyIdentityRequest:function createModifyIdentityRequest(e,r,s,i,n,a){return {client_sdk:{platform:s,sdk_vendor:i,sdk_version:n},context:a,environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",request_id:t._Helpers.generateUniqueId(),request_timestamp_ms:new Date().getTime(),identity_changes:this.createIdentityChanges(e,r)}},createIdentityChanges:function createIdentityChanges(e,r){var s,i=[];if(r&&t._Helpers.isObject(r)&&e&&t._Helpers.isObject(e))for(s in r)i.push({old_value:e[s]||null,new_value:r[s],identity_type:s});return i},// takes 2 UI objects keyed by name, combines them, returns them keyed by type
745
750
  combineUserIdentities:function combineUserIdentities(e,r){var s={},i=t._Helpers.extend(e,r);for(var n in i){var a=Types.IdentityType.getIdentityType(n);// this check removes anything that is not whitelisted as an identity type
746
751
  !1!==a&&0<=a&&(s[Types.IdentityType.getIdentityType(n)]=i[n]);}return s},createAliasNetworkRequest:function createAliasNetworkRequest(e){return {request_id:t._Helpers.generateUniqueId(),request_type:"alias",environment:t._Store.SDKConfig.isDevelopmentMode?"development":"production",api_key:t._Store.devToken,data:{destination_mpid:e.destinationMpid,source_mpid:e.sourceMpid,start_unixtime_ms:e.startTime,end_unixtime_ms:e.endTime,scope:e.scope,device_application_stamp:t._Store.deviceId}}},convertAliasToNative:function convertAliasToNative(e){return {DestinationMpid:e.destinationMpid,SourceMpid:e.sourceMpid,StartUnixtimeMs:e.startTime,EndUnixtimeMs:e.endTime}},convertToNative:function convertToNative(e){var t=[];if(e&&e.userIdentities){for(var r in e.userIdentities)e.userIdentities.hasOwnProperty(r)&&t.push({Type:Types.IdentityType.getIdentityType(r),Identity:e.userIdentities[r]});return {UserIdentities:t}}}},this.IdentityAPI={HTTPCodes:HTTPCodes$2,/**
747
752
  * Initiate a logout request to the mParticle server
748
753
  * @method identify
749
754
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
750
755
  * @param {Function} [callback] A callback function that is called when the identify request completes
751
- */identify:function identify(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Identify);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Identify);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Identify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Identify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Identify,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
756
+ */identify:function identify(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
757
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Identify);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Identify);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Identify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Identify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Identify,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
752
758
  * Initiate a logout request to the mParticle server
753
759
  * @method logout
754
760
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
755
761
  * @param {Function} [callback] A callback function that is called when the logout request completes
756
- */logout:function logout(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Logout);if(n&&(i=n.getMPID()),a.valid){var o,d=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Logout,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Logout request sent to native sdk")):(t._IdentityAPIClient.sendIdentityRequest(d,Logout,s,e,r.parseIdentityResponse,i),o=t._ServerModel.createEventObject({messageType:Types.MessageType.Profile}),o.ProfileMessageType=Types.ProfileMessageType.Logout,t._Store.activeForwarders.length&&t._Store.activeForwarders.forEach(function(e){e.logOut&&e.logOut(o);})):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
762
+ */logout:function logout(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
763
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Logout);if(n&&(i=n.getMPID()),a.valid){var o,d=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Logout,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Logout request sent to native sdk")):(t._IdentityAPIClient.sendIdentityRequest(d,Logout,s,e,r.parseIdentityResponse,i),o=t._ServerModel.createEventObject({messageType:Types.MessageType.Profile}),o.ProfileMessageType=Types.ProfileMessageType.Logout,t._Store.activeForwarders.length&&t._Store.activeForwarders.forEach(function(e){e.logOut&&e.logOut(o);})):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
757
764
  * Initiate a login request to the mParticle server
758
765
  * @method login
759
766
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
760
767
  * @param {Function} [callback] A callback function that is called when the login request completes
761
- */login:function login(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Login);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Login);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Login,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Login request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Login,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
768
+ */login:function login(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
769
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Login);if(n&&(i=n.getMPID()),a.valid){var o=t._Identity.IdentityRequest.createIdentityRequest(e,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.deviceId,t._Store.context,i);if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)){var d=tryCacheIdentity(o.known_identities,r.idCache,r.parseIdentityResponse,i,s,e,Login);if(d)return}t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Login,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Login request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(o,Login,s,e,r.parseIdentityResponse,i,o.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
762
770
  * Initiate a modify request to the mParticle server
763
771
  * @method modify
764
772
  * @param {Object} identityApiData The identityApiData object as indicated [here](https://github.com/mParticle/mparticle-sdk-javascript/blob/master-v2/README.md#1-customize-the-sdk)
765
773
  * @param {Function} [callback] A callback function that is called when the modify request completes
766
- */modify:function modify(e,s){var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Modify$1);n&&(i=n.getMPID());var o=e&&e.userIdentities?e.userIdentities:{};if(a.valid){var d=t._Identity.IdentityRequest.createModifyIdentityRequest(n?n.getUserIdentities().userIdentities:{},o,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.context);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Modify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Modify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(d,Modify$1,s,e,r.parseIdentityResponse,i,d.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
774
+ */modify:function modify(e,s){// https://go.mparticle.com/work/SQDSDKS-6337
775
+ var i,n=t.Identity.getCurrentUser(),a=t._Identity.IdentityRequest.preProcessIdentityRequest(e,s,Modify$1);n&&(i=n.getMPID());var o=e&&e.userIdentities?e.userIdentities:{};if(a.valid){var d=t._Identity.IdentityRequest.createModifyIdentityRequest(n?n.getUserIdentities().userIdentities:{},o,Constants.platform,Constants.sdkVendor,Constants.sdkVersion,t._Store.context);t._Helpers.canLog()?t._Store.webviewBridgeEnabled?(t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Modify,JSON.stringify(t._Identity.IdentityRequest.convertToNative(e))),t._Helpers.invokeCallback(s,HTTPCodes$2.nativeIdentityRequest,"Modify request sent to native sdk")):t._IdentityAPIClient.sendIdentityRequest(d,Modify$1,s,e,r.parseIdentityResponse,i,d.known_identities):(t._Helpers.invokeCallback(s,HTTPCodes$2.loggingDisabledOrMissingAPIKey,Messages$2.InformationMessages.AbandonLogEvent),t.Logger.verbose(Messages$2.InformationMessages.AbandonLogEvent));}else t._Helpers.invokeCallback(s,HTTPCodes$2.validationIssue,a.error),t.Logger.verbose(a);},/**
767
776
  * Returns a user object with methods to interact with the current user
768
777
  * @method getCurrentUser
769
778
  * @return {Object} the current user object
@@ -831,10 +840,10 @@ return s<i&&(s=i,n<s&&t.Logger.warning("Source User has not been seen in the las
831
840
  * @method setUserAttributeList
832
841
  * @param {String} key
833
842
  * @param {Array} value an array of values
834
- */setUserAttributeList:function setUserAttributeList(r,n){var a,o,d,g,l;if(t._SessionManager.resetSessionTimer(),!t._Helpers.Validators.isValidKeyValue(r))return void t.Logger.error(Messages$2.ErrorMessages.BadKey);if(!Array.isArray(n))return void t.Logger.error("The value you passed in to setUserAttributeList must be an array. You passed in a "+("undefined"==typeof value?"undefined":_typeof(value)));var u=n.slice();if(t._Store.webviewBridgeEnabled)t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.SetUserAttributeList,JSON.stringify({key:r,value:u}));else {a=t._Persistence.getPersistence(),o=this.getAllUserAttributes();var c=t._Helpers.findKeyInObject(o,r);// If the new attributeList length is different previous, then there is a change event.
843
+ */setUserAttributeList:function setUserAttributeList(r,n){var a,o,d,g,l;if(t._SessionManager.resetSessionTimer(),!t._Helpers.Validators.isValidKeyValue(r))return void t.Logger.error(Messages$2.ErrorMessages.BadKey);if(!Array.isArray(n))return void t.Logger.error("The value you passed in to setUserAttributeList must be an array. You passed in a "+("undefined"==typeof value?"undefined":_typeof(value)));var u=n.slice();if(t._Store.webviewBridgeEnabled)t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.SetUserAttributeList,JSON.stringify({key:r,value:u}));else {a=t._Persistence.getPersistence(),o=this.getAllUserAttributes();var p=t._Helpers.findKeyInObject(o,r);// If the new attributeList length is different previous, then there is a change event.
835
844
  // Loop through new attributes list, see if they are all in the same index as previous user attributes list
836
845
  // If there are any changes, break, and immediately send a userAttributeChangeEvent with full array as a value
837
- if(c?(g=!1,d=o[c],delete o[c]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.savePersistence(a,e)),!d||!Array.isArray(d))l=!0;else if(n.length!==d.length)l=!0;else for(var p=0;p<n.length;p++)if(d[p]!==n[p]){l=!0;break}l&&s.sendUserAttributeChangeEvent(r,n,d,g,!1,this),t._Forwarders.initForwarders(s.IdentityAPI.getCurrentUser().getUserIdentities(),t._APIClient.prepareForwardingStats),t._Forwarders.handleForwarderUserAttributes("setUserAttribute",r,u);}},/**
846
+ if(p?(g=!1,d=o[p],delete o[p]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.savePersistence(a,e)),!d||!Array.isArray(d))l=!0;else if(n.length!==d.length)l=!0;else for(var c=0;c<n.length;c++)if(d[c]!==n[c]){l=!0;break}l&&s.sendUserAttributeChangeEvent(r,n,d,g,!1,this),t._Forwarders.initForwarders(s.IdentityAPI.getCurrentUser().getUserIdentities(),t._APIClient.prepareForwardingStats),t._Forwarders.handleForwarderUserAttributes("setUserAttribute",r,u);}},/**
838
847
  * Removes all user attributes
839
848
  * @method removeAllUserAttributes
840
849
  */removeAllUserAttributes:function removeAllUserAttributes(){var e;if(t._SessionManager.resetSessionTimer(),t._Store.webviewBridgeEnabled)t._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.RemoveAllUserAttributes);else if(e=this.getAllUserAttributes(),t._Forwarders.initForwarders(s.IdentityAPI.getCurrentUser().getUserIdentities(),t._APIClient.prepareForwardingStats),e)for(var r in e)e.hasOwnProperty(r)&&t._Forwarders.handleForwarderUserAttributes("removeUserAttribute",r,null),this.removeUserAttribute(r);},/**
@@ -884,7 +893,9 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
884
893
  * @method getCartProducts
885
894
  * @return {Array} array of cart products
886
895
  * @deprecated
887
- */getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,c,p,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(c=JSON.parse(s.responseText),c.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=c.is_logged_in)),(!_||_.getMPID()&&c.mpid&&c.mpid!==_.getMPID())&&(t._Store.mpid=c.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(c.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(c.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(c.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&c.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(c.mpid),p=t._Store.currentSessionMPIDs.indexOf(c.mpid),t._Store.sessionId&&c.mpid&&i!==c.mpid&&0>p&&t._Store.currentSessionMPIDs.push(c.mpid),-1<p&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,p).concat(t._Store.currentSessionMPIDs.slice(p+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(c.mpid)),t._CookieSyncManager.attemptCookieSync(i,c.mpid,u),r.checkIdentitySwap(i,c.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(c.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=c.context||t._Store.context;}if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var k in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(k))]=I[k];r.sendUserIdentityChangeEvent(A,o,c.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,c||null,l):t._Helpers.invokeCallback(n,s.status,c||null,l):c&&c.errors&&c.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+c.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,c||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}},this.createUserIdentityChange=function(e,r,s,i,n){var a;// https://go.mparticle.com/work/SQDSDKS-6439
896
+ */getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,p,c,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(p=JSON.parse(s.responseText),p.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=p.is_logged_in)),(!_||_.getMPID()&&p.mpid&&p.mpid!==_.getMPID())&&(t._Store.mpid=p.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(p.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(p.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(p.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&p.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(p.mpid),c=t._Store.currentSessionMPIDs.indexOf(p.mpid),t._Store.sessionId&&p.mpid&&i!==p.mpid&&0>c&&t._Store.currentSessionMPIDs.push(p.mpid),-1<c&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,c).concat(t._Store.currentSessionMPIDs.slice(c+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(p.mpid)),t._CookieSyncManager.attemptCookieSync(i,p.mpid,u),t._Persistence.swapCurrentUser(i,p.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(p.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=p.context||t._Store.context;}// https://go.mparticle.com/work/SQDSDKS-6359
897
+ if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var U in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(U))]=I[U];r.sendUserIdentityChangeEvent(A,o,p.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,p||null,l):t._Helpers.invokeCallback(n,s.status,p||null,l):p&&p.errors&&p.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+p.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}// https://go.mparticle.com/work/SQDSDKS-6354
898
+ },this.createUserIdentityChange=function(e,r,s,i,n){var a;// https://go.mparticle.com/work/SQDSDKS-6439
888
899
  return a=t._ServerModel.createEventObject({messageType:Types.MessageType.UserIdentityChange,userIdentityChanges:{New:{IdentityType:e,Identity:r,CreatedThisBatch:i},Old:{IdentityType:e,Identity:s,CreatedThisBatch:!1}},userInMemory:n}),a},this.sendUserAttributeChangeEvent=function(e,s,i,n,a,o){var d=r.createUserAttributeChange(e,s,i,n,a,o);d&&t._APIClient.sendEventToServer(d);},this.createUserAttributeChange=function(e,r,s,i,n,a){"undefined"==typeof s&&(s=null);var o;return r!==s&&(o=t._ServerModel.createEventObject({messageType:Types.MessageType.UserAttributeChange,userAttributeChanges:{UserAttributeName:e,New:r,Old:s,Deleted:n,IsNewAttribute:i}},a)),o};}
889
900
 
890
901
  var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){var b=this;// this function is called when consent is required to
package/dist/mparticle.js CHANGED
@@ -608,7 +608,7 @@ var mParticle = (function () {
608
608
  Environment: Environment
609
609
  };
610
610
 
611
- var version = "2.26.4";
611
+ var version = "2.26.6";
612
612
 
613
613
  var Constants = {
614
614
  sdkVersion: version,
@@ -4950,6 +4950,16 @@ var mParticle = (function () {
4950
4950
  }
4951
4951
  }
4952
4952
  };
4953
+ this.swapCurrentUser = function (previousMPID, currentMPID, currentSessionMPIDs) {
4954
+ if (previousMPID && currentMPID && previousMPID !== currentMPID) {
4955
+ var persistence = self.getPersistence();
4956
+ if (persistence) {
4957
+ persistence.cu = currentMPID;
4958
+ persistence.gs.csm = currentSessionMPIDs;
4959
+ self.savePersistence(persistence);
4960
+ }
4961
+ }
4962
+ };
4953
4963
 
4954
4964
  // https://go.mparticle.com/work/SQDSDKS-6021
4955
4965
  this.savePersistence = function (persistence) {
@@ -5005,6 +5015,7 @@ var mParticle = (function () {
5005
5015
  if (!mpid) {
5006
5016
  return;
5007
5017
  }
5018
+ // https://go.mparticle.com/work/SQDSDKS-6329
5008
5019
  if (!time) {
5009
5020
  time = new Date().getTime();
5010
5021
  }
@@ -5044,6 +5055,7 @@ var mParticle = (function () {
5044
5055
  if (!mpid) {
5045
5056
  return;
5046
5057
  }
5058
+ // https://go.mparticle.com/work/SQDSDKS-6329
5047
5059
  if (!time) {
5048
5060
  time = new Date().getTime();
5049
5061
  }
@@ -6463,16 +6475,8 @@ var mParticle = (function () {
6463
6475
  var self = this;
6464
6476
  this.idCache = null;
6465
6477
  this.audienceManager = null;
6466
- this.checkIdentitySwap = function (previousMPID, currentMPID, currentSessionMPIDs) {
6467
- if (previousMPID && currentMPID && previousMPID !== currentMPID) {
6468
- var persistence = mpInstance._Persistence.getPersistence();
6469
- if (persistence) {
6470
- persistence.cu = currentMPID;
6471
- persistence.gs.csm = currentSessionMPIDs;
6472
- mpInstance._Persistence.savePersistence(persistence);
6473
- }
6474
- }
6475
- };
6478
+
6479
+ // https://go.mparticle.com/work/SQDSDKS-6353
6476
6480
  this.IdentityRequest = {
6477
6481
  preProcessIdentityRequest: function preProcessIdentityRequest(identityApiData, callback, method) {
6478
6482
  mpInstance.Logger.verbose(Messages$2.InformationMessages.StartingLogEvent + ': ' + method);
@@ -6608,6 +6612,7 @@ var mParticle = (function () {
6608
6612
  * @param {Function} [callback] A callback function that is called when the identify request completes
6609
6613
  */
6610
6614
  identify: function identify(identityApiData, callback) {
6615
+ // https://go.mparticle.com/work/SQDSDKS-6337
6611
6616
  var mpid,
6612
6617
  currentUser = mpInstance.Identity.getCurrentUser(),
6613
6618
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Identify);
@@ -6645,6 +6650,7 @@ var mParticle = (function () {
6645
6650
  * @param {Function} [callback] A callback function that is called when the logout request completes
6646
6651
  */
6647
6652
  logout: function logout(identityApiData, callback) {
6653
+ // https://go.mparticle.com/work/SQDSDKS-6337
6648
6654
  var mpid,
6649
6655
  currentUser = mpInstance.Identity.getCurrentUser(),
6650
6656
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Logout);
@@ -6688,6 +6694,7 @@ var mParticle = (function () {
6688
6694
  * @param {Function} [callback] A callback function that is called when the login request completes
6689
6695
  */
6690
6696
  login: function login(identityApiData, callback) {
6697
+ // https://go.mparticle.com/work/SQDSDKS-6337
6691
6698
  var mpid,
6692
6699
  currentUser = mpInstance.Identity.getCurrentUser(),
6693
6700
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Login);
@@ -6725,6 +6732,7 @@ var mParticle = (function () {
6725
6732
  * @param {Function} [callback] A callback function that is called when the modify request completes
6726
6733
  */
6727
6734
  modify: function modify(identityApiData, callback) {
6735
+ // https://go.mparticle.com/work/SQDSDKS-6337
6728
6736
  var mpid,
6729
6737
  currentUser = mpInstance.Identity.getCurrentUser(),
6730
6738
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Modify$1);
@@ -6906,6 +6914,7 @@ var mParticle = (function () {
6906
6914
  }
6907
6915
  };
6908
6916
 
6917
+ // https://go.mparticle.com/work/SQDSDKS-6354
6909
6918
  /**
6910
6919
  * Invoke these methods on the mParticle.Identity.getCurrentUser() object.
6911
6920
  * Example: mParticle.Identity.getCurrentUser().getAllUserAttributes()
@@ -7356,6 +7365,8 @@ var mParticle = (function () {
7356
7365
  }
7357
7366
  };
7358
7367
  };
7368
+
7369
+ // https://go.mparticle.com/work/SQDSDKS-6355
7359
7370
  this.parseIdentityResponse = function (xhr, previousMPID, callback, identityApiData, method, knownIdentities, parsingCachedResponse) {
7360
7371
  var prevUser = mpInstance.Identity.getUser(previousMPID),
7361
7372
  newUser,
@@ -7379,6 +7390,7 @@ var mParticle = (function () {
7379
7390
  if (!prevUser || prevUser.getMPID() && identityApiResult.mpid && identityApiResult.mpid !== prevUser.getMPID()) {
7380
7391
  mpInstance._Store.mpid = identityApiResult.mpid;
7381
7392
  if (prevUser) {
7393
+ // https://go.mparticle.com/work/SQDSDKS-6329
7382
7394
  mpInstance._Persistence.setLastSeenTime(previousMPID);
7383
7395
  }
7384
7396
  if (!mpInstance._Persistence.getFirstSeenTime(identityApiResult.mpid)) mpidIsNotInCookies = true;
@@ -7397,10 +7409,12 @@ var mParticle = (function () {
7397
7409
  var incomingMpidUIByNameCopy = mpInstance._Helpers.extend({}, incomingMpidUIByName);
7398
7410
  mpInstance.Logger.verbose('Successfully parsed Identity Response');
7399
7411
 
7412
+ // https://go.mparticle.com/work/SQDSDKS-6356
7400
7413
  //this covers an edge case where, users stored before "firstSeenTime" was introduced
7401
7414
  //will not have a value for "fst" until the current MPID changes, and in some cases,
7402
7415
  //the current MPID will never change
7403
7416
  if (method === Identify && prevUser && identityApiResult.mpid === prevUser.getMPID()) {
7417
+ // https://go.mparticle.com/work/SQDSDKS-6329
7404
7418
  mpInstance._Persistence.setFirstSeenTime(identityApiResult.mpid);
7405
7419
  }
7406
7420
  indexOfMPID = mpInstance._Store.currentSessionMPIDs.indexOf(identityApiResult.mpid);
@@ -7412,7 +7426,7 @@ var mParticle = (function () {
7412
7426
  mpInstance._Store.currentSessionMPIDs.push(identityApiResult.mpid);
7413
7427
  }
7414
7428
  mpInstance._CookieSyncManager.attemptCookieSync(previousMPID, identityApiResult.mpid, mpidIsNotInCookies);
7415
- self.checkIdentitySwap(previousMPID, identityApiResult.mpid, mpInstance._Store.currentSessionMPIDs);
7429
+ mpInstance._Persistence.swapCurrentUser(previousMPID, identityApiResult.mpid, mpInstance._Store.currentSessionMPIDs);
7416
7430
  if (identityApiData && identityApiData.userIdentities && Object.keys(identityApiData.userIdentities).length) {
7417
7431
  newIdentitiesByType = self.IdentityRequest.combineUserIdentities(incomingMpidUIByName, identityApiData.userIdentities);
7418
7432
  }
@@ -7421,9 +7435,13 @@ var mParticle = (function () {
7421
7435
  mpInstance._Persistence.saveUserIdentitiesToPersistence(identityApiResult.mpid, newIdentitiesByType);
7422
7436
  mpInstance._Persistence.update();
7423
7437
  mpInstance._Persistence.findPrevCookiesBasedOnUI(identityApiData);
7438
+
7439
+ // https://go.mparticle.com/work/SQDSDKS-6357
7424
7440
  mpInstance._Store.context = identityApiResult.context || mpInstance._Store.context;
7425
7441
  }
7426
7442
  newUser = mpInstance.Identity.getCurrentUser();
7443
+
7444
+ // https://go.mparticle.com/work/SQDSDKS-6359
7427
7445
  if (identityApiData && identityApiData.onUserAlias && mpInstance._Helpers.Validators.isFunction(identityApiData.onUserAlias)) {
7428
7446
  try {
7429
7447
  mpInstance.Logger.warning('Deprecated function onUserAlias will be removed in future releases');
@@ -7481,6 +7499,8 @@ var mParticle = (function () {
7481
7499
  return;
7482
7500
  }
7483
7501
  }
7502
+
7503
+ // https://go.mparticle.com/work/SQDSDKS-6354
7484
7504
  currentUserInMemory = this.IdentityAPI.getUser(mpid);
7485
7505
  for (var identityType in newUserIdentities) {
7486
7506
  if (prevUserIdentities[identityType] !== newUserIdentities[identityType]) {
@@ -8344,6 +8364,7 @@ var mParticle = (function () {
8344
8364
  var xhr,
8345
8365
  xhrCallback = function xhrCallback() {
8346
8366
  if (xhr.readyState === 4) {
8367
+ // https://go.mparticle.com/work/SQDSDKS-6368
8347
8368
  mpInstance.Logger.verbose('Received ' + xhr.statusText + ' from server');
8348
8369
  //only parse error messages from failing requests
8349
8370
  if (xhr.status !== 200 && xhr.status !== 202) {
@@ -8376,6 +8397,7 @@ var mParticle = (function () {
8376
8397
  previousMPID,
8377
8398
  xhrCallback = function xhrCallback() {
8378
8399
  if (xhr.readyState === 4) {
8400
+ // https://go.mparticle.com/work/SQDSDKS-6368
8379
8401
  mpInstance.Logger.verbose('Received ' + xhr.statusText + ' from server');
8380
8402
  parseIdentityResponse(xhr, previousMPID, callback, originalIdentityApiData, method, knownIdentities, false);
8381
8403
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.26.4",
3
+ "version": "2.26.6",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -1,12 +1,30 @@
1
- import {
2
- AllUserAttributes,
3
- IdentityCallback,
4
- Product,
5
- User,
6
- } from '@mparticle/web-sdk';
1
+ import { AllUserAttributes, MPID, Product, User } from '@mparticle/web-sdk';
7
2
  import { SDKIdentityTypeEnum } from './identity.interfaces';
8
3
  import { MessageType } from './types.interfaces';
9
4
  import { BaseEvent } from './sdkRuntimeModels';
5
+ import Constants from './constants';
6
+ const { HTTPCodes } = Constants;
7
+
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 Cart {
11
+ /**
12
+ * @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.AddToCart, [products])
13
+ */
14
+ add: (product: Product, 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: Product, 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: () => Product[];
27
+ }
10
28
 
11
29
  // https://go.mparticle.com/work/SQDSDKS-5033
12
30
  // https://go.mparticle.com/work/SQDSDKS-6354
@@ -15,6 +33,10 @@ export interface IMParticleUser extends User {
15
33
  setUserTag(tagName: string, value?: any): void;
16
34
  setUserAttribute(key: string, value: any): void;
17
35
  getUserAudiences?(callback?: IdentityCallback): void;
36
+ /*
37
+ * @deprecated
38
+ */
39
+ getCart(): Cart;
18
40
  }
19
41
 
20
42
  export interface ISDKUserIdentity {
@@ -53,6 +75,33 @@ export interface IUserAttributeChangeEvent extends BaseEvent {
53
75
  userAttributeChanges: ISDKUserAttributeChangeData;
54
76
  }
55
77
 
78
+ // https://go.mparticle.com/work/SQDSDKS-6460
79
+ export interface IdentityCallback {
80
+ (result: IdentityResult): void;
81
+ }
82
+
83
+ export interface IdentityResult {
84
+ httpCode: typeof HTTPCodes;
85
+ getPreviousUser(): User;
86
+ getUser(): User;
87
+ body: IdentityResultBody | IdentityModifyResultBody;
88
+ }
89
+
90
+ export interface IdentityResultBody {
91
+ context: string | null;
92
+ is_ephemeral: boolean;
93
+ is_logged_in: boolean;
94
+ matched_identities: Record<string, unknown>;
95
+ mpid?: MPID;
96
+ }
97
+
98
+ export interface IdentityModifyResultBody {
99
+ change_results?: {
100
+ identity_type: SDKIdentityTypeEnum;
101
+ modified_mpid: MPID;
102
+ };
103
+ }
104
+
56
105
  export interface mParticleUserCart {
57
106
  add(product: Product, logEvent: boolean): void;
58
107
  remove(product: Product, logEvent: boolean): void;
@@ -7,6 +7,8 @@ import { IdentityAPIMethod } from './identity.interfaces';
7
7
 
8
8
  const { Identify, Modify, Login, Logout } = Constants.IdentityMethods;
9
9
 
10
+ export type IdentityCache = BaseVault<Dictionary<ICachedIdentityCall>>;
11
+
10
12
  export type IParseCachedIdentityResponse = (
11
13
  cachedIdentity: ICachedIdentityCall,
12
14
  mpid: string,
@@ -69,7 +71,7 @@ export const cacheIdentityRequest = (
69
71
  method: IdentityAPIMethod,
70
72
  identities: IKnownIdentities,
71
73
  expireTimestamp: number,
72
- idCache: BaseVault<Dictionary<ICachedIdentityCall>>,
74
+ idCache: IdentityCache,
73
75
  xhr: XMLHttpRequest
74
76
  ): void => {
75
77
  const cache: Dictionary<ICachedIdentityCall> = idCache.retrieve() || ({} as Dictionary<ICachedIdentityCall>);
@@ -126,7 +128,7 @@ export const concatenateIdentities = (
126
128
  export const hasValidCachedIdentity = (
127
129
  method: IdentityAPIMethod,
128
130
  proposedUserIdentities: IKnownIdentities,
129
- idCache?: BaseVault<Dictionary<ICachedIdentityCall>>
131
+ idCache?: IdentityCache,
130
132
  ): boolean => {
131
133
  // There is an edge case where multiple identity calls are taking place
132
134
  // before identify fires, so there may not be a cache. See what happens when
@@ -166,7 +168,7 @@ export const hasValidCachedIdentity = (
166
168
  export const getCachedIdentity = (
167
169
  method: IdentityAPIMethod,
168
170
  proposedUserIdentities: IKnownIdentities,
169
- idCache: BaseVault<Dictionary<ICachedIdentityCall>>
171
+ idCache: IdentityCache,
170
172
  ): ICachedIdentityCall | null => {
171
173
  const cacheKey: string = concatenateIdentities(
172
174
  method,
@@ -215,7 +217,7 @@ export const removeExpiredIdentityCacheDates = (idCache: BaseVault<Dictionary<IC
215
217
 
216
218
  export const tryCacheIdentity = (
217
219
  knownIdentities: IKnownIdentities,
218
- idCache: BaseVault<Dictionary<ICachedIdentityCall>>,
220
+ idCache: IdentityCache,
219
221
  parseIdentityResponse: IParseCachedIdentityResponse,
220
222
  mpid: string,
221
223
  callback: IdentityCallback,
@@ -1,15 +1,11 @@
1
- import {
2
- IdentityApiData,
3
- IdentityCallback,
4
- MPID,
5
- UserIdentities,
6
- } from '@mparticle/web-sdk';
1
+ import { IdentityApiData, MPID, UserIdentities } from '@mparticle/web-sdk';
7
2
  import AudienceManager from './audienceManager';
8
3
  import { ICachedIdentityCall, IKnownIdentities } from './identity-utils';
9
4
  import { BaseVault } from './vault';
10
5
  import { Dictionary, Environment, valueof } from './utils';
11
6
  import Constants from './constants';
12
7
  import {
8
+ IdentityCallback,
13
9
  IUserAttributeChangeEvent,
14
10
  IUserIdentityChangeEvent,
15
11
  IMParticleUser,
@@ -78,6 +74,10 @@ export interface IIdentityAPIIdentityChangeData {
78
74
  }
79
75
 
80
76
  export interface IIdentityRequest {
77
+ combineUserIdentities(
78
+ previousUIByName: UserIdentities,
79
+ newUIByName: UserIdentities
80
+ ): UserIdentities;
81
81
  createIdentityRequest(
82
82
  identityApiData: IdentityApiData,
83
83
  platform: string,
@@ -154,11 +154,6 @@ export interface IIdentity {
154
154
 
155
155
  mParticleUser(mpid: MPID, IsLoggedIn: boolean): IMParticleUser;
156
156
 
157
- checkIdentitySwap(
158
- previousMPID: MPID,
159
- currentMPID: MPID,
160
- currentSessionMPIDs?: MPID[]
161
- ): void;
162
157
  createUserAttributeChange(
163
158
  key: string,
164
159
  newValue: string,
package/src/identity.js CHANGED
@@ -17,21 +17,7 @@ export default function Identity(mpInstance) {
17
17
  this.idCache = null;
18
18
  this.audienceManager = null;
19
19
 
20
- this.checkIdentitySwap = function(
21
- previousMPID,
22
- currentMPID,
23
- currentSessionMPIDs
24
- ) {
25
- if (previousMPID && currentMPID && previousMPID !== currentMPID) {
26
- var persistence = mpInstance._Persistence.getPersistence();
27
- if (persistence) {
28
- persistence.cu = currentMPID;
29
- persistence.gs.csm = currentSessionMPIDs;
30
- mpInstance._Persistence.savePersistence(persistence);
31
- }
32
- }
33
- };
34
-
20
+ // https://go.mparticle.com/work/SQDSDKS-6353
35
21
  this.IdentityRequest = {
36
22
  preProcessIdentityRequest: function(identityApiData, callback, method) {
37
23
  mpInstance.Logger.verbose(
@@ -232,6 +218,7 @@ export default function Identity(mpInstance) {
232
218
  * @param {Function} [callback] A callback function that is called when the identify request completes
233
219
  */
234
220
  identify: function(identityApiData, callback) {
221
+ // https://go.mparticle.com/work/SQDSDKS-6337
235
222
  var mpid,
236
223
  currentUser = mpInstance.Identity.getCurrentUser(),
237
224
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(
@@ -325,6 +312,7 @@ export default function Identity(mpInstance) {
325
312
  * @param {Function} [callback] A callback function that is called when the logout request completes
326
313
  */
327
314
  logout: function(identityApiData, callback) {
315
+ // https://go.mparticle.com/work/SQDSDKS-6337
328
316
  var mpid,
329
317
  currentUser = mpInstance.Identity.getCurrentUser(),
330
318
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(
@@ -414,6 +402,7 @@ export default function Identity(mpInstance) {
414
402
  * @param {Function} [callback] A callback function that is called when the login request completes
415
403
  */
416
404
  login: function(identityApiData, callback) {
405
+ // https://go.mparticle.com/work/SQDSDKS-6337
417
406
  var mpid,
418
407
  currentUser = mpInstance.Identity.getCurrentUser(),
419
408
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(
@@ -509,6 +498,7 @@ export default function Identity(mpInstance) {
509
498
  * @param {Function} [callback] A callback function that is called when the modify request completes
510
499
  */
511
500
  modify: function(identityApiData, callback) {
501
+ // https://go.mparticle.com/work/SQDSDKS-6337
512
502
  var mpid,
513
503
  currentUser = mpInstance.Identity.getCurrentUser(),
514
504
  preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(
@@ -796,6 +786,7 @@ export default function Identity(mpInstance) {
796
786
  },
797
787
  };
798
788
 
789
+ // https://go.mparticle.com/work/SQDSDKS-6354
799
790
  /**
800
791
  * Invoke these methods on the mParticle.Identity.getCurrentUser() object.
801
792
  * Example: mParticle.Identity.getCurrentUser().getAllUserAttributes()
@@ -1481,6 +1472,7 @@ export default function Identity(mpInstance) {
1481
1472
  };
1482
1473
  };
1483
1474
 
1475
+ // https://go.mparticle.com/work/SQDSDKS-6355
1484
1476
  this.parseIdentityResponse = function(
1485
1477
  xhr,
1486
1478
  previousMPID,
@@ -1528,6 +1520,7 @@ export default function Identity(mpInstance) {
1528
1520
  mpInstance._Store.mpid = identityApiResult.mpid;
1529
1521
 
1530
1522
  if (prevUser) {
1523
+ // https://go.mparticle.com/work/SQDSDKS-6329
1531
1524
  mpInstance._Persistence.setLastSeenTime(previousMPID);
1532
1525
  }
1533
1526
 
@@ -1584,6 +1577,7 @@ export default function Identity(mpInstance) {
1584
1577
  'Successfully parsed Identity Response'
1585
1578
  );
1586
1579
 
1580
+ // https://go.mparticle.com/work/SQDSDKS-6356
1587
1581
  //this covers an edge case where, users stored before "firstSeenTime" was introduced
1588
1582
  //will not have a value for "fst" until the current MPID changes, and in some cases,
1589
1583
  //the current MPID will never change
@@ -1592,6 +1586,7 @@ export default function Identity(mpInstance) {
1592
1586
  prevUser &&
1593
1587
  identityApiResult.mpid === prevUser.getMPID()
1594
1588
  ) {
1589
+ // https://go.mparticle.com/work/SQDSDKS-6329
1595
1590
  mpInstance._Persistence.setFirstSeenTime(
1596
1591
  identityApiResult.mpid
1597
1592
  );
@@ -1632,7 +1627,7 @@ export default function Identity(mpInstance) {
1632
1627
  mpidIsNotInCookies
1633
1628
  );
1634
1629
 
1635
- self.checkIdentitySwap(
1630
+ mpInstance._Persistence.swapCurrentUser(
1636
1631
  previousMPID,
1637
1632
  identityApiResult.mpid,
1638
1633
  mpInstance._Store.currentSessionMPIDs
@@ -1660,12 +1655,14 @@ export default function Identity(mpInstance) {
1660
1655
  identityApiData
1661
1656
  );
1662
1657
 
1658
+ // https://go.mparticle.com/work/SQDSDKS-6357
1663
1659
  mpInstance._Store.context =
1664
1660
  identityApiResult.context || mpInstance._Store.context;
1665
1661
  }
1666
1662
 
1667
1663
  newUser = mpInstance.Identity.getCurrentUser();
1668
1664
 
1665
+ // https://go.mparticle.com/work/SQDSDKS-6359
1669
1666
  if (
1670
1667
  identityApiData &&
1671
1668
  identityApiData.onUserAlias &&
@@ -1799,6 +1796,7 @@ export default function Identity(mpInstance) {
1799
1796
  }
1800
1797
  }
1801
1798
 
1799
+ // https://go.mparticle.com/work/SQDSDKS-6354
1802
1800
  currentUserInMemory = this.IdentityAPI.getUser(mpid);
1803
1801
 
1804
1802
  for (var identityType in newUserIdentities) {
@@ -10,6 +10,7 @@ export default function IdentityAPIClient(mpInstance) {
10
10
  var xhr,
11
11
  xhrCallback = function() {
12
12
  if (xhr.readyState === 4) {
13
+ // https://go.mparticle.com/work/SQDSDKS-6368
13
14
  mpInstance.Logger.verbose(
14
15
  'Received ' + xhr.statusText + ' from server'
15
16
  );
@@ -73,6 +74,7 @@ export default function IdentityAPIClient(mpInstance) {
73
74
  previousMPID,
74
75
  xhrCallback = function() {
75
76
  if (xhr.readyState === 4) {
77
+ // https://go.mparticle.com/work/SQDSDKS-6368
76
78
  mpInstance.Logger.verbose(
77
79
  'Received ' + xhr.statusText + ' from server'
78
80
  );
@@ -125,5 +125,10 @@ export interface IPersistence {
125
125
  getDeviceId(): string;
126
126
  setDeviceId(guid: string): void;
127
127
  resetPersistence(): void;
128
+ swapCurrentUser(
129
+ previousMPID: MPID,
130
+ currentMPID: MPID,
131
+ currentSessionMPIDs?: MPID[]
132
+ ): void;
128
133
  forwardingStatsBatches: iForwardingStatsBatches;
129
134
  }
@@ -1012,6 +1012,21 @@ export default function _Persistence(mpInstance) {
1012
1012
  }
1013
1013
  };
1014
1014
 
1015
+ this.swapCurrentUser = function(
1016
+ previousMPID,
1017
+ currentMPID,
1018
+ currentSessionMPIDs
1019
+ ) {
1020
+ if (previousMPID && currentMPID && previousMPID !== currentMPID) {
1021
+ var persistence = self.getPersistence();
1022
+ if (persistence) {
1023
+ persistence.cu = currentMPID;
1024
+ persistence.gs.csm = currentSessionMPIDs;
1025
+ self.savePersistence(persistence);
1026
+ }
1027
+ }
1028
+ };
1029
+
1015
1030
  // https://go.mparticle.com/work/SQDSDKS-6021
1016
1031
  this.savePersistence = function(persistence) {
1017
1032
  var encodedPersistence = self.encodePersistence(
@@ -1097,6 +1112,7 @@ export default function _Persistence(mpInstance) {
1097
1112
  if (!mpid) {
1098
1113
  return;
1099
1114
  }
1115
+ // https://go.mparticle.com/work/SQDSDKS-6329
1100
1116
  if (!time) {
1101
1117
  time = new Date().getTime();
1102
1118
  }
@@ -1137,6 +1153,7 @@ export default function _Persistence(mpInstance) {
1137
1153
  if (!mpid) {
1138
1154
  return;
1139
1155
  }
1156
+ // https://go.mparticle.com/work/SQDSDKS-6329
1140
1157
  if (!time) {
1141
1158
  time = new Date().getTime();
1142
1159
  }
@@ -1,6 +1,11 @@
1
1
  import * as EventsApi from '@mparticle/event-models';
2
2
  import { DataPlanVersion } from '@mparticle/data-planning-models';
3
- import { MPConfiguration, MPID, Callback } from '@mparticle/web-sdk';
3
+ import {
4
+ MPConfiguration,
5
+ MPID,
6
+ Callback,
7
+ IdentityApiData,
8
+ } from '@mparticle/web-sdk';
4
9
  import { IStore } from './store';
5
10
  import Validators from './validators';
6
11
  import { Dictionary } from './utils';
@@ -11,13 +16,15 @@ import { IPersistence } from './persistence.interfaces';
11
16
  import { IMPSideloadedKit } from './sideloadedKit';
12
17
  import { ISessionManager } from './sessionManager';
13
18
  import { Kit, MPForwarder } from './forwarders.interfaces';
14
- import { SDKIdentityApi } from './identity.interfaces';
19
+ import { IIdentity, SDKIdentityApi } from './identity.interfaces';
15
20
  import {
16
21
  ISDKUserAttributeChangeData,
17
22
  ISDKUserIdentityChanges,
18
23
  IMParticleUser,
19
24
  ISDKUserIdentity,
25
+ IdentityCallback,
20
26
  } from './identity-user-interfaces';
27
+ import { IIdentityType } from './types.interfaces';
21
28
 
22
29
  // TODO: Resolve this with version in @mparticle/web-sdk
23
30
  export type SDKEventCustomFlags = Dictionary<any>;
@@ -27,7 +34,10 @@ export interface SDKEvent {
27
34
  IsFirstRun: boolean;
28
35
  EventName: string;
29
36
  EventCategory: number;
37
+
38
+ // https://go.mparticle.com/work/SQDSDKS-5196
30
39
  UserAttributes?: { [key: string]: string | string[] | null };
40
+
31
41
  UserIdentities?: ISDKUserIdentity[];
32
42
  SourceMessageId: string;
33
43
  MPID: string;
@@ -137,6 +147,8 @@ interface IEvents {
137
147
 
138
148
  export interface MParticleWebSDK {
139
149
  addForwarder(mockForwarder: MPForwarder): void;
150
+ IdentityType: IIdentityType;
151
+ _Identity: IIdentity;
140
152
  Identity: SDKIdentityApi;
141
153
  Logger: SDKLoggerApi;
142
154
  MPSideloadedKit: IMPSideloadedKit;
@@ -160,14 +172,21 @@ export interface MParticleWebSDK {
160
172
  keepPersistence?: boolean,
161
173
  instance?: MParticleWebSDK
162
174
  ): void;
175
+ endSession(): void;
176
+ identifyRequest: IdentityApiData;
163
177
  init(apiKey: string, config: SDKInitConfig, instanceName?: string): void;
178
+ _getActiveForwarders(): MPForwarder[];
164
179
  getAppName(): string;
165
180
  getAppVersion(): string;
166
181
  getDeviceId(): string;
182
+ setDeviceId(deviceId: string): void;
183
+ setSessionAttribute(key: string, value: string): void;
167
184
  getInstance(): MParticleWebSDK; // TODO: Create a new type for MParticleWebSDKInstance
168
185
  ServerModel();
169
186
  upload();
187
+ setLogLevel(logLevel: LogLevelType): void;
170
188
  setPosition(lat: number | string, lng: number | string): void;
189
+ startNewSession(): void;
171
190
  logEvent(
172
191
  eventName: string,
173
192
  eventType?: number,
@@ -224,6 +243,9 @@ export interface SDKInitConfig
224
243
 
225
244
  workspaceToken?: string;
226
245
  isDevelopmentMode?: boolean;
246
+
247
+ // https://go.mparticle.com/work/SQDSDKS-6460
248
+ identityCallback?: IdentityCallback;
227
249
  }
228
250
 
229
251
  export interface DataPlanConfig {
@@ -46,7 +46,10 @@ export interface IServerV2DTO {
46
46
  dp_v?: number;
47
47
  n?: string;
48
48
  et?: number;
49
+
50
+ // https://go.mparticle.com/work/SQDSDKS-5196
49
51
  ua?: Dictionary<string | string[]>;
52
+
50
53
  ui?: ISDKUserIdentity[];
51
54
  ia?: Dictionary<Dictionary<string>>;
52
55
  str?: ServerSettings;
package/src/store.ts CHANGED
@@ -4,7 +4,6 @@ import {
4
4
  DataPlanConfig,
5
5
  MPID,
6
6
  IdentifyRequest,
7
- IdentityCallback,
8
7
  SDKEventCustomFlags,
9
8
  } from '@mparticle/web-sdk';
10
9
  import { IKitConfigs } from './configAPIClient';
@@ -32,6 +31,7 @@ import {
32
31
  import { SDKConsentState } from './consent';
33
32
  import { Kit, MPForwarder } from './forwarders.interfaces';
34
33
  import { IPersistenceMinified } from './persistence.interfaces';
34
+ import { IdentityCallback } from './identity-user-interfaces';
35
35
 
36
36
  // This represents the runtime configuration of the SDK AFTER
37
37
  // initialization has been complete and all settings and
@@ -71,6 +71,7 @@ export interface SDKConfig {
71
71
  identityUrl?: string;
72
72
  userAudienceUrl?: string;
73
73
  isIOS?: boolean;
74
+ maxAliasWindow: number;
74
75
  maxProducts: number;
75
76
  requestConfig?: boolean;
76
77
  sessionTimeout?: number;
@@ -49,4 +49,8 @@ export enum IdentityType {
49
49
  MobileNumber = 19,
50
50
  PhoneNumber2 = 20,
51
51
  PhoneNumber3 = 21,
52
- }
52
+ }
53
+
54
+ export interface IIdentityType {
55
+ getIdentityType(identityType: string): IdentityType | null;
56
+ }