@mparticle/web-sdk 3.13.0 → 3.14.0

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.
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
15
15
  filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
16
16
  isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
17
17
 
18
- var version = "3.13.0";
18
+ var version = "3.14.0";
19
19
 
20
20
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"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",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",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,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
21
21
  },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/"},// These are the paths that are used to construct the CNAME urls
@@ -465,10 +465,49 @@ var dist = {};
465
465
 
466
466
  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={}));
467
467
 
468
- var FeatureFlags$2=Constants.FeatureFlags,CaptureIntegrationSpecificIds$1=FeatureFlags$2.CaptureIntegrationSpecificIds,CaptureIntegrationSpecificIdsV2$1=FeatureFlags$2.CaptureIntegrationSpecificIdsV2;function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c._IntegrationCapture,f=c._Helpers,g=f.getFeatureFlag,h=c.Identity.getCurrentUser(),i=[],j=null,k=0,l=b;k<l.length;k++)if(d=l[k],d){j=d;var m=convertEvent(d);m&&i.push(m);}if(!j)return null;var n=null;// Add the consent state from either the Last Event or the user
468
+ // The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
469
+ // - version is always this prefix: fb
470
+ // - subdomainIndex is which domain the cookie is defined on ('com' = 0, 'example.com' = 1, 'www.example.com' = 2)
471
+ // - creationTime is the UNIX time since epoch in milliseconds when the _fbc was stored. If you don't save the _fbc cookie, use the timestamp when you first observed or received this fbclid value
472
+ // - <fbclid> is the value for the fbclid query parameter in the page URL.
473
+ // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc
474
+ var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b||void 0===b?void 0:b.split("//");if(!d)return "";var e=d[1].split("/"),f=e[0].split("."),g=1;// The rules for subdomainIndex are for parsing the domain portion
475
+ // of the URL for cookies, but in this case we are parsing the URL
476
+ // itself, so we can ignore the use of 0 for 'com'
477
+ 3<=f.length&&(g=2);// If timestamp is not provided, use the current time
478
+ var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};// Integration outputs are used to determine how click ids are used within the SDK
479
+ // CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
480
+ // PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
481
+ // INTEGRATION_ATTRIBUTES are stored initially on the SDKEvent level but then is added to the Batch when the batch is created
482
+ var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_identities",INTEGRATION_ATTRIBUTES:"integration_attributes"},integrationMappingExternal={// Facebook / Meta
483
+ fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor,output:IntegrationOutputs.CUSTOM_FLAGS},_fbp:{mappedKey:"Facebook.BrowserId",output:IntegrationOutputs.CUSTOM_FLAGS},_fbc:{mappedKey:"Facebook.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS},// Google
484
+ gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},// TIKTOK
485
+ ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES},// Snapchat
486
+ // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
487
+ ScCid:{mappedKey:"SnapchatConversions.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS},// Pinterest
488
+ // https://developers.pinterest.com/docs/track-conversions/track-conversions-in-the-api/
489
+ // https://help.pinterest.com/en/business/article/pinterest-tag-parameters-and-cookies
490
+ epik:{mappedKey:"Pinterest.click_id",output:IntegrationOutputs.CUSTOM_FLAGS},_epik:{mappedKey:"Pinterest.click_id",output:IntegrationOutputs.CUSTOM_FLAGS},// Snapchat
491
+ // https://developers.snap.com/api/marketing-api/Conversions-API/UsingTheAPI#sending-click-id
492
+ _scid:{mappedKey:"SnapchatConversions.Cookie1",output:IntegrationOutputs.CUSTOM_FLAGS}},integrationMappingRokt={// Rokt
493
+ // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
494
+ // https://go.mparticle.com/work/SQDSDKS-7167
495
+ rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},rclid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277}};function isIntegrationCaptureEnabled(a){if(!a)return !1;var b=a(Constants.FeatureFlags.CaptureIntegrationSpecificIds),c=a(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2);return !!c&&c!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===b}var IntegrationCapture=/** @class */function(){function a(a){this.initialTimestamp=Date.now(),this.captureMode=a,this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
496
+ * Captures Integration Ids from cookies and query params and stores them in clickIds object
497
+ */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};this.normalizePinterestClickId(a),this.normalizePinterestClickId(c),this.normalizePinterestClickId(b),this.applySourcePrecedence([a,c,b,this.clickIds||{}]),this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),b),c),a);},a.prototype.captureCookies=function(){var a=this.getAllowedKeysForMode(),b=getCookies(a);return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){for(var a=this.getAllowedKeysForMode(),b={},c=0,d=a;c<d.length;c++){var e=d[c],f=localStorage.getItem(e);f&&(b[e]=f);}return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){var a=this.getAllowedKeysForMode();return queryStringParser(getHref(),a)},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
498
+ // {
499
+ // "integration_attributes": {
500
+ // "<moduleId>": {
501
+ // "mappedKey": "clickIdValue"
502
+ // }
503
+ // }
504
+ // }
505
+ for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.normalizePinterestClickId=function(a){isEmpty(null===a||void 0===a?void 0:a._epik)||isEmpty(null===a||void 0===a?void 0:a.epik)||delete a.epik;},a.prototype.applySourcePrecedence=function(a){for(var b=this.getActiveIntegrationMapping(),c=function outputOf(a){var c;return (null===(c=b[a])||void 0===c?void 0:c.mappedKey)||a},d=[],e=0,f=a;e<f.length;e++){var g=f[e],h=[];for(var i in g){var j=c(i);-1===d.indexOf(j)?!isEmpty(g[i])&&h.push(j):delete g[i];}d.push.apply(d,h);}},a.prototype.applyProcessors=function(a,b,c){var d,e={},f=this.getActiveIntegrationMapping();for(var g in a)if(a.hasOwnProperty(g)){var h=a[g],i=null===(d=f[g])||void 0===d?void 0:d.processor;e[g]=i?i(h,b,c):h;}return e},a.prototype.filterMappings=function(a){var b={},c=this.getActiveIntegrationMapping();for(var d in c)c[d].output===a&&(b[d]=c[d]);return b},a.prototype.getAllowedKeysForMode=function(){return Object.keys(this.getActiveIntegrationMapping())},a.prototype.getActiveIntegrationMapping=function(){return this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly?integrationMappingRokt:this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.All?__assign(__assign({},integrationMappingExternal),integrationMappingRokt):{}},a}();
506
+
507
+ function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c._IntegrationCapture,f=c._Helpers,g=f.getFeatureFlag,h=c.Identity.getCurrentUser(),i=[],j=null,k=0,l=b;k<l.length;k++)if(d=l[k],d){j=d;var m=convertEvent(d);m&&i.push(m);}if(!j)return null;var n=null;// Add the consent state from either the Last Event or the user
469
508
  isEmpty(j.ConsentState)?!isEmpty(h)&&(n=h.getConsentState()):n=j.ConsentState;var o={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:j.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:i,mp_deviceid:j.DeviceId,sdk_version:j.SDKVersion,// TODO: Refactor this to read from _Store or a global config
470
- application_info:{application_version:j.AppVersion,application_name:j.AppName,package:j.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.width:0,screen_height:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.height:0},user_attributes:j.UserAttributes,user_identities:convertUserIdentities(j.UserIdentities),consent_state:convertConsentState(n),integration_attributes:j.IntegrationAttributes};j.DataPlan&&j.DataPlan.PlanId&&(o.context={data_plan:{plan_id:j.DataPlan.PlanId,plan_version:j.DataPlan.PlanVersion||void 0}});// https://go.mparticle.com/work/SQDSDKS-7639
471
- var p=g&&!!g(CaptureIntegrationSpecificIds$1),q=g&&g(CaptureIntegrationSpecificIdsV2$1),r=q&&q!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===p;if(r){null===e||void 0===e?void 0:e.capture();var s=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(s)||(o.partner_identities=s);}return o}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
509
+ application_info:{application_version:j.AppVersion,application_name:j.AppName,package:j.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.width:0,screen_height:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.height:0},user_attributes:j.UserAttributes,user_identities:convertUserIdentities(j.UserIdentities),consent_state:convertConsentState(n),integration_attributes:j.IntegrationAttributes};// https://go.mparticle.com/work/SQDSDKS-7639
510
+ if(j.DataPlan&&j.DataPlan.PlanId&&(o.context={data_plan:{plan_id:j.DataPlan.PlanId,plan_version:j.DataPlan.PlanVersion||void 0}}),isIntegrationCaptureEnabled(g)){null===e||void 0===e?void 0:e.capture();var p=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(p)||(o.partner_identities=p);}return o}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
472
511
  return convertCustomEvent(a);case Types.MessageType.PageView:return convertPageViewEvent(a);case Types.MessageType.Profile://deprecated and not supported by the web SDK
473
512
  return null;case Types.MessageType.SessionEnd:return convertSessionEndEvent(a);case Types.MessageType.SessionStart:return convertSessionStartEvent(a);case Types.MessageType.UserAttributeChange:return convertUserAttributeChangeEvent(a);case Types.MessageType.UserIdentityChange:return convertUserIdentityChangeEvent(a);}return null}function convertProductActionType(a){if(!a)return dist.ProductActionActionEnum.unknown;return a===SDKProductActionType.AddToCart?dist.ProductActionActionEnum.addToCart:a===SDKProductActionType.AddToWishlist?dist.ProductActionActionEnum.addToWishlist:a===SDKProductActionType.Checkout?dist.ProductActionActionEnum.checkout:a===SDKProductActionType.CheckoutOption?dist.ProductActionActionEnum.checkoutOption:a===SDKProductActionType.Click?dist.ProductActionActionEnum.click:a===SDKProductActionType.Purchase?dist.ProductActionActionEnum.purchase:a===SDKProductActionType.Refund?dist.ProductActionActionEnum.refund:a===SDKProductActionType.RemoveFromCart?dist.ProductActionActionEnum.removeFromCart:a===SDKProductActionType.RemoveFromWishlist?dist.ProductActionActionEnum.removeFromWishlist:a===SDKProductActionType.ViewDetail?dist.ProductActionActionEnum.viewDetail:dist.ProductActionActionEnum.unknown}function convertProductAction(a){if(!a.ProductAction)return null;var b={action:convertProductActionType(a.ProductAction.ProductActionType),checkout_step:a.ProductAction.CheckoutStep,checkout_options:a.ProductAction.CheckoutOptions,transaction_id:a.ProductAction.TransactionId,affiliation:a.ProductAction.Affiliation,total_amount:a.ProductAction.TotalAmount,tax_amount:a.ProductAction.TaxAmount,shipping_amount:a.ProductAction.ShippingAmount,coupon_code:a.ProductAction.CouponCode,products:convertProducts(a.ProductAction.ProductList)};return b}function convertProducts(a){if(!a||!a.length)return null;for(var b=[],c=0,d=a;c<d.length;c++){var e=d[c],f={id:e.Sku,name:e.Name,brand:e.Brand,category:e.Category,variant:e.Variant,total_product_amount:e.TotalAmount,position:e.Position,price:e.Price,quantity:e.Quantity,coupon_code:e.CouponCode,custom_attributes:e.Attributes};b.push(f);}return b}function convertPromotionAction(a){if(!a.PromotionAction)return null;var b={action:a.PromotionAction.PromotionActionType,promotions:convertPromotions(a.PromotionAction.PromotionList)};return b}function convertPromotions(a){if(!a||!a.length)return null;for(var b=[],c=0,d=a;c<d.length;c++){var e=d[c],f={id:e.Id,name:e.Name,creative:e.Creative,position:e.Position};b.push(f);}return b}function convertImpressions(a){if(!a.ProductImpressions)return null;for(var b=[],c=0,d=a.ProductImpressions;c<d.length;c++){var e=d[c],f={product_impression_list:e.ProductImpressionList,products:convertProducts(e.ProductList)};b.push(f);}return b}function convertCommerceEvent(a){var b=convertBaseEventData(a),c={custom_flags:a.CustomFlags,product_action:convertProductAction(a),promotion_action:convertPromotionAction(a),product_impressions:convertImpressions(a),currency_code:a.CurrencyCode};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.commerceEvent,data:c}}function convertCrashReportEvent(a){var b=convertBaseEventData(a),c={message:a.EventName};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.crashReport,data:c}}function convertAST(a){var b=convertBaseEventData(a),c=dist.ApplicationStateTransitionEventDataApplicationTransitionTypeEnum,d=c.applicationBackground,e=c.applicationInitialized,f=a.IsBackgroundAST?d:e,g={application_transition_type:f,is_first_run:a.IsFirstRun,is_upgrade:!1,launch_referral:a.LaunchReferral};// Determine the transition type based on IsBackgroundAST flag
474
513
  return g=Object.assign(g,b),{event_type:dist.EventTypeEnum.applicationStateTransition,data:g}}function convertSessionEndEvent(a){var b=convertBaseEventData(a),c={session_duration_ms:a.SessionLength//note: External Events DTO does not support the session mpids array as of this time.
@@ -525,8 +564,8 @@ var g=null===(e=b._CookieConsentManager)||void 0===e?void 0:e.getNoFunctional();
525
564
  // TODO: Handle cases where Local Storage is unavailable
526
565
  // Potentially shared between Vault and Persistence as well
527
566
  // https://go.mparticle.com/work/SQDSDKS-5022
528
- return e>=f},a.prototype.shouldDebounceAndUpdateLastASTTime=function(){var a=Date.now();return !!(a-this.lastASTEventTime<this.AST_DEBOUNCE_MS)||(this.lastASTEventTime=a,!1)},a.prototype.createBackgroundASTEvent=function(){var a,b=Date.now(),c=this.mpInstance,d=c._Store,e=c.Identity,f=c._timeOnSiteTimer,g=c._Helpers,h=d.sessionId,i=d.deviceId,j=d.sessionStartDate,k=d.SDKConfig,l=g.generateUniqueId,m=g.getFeatureFlag,n=e.getCurrentUser,o={AppName:k.appName,AppVersion:k.appVersion,Package:k["package"],EventDataType:MessageType$1.AppStateTransition,Timestamp:b,SessionId:h,DeviceId:i,IsFirstRun:!1,SourceMessageId:l(),SDKVersion:Constants.sdkVersion,CustomFlags:{},EventAttributes:{},SessionStartDate:(null===j||void 0===j?void 0:j.getTime())||b,Debug:k.isDevelopmentMode,ActiveTimeOnSite:(null===f||void 0===f?void 0:f.getTimeInForeground())||0,TotalTimeOnSite:(null===(a=d.getTotalTimeOnSite)||void 0===a?void 0:a.call(d))||0,PageUrl:getHref()||null,IsBackgroundAST:!0},p=__assign({},o.CustomFlags),q=d.integrationAttributes,r=m(Constants.FeatureFlags.CaptureIntegrationSpecificIds),s=m(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2)||"",t=s&&s!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===r;// https://go.mparticle.com/work/SQDSDKS-5053
529
- if(t){this.mpInstance._IntegrationCapture.capture();var u=this.mpInstance._IntegrationCapture.getClickIdsAsCustomFlags();p=__assign(__assign({},u),p);var v=this.mpInstance._IntegrationCapture.getClickIdsAsIntegrationAttributes();q=__assign(__assign({},v),q);}return o.CustomFlags=p,o.IntegrationAttributes=q,appendUserInfo(n(),o),o},a.prototype.addEventListeners=function(){var a=this,b=this,c=function(){// Check for debounce before creating and queueing event
567
+ return e>=f},a.prototype.shouldDebounceAndUpdateLastASTTime=function(){var a=Date.now();return !!(a-this.lastASTEventTime<this.AST_DEBOUNCE_MS)||(this.lastASTEventTime=a,!1)},a.prototype.createBackgroundASTEvent=function(){var a,b=Date.now(),c=this.mpInstance,d=c._Store,e=c.Identity,f=c._timeOnSiteTimer,g=c._Helpers,h=d.sessionId,i=d.deviceId,j=d.sessionStartDate,k=d.SDKConfig,l=g.generateUniqueId,m=g.getFeatureFlag,n=e.getCurrentUser,o={AppName:k.appName,AppVersion:k.appVersion,Package:k["package"],EventDataType:MessageType$1.AppStateTransition,Timestamp:b,SessionId:h,DeviceId:i,IsFirstRun:!1,SourceMessageId:l(),SDKVersion:Constants.sdkVersion,CustomFlags:{},EventAttributes:{},SessionStartDate:(null===j||void 0===j?void 0:j.getTime())||b,Debug:k.isDevelopmentMode,ActiveTimeOnSite:(null===f||void 0===f?void 0:f.getTimeInForeground())||0,TotalTimeOnSite:(null===(a=d.getTotalTimeOnSite)||void 0===a?void 0:a.call(d))||0,PageUrl:getHref()||null,IsBackgroundAST:!0},p=__assign({},o.CustomFlags),q=d.integrationAttributes;// https://go.mparticle.com/work/SQDSDKS-5053
568
+ if(isIntegrationCaptureEnabled(m)){this.mpInstance._IntegrationCapture.capture();var r=this.mpInstance._IntegrationCapture.getClickIdsAsCustomFlags();p=__assign(__assign({},r),p);var s=this.mpInstance._IntegrationCapture.getClickIdsAsIntegrationAttributes();q=__assign(__assign({},s),q);}return o.CustomFlags=p,o.IntegrationAttributes=q,appendUserInfo(n(),o),o},a.prototype.addEventListeners=function(){var a=this,b=this,c=function(){// Check for debounce before creating and queueing event
530
569
  var c=a.mpInstance._Helpers.getFeatureFlag,d=Constants.FeatureFlags.AstBackgroundEvents;if(c(d)){if(b.shouldDebounceAndUpdateLastASTTime())return;// Add application state transition event to queue
531
570
  var e=b.createBackgroundASTEvent();b.queueEvent(e);}// Then trigger the upload with beacon
532
571
  b.prepareAndUpload(!1,b.isBeaconAvailable());};this.exitHandler=c,this.visibilityChangeHandler=function(){"hidden"===document.visibilityState&&c();},document.addEventListener("visibilitychange",this.visibilityChangeHandler),window.addEventListener("beforeunload",c),window.addEventListener("pagehide",c);},a.prototype.isBeaconAvailable=function(){return !!navigator.sendBeacon},a.prototype.triggerUploadInterval=function(a,b){var c=this;void 0===a&&(a=!1),void 0===b&&(b=!1),this.uploadIntervalTimerId=setTimeout(function(){c.prepareAndUpload(a,b);},this.uploadIntervalMillis);},a.prototype.queueEvent=function(a){if(!isEmpty(a)){if(this.eventsQueuedForProcessing.push(a),this.offlineStorageEnabled&&this.eventVault&&this.eventVault.store(this.eventsQueuedForProcessing),this.mpInstance.Logger.isVerbose()){var b=obfuscateDevData(a,this.mpInstance._Store.SDKConfig.isDevelopmentMode);this.mpInstance.Logger.verbose("Queuing event: ".concat(JSON.stringify(b))),this.mpInstance.Logger.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));}this.shouldTriggerImmediateUpload(a.EventDataType)&&this.prepareAndUpload(!1,!1);}},a.prototype.shouldTriggerImmediateUpload=function(a){var b=[MessageType$1.Commerce,MessageType$1.UserIdentityChange];return !this.batchingEnabled||b.includes(a)},(a.createNewBatches=function(a,b,c){if(!b||!a||!a.length)return null;//bucket by MPID, and then by session, ordered by timestamp
@@ -757,18 +796,18 @@ var Base64=Polyfill.Base64,Messages$4=Constants.Messages,Base64CookieKeys=Consta
757
796
  // localStorage to cookies, then no mParticle cookie exists yet and there is
758
797
  // localStorage. Get the localStorage, set them to cookies, then delete the
759
798
  // localStorage item.
760
- function d(b,d,e){var f;return d?(f=c(d,e),b.removeItem(a._Store.storageName)):e&&(f=e),C.storeDataInMemory(f),f}// For migrating from cookie to localStorage -- If an instance is newly
799
+ function d(b,d,e){var f;return d?(f=c(d,e),b.removeItem(a._Store.storageName)):e&&(f=e),D.storeDataInMemory(f),f}// For migrating from cookie to localStorage -- If an instance is newly
761
800
  // switching from cookies to localStorage, then no mParticle localStorage
762
801
  // exists yet and there are cookies. Get the cookies, set them to
763
802
  // localStorage, then delete the cookies.
764
- function e(b,c){if(!c)return void C.storeDataInMemory(b);var d=b||c;return C.storeDataInMemory(d),C.expireCookies(a._Store.storageName),d}function f(b,c){return a._Store.isLocalStorageAvailable?a._Store.SDKConfig.useCookieStorage?d(window.localStorage,b,c):e(b,c):void C.storeDataInMemory(c)}function g(b){for(var c in b)b.hasOwnProperty(c)&&!SDKv2NonMPIDCookieKeys[c]&&(a._Store.nonCurrentUserMPIDs[c]=b[c]);}function h(b){return C.useLocalStorage()&&a._Store.isLocalStorageAvailable?void(b||localStorage.removeItem(a._Store.storageName)):void C.expireCookies(a._Store.storageName)}function i(){a.Logger.verbose(Messages$4.InformationMessages.CookieNotFound),a._Store.clientId=a._Store.clientId||a._Helpers.generateUniqueId(),a._Store.deviceId=a._Store.deviceId||a._Helpers.generateUniqueId();}function j(b,c){// For most persistence values, we prioritize localstorage/cookie values over
803
+ function e(b,c){if(!c)return void D.storeDataInMemory(b);var d=b||c;return D.storeDataInMemory(d),D.expireCookies(a._Store.storageName),d}function f(b,c){return a._Store.isLocalStorageAvailable?a._Store.SDKConfig.useCookieStorage?d(window.localStorage,b,c):e(b,c):void D.storeDataInMemory(c)}function g(b){for(var c in b)b.hasOwnProperty(c)&&!SDKv2NonMPIDCookieKeys[c]&&(a._Store.nonCurrentUserMPIDs[c]=b[c]);}function h(b){return D.useLocalStorage()&&a._Store.isLocalStorageAvailable?void(b||localStorage.removeItem(a._Store.storageName)):void D.expireCookies(a._Store.storageName)}function i(){a.Logger.verbose(Messages$4.InformationMessages.CookieNotFound),a._Store.clientId=a._Store.clientId||a._Helpers.generateUniqueId(),a._Store.deviceId=a._Store.deviceId||a._Helpers.generateUniqueId();}function j(b,c){// For most persistence values, we prioritize localstorage/cookie values over
765
804
  // Store. However, we allow device ID to be overriden via a config value and
766
805
  // thus the priority of the deviceId value is
767
806
  // 1. value passed via config.deviceId
768
807
  // 2. previous value in persistence
769
808
  // 3. generate new guid
770
809
  a._Store.mpid=c?c:b.cu||0,b.gs=b.gs||{},a._Store.sessionId=b.gs.sid||a._Store.sessionId,a._Store.isEnabled="undefined"==typeof b.gs.ie?a._Store.isEnabled:b.gs.ie,a._Store.sessionAttributes=b.gs.sa||a._Store.sessionAttributes,a._Store.localSessionAttributes=b.gs.lsa||a._Store.localSessionAttributes,a._Store.serverSettings=b.gs.ss||a._Store.serverSettings,a._Store.devToken=a._Store.devToken||b.gs.dt,a._Store.SDKConfig.appVersion=a._Store.SDKConfig.appVersion||b.gs.av,a._Store.clientId=b.gs.cgid||a._Store.clientId||a._Helpers.generateUniqueId(),a._Store.deviceId=a._Store.deviceId||b.gs.das||a._Helpers.generateUniqueId(),a._Store.integrationAttributes=b.gs.ia||{},a._Store.context=b.gs.c||a._Store.context,a._Store.currentSessionMPIDs=b.gs.csm||a._Store.currentSessionMPIDs,a._Store.isLoggedIn=!0===b.l,b.gs.les&&(a._Store.dateLastEventSent=new Date(b.gs.les)),a._Store.sessionStartDate=b.gs.ssd?new Date(b.gs.ssd):new Date,b=c?b[c]:b[b.cu];}// https://go.mparticle.com/work/SQDSDKS-6045
771
- function k(b){var c=a._Store;return b.gs.sid=c.sessionId,b.gs.ie=c.isEnabled,b.gs.sa=c.sessionAttributes,b.gs.lsa=c.localSessionAttributes,b.gs.ss=c.serverSettings,b.gs.dt=c.devToken,b.gs.les=c.dateLastEventSent?c.dateLastEventSent.getTime():null,b.gs.av=c.SDKConfig.appVersion,b.gs.cgid=c.clientId,b.gs.das=c.deviceId,b.gs.c=c.context,b.gs.ssd=c.sessionStartDate?c.sessionStartDate.getTime():0,b.gs.ia=c.integrationAttributes,b}/* This function determines if a cookie is greater than the configured maxCookieSize.
810
+ function k(b){var c=a._Store;return b.gs.sid=c.sessionId,b.gs.ie=c.isEnabled,b.gs.sa=c.sessionAttributes,b.gs.lsa=c.localSessionAttributes,b.gs.ss=c.serverSettings,b.gs.dt=c.devToken,b.gs.les=c.dateLastEventSent?c.dateLastEventSent.getTime():null,b.gs.av=c.SDKConfig.appVersion,b.gs.cgid=c.clientId,b.gs.das=c.deviceId,b.gs.c=c.context,b.gs.ssd=c.sessionStartDate?c.sessionStartDate.getTime():0,b.gs.ia=c.integrationAttributes,b}function l(b){var c=D.decodePersistence(b);if(!c)return null;var d=JSON.parse(c);return a._Helpers.isObject(d)&&Object.keys(d).length?d:null}/* This function determines if a cookie is greater than the configured maxCookieSize.
772
811
  - If it is, we remove an MPID and its associated UI/UA/CSD from the cookie.
773
812
  - Once removed, check size, and repeat.
774
813
  - Never remove the currentUser's MPID from the cookie.
@@ -779,9 +818,9 @@ function k(b){var c=a._Store;return b.gs.sid=c.sessionId,b.gs.ie=c.isEnabled,b.g
779
818
  a. Remove at random MPIDs on the cookie that are not part of the currentSessionMPIDs
780
819
  b. Then remove MPIDs based on order in currentSessionMPIDs array, which
781
820
  stores MPIDs based on earliest login.
782
- */function l(a,b){return a.length>b}function m(a,b,c,d){var e;for(var f in a)a.hasOwnProperty(f)&&(e=s(a,b,c),!!l(e,d))&&(SDKv2NonMPIDCookieKeys[f]||f===a.cu||delete a[f]);return e}function n(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(SDKv2NonMPIDCookieKeys[c]||c===a.cu||(b[c]=1));return b}function o(a,b,c,d,e,f){var g;for(var h in b)(g=s(a,d,e),!!l(g,f))&&b.hasOwnProperty(h)&&-1===c.indexOf(h)&&delete a[h];return g}function p(b,c,d){return b[c]?(a.Logger.verbose("Size of new encoded cookie is larger than maxCookieSize setting of "+d+". Removing from cookie the earliest logged in MPID containing: "+JSON.stringify(b[c],null,2)),void delete b[c]):void a.Logger.error("Unable to save MPID data to cookies because the resulting encoded cookie is larger than the maxCookieSize setting of "+d+". We recommend using a maxCookieSize of 1500.")}function q(a,b,c,d,e){for(var f,g=0;g<b.length&&(f=s(a,c,d),!!l(f,e));g++)p(a,b[g],e);return f}function r(a){var b="https:"===window.location.protocol;window.document.cookie=b?a+";Secure":a;}function s(a,b,c){return C.encodePersistence(JSON.stringify(a))+";expires="+b+";path=/"+c}function t(b){return Array.isArray(b)?0<b.length:!!a._Helpers.isObject(b)&&0<Object.keys(b).length}function u(a,b){return a[b]&&t(a[b])?void(a[b]=Base64.encode(JSON.stringify(a[b]))):void delete a[b]}function v(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){u(a,b);continue}if("ie"==b){a[b]=a[b]?1:0;continue}a[b]||delete a[b];}}function w(b,c){var d=b[c];return a._Helpers.isObject(d)&&Object.keys(d).length?void(b[c]=Base64.encode(JSON.stringify(d))):void delete b[c]}function x(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&w(a,b);}function y(a){for(var b in a)a.hasOwnProperty(b)&&(SDKv2NonMPIDCookieKeys[b]||x(a[b]));}function z(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){a[b]=JSON.parse(Base64.decode(a[b])),"csm"!==b||Array.isArray(a[b])||delete a[b];continue}"ie"==b&&(a[b]=!!a[b]);}}function A(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&a[b].length&&(a[b]=JSON.parse(Base64.decode(a[b])));}function B(b){for(var c in b)if(b.hasOwnProperty(c)){if(!SDKv2NonMPIDCookieKeys[c]){if(!a._Helpers.isObject(b[c])){delete b[c];continue}A(b[c]);continue}"l"==c&&(b[c]=!!b[c]);}}// TODO: This should actually be decodePersistenceString or
821
+ */function m(a,b){return a.length>b}function n(a,b,c,d){var e;for(var f in a)a.hasOwnProperty(f)&&(e=t(a,b,c),!!m(e,d))&&(SDKv2NonMPIDCookieKeys[f]||f===a.cu||delete a[f]);return e}function o(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(SDKv2NonMPIDCookieKeys[c]||c===a.cu||(b[c]=1));return b}function p(a,b,c,d,e,f){var g;for(var h in b)(g=t(a,d,e),!!m(g,f))&&b.hasOwnProperty(h)&&-1===c.indexOf(h)&&delete a[h];return g}function q(b,c,d){return b[c]?(a.Logger.verbose("Size of new encoded cookie is larger than maxCookieSize setting of "+d+". Removing from cookie the earliest logged in MPID containing: "+JSON.stringify(b[c],null,2)),void delete b[c]):void a.Logger.error("Unable to save MPID data to cookies because the resulting encoded cookie is larger than the maxCookieSize setting of "+d+". We recommend using a maxCookieSize of 1500.")}function r(a,b,c,d,e){for(var f,g=0;g<b.length&&(f=t(a,c,d),!!m(f,e));g++)q(a,b[g],e);return f}function s(a){var b="https:"===window.location.protocol;window.document.cookie=b?a+";Secure":a;}function t(a,b,c){return D.encodePersistence(JSON.stringify(a))+";expires="+b+";path=/"+c}function u(b){return Array.isArray(b)?0<b.length:!!a._Helpers.isObject(b)&&0<Object.keys(b).length}function v(a,b){return a[b]&&u(a[b])?void(a[b]=Base64.encode(JSON.stringify(a[b]))):void delete a[b]}function w(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){v(a,b);continue}if("ie"==b){a[b]=a[b]?1:0;continue}a[b]||delete a[b];}}function x(b,c){var d=b[c];return a._Helpers.isObject(d)&&Object.keys(d).length?void(b[c]=Base64.encode(JSON.stringify(d))):void delete b[c]}function y(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&x(a,b);}function z(a){for(var b in a)a.hasOwnProperty(b)&&(SDKv2NonMPIDCookieKeys[b]||y(a[b]));}function A(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){a[b]=JSON.parse(Base64.decode(a[b])),"csm"!==b||Array.isArray(a[b])||delete a[b];continue}"ie"==b&&(a[b]=!!a[b]);}}function B(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&a[b].length&&(a[b]=JSON.parse(Base64.decode(a[b])));}function C(b){for(var c in b)if(b.hasOwnProperty(c)){if(!SDKv2NonMPIDCookieKeys[c]){if(!a._Helpers.isObject(b[c])){delete b[c];continue}B(b[c]);continue}"l"==c&&(b[c]=!!b[c]);}}// TODO: This should actually be decodePersistenceString or
783
822
  // we should refactor this to take a string and return an object
784
- var C=this;// https://go.mparticle.com/work/SQDSDKS-5022
823
+ var D=this;// https://go.mparticle.com/work/SQDSDKS-5022
785
824
  // https://go.mparticle.com/work/SQDSDKS-5022
786
825
  // https://go.mparticle.com/work/SQDSDKS-6021
787
826
  // https://go.mparticle.com/work/SQDSDKS-5022
@@ -801,16 +840,16 @@ var C=this;// https://go.mparticle.com/work/SQDSDKS-5022
801
840
  * time
802
841
  */ // https://go.mparticle.com/work/SQDSDKS-6045
803
842
  // Forwarder Batching Code
804
- this.useLocalStorage=function(){return !a._Store.SDKConfig.useCookieStorage&&a._Store.isLocalStorageAvailable},this.initializeStorage=function(){var c=null;try{var d=C.getLocalStorage();c=C.getCookie(),b(d,c),a._Store.isLocalStorageAvailable||(a._Store.SDKConfig.useCookieStorage=!0);// https://go.mparticle.com/work/SQDSDKS-6046
805
- var e=f(d,c);g(e),C.update();}catch(b){// If cookies or local storage is corrupt, we want to remove it
843
+ this.useLocalStorage=function(){return !a._Store.SDKConfig.useCookieStorage&&a._Store.isLocalStorageAvailable},this.initializeStorage=function(){var c=null;try{var d=D.getLocalStorage();c=D.getCookie(),b(d,c),a._Store.isLocalStorageAvailable||(a._Store.SDKConfig.useCookieStorage=!0);// https://go.mparticle.com/work/SQDSDKS-6046
844
+ var e=f(d,c);g(e),D.update();}catch(b){// If cookies or local storage is corrupt, we want to remove it
806
845
  // so that in the future, initializeStorage will work
807
- h(!!c),a.Logger.error("Error initializing storage: "+b);}},this.update=function(){a._Store.webviewBridgeEnabled||(a._Store.SDKConfig.useCookieStorage&&C.setCookie(),C.setLocalStorage());},this.storeDataInMemory=function(b,c){try{if(!b)return void i();j(b,c);}catch(b){a.Logger.error(Messages$4.ErrorMessages.CookieParseError);}},this.determineLocalStorageAvailability=function(a){var b=getMParticleManager();if(null===b||void 0===b?void 0:b._forceNoLocalStorage)return !1;try{a.setItem("mparticle","test");var c="test"===a.getItem("mparticle");return a.removeItem("mparticle"),!!(c&&a)}catch(a){return !1}},this.setLocalStorage=function(){var b;if(a._Store.isLocalStorageAvailable&&(null===(b=a._CookieConsentManager)||void 0===b||!b.getNoFunctional()))// Block mprtcl-v4 localStorage when noFunctional is true
808
- {var c=a._Store.storageName,d=C.getLocalStorage()||{},e=a.Identity.getCurrentUser(),f=e?e.getMPID():null;if(!a._Store.SDKConfig.useCookieStorage){d.gs=d.gs||{},d.l=a._Store.isLoggedIn?1:0,a._Store.sessionId&&(d.gs.csm=a._Store.currentSessionMPIDs),d.gs.ie=a._Store.isEnabled,f&&(d.cu=f),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(d=extend({},d,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),d=k(d);try{window.localStorage.setItem(encodeURIComponent(c),C.encodePersistence(JSON.stringify(d)));}catch(b){a.Logger.error("Error with setting localStorage item.");}}}},this.getLocalStorage=function(){if(!a._Store.isLocalStorageAvailable)return null;var b=a._Store.storageName,c=C.decodePersistence(window.localStorage.getItem(b));if(!c)return null;var d=JSON.parse(c),e={};for(var f in d)d.hasOwnProperty(f)&&(e[f]=d[f]);return Object.keys(e).length?e:null},this.expireCookies=function(a){var b,c,d,e=new Date;d=C.getCookieDomain(),c=""===d?"":";domain="+d,e.setTime(e.getTime()-86400000),b="; expires="+e.toUTCString(),r(a+"="+b+"; path=/"+c);},this.getCookie=function(){var b,c,d,e,f,g,h=a._Store.storageName;a.Logger.verbose(Messages$4.InformationMessages.CookieSearch);try{b=window.document.cookie.split("; ");}catch(b){return a.Logger.verbose("Unable to parse undefined cookie"),null}for(c=0,d=b.length;c<d;c++){try{e=b[c].split("="),f=e.shift(),g=e.join("=");}catch(b){a.Logger.verbose("Unable to parse cookie: "+f+". Skipping.");}if(h&&h===f){var j=C.decodePersistence(a._Helpers.converted(g)),k=j?JSON.parse(j):null;if(a._Helpers.isObject(k))return a.Logger.verbose(Messages$4.InformationMessages.CookieFound),k}}return null},this.setCookie=function(){var b;// Block mprtcl-v4 cookies when noFunctional is true
809
- if(!(null!==(b=a._CookieConsentManager)&&void 0!==b)||!b.getNoFunctional()){var c,d=a.Identity.getCurrentUser();d&&(c=d.getMPID());var e,f,g,h=new Date,i=a._Store.storageName,j=C.getCookie()||{},l=new Date(h.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString();e=C.getCookieDomain(),f=""===e?"":";domain="+e,j.gs=j.gs||{},a._Store.sessionId&&(j.gs.csm=a._Store.currentSessionMPIDs),c&&(j.cu=c),j.l=a._Store.isLoggedIn?1:0,j=k(j),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(j=extend({},j,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),g=C.reduceAndEncodePersistence(j,l,f,a._Store.SDKConfig.maxCookieSize),a.Logger.verbose(Messages$4.InformationMessages.CookieSet),r(encodeURIComponent(i)+"="+g);}},this.reduceAndEncodePersistence=function(a,b,c,d){var e=a.gs.csm?a.gs.csm:[];if(!e.length)return m(a,b,c,d);var f=n(a);return Object.keys(f).length&&o(a,f,e,b,c,d),q(a,e,b,c,d)},this.encodePersistence=function(a){var b=JSON.parse(a);return v(b.gs),y(b),createCookieString(JSON.stringify(b))},this.decodePersistence=function(b){try{if(!b)return;var c=JSON.parse(revertCookieString(b));return a._Helpers.isObject(c)&&Object.keys(c).length&&(z(c.gs),B(c)),JSON.stringify(c)}catch(b){a.Logger.error("Problem with decoding cookie");}},this.getCookieDomain=function(){if(a._Store.SDKConfig.cookieDomain)return a._Store.SDKConfig.cookieDomain;var b=C.getDomain(document,location.hostname);return ""===b?"":"."+b},this.getDomain=function(a,b){var c,d,e=b.split(".");for(c=e.length-1;0<=c;c--)if(d=e.slice(c).join("."),a.cookie="mptest=cookie;domain=."+d+";",-1<a.cookie.indexOf("mptest=cookie"))return a.cookie="mptest=;domain=."+d+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",d;return ""},this.saveUserCookieSyncDatesToPersistence=function(b,c){if(c){var d=C.getPersistence();d&&(a._Helpers.isObject(d[b])?d[b].csd=c:d[b]={csd:c}),C.savePersistence(d);}},this.swapCurrentUser=function(a,b,c){if(a&&b&&a!==b){var d=C.getPersistence();d&&(d.cu=b,d.gs.csm=c,C.savePersistence(d));}},this.savePersistence=function(b){var c;// Block mprtcl-v4 persistence when noFunctional is true
810
- if(null===(c=a._CookieConsentManager)||void 0===c||!c.getNoFunctional()){var d,e=C.encodePersistence(JSON.stringify(b)),f=new Date,g=a._Store.storageName,h=new Date(f.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString(),i=C.getCookieDomain();if(d=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=C.reduceAndEncodePersistence(b,h,d,a._Store.SDKConfig.maxCookieSize);r(encodeURIComponent(g)+"="+j);}else if(a._Store.isLocalStorageAvailable)try{localStorage.setItem(a._Store.storageName,e);}catch(b){a.Logger.error("Error saving persistence to localStorage.");}}},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getFirstSeenTime=function(a){if(!a)return null;var b=C.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=C.getPersistence();d&&(!a._Helpers.isObject(d[b])&&(d[b]={}),!d[b].fst&&(d[b].fst=c,C.savePersistence(d)));}// https://go.mparticle.com/work/SQDSDKS-6329
846
+ h(!!c),a.Logger.error("Error initializing storage: "+b);}},this.update=function(){a._Store.webviewBridgeEnabled||(a._Store.SDKConfig.useCookieStorage&&D.setCookie(),D.setLocalStorage());},this.storeDataInMemory=function(b,c){try{if(!b)return void i();j(b,c);}catch(b){a.Logger.error(Messages$4.ErrorMessages.CookieParseError);}},this.determineLocalStorageAvailability=function(a){var b=getMParticleManager();if(null===b||void 0===b?void 0:b._forceNoLocalStorage)return !1;try{a.setItem("mparticle","test");var c="test"===a.getItem("mparticle");return a.removeItem("mparticle"),!!(c&&a)}catch(a){return !1}},this.setLocalStorage=function(){var b;if(a._Store.isLocalStorageAvailable&&(null===(b=a._CookieConsentManager)||void 0===b||!b.getNoFunctional()))// Block mprtcl-v4 localStorage when noFunctional is true
847
+ {var c=a._Store.storageName,d=D.getLocalStorage()||{},e=a.Identity.getCurrentUser(),f=e?e.getMPID():null;if(!a._Store.SDKConfig.useCookieStorage){d.gs=d.gs||{},d.l=a._Store.isLoggedIn?1:0,a._Store.sessionId&&(d.gs.csm=a._Store.currentSessionMPIDs),d.gs.ie=a._Store.isEnabled,f&&(d.cu=f),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(d=extend({},d,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),d=k(d);try{window.localStorage.setItem(encodeURIComponent(c),D.encodePersistence(JSON.stringify(d)));}catch(b){a.Logger.error("Error with setting localStorage item.");}}}},this.getLocalStorage=function(){return a._Store.isLocalStorageAvailable?l(window.localStorage.getItem(a._Store.storageName)):null},this.expireCookies=function(a){var b,c,d,e=new Date;d=D.getCookieDomain(),c=""===d?"":";domain="+d,e.setTime(e.getTime()-86400000),b="; expires="+e.toUTCString(),s(a+"="+b+"; path=/"+c);},this.getCookie=function(){var b,c,d,e,f,g,h=a._Store.storageName;a.Logger.verbose(Messages$4.InformationMessages.CookieSearch);try{b=window.document.cookie.split("; ");}catch(b){return a.Logger.verbose("Unable to parse undefined cookie"),null}for(c=0,d=b.length;c<d;c++){try{e=b[c].split("="),f=e.shift(),g=e.join("=");}catch(b){a.Logger.verbose("Unable to parse cookie: "+f+". Skipping.");}if(h&&h===f){var j=l(a._Helpers.converted(g));if(j)return a.Logger.verbose(Messages$4.InformationMessages.CookieFound),j}}return null},this.setCookie=function(){var b;// Block mprtcl-v4 cookies when noFunctional is true
848
+ if(!(null!==(b=a._CookieConsentManager)&&void 0!==b)||!b.getNoFunctional()){var c,d=a.Identity.getCurrentUser();d&&(c=d.getMPID());var e,f,g,h=new Date,i=a._Store.storageName,j=D.getCookie()||{},l=new Date(h.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString();e=D.getCookieDomain(),f=""===e?"":";domain="+e,j.gs=j.gs||{},a._Store.sessionId&&(j.gs.csm=a._Store.currentSessionMPIDs),c&&(j.cu=c),j.l=a._Store.isLoggedIn?1:0,j=k(j),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(j=extend({},j,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),g=D.reduceAndEncodePersistence(j,l,f,a._Store.SDKConfig.maxCookieSize),a.Logger.verbose(Messages$4.InformationMessages.CookieSet),s(encodeURIComponent(i)+"="+g);}},this.reduceAndEncodePersistence=function(a,b,c,d){var e=a.gs.csm?a.gs.csm:[];if(!e.length)return n(a,b,c,d);var f=o(a);return Object.keys(f).length&&p(a,f,e,b,c,d),r(a,e,b,c,d)},this.encodePersistence=function(a){var b=JSON.parse(a);return w(b.gs),z(b),createCookieString(JSON.stringify(b))},this.decodePersistence=function(b){try{if(!b)return;var c=JSON.parse(revertCookieString(b));return a._Helpers.isObject(c)&&Object.keys(c).length&&(A(c.gs),C(c)),JSON.stringify(c)}catch(b){a.Logger.error("Problem with decoding cookie");}},this.getCookieDomain=function(){if(a._Store.SDKConfig.cookieDomain)return a._Store.SDKConfig.cookieDomain;var b=D.getDomain(document,location.hostname);return ""===b?"":"."+b},this.getDomain=function(a,b){var c,d,e=b.split(".");for(c=e.length-1;0<=c;c--)if(d=e.slice(c).join("."),a.cookie="mptest=cookie;domain=."+d+";",-1<a.cookie.indexOf("mptest=cookie"))return a.cookie="mptest=;domain=."+d+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",d;return ""},this.saveUserCookieSyncDatesToPersistence=function(b,c){if(c){var d=D.getPersistence();d&&(a._Helpers.isObject(d[b])?d[b].csd=c:d[b]={csd:c}),D.savePersistence(d);}},this.swapCurrentUser=function(a,b,c){if(a&&b&&a!==b){var d=D.getPersistence();d&&(d.cu=b,d.gs.csm=c,D.savePersistence(d));}},this.savePersistence=function(b){var c;// Block mprtcl-v4 persistence when noFunctional is true
849
+ if(null===(c=a._CookieConsentManager)||void 0===c||!c.getNoFunctional()){var d,e=D.encodePersistence(JSON.stringify(b)),f=new Date,g=a._Store.storageName,h=new Date(f.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString(),i=D.getCookieDomain();if(d=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=D.reduceAndEncodePersistence(b,h,d,a._Store.SDKConfig.maxCookieSize);s(encodeURIComponent(g)+"="+j);}else if(a._Store.isLocalStorageAvailable)try{localStorage.setItem(a._Store.storageName,e);}catch(b){a.Logger.error("Error saving persistence to localStorage.");}}},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getFirstSeenTime=function(a){if(!a)return null;var b=D.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=D.getPersistence();d&&(!a._Helpers.isObject(d[b])&&(d[b]={}),!d[b].fst&&(d[b].fst=c,D.savePersistence(d)));}// https://go.mparticle.com/work/SQDSDKS-6329
811
850
  },this.getLastSeenTime=function(b){if(!b)return null;if(b===a.Identity.getCurrentUser().getMPID())//if the mpid is the current user, its last seen time is the current time
812
- return new Date().getTime();var c=C.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=C.getPersistence();d&&a._Helpers.isObject(d[b])&&(d[b].lst=c,C.savePersistence(d));}// https://go.mparticle.com/work/SQDSDKS-6329
813
- },this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,C.update();},this.resetPersistence=function(){localStorage.clear(),C.expireCookies(StorageNames.cookieName),C.expireCookies(StorageNames.cookieNameV2),C.expireCookies(StorageNames.cookieNameV3),C.expireCookies(StorageNames.cookieNameV4),C.expireCookies(a._Store.storageName);var b=getMParticleManager();if(null===b||void 0===b?void 0:b._isTestEnv){localStorage.removeItem(a._Helpers.createMainStorageName("abcdef")),C.expireCookies(a._Helpers.createMainStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
851
+ return new Date().getTime();var c=D.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=D.getPersistence();d&&a._Helpers.isObject(d[b])&&(d[b].lst=c,D.savePersistence(d));}// https://go.mparticle.com/work/SQDSDKS-6329
852
+ },this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,D.update();},this.resetPersistence=function(){localStorage.clear(),D.expireCookies(StorageNames.cookieName),D.expireCookies(StorageNames.cookieNameV2),D.expireCookies(StorageNames.cookieNameV3),D.expireCookies(StorageNames.cookieNameV4),D.expireCookies(a._Store.storageName);var b=getMParticleManager();if(null===b||void 0===b?void 0:b._isTestEnv){localStorage.removeItem(a._Helpers.createMainStorageName("abcdef")),D.expireCookies(a._Helpers.createMainStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
814
853
 
815
854
  var HISTORY_METHODS=["pushState","replaceState"],WRAPPED_MARKER="__mpApvWrapped__";var supportsHistoryTracking=function(a){return !!a&&a.history!==void 0&&"function"==typeof a.history.pushState&&"function"==typeof a.addEventListener};// Wraps pushState/replaceState so `onNavigate` runs after the real method, and
816
855
  // returns the single function that undoes it — or null when nothing was
@@ -998,13 +1037,13 @@ function convertCustomFlags(a,b){var c=[];for(var d in b.flags={},a.CustomFlags)
998
1037
  // tracked. If this is an `optOut` Event, we set `optOut` to the inverse of the SDK's
999
1038
  // `isEnabled` boolean which is controlled via `MPInstanceManager.setOptOut`.
1000
1039
  // TODO: Why is Webview Bridge Enabled or Opt Out necessary here?
1001
- if(a._Store.sessionId||b.messageType===Types.MessageType.OptOut||a._Store.webviewBridgeEnabled){var j=__assign({},b.customFlags),k=a._Store.integrationAttributes,l=a._Helpers.getFeatureFlag,m=l&&l(Constants.FeatureFlags.CaptureIntegrationSpecificIds),n=l&&(l(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2)||""),o=n&&n!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===m;// https://go.mparticle.com/work/SQDSDKS-5053
1040
+ if(a._Store.sessionId||b.messageType===Types.MessageType.OptOut||a._Store.webviewBridgeEnabled){var j=__assign({},b.customFlags),k=a._Store.integrationAttributes,l=a._Helpers.getFeatureFlag;// https://go.mparticle.com/work/SQDSDKS-5053
1002
1041
  // https://go.mparticle.com/work/SQDSDKS-7639
1003
- if(o){a._IntegrationCapture.capture();var p=a._IntegrationCapture.getClickIdsAsCustomFlags();j=__assign(__assign({},p),j);var q=a._IntegrationCapture.getClickIdsAsIntegrationAttributes();k=__assign(__assign({},q),k);}h=b.hasOwnProperty("toEventAPIObject")?b.toEventAPIObject():{// This is an artifact from v2 events where SessionStart/End and AST event
1042
+ if(isIntegrationCaptureEnabled(l)){a._IntegrationCapture.capture();var m=a._IntegrationCapture.getClickIdsAsCustomFlags();j=__assign(__assign({},m),j);var n=a._IntegrationCapture.getClickIdsAsIntegrationAttributes();k=__assign(__assign({},n),k);}h=b.hasOwnProperty("toEventAPIObject")?b.toEventAPIObject():{// This is an artifact from v2 events where SessionStart/End and AST event
1004
1043
  // names are numbers (1, 2, or 10), but going forward with v3, these lifecycle
1005
1044
  // events do not have names, but are denoted by their `event_type`
1006
1045
  EventName:b.name||b.messageType+"",EventCategory:b.eventType,EventAttributes:a._Helpers.sanitizeAttributes(b.data,b.name),ActiveTimeOnSite:null===(d=a._timeOnSiteTimer)||void 0===d?void 0:d.getTimeInForeground(),TotalTimeOnSite:null===(f=(e=a._Store).getTotalTimeOnSite)||void 0===f?void 0:f.call(e),PageUrl:getHref()||null,SourceMessageId:b.sourceMessageId||a._Helpers.generateUniqueId(),EventDataType:b.messageType,CustomFlags:j,UserAttributeChanges:b.userAttributeChanges,UserIdentityChanges:b.userIdentityChanges},b.messageType!==Types.MessageType.SessionEnd&&(a._Store.dateLastEventSent=new Date),g={// FIXME: Deprecate when we get rid of V2
1007
- Store:a._Store.serverSettings,SDKVersion:Constants.sdkVersion,SessionId:a._Store.sessionId,SessionStartDate:a._Store.sessionStartDate?a._Store.sessionStartDate.getTime():0,Debug:a._Store.SDKConfig.isDevelopmentMode,Location:a._Store.currentPosition,OptOut:i,ExpandedEventCount:0,AppVersion:a.getAppVersion(),AppName:a.getAppName(),Package:a._Store.SDKConfig["package"],ClientGeneratedId:a._Store.clientId,DeviceId:a._Store.deviceId,IntegrationAttributes:k,CurrencyCode:a._Store.currencyCode,DataPlan:a._Store.SDKConfig.dataPlan?a._Store.SDKConfig.dataPlan:{}},h.EventDataType===MessageType.AppStateTransition&&(h.IsFirstRun=a._Store.isFirstRun,h.LaunchReferral=window.location.href||null),h.CurrencyCode=a._Store.currencyCode;var r=c||a.Identity.getCurrentUser();return appendUserInfo(r,h),b.messageType===Types.MessageType.SessionEnd&&(h.SessionLength=a._Store.dateLastEventSent.getTime()-a._Store.sessionStartDate.getTime(),h.currentSessionMPIDs=a._Store.currentSessionMPIDs,h.EventAttributes=a._Store.sessionAttributes,a._Store.currentSessionMPIDs=[],a._Store.sessionStartDate=null),g.Timestamp=a._Store.dateLastEventSent.getTime(),extend({},h,g)}return null},this.convertEventToV2DTO=function(c){var d={n:c.EventName,et:c.EventCategory,ua:c.UserAttributes,ui:c.UserIdentities,ia:c.IntegrationAttributes,str:c.Store,attrs:c.EventAttributes,sdk:c.SDKVersion,sid:c.SessionId,sl:c.SessionLength,ssd:c.SessionStartDate,dt:c.EventDataType,dbg:c.Debug,ct:c.Timestamp,lc:c.Location,o:c.OptOut,eec:c.ExpandedEventCount,av:c.AppVersion,cgid:c.ClientGeneratedId,das:c.DeviceId,mpid:c.MPID,smpids:c.currentSessionMPIDs};c.DataPlan&&c.DataPlan.PlanId&&(d.dp_id=c.DataPlan.PlanId,c.DataPlan.PlanVersion&&(d.dp_v=c.DataPlan.PlanVersion));var e=b.convertToConsentStateV2DTO(c.ConsentState);return e&&(d.con=e),c.EventDataType===MessageType.AppStateTransition&&(d.fr=c.IsFirstRun,d.iu=!1,d.at=ApplicationTransitionType.AppInit,d.lr=c.LaunchReferral,d.attrs=null),c.CustomFlags&&convertCustomFlags(c,d),c.EventDataType===MessageType.Commerce?(d.cu=c.CurrencyCode,c.ProductAction?d.pd={an:c.ProductAction.ProductActionType,cs:a._Helpers.parseNumber(c.ProductAction.CheckoutStep),co:c.ProductAction.CheckoutOptions,pl:convertProductListToV2DTO(c.ProductAction.ProductList),ti:c.ProductAction.TransactionId,ta:c.ProductAction.Affiliation,tcc:c.ProductAction.CouponCode,tr:a._Helpers.parseNumber(c.ProductAction.TotalAmount),ts:a._Helpers.parseNumber(c.ProductAction.ShippingAmount),tt:a._Helpers.parseNumber(c.ProductAction.TaxAmount)}:c.PromotionAction?d.pm={an:c.PromotionAction.PromotionActionType,pl:c.PromotionAction.PromotionList.map(function(a){return {id:a.Id,nm:a.Name,cr:a.Creative,ps:a.Position?a.Position:0}})}:c.ProductImpressions&&(d.pi=c.ProductImpressions.map(function(a){return {pil:a.ProductImpressionList,pl:convertProductListToV2DTO(a.ProductList)}}))):c.EventDataType===MessageType.Profile&&(d.pet=c.ProfileMessageType),d};}
1046
+ Store:a._Store.serverSettings,SDKVersion:Constants.sdkVersion,SessionId:a._Store.sessionId,SessionStartDate:a._Store.sessionStartDate?a._Store.sessionStartDate.getTime():0,Debug:a._Store.SDKConfig.isDevelopmentMode,Location:a._Store.currentPosition,OptOut:i,ExpandedEventCount:0,AppVersion:a.getAppVersion(),AppName:a.getAppName(),Package:a._Store.SDKConfig["package"],ClientGeneratedId:a._Store.clientId,DeviceId:a._Store.deviceId,IntegrationAttributes:k,CurrencyCode:a._Store.currencyCode,DataPlan:a._Store.SDKConfig.dataPlan?a._Store.SDKConfig.dataPlan:{}},h.EventDataType===MessageType.AppStateTransition&&(h.IsFirstRun=a._Store.isFirstRun,h.LaunchReferral=window.location.href||null),h.CurrencyCode=a._Store.currencyCode;var o=c||a.Identity.getCurrentUser();return appendUserInfo(o,h),b.messageType===Types.MessageType.SessionEnd&&(h.SessionLength=a._Store.dateLastEventSent.getTime()-a._Store.sessionStartDate.getTime(),h.currentSessionMPIDs=a._Store.currentSessionMPIDs,h.EventAttributes=a._Store.sessionAttributes,a._Store.currentSessionMPIDs=[],a._Store.sessionStartDate=null),g.Timestamp=a._Store.dateLastEventSent.getTime(),extend({},h,g)}return null},this.convertEventToV2DTO=function(c){var d={n:c.EventName,et:c.EventCategory,ua:c.UserAttributes,ui:c.UserIdentities,ia:c.IntegrationAttributes,str:c.Store,attrs:c.EventAttributes,sdk:c.SDKVersion,sid:c.SessionId,sl:c.SessionLength,ssd:c.SessionStartDate,dt:c.EventDataType,dbg:c.Debug,ct:c.Timestamp,lc:c.Location,o:c.OptOut,eec:c.ExpandedEventCount,av:c.AppVersion,cgid:c.ClientGeneratedId,das:c.DeviceId,mpid:c.MPID,smpids:c.currentSessionMPIDs};c.DataPlan&&c.DataPlan.PlanId&&(d.dp_id=c.DataPlan.PlanId,c.DataPlan.PlanVersion&&(d.dp_v=c.DataPlan.PlanVersion));var e=b.convertToConsentStateV2DTO(c.ConsentState);return e&&(d.con=e),c.EventDataType===MessageType.AppStateTransition&&(d.fr=c.IsFirstRun,d.iu=!1,d.at=ApplicationTransitionType.AppInit,d.lr=c.LaunchReferral,d.attrs=null),c.CustomFlags&&convertCustomFlags(c,d),c.EventDataType===MessageType.Commerce?(d.cu=c.CurrencyCode,c.ProductAction?d.pd={an:c.ProductAction.ProductActionType,cs:a._Helpers.parseNumber(c.ProductAction.CheckoutStep),co:c.ProductAction.CheckoutOptions,pl:convertProductListToV2DTO(c.ProductAction.ProductList),ti:c.ProductAction.TransactionId,ta:c.ProductAction.Affiliation,tcc:c.ProductAction.CouponCode,tr:a._Helpers.parseNumber(c.ProductAction.TotalAmount),ts:a._Helpers.parseNumber(c.ProductAction.ShippingAmount),tt:a._Helpers.parseNumber(c.ProductAction.TaxAmount)}:c.PromotionAction?d.pm={an:c.PromotionAction.PromotionActionType,pl:c.PromotionAction.PromotionList.map(function(a){return {id:a.Id,nm:a.Name,cr:a.Creative,ps:a.Position?a.Position:0}})}:c.ProductImpressions&&(d.pi=c.ProductImpressions.map(function(a){return {pil:a.ProductImpressionList,pl:convertProductListToV2DTO(a.ProductList)}}))):c.EventDataType===MessageType.Profile&&(d.pet=c.ProfileMessageType),d};}
1008
1047
 
1009
1048
  function forwardingStatsUploader(a){function b(){var b=a._Forwarders.getForwarderStatsQueue(),c=a._Persistence.forwardingStatsBatches.uploadsTable,d=Date.now();for(var e in b.length&&(c[d]={uploading:!1,data:b},a._Forwarders.setForwarderStatsQueue([])),c)(function(b){if(c.hasOwnProperty(b)&&!1===c[b].uploading){var d=function(){4===e.readyState&&(200===e.status||202===e.status?(a.Logger.verbose("Successfully sent "+e.statusText+" from server"),delete c[b]):"4"===e.status.toString()[0]?429!==e.status&&delete c[b]:c[b].uploading=!1);},e=a._Helpers.createXHR(d),f=c[b].data;c[b].uploading=!0,a._APIClient.sendBatchForwardingStatsToServer(f,e);}})(e);}this.startForwardingStatsTimer=function(){window.mParticle._forwardingStatsTimer=setInterval(function(){b();},a._Store.SDKConfig.forwarderStatsTimeout);};}
1010
1049
 
@@ -1262,14 +1301,14 @@ if(this.dataPlanMatchLookups={},this.blockEvents=!1,this.blockEventAttributes=!1
1262
1301
  var e=this.generateMatchKey(a.match),f=this.getPlannedProperties(a.match.type,a.validator);this.dataPlanMatchLookups[e]=f,((null===(b=null===a||void 0===a?void 0:a.match)||void 0===b?void 0:b.type)===DataPlanMatchType.ProductImpression||(null===(c=null===a||void 0===a?void 0:a.match)||void 0===c?void 0:c.type)===DataPlanMatchType.ProductAction||(null===(d=null===a||void 0===a?void 0:a.match)||void 0===d?void 0:d.type)===DataPlanMatchType.PromotionAction)&&(e=this.generateProductAttributeMatchKey(a.match),f=this.getProductProperties(a.match.type,a.validator),this.dataPlanMatchLookups[e]=f);},a.prototype.generateMatchKey=function(a){var b=a.criteria||"";switch(a.type){case DataPlanMatchType.CustomEvent:var c=b;return [DataPlanMatchType.CustomEvent,c.custom_event_type,c.event_name].join(":");case DataPlanMatchType.ScreenView:return [DataPlanMatchType.ScreenView,"",b.screen_name].join(":");case DataPlanMatchType.ProductAction:return [a.type,b.action].join(":");case DataPlanMatchType.PromotionAction:return [a.type,b.action].join(":");case DataPlanMatchType.ProductImpression:return [a.type,b.action].join(":");case DataPlanMatchType.UserIdentities:case DataPlanMatchType.UserAttributes:return [a.type].join(":");default:return null}},a.prototype.generateProductAttributeMatchKey=function(a){var b=a.criteria||"";switch(a.type){case DataPlanMatchType.ProductAction:return [a.type,b.action,"ProductAttributes"].join(":");case DataPlanMatchType.PromotionAction:return [a.type,b.action,"ProductAttributes"].join(":");case DataPlanMatchType.ProductImpression:return [a.type,"ProductAttributes"].join(":");default:return null}},a.prototype.getPlannedProperties=function(a,b){var c,d,e,f,g,h,i,j,k,l;switch(a){case DataPlanMatchType.CustomEvent:case DataPlanMatchType.ScreenView:case DataPlanMatchType.ProductAction:case DataPlanMatchType.PromotionAction:case DataPlanMatchType.ProductImpression:if(k=null===(f=null===(e=null===(d=null===(c=null===b||void 0===b?void 0:b.definition)||void 0===c?void 0:c.properties)||void 0===d?void 0:d.data)||void 0===e?void 0:e.properties)||void 0===f?void 0:f.custom_attributes,k){if(!0===k.additionalProperties||void 0===k.additionalProperties)return !0;for(var m,n={},o=0,p=Object.keys(k.properties);o<p.length;o++)m=p[o],n[m]=!0;return n}return !1!==(null===(i=null===(h=null===(g=null===b||void 0===b?void 0:b.definition)||void 0===g?void 0:g.properties)||void 0===h?void 0:h.data)||void 0===i?void 0:i.additionalProperties)||{};case DataPlanMatchType.UserAttributes:case DataPlanMatchType.UserIdentities:if(l=null===(j=null===b||void 0===b?void 0:b.definition)||void 0===j?void 0:j.additionalProperties,!0===l||void 0===l)return !0;for(var m,n={},q=b.definition.properties,r=0,s=Object.keys(q);r<s.length;r++)m=s[r],n[m]=!0;return n;default:return null}},a.prototype.getProductProperties=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;switch(a){case DataPlanMatchType.ProductImpression://product item attributes
1263
1302
  if(v=null===(l=null===(k=null===(j=null===(i=null===(h=null===(g=null===(f=null===(e=null===(d=null===(c=null===b||void 0===b?void 0:b.definition)||void 0===c?void 0:c.properties)||void 0===d?void 0:d.data)||void 0===e?void 0:e.properties)||void 0===f?void 0:f.product_impressions)||void 0===g?void 0:g.items)||void 0===h?void 0:h.properties)||void 0===i?void 0:i.products)||void 0===j?void 0:j.items)||void 0===k?void 0:k.properties)||void 0===l?void 0:l.custom_attributes,!1===(null===v||void 0===v?void 0:v.additionalProperties)){for(var w,x={},y=0,z=Object.keys(null===v||void 0===v?void 0:v.properties);y<z.length;y++)w=z[y],x[w]=!0;return x}return !0;case DataPlanMatchType.ProductAction:case DataPlanMatchType.PromotionAction://product item attributes
1264
1303
  if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null===(n=null===(m=null===b||void 0===b?void 0:b.definition)||void 0===m?void 0:m.properties)||void 0===n?void 0:n.data)||void 0===o?void 0:o.properties)||void 0===p?void 0:p.product_action)||void 0===q?void 0:q.properties)||void 0===r?void 0:r.products)||void 0===s?void 0:s.items)||void 0===t?void 0:t.properties)||void 0===u?void 0:u.custom_attributes,v&&!1===v.additionalProperties){for(var w,x={},A=0,B=Object.keys(null===v||void 0===v?void 0:v.properties);A<B.length;A++)w=B[A],x[w]=!0;return x}return !0;default:return null}},a.prototype.getMatchKey=function(a){switch(a.event_type){case dist.EventTypeEnum.screenView:var b=a;return b.data?["screen_view","",b.data.screen_name].join(":"):null;case dist.EventTypeEnum.commerceEvent:var c=a,d=[];if(c&&c.data){var e=c.data,f=e.product_action,g=e.product_impressions,h=e.promotion_action;f?(d.push(DataPlanMatchType.ProductAction),d.push(f.action)):h?(d.push(DataPlanMatchType.PromotionAction),d.push(h.action)):g&&d.push(DataPlanMatchType.ProductImpression);}return d.join(":");case dist.EventTypeEnum.customEvent:var i=a;return i.data?["custom_event",i.data.custom_event_type,i.data.event_name].join(":"):null;default:return null}},a.prototype.getProductAttributeMatchKey=function(a){switch(a.event_type){case dist.EventTypeEnum.commerceEvent:var b=[],c=a.data,d=c.product_action,e=c.product_impressions,f=c.promotion_action;return d?(b.push(DataPlanMatchType.ProductAction),b.push(d.action),b.push("ProductAttributes")):f?(b.push(DataPlanMatchType.PromotionAction),b.push(f.action),b.push("ProductAttributes")):e&&(b.push(DataPlanMatchType.ProductImpression),b.push("ProductAttributes")),b.join(":");default:return null}},a.prototype.createBlockedEvent=function(a){return a&&(a=this.applyBlockingStep("the event and its attributes",this.transformEventAndEventAttributes,a,withNoChange)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.applyBlockingStep("product attributes",this.transformProductAttributes,a,withNoChange)),a&&(a=this.applyBlockingStep("user attributes",this.transformUserAttributes,a,withoutUserAttributes),a=this.applyBlockingStep("user identities",this.transformUserIdentities,a,withoutUserIdentities)),a},a.prototype.applyBlockingStep=function(a,b,c,d){try{return b.call(this,c)}catch(b){var e=d(c);return this.reportFailedStep(a,b),e}},a.prototype.reportFailedStep=function(a,b){try{this.mpInstance.Logger.error("Kit blocking could not filter "+a+": "+b);}catch(a){// Best-effort: a logger or error value that throws must not stop the remaining steps.
1265
- }},a.prototype.transformEventAndEventAttributes=function(a){var b,c=__assign({},a),d=convertEvent(c);if(!d)return c;var e=this.getMatchKey(d),f=this.dataPlanMatchLookups[e];if(this.blockEvents&&!f)/*
1304
+ }},a.prototype.transformEventAndEventAttributes=function(a){var b=__assign({},a),c=convertEvent(b);if(!c)return b;var d=this.getMatchKey(c),e=this.dataPlanMatchLookups[d];if(this.blockEvents&&!e)/*
1266
1305
  If the event is not planned, it doesn't exist in dataPlanMatchLookups
1267
1306
  and should be blocked (return null to not send anything to forwarders)
1268
1307
  */return null;if(this.blockEventAttributes){/*
1269
1308
  matchedEvent is set to `true` if additionalProperties is `true`
1270
1309
  otherwise, delete attributes that exist on event.EventAttributes
1271
1310
  that aren't on
1272
- */if(!0===f)return c;if(f){for(var g,h=0,i=Object.keys(null!==(b=c.EventAttributes)&&void 0!==b?b:{});h<i.length;h++)g=i[h],f[g]||delete c.EventAttributes[g];return c}return c}return c},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c)&&b.UserAttributes){for(var d,e={},f=0,g=Object.keys(b.UserAttributes);f<g.length;f++)d=g[f],!0===c[d]&&(e[d]=b.UserAttributes[d]);b.UserAttributes=e;}}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;var b=this.dataPlanMatchLookups.user_attributes;// When additionalProperties is set to true, matchedAttributes
1311
+ */if(!0===e)return b;if(e){if(b.EventAttributes){for(var f,g={},h=0,i=Object.keys(b.EventAttributes);h<i.length;h++)f=i[h],!0===e[f]&&(g[f]=b.EventAttributes[f]);b.EventAttributes=g;}return b}return b}return b},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c)&&b.UserAttributes){for(var d,e={},f=0,g=Object.keys(b.UserAttributes);f<g.length;f++)d=g[f],!0===c[d]&&(e[d]=b.UserAttributes[d]);b.UserAttributes=e;}}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;var b=this.dataPlanMatchLookups.user_attributes;// When additionalProperties is set to true, matchedAttributes
1273
1312
  // will be a boolean, otherwise it will return an object
1274
1313
  return !("boolean"==typeof b&&b)&&"object"===_typeof(b)&&!0!==b[a];// When "Block unplanned user attributes" is enabled and "Allow unplanned user
1275
1314
  // attributes" is also enabled in the UI, allowing unplanned user attributes will be prioritized
@@ -1282,45 +1321,6 @@ return [2/*return*/,b]}})})};}
1282
1321
 
1283
1322
  var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=getErrorMessage(s),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k,l;return __awaiter(this,void 0,void 0,function(){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,A,m,E,m,A,F;return __generator(this,function(G){switch(G.label){case 0:if((null===(i=a._RoktManager)||void 0===i?void 0:i.isInitialized)&&(a._Store.identifyRequestCount=(a._Store.identifyRequestCount||0)+1,m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestStart"))),n=a._Helpers.invokeCallback,o=a.Logger,p=a._ErrorReportingDispatcher,o.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return o.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(o.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return n(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];q=g||null,r=this.getUploadUrl(c,g),s=window.fetch?new FetchUploader(r):new XHRUploader(r),t={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,G.label=1;case 1:return G.trys.push([1,9,,10]),[4/*yield*/,s.upload(t)];case 2:return u=G.sent(),v=void 0,w=void 0,x=u.status,x===HTTP_ACCEPTED?[3/*break*/,3]:x===HTTP_OK?[3/*break*/,3]:x===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return u.json?[4/*yield*/,u.json()]:[3/*break*/,5];case 4:return y=G.sent(),v=this.getIdentityResponseFromFetch(u,y),[3/*break*/,6];case 5:v=this.getIdentityResponseFromXHR(u),G.label=6;case 6:return v.status===HTTP_BAD_REQUEST?(z=v.responseText,w="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+v.status,(null===z||void 0===z?void 0:z.Errors)&&(A=z.Errors.map(function(a){return a.message}).join(", "),w+=" - "+A)):o.isVerbose()&&(B=v.responseText,C=a._Store.SDKConfig.isDevelopmentMode,D=B,!C&&(null===B||void 0===B?void 0:B.matched_identities)&&(D=__assign(__assign({},B),{matched_identities:obfuscateData(B.matched_identities)})),w="Received Identity Response from server: "+JSON.stringify(D)),[3/*break*/,8];case 7:{if(u.status>=HTTP_SERVER_ERROR)throw new Error("Received HTTP Code of "+u.status);return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,A="Received HTTP Code of "+u.status,o.error("Error sending identity request to servers - "+A),n(d,HTTPCodes$1.noHttpCoverage,A),[2/*return*/]}case 8:return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,w&&o.verbose(w),(null===(j=a._RoktManager)||void 0===j?void 0:j.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),f(v,q,d,e,c,h,!1),[3/*break*/,10];case 9:return E=G.sent(),a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!0,(null===(k=a._RoktManager)||void 0===k?void 0:k.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),A=getErrorMessage(E),F="Error sending identity request to servers - "+A,o.error(F),null===p||void 0===p?void 0:p.report({message:F,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),null===(l=a.processQueueOnIdentityFailure)||void 0===l?void 0:l.call(a),n(d,HTTPCodes$1.noHttpCoverage,A),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
1284
1323
 
1285
- // The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
1286
- // - version is always this prefix: fb
1287
- // - subdomainIndex is which domain the cookie is defined on ('com' = 0, 'example.com' = 1, 'www.example.com' = 2)
1288
- // - creationTime is the UNIX time since epoch in milliseconds when the _fbc was stored. If you don't save the _fbc cookie, use the timestamp when you first observed or received this fbclid value
1289
- // - <fbclid> is the value for the fbclid query parameter in the page URL.
1290
- // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc
1291
- var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b||void 0===b?void 0:b.split("//");if(!d)return "";var e=d[1].split("/"),f=e[0].split("."),g=1;// The rules for subdomainIndex are for parsing the domain portion
1292
- // of the URL for cookies, but in this case we are parsing the URL
1293
- // itself, so we can ignore the use of 0 for 'com'
1294
- 3<=f.length&&(g=2);// If timestamp is not provided, use the current time
1295
- var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};// Integration outputs are used to determine how click ids are used within the SDK
1296
- // CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
1297
- // PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
1298
- // INTEGRATION_ATTRIBUTES are stored initially on the SDKEvent level but then is added to the Batch when the batch is created
1299
- var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_identities",INTEGRATION_ATTRIBUTES:"integration_attributes"},integrationMappingExternal={// Facebook / Meta
1300
- fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor,output:IntegrationOutputs.CUSTOM_FLAGS},_fbp:{mappedKey:"Facebook.BrowserId",output:IntegrationOutputs.CUSTOM_FLAGS},_fbc:{mappedKey:"Facebook.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS},// Google
1301
- gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},// TIKTOK
1302
- ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES},// Snapchat
1303
- // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
1304
- ScCid:{mappedKey:"SnapchatConversions.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS},// Pinterest
1305
- // https://developers.pinterest.com/docs/track-conversions/track-conversions-in-the-api/
1306
- // https://help.pinterest.com/en/business/article/pinterest-tag-parameters-and-cookies
1307
- epik:{mappedKey:"Pinterest.click_id",output:IntegrationOutputs.CUSTOM_FLAGS},_epik:{mappedKey:"Pinterest.click_id",output:IntegrationOutputs.CUSTOM_FLAGS},// Snapchat
1308
- // https://developers.snap.com/api/marketing-api/Conversions-API/UsingTheAPI#sending-click-id
1309
- _scid:{mappedKey:"SnapchatConversions.Cookie1",output:IntegrationOutputs.CUSTOM_FLAGS}},integrationMappingRokt={// Rokt
1310
- // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
1311
- // https://go.mparticle.com/work/SQDSDKS-7167
1312
- rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},rclid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277}},IntegrationCapture=/** @class */function(){function a(a){this.initialTimestamp=Date.now(),this.captureMode=a,this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
1313
- * Captures Integration Ids from cookies and query params and stores them in clickIds object
1314
- */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};this.normalizePinterestClickId(a),this.normalizePinterestClickId(c),this.normalizePinterestClickId(b),this.applySourcePrecedence([a,c,b,this.clickIds||{}]),this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),b),c),a);},a.prototype.captureCookies=function(){var a=this.getAllowedKeysForMode(),b=getCookies(a);return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){for(var a=this.getAllowedKeysForMode(),b={},c=0,d=a;c<d.length;c++){var e=d[c],f=localStorage.getItem(e);f&&(b[e]=f);}return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){var a=this.getAllowedKeysForMode();return queryStringParser(getHref(),a)},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
1315
- // {
1316
- // "integration_attributes": {
1317
- // "<moduleId>": {
1318
- // "mappedKey": "clickIdValue"
1319
- // }
1320
- // }
1321
- // }
1322
- for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.normalizePinterestClickId=function(a){isEmpty(null===a||void 0===a?void 0:a._epik)||isEmpty(null===a||void 0===a?void 0:a.epik)||delete a.epik;},a.prototype.applySourcePrecedence=function(a){for(var b=this.getActiveIntegrationMapping(),c=function outputOf(a){var c;return (null===(c=b[a])||void 0===c?void 0:c.mappedKey)||a},d=[],e=0,f=a;e<f.length;e++){var g=f[e],h=[];for(var i in g){var j=c(i);-1===d.indexOf(j)?!isEmpty(g[i])&&h.push(j):delete g[i];}d.push.apply(d,h);}},a.prototype.applyProcessors=function(a,b,c){var d,e={},f=this.getActiveIntegrationMapping();for(var g in a)if(a.hasOwnProperty(g)){var h=a[g],i=null===(d=f[g])||void 0===d?void 0:d.processor;e[g]=i?i(h,b,c):h;}return e},a.prototype.filterMappings=function(a){var b={},c=this.getActiveIntegrationMapping();for(var d in c)c[d].output===a&&(b[d]=c[d]);return b},a.prototype.getAllowedKeysForMode=function(){return Object.keys(this.getActiveIntegrationMapping())},a.prototype.getActiveIntegrationMapping=function(){return this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly?integrationMappingRokt:this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.All?__assign(__assign({},integrationMappingExternal),integrationMappingRokt):{}},a}();
1323
-
1324
1324
  var PASSBACK_CONVERSION_TRACKING_ID="passbackconversiontrackingid",ON_SHOPPABLE_ADS_READY_METHOD="onShoppableAdsReady",RoktManager=/** @class */function(){// Keys this manager's route subscription, so a re-executed bundle's manager replaces
1325
1325
  // it while a second named instance keeps its own.
1326
1326
  function a(a){this.instanceName=a,this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.onReadyCallback=null,this.initialized=!1,this.isShoppableAdsLoaded=!1,this.stopRouteChangeWatch=null;}/**
@@ -1493,10 +1493,9 @@ function completeSDKInitialization(a,b,c){var d,e,f,g,h=createKitBlocker(b,c),i=
1493
1493
  // responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
1494
1494
  // persistence or Identity directly.
1495
1495
  if((null===(d=c._APIClient)||void 0===d?void 0:d.uploader)&&c._APIClient.uploader.destroy(),c._APIClient=new APIClient(c,h),c._Forwarders=new Forwarders(c,h),c._Store.processConfig(b),c._Identity.idCache=createIdentityCache(c),removeExpiredIdentityCacheDates(c._Identity.idCache),c._Store.webviewBridgeEnabled)c._NativeSdkHelpers.initializeSessionAttributes(a);else {c._Persistence.initializeStorage(),c._Store.syncPersistenceData();// Set up user identitiy variables for later use
1496
- var k=c.Identity.getCurrentUser(),l=k?k.getMPID():null,m=k?k.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:m}:c._Store.SDKConfig.identifyRequest,i(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer();// https://go.mparticle.com/work/SQDSDKS-7639
1497
- var n=i(CaptureIntegrationSpecificIds),o=i(CaptureIntegrationSpecificIdsV2),p=o&&o!==CaptureIntegrationSpecificIdsV2Modes.None||!0===n;if(p){var q;n||o===CaptureIntegrationSpecificIdsV2Modes.All?q="all":o===CaptureIntegrationSpecificIdsV2Modes.RoktOnly&&(q="roktonly"),c._IntegrationCapture=new IntegrationCapture(q),c._IntegrationCapture.capture();}// Configure Rokt Manager with user and filtered user
1498
- var r=parseConfig(b,"Rokt",181);if(r){var s=null===(e=r.settings)||void 0===e?void 0:e.accountId;c._Store.setRoktAccountId(s);var t=r.userAttributeFilters,u=filteredMparticleUser(l,{userAttributeFilters:t},c),v={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};// https://go.mparticle.com/work/SQDSDKS-7339
1499
- c._RoktManager.init(r,u,c.Identity,c._Store,c.Logger,v,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher,c._IntegrationCapture);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),i(j)?(!c._PageViewTracker&&(c.Logger.verbose("mParticle APV: [sdk-init] creating new PageViewTracker for this instance"),c._PageViewTracker=new PageViewTracker(c,{isAutoPageView:!0})),hasInitialPageViewFired()?c.Logger.verbose("mParticle APV: [sdk-init] initial page view already logged this page load, skipping"):(markInitialPageViewFired(),c._Events.logPageView({isAutoPageView:!0})),c._PageViewTracker.init()):c._PageViewTracker&&c._PageViewTracker.teardown(),processIdentityCallback(c,k,l,m);}// We will continue to clear out the ready queue as part of the initial init flow
1496
+ var k=c.Identity.getCurrentUser(),l=k?k.getMPID():null,m=k?k.getUserIdentities().userIdentities:{};// https://go.mparticle.com/work/SQDSDKS-7639
1497
+ if(c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:m}:c._Store.SDKConfig.identifyRequest,i(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),isIntegrationCaptureEnabled(i)){var n=i(CaptureIntegrationSpecificIds),o=i(CaptureIntegrationSpecificIdsV2),p=void 0;n||o===CaptureIntegrationSpecificIdsV2Modes.All?p="all":o===CaptureIntegrationSpecificIdsV2Modes.RoktOnly&&(p="roktonly"),c._IntegrationCapture=new IntegrationCapture(p),c._IntegrationCapture.capture();}// Configure Rokt Manager with user and filtered user
1498
+ var q=parseConfig(b,"Rokt",181);if(q){var r=null===(e=q.settings)||void 0===e?void 0:e.accountId;c._Store.setRoktAccountId(r);var s=q.userAttributeFilters,t=filteredMparticleUser(l,{userAttributeFilters:s},c),u={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};c._RoktManager.init(q,t,c.Identity,c._Store,c.Logger,u,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher,c._IntegrationCapture);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),i(j)?(!c._PageViewTracker&&(c.Logger.verbose("mParticle APV: [sdk-init] creating new PageViewTracker for this instance"),c._PageViewTracker=new PageViewTracker(c,{isAutoPageView:!0})),hasInitialPageViewFired()?c.Logger.verbose("mParticle APV: [sdk-init] initial page view already logged this page load, skipping"):(markInitialPageViewFired(),c._Events.logPageView({isAutoPageView:!0})),c._PageViewTracker.init()):c._PageViewTracker&&c._PageViewTracker.teardown(),processIdentityCallback(c,k,l,m);}// We will continue to clear out the ready queue as part of the initial init flow
1500
1499
  // if an identify request is unnecessary, such as if there is an existing session
1501
1500
  (c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,null===(f=c._CookieConsentManager)||void 0===f?void 0:f.syncNoTargetingAttribute(c.Identity.getCurrentUser()),c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue,c.Logger)),null===(g=c.processQueueOnNoFunctional)||void 0===g?void 0:g.call(c),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
1502
1501
  function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan object for blocking can be passed to the SDK: