@mparticle/web-sdk 2.31.1 → 2.32.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.
@@ -154,7 +154,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
154
154
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
155
155
  };
156
156
 
157
- var version = "2.31.1";
157
+ var version = "2.32.0";
158
158
 
159
159
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"is a deprecated method and will be removed in future releases",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
160
160
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
@@ -424,9 +424,9 @@ var dist = {};
424
424
 
425
425
  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={}));
426
426
 
427
- function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c.Identity.getCurrentUser(),f=[],g=null,h=0,i=b;h<i.length;h++)if(d=i[h],d){g=d;var j=convertEvent(d);j&&f.push(j);}if(!g)return null;var k=null;// Add the consent state from either the Last Event or the user
428
- isEmpty(g.ConsentState)?!isEmpty(e)&&(k=e.getConsentState()):k=g.ConsentState;var l={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:g.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:f,mp_deviceid:g.DeviceId,sdk_version:g.SDKVersion,// TODO: Refactor this to read from _Store or a global config
429
- application_info:{application_version:g.AppVersion,application_name:g.AppName,package:g.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:"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:g.UserAttributes,user_identities:convertUserIdentities(g.UserIdentities),consent_state:convertConsentState(k),integration_attributes:g.IntegrationAttributes};return g.DataPlan&&g.DataPlan.PlanId&&(l.context={data_plan:{plan_id:g.DataPlan.PlanId,plan_version:g.DataPlan.PlanVersion||void 0}}),l}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
427
+ var FeatureFlags$2=Constants.FeatureFlags,CaptureIntegrationSpecificIds$1=FeatureFlags$2.CaptureIntegrationSpecificIds;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
428
+ 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
429
+ 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}});var p=g&&!!g(CaptureIntegrationSpecificIds$1);if(p){var q=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(q)||(o.partner_identities=q);}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
430
430
  return convertCustomEvent(a);case Types.MessageType.PageView:return convertPageViewEvent(a);case Types.MessageType.Profile://deprecated and not supported by the web SDK
431
431
  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 convertShoppingCart(a){if(!a.ShoppingCart||!a.ShoppingCart.ProductList||!a.ShoppingCart.ProductList.length)return null;var b={products:convertProducts(a.ShoppingCart.ProductList)};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),shopping_cart:convertShoppingCart(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={application_transition_type:dist.ApplicationStateTransitionEventDataApplicationTransitionTypeEnum.applicationInitialized,is_first_run:a.IsFirstRun,is_upgrade:!1,launch_referral:a.LaunchReferral};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.applicationStateTransition,data:c}}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.
432
432
  //spanning_mpids: sdkEvent.SessionMpids
@@ -1421,11 +1421,15 @@ var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b|
1421
1421
  // of the URL for cookies, but in this case we are parsing the URL
1422
1422
  // itself, so we can ignore the use of 0 for 'com'
1423
1423
  3<=f.length&&(g=2);// If timestamp is not provided, use the current time
1424
- var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};var integrationMapping={// Facebook / Meta
1425
- fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor},_fbp:{mappedKey:"Facebook.BrowserId"},_fbc:{mappedKey:"Facebook.ClickId"},// Google
1426
- gclid:{mappedKey:"GoogleEnhancedConversions.Gclid"},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid"},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid"}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now();}/**
1424
+ 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
1425
+ // CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
1426
+ // PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
1427
+ var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_identities"},integrationMapping={// Facebook / Meta
1428
+ 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
1429
+ 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
1430
+ ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now(),this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS);}/**
1427
1431
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
1428
- */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{};a.fbclid&&b._fbc&&delete b._fbc,this.clickIds=__assign(__assign(__assign({},this.clickIds),a),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){var a,b={};if(!this.clickIds)return b;for(var c=0,d=Object.entries(this.clickIds);c<d.length;c++){var e=d[c],f=e[0],g=e[1],h=null===(a=integrationMapping[f])||void 0===a?void 0:a.mappedKey;isEmpty(h)||(b[h]=g);}return b},a.prototype.applyProcessors=function(a,b,c){for(var d,e={},f=0,g=Object.entries(a);f<g.length;f++){var h=g[f],i=h[0],j=h[1],k=null===(d=integrationMapping[i])||void 0===d?void 0:d.processor;e[i]=k?k(j,b,c):j;}return e},a}();
1432
+ */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{};a.fbclid&&b._fbc&&delete b._fbc,this.clickIds=__assign(__assign(__assign({},this.clickIds),a),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e=0,f=Object.entries(a);e<f.length;e++){var g=f[e],h=g[0],i=g[1],j=null===(c=b[h])||void 0===c?void 0:c.mappedKey;isEmpty(j)||(d[j]=i);}return d},a.prototype.applyProcessors=function(a,b,c){for(var d,e={},f=0,g=Object.entries(a);f<g.length;f++){var h=g[f],i=h[0],j=h[1],k=null===(d=integrationMapping[i])||void 0===d?void 0:d.processor;e[i]=k?k(j,b,c):j;}return e},a.prototype.filterMappings=function(a){return Object.fromEntries(Object.entries(integrationMapping).filter(function(b){var c=b[1];return c.output===a}))},a}();
1429
1433
 
1430
1434
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1431
1435
  * <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
@@ -154,7 +154,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
154
154
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
155
155
  };
156
156
 
157
- var version = "2.31.1";
157
+ var version = "2.32.0";
158
158
 
159
159
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"is a deprecated method and will be removed in future releases",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
160
160
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
@@ -424,9 +424,9 @@ var dist = {};
424
424
 
425
425
  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={}));
426
426
 
427
- function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c.Identity.getCurrentUser(),f=[],g=null,h=0,i=b;h<i.length;h++)if(d=i[h],d){g=d;var j=convertEvent(d);j&&f.push(j);}if(!g)return null;var k=null;// Add the consent state from either the Last Event or the user
428
- isEmpty(g.ConsentState)?!isEmpty(e)&&(k=e.getConsentState()):k=g.ConsentState;var l={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:g.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:f,mp_deviceid:g.DeviceId,sdk_version:g.SDKVersion,// TODO: Refactor this to read from _Store or a global config
429
- application_info:{application_version:g.AppVersion,application_name:g.AppName,package:g.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:"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:g.UserAttributes,user_identities:convertUserIdentities(g.UserIdentities),consent_state:convertConsentState(k),integration_attributes:g.IntegrationAttributes};return g.DataPlan&&g.DataPlan.PlanId&&(l.context={data_plan:{plan_id:g.DataPlan.PlanId,plan_version:g.DataPlan.PlanVersion||void 0}}),l}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
427
+ var FeatureFlags$2=Constants.FeatureFlags,CaptureIntegrationSpecificIds$1=FeatureFlags$2.CaptureIntegrationSpecificIds;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
428
+ 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
429
+ 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}});var p=g&&!!g(CaptureIntegrationSpecificIds$1);if(p){var q=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(q)||(o.partner_identities=q);}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
430
430
  return convertCustomEvent(a);case Types.MessageType.PageView:return convertPageViewEvent(a);case Types.MessageType.Profile://deprecated and not supported by the web SDK
431
431
  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 convertShoppingCart(a){if(!a.ShoppingCart||!a.ShoppingCart.ProductList||!a.ShoppingCart.ProductList.length)return null;var b={products:convertProducts(a.ShoppingCart.ProductList)};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),shopping_cart:convertShoppingCart(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={application_transition_type:dist.ApplicationStateTransitionEventDataApplicationTransitionTypeEnum.applicationInitialized,is_first_run:a.IsFirstRun,is_upgrade:!1,launch_referral:a.LaunchReferral};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.applicationStateTransition,data:c}}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.
432
432
  //spanning_mpids: sdkEvent.SessionMpids
@@ -1421,11 +1421,15 @@ var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b|
1421
1421
  // of the URL for cookies, but in this case we are parsing the URL
1422
1422
  // itself, so we can ignore the use of 0 for 'com'
1423
1423
  3<=f.length&&(g=2);// If timestamp is not provided, use the current time
1424
- var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};var integrationMapping={// Facebook / Meta
1425
- fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor},_fbp:{mappedKey:"Facebook.BrowserId"},_fbc:{mappedKey:"Facebook.ClickId"},// Google
1426
- gclid:{mappedKey:"GoogleEnhancedConversions.Gclid"},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid"},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid"}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now();}/**
1424
+ 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
1425
+ // CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
1426
+ // PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
1427
+ var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_identities"},integrationMapping={// Facebook / Meta
1428
+ 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
1429
+ 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
1430
+ ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now(),this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS);}/**
1427
1431
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
1428
- */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{};a.fbclid&&b._fbc&&delete b._fbc,this.clickIds=__assign(__assign(__assign({},this.clickIds),a),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){var a,b={};if(!this.clickIds)return b;for(var c=0,d=Object.entries(this.clickIds);c<d.length;c++){var e=d[c],f=e[0],g=e[1],h=null===(a=integrationMapping[f])||void 0===a?void 0:a.mappedKey;isEmpty(h)||(b[h]=g);}return b},a.prototype.applyProcessors=function(a,b,c){for(var d,e={},f=0,g=Object.entries(a);f<g.length;f++){var h=g[f],i=h[0],j=h[1],k=null===(d=integrationMapping[i])||void 0===d?void 0:d.processor;e[i]=k?k(j,b,c):j;}return e},a}();
1432
+ */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{};a.fbclid&&b._fbc&&delete b._fbc,this.clickIds=__assign(__assign(__assign({},this.clickIds),a),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e=0,f=Object.entries(a);e<f.length;e++){var g=f[e],h=g[0],i=g[1],j=null===(c=b[h])||void 0===c?void 0:c.mappedKey;isEmpty(j)||(d[j]=i);}return d},a.prototype.applyProcessors=function(a,b,c){for(var d,e={},f=0,g=Object.entries(a);f<g.length;f++){var h=g[f],i=h[0],j=h[1],k=null===(d=integrationMapping[i])||void 0===d?void 0:d.processor;e[i]=k?k(j,b,c):j;}return e},a.prototype.filterMappings=function(a){return Object.fromEntries(Object.entries(integrationMapping).filter(function(b){var c=b[1];return c.output===a}))},a}();
1429
1433
 
1430
1434
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1431
1435
  * <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
package/dist/mparticle.js CHANGED
@@ -393,7 +393,7 @@ var mParticle = (function () {
393
393
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
394
394
  };
395
395
 
396
- var version = "2.31.1";
396
+ var version = "2.32.0";
397
397
 
398
398
  var Constants = {
399
399
  sdkVersion: version,
@@ -1495,6 +1495,8 @@ var mParticle = (function () {
1495
1495
  SDKIdentityTypeEnum["phoneNumber3"] = "phone_number_3";
1496
1496
  })(SDKIdentityTypeEnum || (SDKIdentityTypeEnum = {}));
1497
1497
 
1498
+ var FeatureFlags$2 = Constants.FeatureFlags;
1499
+ var CaptureIntegrationSpecificIds$1 = FeatureFlags$2.CaptureIntegrationSpecificIds;
1498
1500
  function convertEvents(mpid, sdkEvents, mpInstance) {
1499
1501
  if (!mpid) {
1500
1502
  return null;
@@ -1502,6 +1504,9 @@ var mParticle = (function () {
1502
1504
  if (!sdkEvents || sdkEvents.length < 1) {
1503
1505
  return null;
1504
1506
  }
1507
+ var _IntegrationCapture = mpInstance._IntegrationCapture,
1508
+ _Helpers = mpInstance._Helpers;
1509
+ var getFeatureFlag = _Helpers.getFeatureFlag;
1505
1510
  var user = mpInstance.Identity.getCurrentUser();
1506
1511
  var uploadEvents = [];
1507
1512
  var lastEvent = null;
@@ -1558,6 +1563,13 @@ var mParticle = (function () {
1558
1563
  }
1559
1564
  };
1560
1565
  }
1566
+ var isIntegrationCaptureEnabled = getFeatureFlag && Boolean(getFeatureFlag(CaptureIntegrationSpecificIds$1));
1567
+ if (isIntegrationCaptureEnabled) {
1568
+ var capturedPartnerIdentities = _IntegrationCapture === null || _IntegrationCapture === void 0 ? void 0 : _IntegrationCapture.getClickIdsAsPartnerIdentities();
1569
+ if (!isEmpty(capturedPartnerIdentities)) {
1570
+ upload.partner_identities = capturedPartnerIdentities;
1571
+ }
1572
+ }
1561
1573
  return upload;
1562
1574
  }
1563
1575
  function convertConsentState(sdkConsentState) {
@@ -9247,32 +9259,57 @@ var mParticle = (function () {
9247
9259
  var _timestamp = timestamp || Date.now();
9248
9260
  return "fb.".concat(subdomainIndex, ".").concat(_timestamp, ".").concat(clickId);
9249
9261
  };
9262
+ // Integration outputs are used to determine how click ids are used within the SDK
9263
+ // CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
9264
+ // PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
9265
+ var IntegrationOutputs = {
9266
+ CUSTOM_FLAGS: 'custom_flags',
9267
+ PARTNER_IDENTITIES: 'partner_identities'
9268
+ };
9250
9269
  var integrationMapping = {
9251
9270
  // Facebook / Meta
9252
9271
  fbclid: {
9253
9272
  mappedKey: 'Facebook.ClickId',
9254
- processor: facebookClickIdProcessor
9273
+ processor: facebookClickIdProcessor,
9274
+ output: IntegrationOutputs.CUSTOM_FLAGS
9255
9275
  },
9256
9276
  _fbp: {
9257
- mappedKey: 'Facebook.BrowserId'
9277
+ mappedKey: 'Facebook.BrowserId',
9278
+ output: IntegrationOutputs.CUSTOM_FLAGS
9258
9279
  },
9259
9280
  _fbc: {
9260
- mappedKey: 'Facebook.ClickId'
9281
+ mappedKey: 'Facebook.ClickId',
9282
+ output: IntegrationOutputs.CUSTOM_FLAGS
9261
9283
  },
9262
9284
  // Google
9263
9285
  gclid: {
9264
- mappedKey: 'GoogleEnhancedConversions.Gclid'
9286
+ mappedKey: 'GoogleEnhancedConversions.Gclid',
9287
+ output: IntegrationOutputs.CUSTOM_FLAGS
9265
9288
  },
9266
9289
  gbraid: {
9267
- mappedKey: 'GoogleEnhancedConversions.Gbraid'
9290
+ mappedKey: 'GoogleEnhancedConversions.Gbraid',
9291
+ output: IntegrationOutputs.CUSTOM_FLAGS
9268
9292
  },
9269
9293
  wbraid: {
9270
- mappedKey: 'GoogleEnhancedConversions.Wbraid'
9294
+ mappedKey: 'GoogleEnhancedConversions.Wbraid',
9295
+ output: IntegrationOutputs.CUSTOM_FLAGS
9296
+ },
9297
+ // TIKTOK
9298
+ ttclid: {
9299
+ mappedKey: 'TikTok.Callback',
9300
+ output: IntegrationOutputs.CUSTOM_FLAGS
9301
+ },
9302
+ _ttp: {
9303
+ mappedKey: 'tiktok_cookie_id',
9304
+ output: IntegrationOutputs.PARTNER_IDENTITIES
9271
9305
  }
9272
9306
  };
9273
9307
  var IntegrationCapture = /** @class */function () {
9274
9308
  function IntegrationCapture() {
9275
9309
  this.initialTimestamp = Date.now();
9310
+ // Cache filtered mappings for faster access
9311
+ this.filteredPartnerIdentityMappings = this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES);
9312
+ this.filteredCustomFlagMappings = this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS);
9276
9313
  }
9277
9314
  /**
9278
9315
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
@@ -9313,21 +9350,31 @@ var mParticle = (function () {
9313
9350
  * @returns {SDKEventCustomFlags} The custom flags.
9314
9351
  */
9315
9352
  IntegrationCapture.prototype.getClickIdsAsCustomFlags = function () {
9353
+ return this.getClickIds(this.clickIds, this.filteredCustomFlagMappings);
9354
+ };
9355
+ /**
9356
+ * Returns only the `partner_identities` mapped integration output.
9357
+ * @returns {Dictionary<string>} The partner identities.
9358
+ */
9359
+ IntegrationCapture.prototype.getClickIdsAsPartnerIdentities = function () {
9360
+ return this.getClickIds(this.clickIds, this.filteredPartnerIdentityMappings);
9361
+ };
9362
+ IntegrationCapture.prototype.getClickIds = function (clickIds, mappingList) {
9316
9363
  var _a;
9317
- var customFlags = {};
9318
- if (!this.clickIds) {
9319
- return customFlags;
9364
+ var mappedClickIds = {};
9365
+ if (!clickIds) {
9366
+ return mappedClickIds;
9320
9367
  }
9321
- for (var _i = 0, _b = Object.entries(this.clickIds); _i < _b.length; _i++) {
9368
+ for (var _i = 0, _b = Object.entries(clickIds); _i < _b.length; _i++) {
9322
9369
  var _c = _b[_i],
9323
9370
  key = _c[0],
9324
9371
  value = _c[1];
9325
- var mappedKey = (_a = integrationMapping[key]) === null || _a === void 0 ? void 0 : _a.mappedKey;
9372
+ var mappedKey = (_a = mappingList[key]) === null || _a === void 0 ? void 0 : _a.mappedKey;
9326
9373
  if (!isEmpty(mappedKey)) {
9327
- customFlags[mappedKey] = value;
9374
+ mappedClickIds[mappedKey] = value;
9328
9375
  }
9329
9376
  }
9330
- return customFlags;
9377
+ return mappedClickIds;
9331
9378
  };
9332
9379
  IntegrationCapture.prototype.applyProcessors = function (clickIds, url, timestamp) {
9333
9380
  var _a;
@@ -9345,6 +9392,12 @@ var mParticle = (function () {
9345
9392
  }
9346
9393
  return processedClickIds;
9347
9394
  };
9395
+ IntegrationCapture.prototype.filterMappings = function (outputType) {
9396
+ return Object.fromEntries(Object.entries(integrationMapping).filter(function (_a) {
9397
+ var value = _a[1];
9398
+ return value.output === outputType;
9399
+ }));
9400
+ };
9348
9401
  return IntegrationCapture;
9349
9402
  }();
9350
9403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.31.1",
3
+ "version": "2.32.0",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -5,6 +5,7 @@ import {
5
5
  getCookies,
6
6
  getHref,
7
7
  isEmpty,
8
+ valueof,
8
9
  } from './utils';
9
10
 
10
11
  export interface IntegrationCaptureProcessorFunction {
@@ -48,11 +49,24 @@ export const facebookClickIdProcessor: IntegrationCaptureProcessorFunction = (
48
49
 
49
50
  return `fb.${subdomainIndex}.${_timestamp}.${clickId}`;
50
51
  };
52
+
53
+ // Integration outputs are used to determine how click ids are used within the SDK
54
+ // CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
55
+ // PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
56
+
57
+ const IntegrationOutputs = {
58
+ CUSTOM_FLAGS: 'custom_flags',
59
+ PARTNER_IDENTITIES: 'partner_identities',
60
+ } as const;
61
+
62
+ interface IntegrationMappingItem {
63
+ mappedKey: string;
64
+ output: valueof<typeof IntegrationOutputs>;
65
+ processor?: IntegrationCaptureProcessorFunction;
66
+ }
67
+
51
68
  interface IntegrationIdMapping {
52
- [key: string]: {
53
- mappedKey: string;
54
- processor?: IntegrationCaptureProcessorFunction;
55
- };
69
+ [key: string]: IntegrationMappingItem;
56
70
  }
57
71
 
58
72
  const integrationMapping: IntegrationIdMapping = {
@@ -60,33 +74,54 @@ const integrationMapping: IntegrationIdMapping = {
60
74
  fbclid: {
61
75
  mappedKey: 'Facebook.ClickId',
62
76
  processor: facebookClickIdProcessor,
77
+ output: IntegrationOutputs.CUSTOM_FLAGS,
63
78
  },
64
79
  _fbp: {
65
80
  mappedKey: 'Facebook.BrowserId',
81
+ output: IntegrationOutputs.CUSTOM_FLAGS,
66
82
  },
67
83
  _fbc: {
68
84
  mappedKey: 'Facebook.ClickId',
85
+ output: IntegrationOutputs.CUSTOM_FLAGS,
69
86
  },
70
87
 
71
88
  // Google
72
89
  gclid: {
73
90
  mappedKey: 'GoogleEnhancedConversions.Gclid',
91
+ output: IntegrationOutputs.CUSTOM_FLAGS,
74
92
  },
75
93
  gbraid: {
76
94
  mappedKey: 'GoogleEnhancedConversions.Gbraid',
95
+ output: IntegrationOutputs.CUSTOM_FLAGS,
77
96
  },
78
97
  wbraid: {
79
98
  mappedKey: 'GoogleEnhancedConversions.Wbraid',
99
+ output: IntegrationOutputs.CUSTOM_FLAGS,
80
100
  },
81
101
 
102
+ // TIKTOK
103
+ ttclid: {
104
+ mappedKey: 'TikTok.Callback',
105
+ output: IntegrationOutputs.CUSTOM_FLAGS,
106
+ },
107
+ _ttp: {
108
+ mappedKey: 'tiktok_cookie_id',
109
+ output: IntegrationOutputs.PARTNER_IDENTITIES,
110
+ },
82
111
  };
83
112
 
84
113
  export default class IntegrationCapture {
85
114
  public clickIds: Dictionary<string>;
86
115
  public readonly initialTimestamp: number;
116
+ public readonly filteredPartnerIdentityMappings: IntegrationIdMapping;
117
+ public readonly filteredCustomFlagMappings: IntegrationIdMapping;
87
118
 
88
119
  constructor() {
89
120
  this.initialTimestamp = Date.now();
121
+
122
+ // Cache filtered mappings for faster access
123
+ this.filteredPartnerIdentityMappings = this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES);
124
+ this.filteredCustomFlagMappings = this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS);
90
125
  }
91
126
 
92
127
  /**
@@ -134,22 +169,42 @@ export default class IntegrationCapture {
134
169
  * @returns {SDKEventCustomFlags} The custom flags.
135
170
  */
136
171
  public getClickIdsAsCustomFlags(): SDKEventCustomFlags {
137
- const customFlags: SDKEventCustomFlags = {};
172
+ return this.getClickIds(this.clickIds, this.filteredCustomFlagMappings);
173
+ }
138
174
 
139
- if (!this.clickIds) {
140
- return customFlags;
175
+ /**
176
+ * Returns only the `partner_identities` mapped integration output.
177
+ * @returns {Dictionary<string>} The partner identities.
178
+ */
179
+ public getClickIdsAsPartnerIdentities(): Dictionary<string> {
180
+ return this.getClickIds(this.clickIds, this.filteredPartnerIdentityMappings);
181
+ }
182
+
183
+ private getClickIds(
184
+ clickIds: Dictionary<string>,
185
+ mappingList: IntegrationIdMapping
186
+ ): Dictionary<string> {
187
+ const mappedClickIds: Dictionary<string> = {};
188
+
189
+ if (!clickIds) {
190
+ return mappedClickIds;
141
191
  }
142
192
 
143
- for (const [key, value] of Object.entries(this.clickIds)) {
144
- const mappedKey = integrationMapping[key]?.mappedKey;
193
+ for (const [key, value] of Object.entries(clickIds)) {
194
+ const mappedKey = mappingList[key]?.mappedKey;
145
195
  if (!isEmpty(mappedKey)) {
146
- customFlags[mappedKey] = value;
196
+ mappedClickIds[mappedKey] = value;
147
197
  }
148
198
  }
149
- return customFlags;
199
+
200
+ return mappedClickIds;
150
201
  }
151
202
 
152
- private applyProcessors(clickIds: Dictionary<string>, url?: string, timestamp?: number): Dictionary<string> {
203
+ private applyProcessors(
204
+ clickIds: Dictionary<string>,
205
+ url?: string,
206
+ timestamp?: number
207
+ ): Dictionary<string> {
153
208
  const processedClickIds: Dictionary<string> = {};
154
209
 
155
210
  for (const [key, value] of Object.entries(clickIds)) {
@@ -163,4 +218,14 @@ export default class IntegrationCapture {
163
218
 
164
219
  return processedClickIds;
165
220
  }
221
+
222
+ private filterMappings(
223
+ outputType: valueof<typeof IntegrationOutputs>
224
+ ): IntegrationIdMapping {
225
+ return Object.fromEntries(
226
+ Object.entries(integrationMapping).filter(
227
+ ([, value]) => value.output === outputType
228
+ )
229
+ );
230
+ }
166
231
  }
@@ -13,15 +13,30 @@ import {
13
13
  SDKCCPAConsentState,
14
14
  } from './consent';
15
15
  import Types from './types';
16
- import { isEmpty } from './utils';
16
+ import { Dictionary, isEmpty } from './utils';
17
17
  import { ISDKUserIdentity } from './identity-user-interfaces';
18
18
  import { SDKIdentityTypeEnum } from './identity.interfaces';
19
+ import Constants from './constants';
20
+
21
+ const {
22
+ FeatureFlags
23
+ } = Constants;
24
+ const {
25
+ CaptureIntegrationSpecificIds
26
+ } = FeatureFlags;
27
+
28
+ type PartnerIdentities = Dictionary<string>;
29
+
30
+ // https://go.mparticle.com/work/SQDSDKS-6964
31
+ interface Batch extends EventsApi.Batch {
32
+ partner_identities?: PartnerIdentities;
33
+ }
19
34
 
20
35
  export function convertEvents(
21
36
  mpid: string,
22
37
  sdkEvents: SDKEvent[],
23
38
  mpInstance: MParticleWebSDK
24
- ): EventsApi.Batch | null {
39
+ ): Batch | null {
25
40
  if (!mpid) {
26
41
  return null;
27
42
  }
@@ -29,6 +44,16 @@ export function convertEvents(
29
44
  return null;
30
45
  }
31
46
 
47
+ const {
48
+ _IntegrationCapture,
49
+ _Helpers,
50
+ } = mpInstance
51
+
52
+ const {
53
+ getFeatureFlag,
54
+ } = _Helpers;
55
+
56
+
32
57
  const user = mpInstance.Identity.getCurrentUser();
33
58
 
34
59
  const uploadEvents: EventsApi.BaseEvent[] = [];
@@ -56,7 +81,7 @@ export function convertEvents(
56
81
  currentConsentState = user.getConsentState();
57
82
  }
58
83
 
59
- const upload: EventsApi.Batch = {
84
+ const upload: Batch = {
60
85
  source_request_id: mpInstance._Helpers.generateUniqueId(),
61
86
  mpid,
62
87
  timestamp_unixtime_ms: new Date().getTime(),
@@ -102,6 +127,15 @@ export function convertEvents(
102
127
  },
103
128
  };
104
129
  }
130
+
131
+ const isIntegrationCaptureEnabled: boolean = getFeatureFlag && Boolean(getFeatureFlag(CaptureIntegrationSpecificIds));
132
+ if (isIntegrationCaptureEnabled) {
133
+ const capturedPartnerIdentities: PartnerIdentities = _IntegrationCapture?.getClickIdsAsPartnerIdentities();
134
+ if (!isEmpty(capturedPartnerIdentities)) {
135
+ upload.partner_identities = capturedPartnerIdentities;
136
+ }
137
+ }
138
+
105
139
  return upload;
106
140
  }
107
141