@mparticle/web-sdk 2.26.3 → 2.26.4

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.3";
64
+ var version = "2.26.4";
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
@@ -162,7 +162,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
162
162
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
163
163
  };
164
164
 
165
- var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a.facebook="facebook",a.twitter="twitter",a.google="google",a.microsoft="microsoft",a.yahoo="yahoo",a.email="email",a.alias="alias",a.facebookCustomAudienceId="facebookcustomaudienceid",a.otherId2="other2",a.otherId3="other3",a.otherId4="other4",a.otherId5="other5",a.otherId6="other6",a.otherId7="other7",a.otherId8="other8",a.otherId9="other9",a.otherId10="other10",a.mobileNumber="mobile_number",a.phoneNumber2="phone_number_2",a.phoneNumber3="phone_number_3";})(SDKIdentityTypeEnum||(SDKIdentityTypeEnum={}));
165
+ var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));
166
166
 
167
167
  var dist = {};
168
168
 
@@ -408,6 +408,8 @@ return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"
408
408
  * Returns a value between 1-100 inclusive.
409
409
  */ // FIXME: REFACTOR for V3
410
410
 
411
+ var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a.facebook="facebook",a.twitter="twitter",a.google="google",a.microsoft="microsoft",a.yahoo="yahoo",a.email="email",a.alias="alias",a.facebookCustomAudienceId="facebookcustomaudienceid",a.otherId2="other2",a.otherId3="other3",a.otherId4="other4",a.otherId5="other5",a.otherId6="other6",a.otherId7="other7",a.otherId8="other8",a.otherId9="other9",a.otherId10="other10",a.mobileNumber="mobile_number",a.phoneNumber2="phone_number_2",a.phoneNumber3="phone_number_3";})(SDKIdentityTypeEnum||(SDKIdentityTypeEnum={}));
412
+
411
413
  function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c.Identity.getCurrentUser(),f=[],g=null,h=0,i=b;h<i.length;h++)if(d=i[h],d){g=d;var j=convertEvent(d);j&&f.push(j);}if(!g)return null;var k=null;// Add the consent state from either the Last Event or the user
412
414
  isEmpty(g.ConsentState)?!isEmpty(e)&&(k=e.getConsentState()):k=g.ConsentState;var l={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:g.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:f,mp_deviceid:g.DeviceId,sdk_version:g.SDKVersion,// TODO: Refactor this to read from _Store or a global config
413
415
  application_info:{application_version:g.AppVersion,application_name:g.AppName,package:g.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:window.screen.width,screen_height:window.screen.height},user_attributes:g.UserAttributes,user_identities:convertUserIdentities(g.UserIdentities),consent_state:convertConsentState(k),integration_attributes:g.IntegrationAttributes};return g.DataPlan&&g.DataPlan.PlanId&&(l.context={data_plan:{plan_id:g.DataPlan.PlanId,plan_version:g.DataPlan.PlanVersion||void 0}}),l}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
@@ -859,7 +861,8 @@ if(c?(g=!1,d=o[c],delete o[c]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.sa
859
861
  * Get user audiences
860
862
  * @method getuserAudiences
861
863
  * @param {Function} [callback] A callback function that is invoked when the user audience request completes
862
- */getUserAudiences:function getUserAudiences(r){// user audience API is feature flagged
864
+ */ // https://go.mparticle.com/work/SQDSDKS-6436
865
+ getUserAudiences:function getUserAudiences(r){// user audience API is feature flagged
863
866
  return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audienceManager&&(s.audienceManager=new AudienceManager(t._Store.SDKConfig.userAudienceUrl,t._Store.devToken,t.Logger,e)),s.audienceManager.sendGetUserAudienceRequest(e,r)):void t.Logger.error(ErrorMessages.AudienceAPINotEnabled)}}},this.mParticleUserCart=function(e){return {/**
864
867
  * Adds a cart product to the user cart
865
868
  * @method add
@@ -881,7 +884,8 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
881
884
  * @method getCartProducts
882
885
  * @return {Array} array of cart products
883
886
  * @deprecated
884
- */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;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};}
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
888
+ 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};}
885
889
 
886
890
  var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){var b=this;// this function is called when consent is required to
887
891
  // determine if a cookie sync should happen, or a
@@ -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.3";
64
+ var version = "2.26.4";
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
@@ -162,7 +162,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
162
162
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
163
163
  };
164
164
 
165
- var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a.facebook="facebook",a.twitter="twitter",a.google="google",a.microsoft="microsoft",a.yahoo="yahoo",a.email="email",a.alias="alias",a.facebookCustomAudienceId="facebookcustomaudienceid",a.otherId2="other2",a.otherId3="other3",a.otherId4="other4",a.otherId5="other5",a.otherId6="other6",a.otherId7="other7",a.otherId8="other8",a.otherId9="other9",a.otherId10="other10",a.mobileNumber="mobile_number",a.phoneNumber2="phone_number_2",a.phoneNumber3="phone_number_3";})(SDKIdentityTypeEnum||(SDKIdentityTypeEnum={}));
165
+ var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));
166
166
 
167
167
  var dist = {};
168
168
 
@@ -408,6 +408,8 @@ return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"
408
408
  * Returns a value between 1-100 inclusive.
409
409
  */ // FIXME: REFACTOR for V3
410
410
 
411
+ var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a.facebook="facebook",a.twitter="twitter",a.google="google",a.microsoft="microsoft",a.yahoo="yahoo",a.email="email",a.alias="alias",a.facebookCustomAudienceId="facebookcustomaudienceid",a.otherId2="other2",a.otherId3="other3",a.otherId4="other4",a.otherId5="other5",a.otherId6="other6",a.otherId7="other7",a.otherId8="other8",a.otherId9="other9",a.otherId10="other10",a.mobileNumber="mobile_number",a.phoneNumber2="phone_number_2",a.phoneNumber3="phone_number_3";})(SDKIdentityTypeEnum||(SDKIdentityTypeEnum={}));
412
+
411
413
  function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c.Identity.getCurrentUser(),f=[],g=null,h=0,i=b;h<i.length;h++)if(d=i[h],d){g=d;var j=convertEvent(d);j&&f.push(j);}if(!g)return null;var k=null;// Add the consent state from either the Last Event or the user
412
414
  isEmpty(g.ConsentState)?!isEmpty(e)&&(k=e.getConsentState()):k=g.ConsentState;var l={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:g.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:f,mp_deviceid:g.DeviceId,sdk_version:g.SDKVersion,// TODO: Refactor this to read from _Store or a global config
413
415
  application_info:{application_version:g.AppVersion,application_name:g.AppName,package:g.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:window.screen.width,screen_height:window.screen.height},user_attributes:g.UserAttributes,user_identities:convertUserIdentities(g.UserIdentities),consent_state:convertConsentState(k),integration_attributes:g.IntegrationAttributes};return g.DataPlan&&g.DataPlan.PlanId&&(l.context={data_plan:{plan_id:g.DataPlan.PlanId,plan_version:g.DataPlan.PlanVersion||void 0}}),l}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
@@ -859,7 +861,8 @@ if(c?(g=!1,d=o[c],delete o[c]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.sa
859
861
  * Get user audiences
860
862
  * @method getuserAudiences
861
863
  * @param {Function} [callback] A callback function that is invoked when the user audience request completes
862
- */getUserAudiences:function getUserAudiences(r){// user audience API is feature flagged
864
+ */ // https://go.mparticle.com/work/SQDSDKS-6436
865
+ getUserAudiences:function getUserAudiences(r){// user audience API is feature flagged
863
866
  return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audienceManager&&(s.audienceManager=new AudienceManager(t._Store.SDKConfig.userAudienceUrl,t._Store.devToken,t.Logger,e)),s.audienceManager.sendGetUserAudienceRequest(e,r)):void t.Logger.error(ErrorMessages.AudienceAPINotEnabled)}}},this.mParticleUserCart=function(e){return {/**
864
867
  * Adds a cart product to the user cart
865
868
  * @method add
@@ -881,7 +884,8 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
881
884
  * @method getCartProducts
882
885
  * @return {Array} array of cart products
883
886
  * @deprecated
884
- */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;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};}
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
888
+ 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};}
885
889
 
886
890
  var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){var b=this;// this function is called when consent is required to
887
891
  // determine if a cookie sync should happen, or a
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.3";
611
+ var version = "2.26.4";
612
612
 
613
613
  var Constants = {
614
614
  sdkVersion: version,
@@ -891,31 +891,6 @@ var mParticle = (function () {
891
891
  SDKProductActionType[SDKProductActionType["AddToWishlist"] = 9] = "AddToWishlist";
892
892
  SDKProductActionType[SDKProductActionType["RemoveFromWishlist"] = 10] = "RemoveFromWishlist";
893
893
  })(SDKProductActionType || (SDKProductActionType = {}));
894
- var SDKIdentityTypeEnum;
895
- (function (SDKIdentityTypeEnum) {
896
- SDKIdentityTypeEnum["other"] = "other";
897
- SDKIdentityTypeEnum["customerId"] = "customerid";
898
- SDKIdentityTypeEnum["facebook"] = "facebook";
899
- SDKIdentityTypeEnum["twitter"] = "twitter";
900
- SDKIdentityTypeEnum["google"] = "google";
901
- SDKIdentityTypeEnum["microsoft"] = "microsoft";
902
- SDKIdentityTypeEnum["yahoo"] = "yahoo";
903
- SDKIdentityTypeEnum["email"] = "email";
904
- SDKIdentityTypeEnum["alias"] = "alias";
905
- SDKIdentityTypeEnum["facebookCustomAudienceId"] = "facebookcustomaudienceid";
906
- SDKIdentityTypeEnum["otherId2"] = "other2";
907
- SDKIdentityTypeEnum["otherId3"] = "other3";
908
- SDKIdentityTypeEnum["otherId4"] = "other4";
909
- SDKIdentityTypeEnum["otherId5"] = "other5";
910
- SDKIdentityTypeEnum["otherId6"] = "other6";
911
- SDKIdentityTypeEnum["otherId7"] = "other7";
912
- SDKIdentityTypeEnum["otherId8"] = "other8";
913
- SDKIdentityTypeEnum["otherId9"] = "other9";
914
- SDKIdentityTypeEnum["otherId10"] = "other10";
915
- SDKIdentityTypeEnum["mobileNumber"] = "mobile_number";
916
- SDKIdentityTypeEnum["phoneNumber2"] = "phone_number_2";
917
- SDKIdentityTypeEnum["phoneNumber3"] = "phone_number_3";
918
- })(SDKIdentityTypeEnum || (SDKIdentityTypeEnum = {}));
919
894
 
920
895
  var dist = {};
921
896
 
@@ -1330,6 +1305,32 @@ var mParticle = (function () {
1330
1305
  return value == null || !(Object.keys(value) || value).length;
1331
1306
  };
1332
1307
 
1308
+ var SDKIdentityTypeEnum;
1309
+ (function (SDKIdentityTypeEnum) {
1310
+ SDKIdentityTypeEnum["other"] = "other";
1311
+ SDKIdentityTypeEnum["customerId"] = "customerid";
1312
+ SDKIdentityTypeEnum["facebook"] = "facebook";
1313
+ SDKIdentityTypeEnum["twitter"] = "twitter";
1314
+ SDKIdentityTypeEnum["google"] = "google";
1315
+ SDKIdentityTypeEnum["microsoft"] = "microsoft";
1316
+ SDKIdentityTypeEnum["yahoo"] = "yahoo";
1317
+ SDKIdentityTypeEnum["email"] = "email";
1318
+ SDKIdentityTypeEnum["alias"] = "alias";
1319
+ SDKIdentityTypeEnum["facebookCustomAudienceId"] = "facebookcustomaudienceid";
1320
+ SDKIdentityTypeEnum["otherId2"] = "other2";
1321
+ SDKIdentityTypeEnum["otherId3"] = "other3";
1322
+ SDKIdentityTypeEnum["otherId4"] = "other4";
1323
+ SDKIdentityTypeEnum["otherId5"] = "other5";
1324
+ SDKIdentityTypeEnum["otherId6"] = "other6";
1325
+ SDKIdentityTypeEnum["otherId7"] = "other7";
1326
+ SDKIdentityTypeEnum["otherId8"] = "other8";
1327
+ SDKIdentityTypeEnum["otherId9"] = "other9";
1328
+ SDKIdentityTypeEnum["otherId10"] = "other10";
1329
+ SDKIdentityTypeEnum["mobileNumber"] = "mobile_number";
1330
+ SDKIdentityTypeEnum["phoneNumber2"] = "phone_number_2";
1331
+ SDKIdentityTypeEnum["phoneNumber3"] = "phone_number_3";
1332
+ })(SDKIdentityTypeEnum || (SDKIdentityTypeEnum = {}));
1333
+
1333
1334
  function convertEvents(mpid, sdkEvents, mpInstance) {
1334
1335
  if (!mpid) {
1335
1336
  return null;
@@ -7223,6 +7224,7 @@ var mParticle = (function () {
7223
7224
  * @method getuserAudiences
7224
7225
  * @param {Function} [callback] A callback function that is invoked when the user audience request completes
7225
7226
  */
7227
+ // https://go.mparticle.com/work/SQDSDKS-6436
7226
7228
  getUserAudiences: function getUserAudiences(callback) {
7227
7229
  // user audience API is feature flagged
7228
7230
  if (!mpInstance._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)) {
@@ -7490,6 +7492,8 @@ var mParticle = (function () {
7490
7492
  };
7491
7493
  this.createUserIdentityChange = function (identityType, newIdentity, oldIdentity, newCreatedThisBatch, userInMemory) {
7492
7494
  var userIdentityChangeEvent;
7495
+
7496
+ // https://go.mparticle.com/work/SQDSDKS-6439
7493
7497
  userIdentityChangeEvent = mpInstance._ServerModel.createEventObject({
7494
7498
  messageType: Types.MessageType.UserIdentityChange,
7495
7499
  userIdentityChanges: {
@@ -7520,6 +7524,7 @@ var mParticle = (function () {
7520
7524
  }
7521
7525
  var userAttributeChangeEvent;
7522
7526
  if (newValue !== previousUserAttributeValue) {
7527
+ // https://go.mparticle.com/work/SQDSDKS-6439
7523
7528
  userAttributeChangeEvent = mpInstance._ServerModel.createEventObject({
7524
7529
  messageType: Types.MessageType.UserAttributeChange,
7525
7530
  userAttributeChanges: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.26.3",
3
+ "version": "2.26.4",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
package/src/apiClient.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import Constants from './constants';
2
2
  import Types from './types';
3
3
  import { BatchUploader } from './batchUploader';
4
- import { MParticleUser, MParticleWebSDK, SDKEvent } from './sdkRuntimeModels';
4
+ import { MParticleWebSDK, SDKEvent } from './sdkRuntimeModels';
5
5
  import KitBlocker from './kitBlocking';
6
6
  import { Dictionary, getRampNumber, isEmpty, parseNumber } from './utils';
7
7
  import { IUploadObject } from './serverModel';
8
8
  import { MPForwarder } from './forwarders.interfaces';
9
+ import { IMParticleUser } from './identity-user-interfaces';
9
10
 
10
11
  export type ForwardingStatsData = Dictionary<any>;
11
12
 
@@ -13,7 +14,7 @@ export interface IAPIClient {
13
14
  uploader: BatchUploader | null;
14
15
  queueEventForBatchUpload: (event: SDKEvent) => void;
15
16
  processQueuedEvents: () => void;
16
- appendUserInfoToEvents: (user: MParticleUser, events: SDKEvent[]) => void;
17
+ appendUserInfoToEvents: (user: IMParticleUser, events: SDKEvent[]) => void;
17
18
  sendEventToServer: (event: SDKEvent, _options?: Dictionary<any>) => void;
18
19
  sendSingleEventToServer: (event: SDKEvent) => void;
19
20
  sendBatchForwardingStatsToServer: (
@@ -1,21 +1,17 @@
1
1
  import { Batch } from '@mparticle/event-models';
2
2
  import Constants from './constants';
3
- import {
4
- SDKEvent,
5
- MParticleUser,
6
- MParticleWebSDK,
7
- SDKLoggerApi,
8
- } from './sdkRuntimeModels';
3
+ import { SDKEvent, MParticleWebSDK, SDKLoggerApi } from './sdkRuntimeModels';
9
4
  import { convertEvents } from './sdkToEventsApiConverter';
10
5
  import Types from './types';
11
6
  import { getRampNumber, isEmpty } from './utils';
12
7
  import { SessionStorageVault, LocalStorageVault } from './vault';
13
- import {
8
+ import {
14
9
  AsyncUploader,
15
10
  FetchUploader,
16
11
  XHRUploader,
17
- fetchPayload
12
+ fetchPayload,
18
13
  } from './uploaders';
14
+ import { IMParticleUser } from './identity-user-interfaces';
19
15
 
20
16
  /**
21
17
  * BatchUploader contains all the logic to store/retrieve events and batches
@@ -205,7 +201,7 @@ export class BatchUploader {
205
201
  */
206
202
  private static createNewBatches(
207
203
  sdkEvents: SDKEvent[],
208
- defaultUser: MParticleUser,
204
+ defaultUser: IMParticleUser,
209
205
  mpInstance: MParticleWebSDK
210
206
  ): Batch[] | null {
211
207
  if (!defaultUser || !sdkEvents || !sdkEvents.length) {
package/src/consent.ts CHANGED
@@ -4,10 +4,11 @@ import {
4
4
  GDPRConsentState,
5
5
  PrivacyConsentState,
6
6
  } from '@mparticle/web-sdk';
7
- import { MParticleUser, MParticleWebSDK } from './sdkRuntimeModels';
7
+ import { MParticleWebSDK } from './sdkRuntimeModels';
8
8
  import { Dictionary, isObject } from './utils';
9
9
  import KitFilterHelper from './kitFilterHelper';
10
10
  import Constants from './constants';
11
+ import { IMParticleUser } from './identity-user-interfaces';
11
12
 
12
13
  const { CCPAPurpose } = Constants;
13
14
 
@@ -108,7 +109,7 @@ export interface IConsentState extends ConsentState {
108
109
  export interface IConsent {
109
110
  isEnabledForUserConsent: (
110
111
  consentRules: IConsentRules,
111
- user: MParticleUser
112
+ user: IMParticleUser
112
113
  ) => boolean;
113
114
  createPrivacyConsent: ICreatePrivacyConsentFunction;
114
115
  createConsentState: (consentState?: ConsentState) => ConsentState;
@@ -123,7 +124,7 @@ export default function Consent(this: IConsent, mpInstance: MParticleWebSDK) {
123
124
  // forwarder should be initialized
124
125
  this.isEnabledForUserConsent = function(
125
126
  consentRules: IConsentRules,
126
- user: MParticleUser
127
+ user: IMParticleUser
127
128
  ): boolean {
128
129
  if (
129
130
  !consentRules ||
@@ -1,13 +1,12 @@
1
- import {
2
- MParticleUser,
3
- SDKEvent,
4
- SDKEventCustomFlags,
5
- SDKUserIdentity,
6
- } from './sdkRuntimeModels';
1
+ import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels';
7
2
  import { Dictionary } from './utils';
8
3
  import { IKitConfigs } from './configAPIClient';
9
- import { UserAttributes } from './persistence.interfaces';
10
4
  import { IdentityApiData } from '@mparticle/web-sdk';
5
+ import {
6
+ IMParticleUser,
7
+ ISDKUserIdentity,
8
+ UserAttributes,
9
+ } from './identity-user-interfaces';
11
10
 
12
11
  // TODO: https://go.mparticle.com/work/SQDSDKS-6035
13
12
  export type Kit = Dictionary;
@@ -19,7 +18,7 @@ export interface UnregisteredKit {
19
18
  register(config): void;
20
19
  }
21
20
 
22
- // The state of the kit after being added to forwarderConstructors in the CDN
21
+ // The state of the kit after being added to forwarderConstructors in the CDN
23
22
  // or after registered to SDKConfig.kits via NPM
24
23
  export interface RegisteredKit {
25
24
  constructor(): void;
@@ -37,47 +36,50 @@ export interface ConfiguredKit
37
36
  testMode: boolean,
38
37
  trackerId: string | null,
39
38
  userAttributes: UserAttributes,
40
- userIdentities: SDKUserIdentity,
39
+ userIdentities: ISDKUserIdentity,
41
40
  appVersion: string,
42
41
  appName: string,
43
42
  customFlags: SDKEventCustomFlags,
44
43
  clientId: string
45
44
  ): string;
46
45
  onIdentifyComplete(
47
- user: MParticleUser,
46
+ user: IMParticleUser,
48
47
  filteredIdentityRequest: IdentityApiData
49
48
  ): string | KitMappedMethodFailure;
50
49
  onLoginComplete(
51
- user: MParticleUser,
50
+ user: IMParticleUser,
52
51
  filteredIdentityRequest: IdentityApiData
53
52
  ): string | KitMappedMethodFailure;
54
53
  onLogoutComplete(
55
- user: MParticleUser,
54
+ user: IMParticleUser,
56
55
  filteredIdentityRequest: IdentityApiData
57
56
  ): string | KitMappedMethodFailure;
58
57
  onModifyComplete(
59
- user: MParticleUser,
58
+ user: IMParticleUser,
60
59
  filteredIdentityRequest: IdentityApiData
61
60
  ): string | KitMappedMethodFailure;
62
- onUserIdentified(user: MParticleUser): string | KitMappedMethodFailure;
61
+ onUserIdentified(user: IMParticleUser): string | KitMappedMethodFailure;
63
62
  process(event: SDKEvent): string;
64
63
  setOptOut(isOptingOut: boolean): string | KitMappedMethodFailure;
65
64
  removeUserAttribute(key: string): string;
66
- setUserAttribute(key: string, value:string): string;
65
+ setUserAttribute(key: string, value: string): string;
67
66
 
68
67
  // TODO: Convert type to enum during Identity migration
69
68
  // https://go.mparticle.com/work/SQDSDKS-5218
70
69
  setUserIdentity(id: UserIdentityId, type: UserIdentityType): void;
71
70
 
72
71
  // TODO: https://go.mparticle.com/work/SQDSDKS-5156
73
- isSandbox: boolean;
72
+ isSandbox: boolean;
74
73
  hasSandbox: boolean;
75
74
  }
76
75
  export interface KitMappedMethodFailure {
77
- error: string
76
+ error: string;
78
77
  }
79
78
 
80
79
  export type UserIdentityId = string;
81
80
  export type UserIdentityType = number;
82
81
 
83
- export type forwardingStatsCallback = (forwarder: ConfiguredKit, event: SDKEvent) => void;
82
+ export type forwardingStatsCallback = (
83
+ forwarder: ConfiguredKit,
84
+ event: SDKEvent
85
+ ) => void;
@@ -0,0 +1,64 @@
1
+ import {
2
+ AllUserAttributes,
3
+ IdentityCallback,
4
+ Product,
5
+ User,
6
+ } from '@mparticle/web-sdk';
7
+ import { SDKIdentityTypeEnum } from './identity.interfaces';
8
+ import { MessageType } from './types.interfaces';
9
+ import { BaseEvent } from './sdkRuntimeModels';
10
+
11
+ // https://go.mparticle.com/work/SQDSDKS-5033
12
+ // https://go.mparticle.com/work/SQDSDKS-6354
13
+ export interface IMParticleUser extends User {
14
+ getAllUserAttributes(): any;
15
+ setUserTag(tagName: string, value?: any): void;
16
+ setUserAttribute(key: string, value: any): void;
17
+ getUserAudiences?(callback?: IdentityCallback): void;
18
+ }
19
+
20
+ export interface ISDKUserIdentity {
21
+ Identity: string;
22
+ Type: number;
23
+ }
24
+
25
+ export interface ISDKUserIdentityChanges {
26
+ New: ISDKUserIdentityChangeData;
27
+ Old: ISDKUserIdentityChangeData;
28
+ }
29
+
30
+ export interface ISDKUserIdentityChangeData {
31
+ IdentityType: SDKIdentityTypeEnum;
32
+ Identity: string;
33
+ CreatedThisBatch: boolean;
34
+ // https://go.mparticle.com/work/SQDSDKS-6438
35
+ Timestamp?: number;
36
+ }
37
+
38
+ export interface IUserIdentityChangeEvent extends BaseEvent {
39
+ messageType: MessageType.UserIdentityChange;
40
+ userIdentityChanges: ISDKUserIdentityChanges;
41
+ }
42
+
43
+ export interface ISDKUserAttributeChangeData {
44
+ UserAttributeName: string;
45
+ New: string;
46
+ Old: string;
47
+ Deleted: boolean;
48
+ IsNewAttribute: boolean;
49
+ }
50
+
51
+ export interface IUserAttributeChangeEvent extends BaseEvent {
52
+ messageType: MessageType.UserAttributeChange;
53
+ userAttributeChanges: ISDKUserAttributeChangeData;
54
+ }
55
+
56
+ export interface mParticleUserCart {
57
+ add(product: Product, logEvent: boolean): void;
58
+ remove(product: Product, logEvent: boolean): void;
59
+ clear(): void;
60
+ getCartProducts(): Product[];
61
+ }
62
+
63
+ // https://go.mparticle.com/work/SQDSDKS-5196
64
+ export type UserAttributes = AllUserAttributes;
@@ -3,7 +3,7 @@ import { Dictionary, parseNumber, isObject, generateHash } from './utils';
3
3
  import { BaseVault } from './vault';
4
4
  import Types from './types';
5
5
  import { IdentityApiData, UserIdentities, IdentityCallback } from '@mparticle/web-sdk';
6
- import { IdentityAPIMethod, MParticleWebSDK } from './sdkRuntimeModels';
6
+ import { IdentityAPIMethod } from './identity.interfaces';
7
7
 
8
8
  const { Identify, Modify, Login, Logout } = Constants.IdentityMethods;
9
9
 
@@ -0,0 +1,205 @@
1
+ import {
2
+ IdentityApiData,
3
+ IdentityCallback,
4
+ MPID,
5
+ UserIdentities,
6
+ } from '@mparticle/web-sdk';
7
+ import AudienceManager from './audienceManager';
8
+ import { ICachedIdentityCall, IKnownIdentities } from './identity-utils';
9
+ import { BaseVault } from './vault';
10
+ import { Dictionary, Environment, valueof } from './utils';
11
+ import Constants from './constants';
12
+ import {
13
+ IUserAttributeChangeEvent,
14
+ IUserIdentityChangeEvent,
15
+ IMParticleUser,
16
+ mParticleUserCart,
17
+ } from './identity-user-interfaces';
18
+ const { platform, sdkVendor, sdkVersion, HTTPCodes } = Constants;
19
+
20
+ export type IdentityPreProcessResult = {
21
+ valid: boolean;
22
+ error?: string;
23
+ };
24
+
25
+ export type IdentityAPIMethod = valueof<typeof Constants.IdentityMethods>;
26
+
27
+ export enum SDKIdentityTypeEnum {
28
+ other = 'other',
29
+ customerId = 'customerid',
30
+ facebook = 'facebook',
31
+ twitter = 'twitter',
32
+ google = 'google',
33
+ microsoft = 'microsoft',
34
+ yahoo = 'yahoo',
35
+ email = 'email',
36
+ alias = 'alias',
37
+ facebookCustomAudienceId = 'facebookcustomaudienceid',
38
+ otherId2 = 'other2',
39
+ otherId3 = 'other3',
40
+ otherId4 = 'other4',
41
+ otherId5 = 'other5',
42
+ otherId6 = 'other6',
43
+ otherId7 = 'other7',
44
+ otherId8 = 'other8',
45
+ otherId9 = 'other9',
46
+ otherId10 = 'other10',
47
+ mobileNumber = 'mobile_number',
48
+ phoneNumber2 = 'phone_number_2',
49
+ phoneNumber3 = 'phone_number_3',
50
+ }
51
+
52
+ export interface IIdentityAPIRequestData {
53
+ client_sdk: {
54
+ platform: typeof platform;
55
+ sdk_vendor: typeof sdkVendor;
56
+ sdk_version: typeof sdkVersion;
57
+ };
58
+ context: string | null;
59
+ environment: Environment;
60
+ request_id: string;
61
+ reqest_timestamp_unixtime_ms: number;
62
+ previous_mpid: MPID | null;
63
+ known_identities: IKnownIdentities;
64
+ }
65
+
66
+ export interface IIdentityAPIModifyRequestData
67
+ extends Omit<
68
+ IIdentityAPIRequestData,
69
+ 'known_identities' | 'previous_mpid'
70
+ > {
71
+ identity_changes: IIdentityAPIIdentityChangeData[];
72
+ }
73
+
74
+ export interface IIdentityAPIIdentityChangeData {
75
+ identity_type: SDKIdentityTypeEnum;
76
+ old_value: string;
77
+ new_value: string;
78
+ }
79
+
80
+ export interface IIdentityRequest {
81
+ createIdentityRequest(
82
+ identityApiData: IdentityApiData,
83
+ platform: string,
84
+ sdkVendor: string,
85
+ sdkVersion: string,
86
+ deviceId: string,
87
+ context: string | null,
88
+ mpid: MPID
89
+ ): IIdentityAPIRequestData;
90
+ createModifyIdentityRequest(
91
+ currentUserIdentities: UserIdentities,
92
+ newUserIdentities: UserIdentities,
93
+ platform: string,
94
+ sdkVendor: string,
95
+ sdkVersion: string,
96
+ context: string | null
97
+ ): IIdentityAPIModifyRequestData;
98
+ createIdentityChanges(
99
+ previousIdentities: UserIdentities,
100
+ newIdentitie: UserIdentities
101
+ ): IIdentityAPIIdentityChangeData;
102
+ preProcessIdentityRequest(
103
+ identityApiData: IdentityApiData,
104
+ callback: IdentityCallback,
105
+ method: IdentityAPIMethod
106
+ ): IdentityPreProcessResult;
107
+ }
108
+
109
+ export interface IAliasRequest {
110
+ destinationMpid: MPID;
111
+ sourceMpid: MPID;
112
+ startTime: number;
113
+ endTime: number;
114
+ scope?: string;
115
+ }
116
+
117
+ export interface SDKIdentityApi {
118
+ HTTPCodes: typeof HTTPCodes;
119
+ identify?(
120
+ identityApiData?: IdentityApiData,
121
+ callback?: IdentityCallback
122
+ ): void;
123
+ login?(
124
+ identityApiData?: IdentityApiData,
125
+ callback?: IdentityCallback
126
+ ): void;
127
+ logout?(
128
+ identityApiData?: IdentityApiData,
129
+ callback?: IdentityCallback
130
+ ): void;
131
+ modify?(
132
+ identityApiData?: IdentityApiData,
133
+ callback?: IdentityCallback
134
+ ): void;
135
+ getCurrentUser?(): IMParticleUser;
136
+ getUser?(mpid: string): IMParticleUser;
137
+ getUsers?(): IMParticleUser[];
138
+ aliasUsers?(
139
+ aliasRequest?: IAliasRequest,
140
+ callback?: IdentityCallback
141
+ ): void;
142
+ createAliasRequest?(
143
+ sourceUser: IMParticleUser,
144
+ destinationUser: IMParticleUser
145
+ ): IAliasRequest;
146
+ }
147
+
148
+ export interface IIdentity {
149
+ audienceManager: AudienceManager;
150
+ idCache: BaseVault<Dictionary<ICachedIdentityCall>>;
151
+
152
+ IdentityAPI: SDKIdentityApi;
153
+ IdentityRequest: IIdentityRequest;
154
+
155
+ mParticleUser(mpid: MPID, IsLoggedIn: boolean): IMParticleUser;
156
+
157
+ checkIdentitySwap(
158
+ previousMPID: MPID,
159
+ currentMPID: MPID,
160
+ currentSessionMPIDs?: MPID[]
161
+ ): void;
162
+ createUserAttributeChange(
163
+ key: string,
164
+ newValue: string,
165
+ previousUserAttributeValue: string,
166
+ isNewAttribute: boolean,
167
+ deleted: boolean,
168
+ user: IMParticleUser
169
+ ): IUserAttributeChangeEvent;
170
+ createUserIdentityChange(
171
+ identityType: SDKIdentityTypeEnum,
172
+ newIdentity: string,
173
+ oldIdentity: string,
174
+ newCreatedThisBatch: boolean,
175
+ userInMemory: IMParticleUser
176
+ ): IUserIdentityChangeEvent;
177
+ parseIdentityResponse(
178
+ xhr: XMLHttpRequest,
179
+ previousMPID: MPID,
180
+ callback: IdentityCallback,
181
+ identityApiData: IdentityApiData,
182
+ method: IdentityAPIMethod,
183
+ knownIdentities: UserIdentities,
184
+ parsingCachedResponse: boolean
185
+ ): void;
186
+ sendUserAttributeChangeEvent(
187
+ attributeKey: string,
188
+ newUserAttributeValue: string,
189
+ previousUserAttributeValue: string,
190
+ isNewAttribute: boolean,
191
+ deleted: boolean,
192
+ user: IMParticleUser
193
+ ): void;
194
+ sendUserIdentityChangeEvent(
195
+ newUserIdentities: UserIdentities,
196
+ method: IdentityAPIMethod,
197
+ mpid: MPID,
198
+ prevUserIdentities: UserIdentities
199
+ ): void;
200
+
201
+ /**
202
+ * @deprecated
203
+ */
204
+ mParticleUserCart(mpid: MPID): mParticleUserCart;
205
+ }
package/src/identity.js CHANGED
@@ -1272,6 +1272,7 @@ export default function Identity(mpInstance) {
1272
1272
  * @method getuserAudiences
1273
1273
  * @param {Function} [callback] A callback function that is invoked when the user audience request completes
1274
1274
  */
1275
+ // https://go.mparticle.com/work/SQDSDKS-6436
1275
1276
  getUserAudiences: function(callback) {
1276
1277
  // user audience API is feature flagged
1277
1278
  if (
@@ -1829,6 +1830,7 @@ export default function Identity(mpInstance) {
1829
1830
  ) {
1830
1831
  var userIdentityChangeEvent;
1831
1832
 
1833
+ // https://go.mparticle.com/work/SQDSDKS-6439
1832
1834
  userIdentityChangeEvent = mpInstance._ServerModel.createEventObject({
1833
1835
  messageType: Types.MessageType.UserIdentityChange,
1834
1836
  userIdentityChanges: {
@@ -1883,6 +1885,7 @@ export default function Identity(mpInstance) {
1883
1885
  }
1884
1886
  var userAttributeChangeEvent;
1885
1887
  if (newValue !== previousUserAttributeValue) {
1888
+ // https://go.mparticle.com/work/SQDSDKS-6439
1886
1889
  userAttributeChangeEvent = mpInstance._ServerModel.createEventObject(
1887
1890
  {
1888
1891
  messageType: Types.MessageType.UserAttributeChange,
@@ -14,6 +14,7 @@ import {
14
14
  SessionAttributes,
15
15
  } from './store';
16
16
  import { Dictionary } from './utils';
17
+ import { UserAttributes } from './identity-user-interfaces';
17
18
 
18
19
  export type CookieSyncDate = Dictionary<string>;
19
20
  export type UploadsTable = Dictionary<any>;
@@ -22,10 +23,6 @@ export interface iForwardingStatsBatches {
22
23
  forwardingStatsEventQueue: ForwardingStatsData[];
23
24
  }
24
25
 
25
- // TODO: Migrate this to @types/mparticle__web-sdk
26
- // https://go.mparticle.com/work/SQDSDKS-5196
27
- export type UserAttributes = AllUserAttributes;
28
-
29
26
  export interface IGlobalStoreV2MinifiedKeys {
30
27
  sid: string; // Session ID
31
28
  ie: boolean; // Is Enabled
@@ -1,14 +1,9 @@
1
1
  import * as EventsApi from '@mparticle/event-models';
2
2
  import { DataPlanVersion } from '@mparticle/data-planning-models';
3
- import {
4
- MPConfiguration,
5
- IdentityApiData,
6
- MPID,
7
- Callback,
8
- } from '@mparticle/web-sdk';
3
+ import { MPConfiguration, MPID, Callback } from '@mparticle/web-sdk';
9
4
  import { IStore } from './store';
10
5
  import Validators from './validators';
11
- import { Dictionary, valueof } from './utils';
6
+ import { Dictionary } from './utils';
12
7
  import { IServerModel } from './serverModel';
13
8
  import { IKitConfigs } from './configAPIClient';
14
9
  import { SDKConsentApi, SDKConsentState } from './consent';
@@ -16,7 +11,13 @@ import { IPersistence } from './persistence.interfaces';
16
11
  import { IMPSideloadedKit } from './sideloadedKit';
17
12
  import { ISessionManager } from './sessionManager';
18
13
  import { Kit, MPForwarder } from './forwarders.interfaces';
19
- import Constants from './constants';
14
+ import { SDKIdentityApi } from './identity.interfaces';
15
+ import {
16
+ ISDKUserAttributeChangeData,
17
+ ISDKUserIdentityChanges,
18
+ IMParticleUser,
19
+ ISDKUserIdentity,
20
+ } from './identity-user-interfaces';
20
21
 
21
22
  // TODO: Resolve this with version in @mparticle/web-sdk
22
23
  export type SDKEventCustomFlags = Dictionary<any>;
@@ -27,7 +28,7 @@ export interface SDKEvent {
27
28
  EventName: string;
28
29
  EventCategory: number;
29
30
  UserAttributes?: { [key: string]: string | string[] | null };
30
- UserIdentities?: SDKUserIdentity[];
31
+ UserIdentities?: ISDKUserIdentity[];
31
32
  SourceMessageId: string;
32
33
  MPID: string;
33
34
  EventAttributes?: { [key: string]: string };
@@ -51,15 +52,12 @@ export interface SDKEvent {
51
52
  PromotionAction?: SDKPromotionAction;
52
53
  ProductImpressions?: SDKProductImpression[];
53
54
  ShoppingCart?: SDKShoppingCart;
54
- UserIdentityChanges?: SDKUserIdentityChangeData;
55
- UserAttributeChanges?: SDKUserAttributeChangeData;
55
+ UserIdentityChanges?: ISDKUserIdentityChanges;
56
+ UserAttributeChanges?: ISDKUserAttributeChangeData;
56
57
  CurrencyCode: string;
57
58
  DataPlan?: SDKDataPlan;
58
59
  LaunchReferral?: string;
59
60
  }
60
-
61
- export type IdentityAPIMethod = valueof<typeof Constants.IdentityMethods>;
62
-
63
61
  export interface SDKGeoLocation {
64
62
  lat: number | string;
65
63
  lng: number | string;
@@ -70,11 +68,6 @@ export interface SDKDataPlan {
70
68
  PlanId?: string | null;
71
69
  }
72
70
 
73
- export interface SDKUserIdentity {
74
- Identity?: string;
75
- Type: number;
76
- }
77
-
78
71
  export interface SDKShoppingCart {
79
72
  ProductList?: SDKProduct[];
80
73
  }
@@ -239,16 +232,6 @@ export interface DataPlanConfig {
239
232
  document?: DataPlanResult; // when the data plan comes from the server via /mparticle.js
240
233
  }
241
234
 
242
- export interface SDKIdentityApi {
243
- getCurrentUser();
244
- IdentityAPI;
245
- identify;
246
- login;
247
- logout;
248
- modify;
249
- getUser(mpid: string): MParticleUser;
250
- }
251
-
252
235
  export interface SDKHelpersApi {
253
236
  canLog?(): boolean;
254
237
  createMainStorageName?(workspaceToken: string): string;
@@ -271,7 +254,7 @@ export interface SDKHelpersApi {
271
254
  callback: Callback,
272
255
  code: string,
273
256
  body: string,
274
- mParticleUser?: MParticleUser,
257
+ mParticleUser?: IMParticleUser,
275
258
  previousMpid?: MPID
276
259
  ): void;
277
260
  sanitizeAttributes?(
@@ -304,35 +287,6 @@ export interface SDKConfigApi {
304
287
  onCreateBatch(batch: EventsApi.Batch): EventsApi.Batch;
305
288
  }
306
289
 
307
- // FIXME: Resolve with User in @types/mparticle-web-sdk
308
- // https://go.mparticle.com/work/SQDSDKS-5033
309
- export interface MParticleUser {
310
- getMPID(): string;
311
- getConsentState(): SDKConsentState;
312
- getAllUserAttributes(): any; // FIXME;
313
- getUserIdentities(): IdentityApiData; // FIXME: Is this correct?
314
- }
315
-
316
- export interface SDKUserIdentityChangeData {
317
- New: Identity;
318
- Old: Identity;
319
- }
320
-
321
- export interface Identity {
322
- IdentityType: SDKIdentityTypeEnum;
323
- Identity: string;
324
- Timestamp: number;
325
- CreatedThisBatch: boolean;
326
- }
327
-
328
- export interface SDKUserAttributeChangeData {
329
- UserAttributeName: string;
330
- New: string;
331
- Old: string;
332
- Deleted: boolean;
333
- IsNewAttribute: boolean;
334
- }
335
-
336
290
  export interface BaseEvent {
337
291
  messageType: number;
338
292
  name?: string;
@@ -341,8 +295,8 @@ export interface BaseEvent {
341
295
  customFlags?: { [key: string]: string };
342
296
  toEventAPIObject?(): SDKEvent;
343
297
  sourceMessageId?: string;
344
- userAttributeChanges?: SDKUserAttributeChangeData;
345
- userIdentityChanges?: SDKUserIdentityChangeData;
298
+ userAttributeChanges?: ISDKUserAttributeChangeData;
299
+ userIdentityChanges?: ISDKUserIdentityChanges;
346
300
  }
347
301
 
348
302
  export interface KitBlockerOptions {
@@ -369,28 +323,3 @@ export interface DataPlanResult {
369
323
  };
370
324
  error_message?: string;
371
325
  }
372
-
373
- export enum SDKIdentityTypeEnum {
374
- other = 'other',
375
- customerId = 'customerid',
376
- facebook = 'facebook',
377
- twitter = 'twitter',
378
- google = 'google',
379
- microsoft = 'microsoft',
380
- yahoo = 'yahoo',
381
- email = 'email',
382
- alias = 'alias',
383
- facebookCustomAudienceId = 'facebookcustomaudienceid',
384
- otherId2 = 'other2',
385
- otherId3 = 'other3',
386
- otherId4 = 'other4',
387
- otherId5 = 'other5',
388
- otherId6 = 'other6',
389
- otherId7 = 'other7',
390
- otherId8 = 'other8',
391
- otherId9 = 'other9',
392
- otherId10 = 'other10',
393
- mobileNumber = 'mobile_number',
394
- phoneNumber2 = 'phone_number_2',
395
- phoneNumber3 = 'phone_number_3',
396
- }
@@ -3,10 +3,8 @@ import {
3
3
  SDKGeoLocation,
4
4
  SDKProduct,
5
5
  SDKPromotion,
6
- SDKUserIdentity,
7
6
  SDKProductActionType,
8
7
  MParticleWebSDK,
9
- SDKIdentityTypeEnum,
10
8
  } from './sdkRuntimeModels';
11
9
  import * as EventsApi from '@mparticle/event-models';
12
10
  import {
@@ -16,6 +14,8 @@ import {
16
14
  } from './consent';
17
15
  import Types from './types';
18
16
  import { isEmpty } from './utils';
17
+ import { ISDKUserIdentity } from './identity-user-interfaces';
18
+ import { SDKIdentityTypeEnum } from './identity.interfaces';
19
19
 
20
20
  export function convertEvents(
21
21
  mpid: string,
@@ -151,7 +151,7 @@ export function convertCcpaConsentState(
151
151
  }
152
152
 
153
153
  export function convertUserIdentities(
154
- sdkUserIdentities?: SDKUserIdentity[]
154
+ sdkUserIdentities?: ISDKUserIdentity[]
155
155
  ): EventsApi.BatchUserIdentities | null {
156
156
  if (!sdkUserIdentities || !sdkUserIdentities.length) {
157
157
  return null;
@@ -407,8 +407,9 @@ export function convertShoppingCart(
407
407
  export function convertCommerceEvent(
408
408
  sdkEvent: SDKEvent
409
409
  ): EventsApi.CommerceEvent {
410
- const commonEventData: EventsApi.CommonEventData =
411
- convertBaseEventData(sdkEvent);
410
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
411
+ sdkEvent
412
+ );
412
413
  let commerceEventData: EventsApi.CommerceEventData = {
413
414
  custom_flags: sdkEvent.CustomFlags,
414
415
  product_action: convertProductAction(sdkEvent),
@@ -427,8 +428,9 @@ export function convertCommerceEvent(
427
428
  export function convertCrashReportEvent(
428
429
  sdkEvent: SDKEvent
429
430
  ): EventsApi.CrashReportEvent {
430
- const commonEventData: EventsApi.CommonEventData =
431
- convertBaseEventData(sdkEvent);
431
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
432
+ sdkEvent
433
+ );
432
434
  let crashReportEventData: EventsApi.CrashReportEventData = {
433
435
  message: sdkEvent.EventName,
434
436
  };
@@ -442,8 +444,9 @@ export function convertCrashReportEvent(
442
444
  export function convertAST(
443
445
  sdkEvent: SDKEvent
444
446
  ): EventsApi.ApplicationStateTransitionEvent {
445
- const commonEventData: EventsApi.CommonEventData =
446
- convertBaseEventData(sdkEvent);
447
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
448
+ sdkEvent
449
+ );
447
450
  let astEventData: EventsApi.ApplicationStateTransitionEventData = {
448
451
  application_transition_type:
449
452
  EventsApi
@@ -463,8 +466,9 @@ export function convertAST(
463
466
  export function convertSessionEndEvent(
464
467
  sdkEvent: SDKEvent
465
468
  ): EventsApi.SessionEndEvent {
466
- const commonEventData: EventsApi.CommonEventData =
467
- convertBaseEventData(sdkEvent);
469
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
470
+ sdkEvent
471
+ );
468
472
  let sessionEndEventData: EventsApi.SessionEndEventData = {
469
473
  session_duration_ms: sdkEvent.SessionLength,
470
474
  //note: External Events DTO does not support the session mpids array as of this time.
@@ -480,8 +484,9 @@ export function convertSessionEndEvent(
480
484
  export function convertSessionStartEvent(
481
485
  sdkEvent: SDKEvent
482
486
  ): EventsApi.SessionStartEvent {
483
- const commonEventData: EventsApi.CommonEventData =
484
- convertBaseEventData(sdkEvent);
487
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
488
+ sdkEvent
489
+ );
485
490
  let sessionStartEventData: EventsApi.SessionStartEventData = {};
486
491
  sessionStartEventData = Object.assign(
487
492
  sessionStartEventData,
@@ -496,8 +501,9 @@ export function convertSessionStartEvent(
496
501
  export function convertPageViewEvent(
497
502
  sdkEvent: SDKEvent
498
503
  ): EventsApi.ScreenViewEvent {
499
- const commonEventData: EventsApi.CommonEventData =
500
- convertBaseEventData(sdkEvent);
504
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
505
+ sdkEvent
506
+ );
501
507
  let screenViewEventData: EventsApi.ScreenViewEventData = {
502
508
  custom_flags: sdkEvent.CustomFlags,
503
509
  screen_name: sdkEvent.EventName,
@@ -510,8 +516,9 @@ export function convertPageViewEvent(
510
516
  }
511
517
 
512
518
  export function convertOptOutEvent(sdkEvent: SDKEvent): EventsApi.OptOutEvent {
513
- const commonEventData: EventsApi.CommonEventData =
514
- convertBaseEventData(sdkEvent);
519
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
520
+ sdkEvent
521
+ );
515
522
  let optOutEventData: EventsApi.OptOutEventData = {
516
523
  is_opted_out: sdkEvent.OptOut,
517
524
  };
@@ -523,8 +530,9 @@ export function convertOptOutEvent(sdkEvent: SDKEvent): EventsApi.OptOutEvent {
523
530
  }
524
531
 
525
532
  export function convertCustomEvent(sdkEvent: SDKEvent): EventsApi.CustomEvent {
526
- const commonEventData: EventsApi.CommonEventData =
527
- convertBaseEventData(sdkEvent);
533
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
534
+ sdkEvent
535
+ );
528
536
  let customEventData: EventsApi.CustomEventData = {
529
537
  custom_event_type: convertSdkEventType(
530
538
  sdkEvent.EventCategory
@@ -628,8 +636,9 @@ export function convertSDKLocation(
628
636
  export function convertUserAttributeChangeEvent(
629
637
  sdkEvent: SDKEvent
630
638
  ): EventsApi.UserAttributeChangeEvent | null {
631
- const commonEventData: EventsApi.CommonEventData =
632
- convertBaseEventData(sdkEvent);
639
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
640
+ sdkEvent
641
+ );
633
642
  let userAttributeChangeEvent: EventsApi.UserAttributeChangeEventData = {
634
643
  user_attribute_name: sdkEvent.UserAttributeChanges.UserAttributeName,
635
644
  new: sdkEvent.UserAttributeChanges.New,
@@ -652,8 +661,9 @@ export function convertUserAttributeChangeEvent(
652
661
  export function convertUserIdentityChangeEvent(
653
662
  sdkEvent: SDKEvent
654
663
  ): EventsApi.UserIdentityChangeEvent | null {
655
- const commonEventData: EventsApi.CommonEventData =
656
- convertBaseEventData(sdkEvent);
664
+ const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
665
+ sdkEvent
666
+ );
657
667
 
658
668
  let userIdentityChangeEvent: EventsApi.UserIdentityChangeEventData = {
659
669
  new: {
@@ -6,12 +6,10 @@ import Types from './types';
6
6
  import Constants from './constants';
7
7
  import {
8
8
  BaseEvent,
9
- MParticleUser,
10
9
  MParticleWebSDK,
11
10
  SDKEvent,
12
11
  SDKGeoLocation,
13
12
  SDKProduct,
14
- SDKUserIdentity,
15
13
  } from './sdkRuntimeModels';
16
14
  import {
17
15
  parseNumber,
@@ -27,6 +25,7 @@ import {
27
25
  IPrivacyV2DTO,
28
26
  SDKConsentState,
29
27
  } from './consent';
28
+ import { IMParticleUser, ISDKUserIdentity } from './identity-user-interfaces';
30
29
 
31
30
  const MessageType = Types.MessageType;
32
31
  const ApplicationTransitionType = Types.ApplicationTransitionType;
@@ -48,7 +47,7 @@ export interface IServerV2DTO {
48
47
  n?: string;
49
48
  et?: number;
50
49
  ua?: Dictionary<string | string[]>;
51
- ui?: SDKUserIdentity[];
50
+ ui?: ISDKUserIdentity[];
52
51
  ia?: Dictionary<Dictionary<string>>;
53
52
  str?: ServerSettings;
54
53
  sdk?: string;
@@ -135,9 +134,9 @@ export interface IUploadObject extends SDKEvent {
135
134
 
136
135
  export interface IServerModel {
137
136
  convertEventToV2DTO: (event: IUploadObject) => IServerV2DTO;
138
- createEventObject: (event: BaseEvent, user?: MParticleUser) => SDKEvent;
137
+ createEventObject: (event: BaseEvent, user?: IMParticleUser) => SDKEvent;
139
138
  convertToConsentStateV2DTO: (state: SDKConsentState) => IConsentStateV2DTO;
140
- appendUserInfo: (user: MParticleUser, event: SDKEvent) => void;
139
+ appendUserInfo: (user: IMParticleUser, event: SDKEvent) => void;
141
140
  }
142
141
 
143
142
  // TODO: Make this a pure function that returns a new object
@@ -199,7 +198,10 @@ export default function ServerModel(
199
198
  var self = this;
200
199
 
201
200
  // TODO: Can we refactor this to not mutate the event?
202
- this.appendUserInfo = function(user: MParticleUser, event: SDKEvent): void {
201
+ this.appendUserInfo = function(
202
+ user: IMParticleUser,
203
+ event: SDKEvent
204
+ ): void {
203
205
  if (!event) {
204
206
  return;
205
207
  }
@@ -230,7 +232,7 @@ export default function ServerModel(
230
232
  if (mpInstance._Helpers.isObject(dtoUserIdentities)) {
231
233
  if (Object.keys(dtoUserIdentities).length) {
232
234
  for (var key in dtoUserIdentities) {
233
- var userIdentity: Partial<SDKUserIdentity> = {};
235
+ var userIdentity: Partial<ISDKUserIdentity> = {};
234
236
  userIdentity.Identity = dtoUserIdentities[key];
235
237
  userIdentity.Type = mpInstance._Helpers.parseNumber(key);
236
238
  validUserIdentities.push(userIdentity);
@@ -292,7 +294,7 @@ export default function ServerModel(
292
294
 
293
295
  this.createEventObject = function(
294
296
  event: BaseEvent,
295
- user?: MParticleUser
297
+ user?: IMParticleUser
296
298
  ): SDKEvent | IUploadObject {
297
299
  var uploadObject: Partial<IUploadObject> = {};
298
300
  var eventObject: Partial<SDKEvent> = {};
@@ -1,9 +1,10 @@
1
1
  import { MPID } from '@mparticle/web-sdk';
2
2
  import Constants from './constants';
3
3
  import { IPersistenceMinified } from './persistence.interfaces';
4
- import { MParticleUser, MParticleWebSDK } from './sdkRuntimeModels';
4
+ import { MParticleWebSDK } from './sdkRuntimeModels';
5
5
  import Types from './types';
6
6
  import { generateDeprecationMessage } from './utils';
7
+ import { IMParticleUser } from './identity-user-interfaces';
7
8
 
8
9
  const { Messages } = Constants;
9
10
 
@@ -86,7 +87,7 @@ export default function SessionManager(
86
87
  .generateUniqueId()
87
88
  .toUpperCase();
88
89
 
89
- const currentUser: MParticleUser = mpInstance.Identity.getCurrentUser();
90
+ const currentUser: IMParticleUser = mpInstance.Identity.getCurrentUser();
90
91
  const mpid: MPID = currentUser ? currentUser.getMPID() : null;
91
92
 
92
93
  if (mpid) {
package/src/utils.ts CHANGED
@@ -7,6 +7,8 @@ type valueof<T> = T[keyof T];
7
7
  // Placeholder for Dictionary-like Types
8
8
  export type Dictionary<V = any> = Record<string, V>;
9
9
 
10
+ export type Environment = 'development' | 'production';
11
+
10
12
  const createCookieString = (value: string): string =>
11
13
  replaceCommasWithPipes(replaceQuotesWithApostrophes(value));
12
14
 
package/src/validators.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  } from './utils';
9
9
  import Constants from './constants';
10
10
  import { IdentityApiData } from '@mparticle/web-sdk';
11
- import { IdentityAPIMethod } from './sdkRuntimeModels';
11
+ import { IdentityAPIMethod } from './identity.interfaces';
12
12
 
13
13
  type ValidationIdentitiesReturn = {
14
14
  valid: boolean;