@mparticle/web-sdk 2.31.0 → 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.0";
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
@@ -1392,7 +1392,11 @@ if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null=
1392
1392
  */if(!0===g)return d;if(g){switch(a.EventCategory){case Types.CommerceEventType.ProductImpression:d.ProductImpressions.forEach(function(a){b(g,null===a||void 0===a?void 0:a.ProductList);});break;case Types.CommerceEventType.ProductPurchase:b(g,null===(c=d.ProductAction)||void 0===c?void 0:c.ProductList);break;default:this.mpInstance.Logger.warning("Product Not Supported ");}return d}return d}return d},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
1393
1393
  If the user attribute is not found in the matchedAttributes
1394
1394
  then remove it from event.UserAttributes as it is blocked
1395
- */var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c))for(var d,e=0,f=Object.keys(b.UserAttributes);e<f.length;e++)d=f[e],c[d]||delete b.UserAttributes[d];}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;if(this.blockUserAttributes){var b=this.dataPlanMatchLookups.user_attributes;if(!0===b)return !1;if(!b[a])return !0}return !1},a.prototype.isIdentityBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserIdentities)return !1;if(this.blockUserIdentities){var b=this.dataPlanMatchLookups.user_identities;if(!0===b)return !1;if(!b[a])return !0}else return !1;return !1},a.prototype.transformUserIdentities=function(a){var b,c=this,d=__assign({},a);/*
1395
+ */var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c))for(var d,e=0,f=Object.keys(b.UserAttributes);e<f.length;e++)d=f[e],c[d]||delete b.UserAttributes[d];}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
1396
+ // will be a boolean, otherwise it will return an object
1397
+ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Block unplanned user attributes" is enabled and "Allow unplanned user
1398
+ // attributes" is also enabled in the UI, allowing unplanned user attributes will be prioritized
1399
+ },a.prototype.isIdentityBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserIdentities)return !1;if(this.blockUserIdentities){var b=this.dataPlanMatchLookups.user_identities;if(!0===b)return !1;if(!b[a])return !0}else return !1;return !1},a.prototype.transformUserIdentities=function(a){var b,c=this,d=__assign({},a);/*
1396
1400
  If the user identity is not found in matchedIdentities
1397
1401
  then remove it from event.UserIdentities as it is blocked.
1398
1402
  event.UserIdentities is of type [{Identity: 'id1', Type: 7}, ...]
@@ -1417,11 +1421,15 @@ var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b|
1417
1421
  // of the URL for cookies, but in this case we are parsing the URL
1418
1422
  // itself, so we can ignore the use of 0 for 'com'
1419
1423
  3<=f.length&&(g=2);// If timestamp is not provided, use the current time
1420
- var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};var integrationMapping={// Facebook / Meta
1421
- fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor},_fbp:{mappedKey:"Facebook.BrowserId"},_fbc:{mappedKey:"Facebook.ClickId"},// Google
1422
- 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);}/**
1423
1431
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
1424
- */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}();
1425
1433
 
1426
1434
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1427
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>
@@ -1601,7 +1609,7 @@ this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._Ses
1601
1609
  // Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
1602
1610
  // to it for it to be run after fetched
1603
1611
  if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()&&"function"==typeof a?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Types.Environment.Development:Types.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
1604
- b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=Types.EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=Types.EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:Types.MessageType.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(Types.EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:Types.MessageType.CrashReport,name:a.name?a.name:"Error",data:e,eventType:Types.EventType.Other});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:Types.MessageType.PageView,name:a,data:c,eventType:Types.EventType.Unknown,customFlags:d},e);}},this.upload=function(){b._Helpers.canLog()&&(b._Store.webviewBridgeEnabled?b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload):b._APIClient.uploader.prepareAndUpload(!1,!1));},this.Consent={/**
1612
+ b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=Types.EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=Types.EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:Types.MessageType.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(Types.EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:Types.MessageType.CrashReport,name:a.name?a.name:"Error",data:e,eventType:Types.EventType.Other});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:Types.MessageType.PageView,name:a,data:c,eventType:Types.EventType.Unknown,customFlags:d},e);}},this.upload=function(){if(b._Helpers.canLog())if(b._Store.webviewBridgeEnabled)b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload);else {var a;null===(a=b._APIClient)||void 0===a||null===(a=a.uploader)||void 0===a||a.prepareAndUpload(!1,!1);}},this.Consent={/**
1605
1613
  * Creates a CCPA Opt Out Consent State.
1606
1614
  *
1607
1615
  * @method createCCPAConsent
@@ -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.0";
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
@@ -1392,7 +1392,11 @@ if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null=
1392
1392
  */if(!0===g)return d;if(g){switch(a.EventCategory){case Types.CommerceEventType.ProductImpression:d.ProductImpressions.forEach(function(a){b(g,null===a||void 0===a?void 0:a.ProductList);});break;case Types.CommerceEventType.ProductPurchase:b(g,null===(c=d.ProductAction)||void 0===c?void 0:c.ProductList);break;default:this.mpInstance.Logger.warning("Product Not Supported ");}return d}return d}return d},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
1393
1393
  If the user attribute is not found in the matchedAttributes
1394
1394
  then remove it from event.UserAttributes as it is blocked
1395
- */var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c))for(var d,e=0,f=Object.keys(b.UserAttributes);e<f.length;e++)d=f[e],c[d]||delete b.UserAttributes[d];}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;if(this.blockUserAttributes){var b=this.dataPlanMatchLookups.user_attributes;if(!0===b)return !1;if(!b[a])return !0}return !1},a.prototype.isIdentityBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserIdentities)return !1;if(this.blockUserIdentities){var b=this.dataPlanMatchLookups.user_identities;if(!0===b)return !1;if(!b[a])return !0}else return !1;return !1},a.prototype.transformUserIdentities=function(a){var b,c=this,d=__assign({},a);/*
1395
+ */var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c))for(var d,e=0,f=Object.keys(b.UserAttributes);e<f.length;e++)d=f[e],c[d]||delete b.UserAttributes[d];}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
1396
+ // will be a boolean, otherwise it will return an object
1397
+ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Block unplanned user attributes" is enabled and "Allow unplanned user
1398
+ // attributes" is also enabled in the UI, allowing unplanned user attributes will be prioritized
1399
+ },a.prototype.isIdentityBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserIdentities)return !1;if(this.blockUserIdentities){var b=this.dataPlanMatchLookups.user_identities;if(!0===b)return !1;if(!b[a])return !0}else return !1;return !1},a.prototype.transformUserIdentities=function(a){var b,c=this,d=__assign({},a);/*
1396
1400
  If the user identity is not found in matchedIdentities
1397
1401
  then remove it from event.UserIdentities as it is blocked.
1398
1402
  event.UserIdentities is of type [{Identity: 'id1', Type: 7}, ...]
@@ -1417,11 +1421,15 @@ var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b|
1417
1421
  // of the URL for cookies, but in this case we are parsing the URL
1418
1422
  // itself, so we can ignore the use of 0 for 'com'
1419
1423
  3<=f.length&&(g=2);// If timestamp is not provided, use the current time
1420
- var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};var integrationMapping={// Facebook / Meta
1421
- fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor},_fbp:{mappedKey:"Facebook.BrowserId"},_fbc:{mappedKey:"Facebook.ClickId"},// Google
1422
- 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);}/**
1423
1431
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
1424
- */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}();
1425
1433
 
1426
1434
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1427
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>
@@ -1601,7 +1609,7 @@ this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._Ses
1601
1609
  // Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
1602
1610
  // to it for it to be run after fetched
1603
1611
  if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()&&"function"==typeof a?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Types.Environment.Development:Types.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
1604
- b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=Types.EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=Types.EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:Types.MessageType.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(Types.EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:Types.MessageType.CrashReport,name:a.name?a.name:"Error",data:e,eventType:Types.EventType.Other});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:Types.MessageType.PageView,name:a,data:c,eventType:Types.EventType.Unknown,customFlags:d},e);}},this.upload=function(){b._Helpers.canLog()&&(b._Store.webviewBridgeEnabled?b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload):b._APIClient.uploader.prepareAndUpload(!1,!1));},this.Consent={/**
1612
+ b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=Types.EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=Types.EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:Types.MessageType.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(Types.EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:Types.MessageType.CrashReport,name:a.name?a.name:"Error",data:e,eventType:Types.EventType.Other});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:Types.MessageType.PageView,name:a,data:c,eventType:Types.EventType.Unknown,customFlags:d},e);}},this.upload=function(){if(b._Helpers.canLog())if(b._Store.webviewBridgeEnabled)b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload);else {var a;null===(a=b._APIClient)||void 0===a||null===(a=a.uploader)||void 0===a||a.prepareAndUpload(!1,!1);}},this.Consent={/**
1605
1613
  * Creates a CCPA Opt Out Consent State.
1606
1614
  *
1607
1615
  * @method createCCPAConsent
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.0";
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) {
@@ -8885,15 +8897,21 @@ var mParticle = (function () {
8885
8897
  if (!this.blockUserAttributes) {
8886
8898
  return false;
8887
8899
  }
8888
- if (this.blockUserAttributes) {
8889
- var matchedAttributes = this.dataPlanMatchLookups['user_attributes'];
8890
- if (matchedAttributes === true) {
8900
+ var matchedAttributes = this.dataPlanMatchLookups['user_attributes'];
8901
+ // When additionalProperties is set to true, matchedAttributes
8902
+ // will be a boolean, otherwise it will return an object
8903
+ if (typeof matchedAttributes === 'boolean' && matchedAttributes) {
8904
+ return false;
8905
+ }
8906
+ if (_typeof$1(matchedAttributes) === "object") {
8907
+ if (matchedAttributes[key] === true) {
8891
8908
  return false;
8892
- }
8893
- if (!matchedAttributes[key]) {
8909
+ } else {
8894
8910
  return true;
8895
8911
  }
8896
8912
  }
8913
+ // When "Block unplanned user attributes" is enabled and "Allow unplanned user
8914
+ // attributes" is also enabled in the UI, allowing unplanned user attributes will be prioritized
8897
8915
  return false;
8898
8916
  };
8899
8917
  KitBlocker.prototype.isIdentityBlocked = function (key) {
@@ -9241,32 +9259,57 @@ var mParticle = (function () {
9241
9259
  var _timestamp = timestamp || Date.now();
9242
9260
  return "fb.".concat(subdomainIndex, ".").concat(_timestamp, ".").concat(clickId);
9243
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
+ };
9244
9269
  var integrationMapping = {
9245
9270
  // Facebook / Meta
9246
9271
  fbclid: {
9247
9272
  mappedKey: 'Facebook.ClickId',
9248
- processor: facebookClickIdProcessor
9273
+ processor: facebookClickIdProcessor,
9274
+ output: IntegrationOutputs.CUSTOM_FLAGS
9249
9275
  },
9250
9276
  _fbp: {
9251
- mappedKey: 'Facebook.BrowserId'
9277
+ mappedKey: 'Facebook.BrowserId',
9278
+ output: IntegrationOutputs.CUSTOM_FLAGS
9252
9279
  },
9253
9280
  _fbc: {
9254
- mappedKey: 'Facebook.ClickId'
9281
+ mappedKey: 'Facebook.ClickId',
9282
+ output: IntegrationOutputs.CUSTOM_FLAGS
9255
9283
  },
9256
9284
  // Google
9257
9285
  gclid: {
9258
- mappedKey: 'GoogleEnhancedConversions.Gclid'
9286
+ mappedKey: 'GoogleEnhancedConversions.Gclid',
9287
+ output: IntegrationOutputs.CUSTOM_FLAGS
9259
9288
  },
9260
9289
  gbraid: {
9261
- mappedKey: 'GoogleEnhancedConversions.Gbraid'
9290
+ mappedKey: 'GoogleEnhancedConversions.Gbraid',
9291
+ output: IntegrationOutputs.CUSTOM_FLAGS
9262
9292
  },
9263
9293
  wbraid: {
9264
- 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
9265
9305
  }
9266
9306
  };
9267
9307
  var IntegrationCapture = /** @class */function () {
9268
9308
  function IntegrationCapture() {
9269
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);
9270
9313
  }
9271
9314
  /**
9272
9315
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
@@ -9307,21 +9350,31 @@ var mParticle = (function () {
9307
9350
  * @returns {SDKEventCustomFlags} The custom flags.
9308
9351
  */
9309
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) {
9310
9363
  var _a;
9311
- var customFlags = {};
9312
- if (!this.clickIds) {
9313
- return customFlags;
9364
+ var mappedClickIds = {};
9365
+ if (!clickIds) {
9366
+ return mappedClickIds;
9314
9367
  }
9315
- 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++) {
9316
9369
  var _c = _b[_i],
9317
9370
  key = _c[0],
9318
9371
  value = _c[1];
9319
- 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;
9320
9373
  if (!isEmpty(mappedKey)) {
9321
- customFlags[mappedKey] = value;
9374
+ mappedClickIds[mappedKey] = value;
9322
9375
  }
9323
9376
  }
9324
- return customFlags;
9377
+ return mappedClickIds;
9325
9378
  };
9326
9379
  IntegrationCapture.prototype.applyProcessors = function (clickIds, url, timestamp) {
9327
9380
  var _a;
@@ -9339,6 +9392,12 @@ var mParticle = (function () {
9339
9392
  }
9340
9393
  return processedClickIds;
9341
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
+ };
9342
9401
  return IntegrationCapture;
9343
9402
  }();
9344
9403
 
@@ -9793,7 +9852,8 @@ var mParticle = (function () {
9793
9852
  if (self._Store.webviewBridgeEnabled) {
9794
9853
  self._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload);
9795
9854
  } else {
9796
- self._APIClient.uploader.prepareAndUpload(false, false);
9855
+ var _self$_APIClient;
9856
+ (_self$_APIClient = self._APIClient) === null || _self$_APIClient === void 0 || (_self$_APIClient = _self$_APIClient.uploader) === null || _self$_APIClient === void 0 || _self$_APIClient.prepareAndUpload(false, false);
9797
9857
  }
9798
9858
  }
9799
9859
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.31.0",
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
  }
@@ -460,17 +460,25 @@ export default class KitBlocker {
460
460
  if (!this.blockUserAttributes) {
461
461
  return false
462
462
  }
463
- if (this.blockUserAttributes) {
464
- const matchedAttributes = this.dataPlanMatchLookups['user_attributes'];
465
- if (matchedAttributes === true) {
466
- return false
467
- }
468
- if (!matchedAttributes[key]) {
469
- return true
463
+ const matchedAttributes = this.dataPlanMatchLookups['user_attributes'];
464
+
465
+ // When additionalProperties is set to true, matchedAttributes
466
+ // will be a boolean, otherwise it will return an object
467
+ if (typeof matchedAttributes === 'boolean' && matchedAttributes) {
468
+ return false
469
+ }
470
+
471
+ if (typeof matchedAttributes === "object") {
472
+ if (matchedAttributes[key] === true) {
473
+ return false;
474
+ } else {
475
+ return true;
470
476
  }
471
477
  }
472
478
 
473
- return false
479
+ // When "Block unplanned user attributes" is enabled and "Allow unplanned user
480
+ // attributes" is also enabled in the UI, allowing unplanned user attributes will be prioritized
481
+ return false;
474
482
  }
475
483
 
476
484
  isIdentityBlocked(key: string) {
@@ -591,7 +591,7 @@ export default function mParticleInstance(instanceName) {
591
591
  Constants.NativeSdkPaths.Upload
592
592
  );
593
593
  } else {
594
- self._APIClient.uploader.prepareAndUpload(false, false);
594
+ self._APIClient?.uploader?.prepareAndUpload(false, false);
595
595
  }
596
596
  }
597
597
  };
@@ -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