@mparticle/web-sdk 3.10.0 → 3.11.1
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.
- package/dist/mparticle.common.js +6 -17
- package/dist/mparticle.esm.js +6 -17
- package/dist/mparticle.js +51 -70
- package/dist/types/src/integrationCapture.d.ts +1 -2
- package/package.json +2 -1
- package/src/integrationCapture.ts +22 -66
- package/src/kitBlocking.ts +22 -16
- package/src/sdkToEventsApiConverter.ts +1 -0
package/dist/mparticle.common.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "3.
|
|
18
|
+
var version = "3.11.1";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -468,7 +468,7 @@ var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a
|
|
|
468
468
|
var FeatureFlags$2=Constants.FeatureFlags,CaptureIntegrationSpecificIds$1=FeatureFlags$2.CaptureIntegrationSpecificIds,CaptureIntegrationSpecificIdsV2$1=FeatureFlags$2.CaptureIntegrationSpecificIdsV2;function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c._IntegrationCapture,f=c._Helpers,g=f.getFeatureFlag,h=c.Identity.getCurrentUser(),i=[],j=null,k=0,l=b;k<l.length;k++)if(d=l[k],d){j=d;var m=convertEvent(d);m&&i.push(m);}if(!j)return null;var n=null;// Add the consent state from either the Last Event or the user
|
|
469
469
|
isEmpty(j.ConsentState)?!isEmpty(h)&&(n=h.getConsentState()):n=j.ConsentState;var o={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:j.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:i,mp_deviceid:j.DeviceId,sdk_version:j.SDKVersion,// TODO: Refactor this to read from _Store or a global config
|
|
470
470
|
application_info:{application_version:j.AppVersion,application_name:j.AppName,package:j.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.width:0,screen_height:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.height:0},user_attributes:j.UserAttributes,user_identities:convertUserIdentities(j.UserIdentities),consent_state:convertConsentState(n),integration_attributes:j.IntegrationAttributes};j.DataPlan&&j.DataPlan.PlanId&&(o.context={data_plan:{plan_id:j.DataPlan.PlanId,plan_version:j.DataPlan.PlanVersion||void 0}});// https://go.mparticle.com/work/SQDSDKS-7639
|
|
471
|
-
var p=g&&!!g(CaptureIntegrationSpecificIds$1),q=g&&g(CaptureIntegrationSpecificIdsV2$1),r=q&&q!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===p;if(r){var s=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(s)||(o.partner_identities=s);}return o}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
|
|
471
|
+
var p=g&&!!g(CaptureIntegrationSpecificIds$1),q=g&&g(CaptureIntegrationSpecificIdsV2$1),r=q&&q!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===p;if(r){null===e||void 0===e?void 0:e.capture();var s=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(s)||(o.partner_identities=s);}return o}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
|
|
472
472
|
return convertCustomEvent(a);case Types.MessageType.PageView:return convertPageViewEvent(a);case Types.MessageType.Profile://deprecated and not supported by the web SDK
|
|
473
473
|
return null;case Types.MessageType.SessionEnd:return convertSessionEndEvent(a);case Types.MessageType.SessionStart:return convertSessionStartEvent(a);case Types.MessageType.UserAttributeChange:return convertUserAttributeChangeEvent(a);case Types.MessageType.UserIdentityChange:return convertUserIdentityChangeEvent(a);}return null}function convertProductActionType(a){if(!a)return dist.ProductActionActionEnum.unknown;return a===SDKProductActionType.AddToCart?dist.ProductActionActionEnum.addToCart:a===SDKProductActionType.AddToWishlist?dist.ProductActionActionEnum.addToWishlist:a===SDKProductActionType.Checkout?dist.ProductActionActionEnum.checkout:a===SDKProductActionType.CheckoutOption?dist.ProductActionActionEnum.checkoutOption:a===SDKProductActionType.Click?dist.ProductActionActionEnum.click:a===SDKProductActionType.Purchase?dist.ProductActionActionEnum.purchase:a===SDKProductActionType.Refund?dist.ProductActionActionEnum.refund:a===SDKProductActionType.RemoveFromCart?dist.ProductActionActionEnum.removeFromCart:a===SDKProductActionType.RemoveFromWishlist?dist.ProductActionActionEnum.removeFromWishlist:a===SDKProductActionType.ViewDetail?dist.ProductActionActionEnum.viewDetail:dist.ProductActionActionEnum.unknown}function convertProductAction(a){if(!a.ProductAction)return null;var b={action:convertProductActionType(a.ProductAction.ProductActionType),checkout_step:a.ProductAction.CheckoutStep,checkout_options:a.ProductAction.CheckoutOptions,transaction_id:a.ProductAction.TransactionId,affiliation:a.ProductAction.Affiliation,total_amount:a.ProductAction.TotalAmount,tax_amount:a.ProductAction.TaxAmount,shipping_amount:a.ProductAction.ShippingAmount,coupon_code:a.ProductAction.CouponCode,products:convertProducts(a.ProductAction.ProductList)};return b}function convertProducts(a){if(!a||!a.length)return null;for(var b=[],c=0,d=a;c<d.length;c++){var e=d[c],f={id:e.Sku,name:e.Name,brand:e.Brand,category:e.Category,variant:e.Variant,total_product_amount:e.TotalAmount,position:e.Position,price:e.Price,quantity:e.Quantity,coupon_code:e.CouponCode,custom_attributes:e.Attributes};b.push(f);}return b}function convertPromotionAction(a){if(!a.PromotionAction)return null;var b={action:a.PromotionAction.PromotionActionType,promotions:convertPromotions(a.PromotionAction.PromotionList)};return b}function convertPromotions(a){if(!a||!a.length)return null;for(var b=[],c=0,d=a;c<d.length;c++){var e=d[c],f={id:e.Id,name:e.Name,creative:e.Creative,position:e.Position};b.push(f);}return b}function convertImpressions(a){if(!a.ProductImpressions)return null;for(var b=[],c=0,d=a.ProductImpressions;c<d.length;c++){var e=d[c],f={product_impression_list:e.ProductImpressionList,products:convertProducts(e.ProductList)};b.push(f);}return b}function convertCommerceEvent(a){var b=convertBaseEventData(a),c={custom_flags:a.CustomFlags,product_action:convertProductAction(a),promotion_action:convertPromotionAction(a),product_impressions:convertImpressions(a),currency_code:a.CurrencyCode};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.commerceEvent,data:c}}function convertCrashReportEvent(a){var b=convertBaseEventData(a),c={message:a.EventName};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.crashReport,data:c}}function convertAST(a){var b=convertBaseEventData(a),c=dist.ApplicationStateTransitionEventDataApplicationTransitionTypeEnum,d=c.applicationBackground,e=c.applicationInitialized,f=a.IsBackgroundAST?d:e,g={application_transition_type:f,is_first_run:a.IsFirstRun,is_upgrade:!1,launch_referral:a.LaunchReferral};// Determine the transition type based on IsBackgroundAST flag
|
|
474
474
|
return g=Object.assign(g,b),{event_type:dist.EventTypeEnum.applicationStateTransition,data:g}}function convertSessionEndEvent(a){var b=convertBaseEventData(a),c={session_duration_ms:a.SessionLength//note: External Events DTO does not support the session mpids array as of this time.
|
|
@@ -1270,21 +1270,14 @@ if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null=
|
|
|
1270
1270
|
return a transformed event based on event/event attributes,
|
|
1271
1271
|
then product attributes if applicable, then user attributes,
|
|
1272
1272
|
then the user identities
|
|
1273
|
-
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b=__assign({},a),
|
|
1273
|
+
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b,c=__assign({},a),d=convertEvent(c),e=this.getMatchKey(d),f=this.dataPlanMatchLookups[e];if(this.blockEvents&&!f)/*
|
|
1274
1274
|
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1275
1275
|
and should be blocked (return null to not send anything to forwarders)
|
|
1276
1276
|
*/return null;if(this.blockEventAttributes){/*
|
|
1277
1277
|
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1278
1278
|
otherwise, delete attributes that exist on event.EventAttributes
|
|
1279
1279
|
that aren't on
|
|
1280
|
-
*/if(!0===
|
|
1281
|
-
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1282
|
-
and should be blocked (return null to not send anything to forwarders)
|
|
1283
|
-
*/return null;if(this.blockEventAttributes){/*
|
|
1284
|
-
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1285
|
-
otherwise, delete attributes that exist on event.EventAttributes
|
|
1286
|
-
that aren't on
|
|
1287
|
-
*/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){/*
|
|
1280
|
+
*/if(!0===f)return c;if(f){for(var g,h=0,i=Object.keys(null!==(b=c.EventAttributes)&&void 0!==b?b:{});h<i.length;h++)g=i[h],f[g]||delete c.EventAttributes[g];return c}return c}return c},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
|
|
1288
1281
|
If the user attribute is not found in the matchedAttributes
|
|
1289
1282
|
then remove it from event.UserAttributes as it is blocked
|
|
1290
1283
|
*/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
|
|
@@ -1335,11 +1328,7 @@ _scid:{mappedKey:"SnapchatConversions.Cookie1",output:IntegrationOutputs.CUSTOM_
|
|
|
1335
1328
|
// https://go.mparticle.com/work/SQDSDKS-7167
|
|
1336
1329
|
rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},rclid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277}},IntegrationCapture=/** @class */function(){function a(a){this.initialTimestamp=Date.now(),this.captureMode=a,this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
|
|
1337
1330
|
* Captures Integration Ids from cookies and query params and stores them in clickIds object
|
|
1338
|
-
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};this.
|
|
1339
|
-
// If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
|
|
1340
|
-
// If RoktTransactionId is present in both cookies and localStorage,
|
|
1341
|
-
// prioritize localStorage
|
|
1342
|
-
var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c.RoktTransactionId,f&&delete b.RoktTransactionId):e&&f&&delete b.RoktTransactionId,this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),a),c),b);},a.prototype.captureCookies=function(){var a=this.getAllowedKeysForMode(),b=getCookies(a);return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){for(var a=this.getAllowedKeysForMode(),b={},c=0,d=a;c<d.length;c++){var e=d[c],f=localStorage.getItem(e);f&&(b[e]=f);}return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){var a=this.getAllowedKeysForMode();return queryStringParser(getHref(),a)},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
|
|
1331
|
+
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};this.normalizePinterestClickId(a),this.normalizePinterestClickId(c),this.normalizePinterestClickId(b),this.applySourcePrecedence([a,c,b,this.clickIds||{}]),this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),b),c),a);},a.prototype.captureCookies=function(){var a=this.getAllowedKeysForMode(),b=getCookies(a);return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){for(var a=this.getAllowedKeysForMode(),b={},c=0,d=a;c<d.length;c++){var e=d[c],f=localStorage.getItem(e);f&&(b[e]=f);}return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){var a=this.getAllowedKeysForMode();return queryStringParser(getHref(),a)},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
|
|
1343
1332
|
// {
|
|
1344
1333
|
// "integration_attributes": {
|
|
1345
1334
|
// "<moduleId>": {
|
|
@@ -1347,7 +1336,7 @@ var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c
|
|
|
1347
1336
|
// }
|
|
1348
1337
|
// }
|
|
1349
1338
|
// }
|
|
1350
|
-
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.normalizePinterestClickId=function(a){isEmpty(null===a||void 0===a?void 0:a._epik)||isEmpty(null===a||void 0===a?void 0:a.epik)||delete a.epik;},a.prototype.
|
|
1339
|
+
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.normalizePinterestClickId=function(a){isEmpty(null===a||void 0===a?void 0:a._epik)||isEmpty(null===a||void 0===a?void 0:a.epik)||delete a.epik;},a.prototype.applySourcePrecedence=function(a){for(var b=this.getActiveIntegrationMapping(),c=function outputOf(a){var c;return (null===(c=b[a])||void 0===c?void 0:c.mappedKey)||a},d=[],e=0,f=a;e<f.length;e++){var g=f[e],h=[];for(var i in g){var j=c(i);-1===d.indexOf(j)?!isEmpty(g[i])&&h.push(j):delete g[i];}d.push.apply(d,h);}},a.prototype.applyProcessors=function(a,b,c){var d,e={},f=this.getActiveIntegrationMapping();for(var g in a)if(a.hasOwnProperty(g)){var h=a[g],i=null===(d=f[g])||void 0===d?void 0:d.processor;e[g]=i?i(h,b,c):h;}return e},a.prototype.filterMappings=function(a){var b={},c=this.getActiveIntegrationMapping();for(var d in c)c[d].output===a&&(b[d]=c[d]);return b},a.prototype.getAllowedKeysForMode=function(){return Object.keys(this.getActiveIntegrationMapping())},a.prototype.getActiveIntegrationMapping=function(){return this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly?integrationMappingRokt:this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.All?__assign(__assign({},integrationMappingExternal),integrationMappingRokt):{}},a}();
|
|
1351
1340
|
|
|
1352
1341
|
var PASSBACK_CONVERSION_TRACKING_ID="passbackconversiontrackingid",ON_SHOPPABLE_ADS_READY_METHOD="onShoppableAdsReady",RoktManager=/** @class */function(){// Keys this manager's route subscription, so a re-executed bundle's manager replaces
|
|
1353
1342
|
// it while a second named instance keeps its own.
|
package/dist/mparticle.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "3.
|
|
18
|
+
var version = "3.11.1";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -468,7 +468,7 @@ var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a
|
|
|
468
468
|
var FeatureFlags$2=Constants.FeatureFlags,CaptureIntegrationSpecificIds$1=FeatureFlags$2.CaptureIntegrationSpecificIds,CaptureIntegrationSpecificIdsV2$1=FeatureFlags$2.CaptureIntegrationSpecificIdsV2;function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c._IntegrationCapture,f=c._Helpers,g=f.getFeatureFlag,h=c.Identity.getCurrentUser(),i=[],j=null,k=0,l=b;k<l.length;k++)if(d=l[k],d){j=d;var m=convertEvent(d);m&&i.push(m);}if(!j)return null;var n=null;// Add the consent state from either the Last Event or the user
|
|
469
469
|
isEmpty(j.ConsentState)?!isEmpty(h)&&(n=h.getConsentState()):n=j.ConsentState;var o={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:j.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:i,mp_deviceid:j.DeviceId,sdk_version:j.SDKVersion,// TODO: Refactor this to read from _Store or a global config
|
|
470
470
|
application_info:{application_version:j.AppVersion,application_name:j.AppName,package:j.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.width:0,screen_height:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.height:0},user_attributes:j.UserAttributes,user_identities:convertUserIdentities(j.UserIdentities),consent_state:convertConsentState(n),integration_attributes:j.IntegrationAttributes};j.DataPlan&&j.DataPlan.PlanId&&(o.context={data_plan:{plan_id:j.DataPlan.PlanId,plan_version:j.DataPlan.PlanVersion||void 0}});// https://go.mparticle.com/work/SQDSDKS-7639
|
|
471
|
-
var p=g&&!!g(CaptureIntegrationSpecificIds$1),q=g&&g(CaptureIntegrationSpecificIdsV2$1),r=q&&q!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===p;if(r){var s=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(s)||(o.partner_identities=s);}return o}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
|
|
471
|
+
var p=g&&!!g(CaptureIntegrationSpecificIds$1),q=g&&g(CaptureIntegrationSpecificIdsV2$1),r=q&&q!==Constants.CaptureIntegrationSpecificIdsV2Modes.None||!0===p;if(r){null===e||void 0===e?void 0:e.capture();var s=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(s)||(o.partner_identities=s);}return o}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
|
|
472
472
|
return convertCustomEvent(a);case Types.MessageType.PageView:return convertPageViewEvent(a);case Types.MessageType.Profile://deprecated and not supported by the web SDK
|
|
473
473
|
return null;case Types.MessageType.SessionEnd:return convertSessionEndEvent(a);case Types.MessageType.SessionStart:return convertSessionStartEvent(a);case Types.MessageType.UserAttributeChange:return convertUserAttributeChangeEvent(a);case Types.MessageType.UserIdentityChange:return convertUserIdentityChangeEvent(a);}return null}function convertProductActionType(a){if(!a)return dist.ProductActionActionEnum.unknown;return a===SDKProductActionType.AddToCart?dist.ProductActionActionEnum.addToCart:a===SDKProductActionType.AddToWishlist?dist.ProductActionActionEnum.addToWishlist:a===SDKProductActionType.Checkout?dist.ProductActionActionEnum.checkout:a===SDKProductActionType.CheckoutOption?dist.ProductActionActionEnum.checkoutOption:a===SDKProductActionType.Click?dist.ProductActionActionEnum.click:a===SDKProductActionType.Purchase?dist.ProductActionActionEnum.purchase:a===SDKProductActionType.Refund?dist.ProductActionActionEnum.refund:a===SDKProductActionType.RemoveFromCart?dist.ProductActionActionEnum.removeFromCart:a===SDKProductActionType.RemoveFromWishlist?dist.ProductActionActionEnum.removeFromWishlist:a===SDKProductActionType.ViewDetail?dist.ProductActionActionEnum.viewDetail:dist.ProductActionActionEnum.unknown}function convertProductAction(a){if(!a.ProductAction)return null;var b={action:convertProductActionType(a.ProductAction.ProductActionType),checkout_step:a.ProductAction.CheckoutStep,checkout_options:a.ProductAction.CheckoutOptions,transaction_id:a.ProductAction.TransactionId,affiliation:a.ProductAction.Affiliation,total_amount:a.ProductAction.TotalAmount,tax_amount:a.ProductAction.TaxAmount,shipping_amount:a.ProductAction.ShippingAmount,coupon_code:a.ProductAction.CouponCode,products:convertProducts(a.ProductAction.ProductList)};return b}function convertProducts(a){if(!a||!a.length)return null;for(var b=[],c=0,d=a;c<d.length;c++){var e=d[c],f={id:e.Sku,name:e.Name,brand:e.Brand,category:e.Category,variant:e.Variant,total_product_amount:e.TotalAmount,position:e.Position,price:e.Price,quantity:e.Quantity,coupon_code:e.CouponCode,custom_attributes:e.Attributes};b.push(f);}return b}function convertPromotionAction(a){if(!a.PromotionAction)return null;var b={action:a.PromotionAction.PromotionActionType,promotions:convertPromotions(a.PromotionAction.PromotionList)};return b}function convertPromotions(a){if(!a||!a.length)return null;for(var b=[],c=0,d=a;c<d.length;c++){var e=d[c],f={id:e.Id,name:e.Name,creative:e.Creative,position:e.Position};b.push(f);}return b}function convertImpressions(a){if(!a.ProductImpressions)return null;for(var b=[],c=0,d=a.ProductImpressions;c<d.length;c++){var e=d[c],f={product_impression_list:e.ProductImpressionList,products:convertProducts(e.ProductList)};b.push(f);}return b}function convertCommerceEvent(a){var b=convertBaseEventData(a),c={custom_flags:a.CustomFlags,product_action:convertProductAction(a),promotion_action:convertPromotionAction(a),product_impressions:convertImpressions(a),currency_code:a.CurrencyCode};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.commerceEvent,data:c}}function convertCrashReportEvent(a){var b=convertBaseEventData(a),c={message:a.EventName};return c=Object.assign(c,b),{event_type:dist.EventTypeEnum.crashReport,data:c}}function convertAST(a){var b=convertBaseEventData(a),c=dist.ApplicationStateTransitionEventDataApplicationTransitionTypeEnum,d=c.applicationBackground,e=c.applicationInitialized,f=a.IsBackgroundAST?d:e,g={application_transition_type:f,is_first_run:a.IsFirstRun,is_upgrade:!1,launch_referral:a.LaunchReferral};// Determine the transition type based on IsBackgroundAST flag
|
|
474
474
|
return g=Object.assign(g,b),{event_type:dist.EventTypeEnum.applicationStateTransition,data:g}}function convertSessionEndEvent(a){var b=convertBaseEventData(a),c={session_duration_ms:a.SessionLength//note: External Events DTO does not support the session mpids array as of this time.
|
|
@@ -1270,21 +1270,14 @@ if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null=
|
|
|
1270
1270
|
return a transformed event based on event/event attributes,
|
|
1271
1271
|
then product attributes if applicable, then user attributes,
|
|
1272
1272
|
then the user identities
|
|
1273
|
-
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b=__assign({},a),
|
|
1273
|
+
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b,c=__assign({},a),d=convertEvent(c),e=this.getMatchKey(d),f=this.dataPlanMatchLookups[e];if(this.blockEvents&&!f)/*
|
|
1274
1274
|
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1275
1275
|
and should be blocked (return null to not send anything to forwarders)
|
|
1276
1276
|
*/return null;if(this.blockEventAttributes){/*
|
|
1277
1277
|
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1278
1278
|
otherwise, delete attributes that exist on event.EventAttributes
|
|
1279
1279
|
that aren't on
|
|
1280
|
-
*/if(!0===
|
|
1281
|
-
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1282
|
-
and should be blocked (return null to not send anything to forwarders)
|
|
1283
|
-
*/return null;if(this.blockEventAttributes){/*
|
|
1284
|
-
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1285
|
-
otherwise, delete attributes that exist on event.EventAttributes
|
|
1286
|
-
that aren't on
|
|
1287
|
-
*/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){/*
|
|
1280
|
+
*/if(!0===f)return c;if(f){for(var g,h=0,i=Object.keys(null!==(b=c.EventAttributes)&&void 0!==b?b:{});h<i.length;h++)g=i[h],f[g]||delete c.EventAttributes[g];return c}return c}return c},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
|
|
1288
1281
|
If the user attribute is not found in the matchedAttributes
|
|
1289
1282
|
then remove it from event.UserAttributes as it is blocked
|
|
1290
1283
|
*/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
|
|
@@ -1335,11 +1328,7 @@ _scid:{mappedKey:"SnapchatConversions.Cookie1",output:IntegrationOutputs.CUSTOM_
|
|
|
1335
1328
|
// https://go.mparticle.com/work/SQDSDKS-7167
|
|
1336
1329
|
rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},rclid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277}},IntegrationCapture=/** @class */function(){function a(a){this.initialTimestamp=Date.now(),this.captureMode=a,this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
|
|
1337
1330
|
* Captures Integration Ids from cookies and query params and stores them in clickIds object
|
|
1338
|
-
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};this.
|
|
1339
|
-
// If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
|
|
1340
|
-
// If RoktTransactionId is present in both cookies and localStorage,
|
|
1341
|
-
// prioritize localStorage
|
|
1342
|
-
var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c.RoktTransactionId,f&&delete b.RoktTransactionId):e&&f&&delete b.RoktTransactionId,this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),a),c),b);},a.prototype.captureCookies=function(){var a=this.getAllowedKeysForMode(),b=getCookies(a);return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){for(var a=this.getAllowedKeysForMode(),b={},c=0,d=a;c<d.length;c++){var e=d[c],f=localStorage.getItem(e);f&&(b[e]=f);}return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){var a=this.getAllowedKeysForMode();return queryStringParser(getHref(),a)},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
|
|
1331
|
+
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};this.normalizePinterestClickId(a),this.normalizePinterestClickId(c),this.normalizePinterestClickId(b),this.applySourcePrecedence([a,c,b,this.clickIds||{}]),this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),b),c),a);},a.prototype.captureCookies=function(){var a=this.getAllowedKeysForMode(),b=getCookies(a);return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){for(var a=this.getAllowedKeysForMode(),b={},c=0,d=a;c<d.length;c++){var e=d[c],f=localStorage.getItem(e);f&&(b[e]=f);}return this.applyProcessors(b,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){var a=this.getAllowedKeysForMode();return queryStringParser(getHref(),a)},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
|
|
1343
1332
|
// {
|
|
1344
1333
|
// "integration_attributes": {
|
|
1345
1334
|
// "<moduleId>": {
|
|
@@ -1347,7 +1336,7 @@ var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c
|
|
|
1347
1336
|
// }
|
|
1348
1337
|
// }
|
|
1349
1338
|
// }
|
|
1350
|
-
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.normalizePinterestClickId=function(a){isEmpty(null===a||void 0===a?void 0:a._epik)||isEmpty(null===a||void 0===a?void 0:a.epik)||delete a.epik;},a.prototype.
|
|
1339
|
+
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.normalizePinterestClickId=function(a){isEmpty(null===a||void 0===a?void 0:a._epik)||isEmpty(null===a||void 0===a?void 0:a.epik)||delete a.epik;},a.prototype.applySourcePrecedence=function(a){for(var b=this.getActiveIntegrationMapping(),c=function outputOf(a){var c;return (null===(c=b[a])||void 0===c?void 0:c.mappedKey)||a},d=[],e=0,f=a;e<f.length;e++){var g=f[e],h=[];for(var i in g){var j=c(i);-1===d.indexOf(j)?!isEmpty(g[i])&&h.push(j):delete g[i];}d.push.apply(d,h);}},a.prototype.applyProcessors=function(a,b,c){var d,e={},f=this.getActiveIntegrationMapping();for(var g in a)if(a.hasOwnProperty(g)){var h=a[g],i=null===(d=f[g])||void 0===d?void 0:d.processor;e[g]=i?i(h,b,c):h;}return e},a.prototype.filterMappings=function(a){var b={},c=this.getActiveIntegrationMapping();for(var d in c)c[d].output===a&&(b[d]=c[d]);return b},a.prototype.getAllowedKeysForMode=function(){return Object.keys(this.getActiveIntegrationMapping())},a.prototype.getActiveIntegrationMapping=function(){return this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly?integrationMappingRokt:this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.All?__assign(__assign({},integrationMappingExternal),integrationMappingRokt):{}},a}();
|
|
1351
1340
|
|
|
1352
1341
|
var PASSBACK_CONVERSION_TRACKING_ID="passbackconversiontrackingid",ON_SHOPPABLE_ADS_READY_METHOD="onShoppableAdsReady",RoktManager=/** @class */function(){// Keys this manager's route subscription, so a re-executed bundle's manager replaces
|
|
1353
1342
|
// it while a second named instance keeps its own.
|
package/dist/mparticle.js
CHANGED
|
@@ -204,7 +204,7 @@ var mParticle = (function () {
|
|
|
204
204
|
Base64: Base64$1
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
var version = "3.
|
|
207
|
+
var version = "3.11.1";
|
|
208
208
|
|
|
209
209
|
var Constants = {
|
|
210
210
|
sdkVersion: version,
|
|
@@ -1888,6 +1888,7 @@ var mParticle = (function () {
|
|
|
1888
1888
|
var integrationSpecificIdsV2 = getFeatureFlag && getFeatureFlag(CaptureIntegrationSpecificIdsV2$1);
|
|
1889
1889
|
var isIntegrationCaptureEnabled = integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None || integrationSpecificIds === true;
|
|
1890
1890
|
if (isIntegrationCaptureEnabled) {
|
|
1891
|
+
_IntegrationCapture === null || _IntegrationCapture === void 0 ? void 0 : _IntegrationCapture.capture();
|
|
1891
1892
|
var capturedPartnerIdentities = _IntegrationCapture === null || _IntegrationCapture === void 0 ? void 0 : _IntegrationCapture.getClickIdsAsPartnerIdentities();
|
|
1892
1893
|
if (!isEmpty(capturedPartnerIdentities)) {
|
|
1893
1894
|
upload.partner_identities = capturedPartnerIdentities;
|
|
@@ -9811,6 +9812,7 @@ var mParticle = (function () {
|
|
|
9811
9812
|
}
|
|
9812
9813
|
};
|
|
9813
9814
|
KitBlocker.prototype.transformEventAndEventAttributes = function (event) {
|
|
9815
|
+
var _a;
|
|
9814
9816
|
var clonedEvent = __assign({}, event);
|
|
9815
9817
|
var baseEvent = convertEvent(clonedEvent);
|
|
9816
9818
|
var matchKey = this.getMatchKey(baseEvent);
|
|
@@ -9834,8 +9836,8 @@ var mParticle = (function () {
|
|
|
9834
9836
|
return clonedEvent;
|
|
9835
9837
|
}
|
|
9836
9838
|
if (matchedEvent) {
|
|
9837
|
-
for (var _i = 0,
|
|
9838
|
-
var key =
|
|
9839
|
+
for (var _i = 0, _b = Object.keys((_a = clonedEvent.EventAttributes) !== null && _a !== void 0 ? _a : {}); _i < _b.length; _i++) {
|
|
9840
|
+
var key = _b[_i];
|
|
9839
9841
|
if (!matchedEvent[key]) {
|
|
9840
9842
|
delete clonedEvent.EventAttributes[key];
|
|
9841
9843
|
}
|
|
@@ -9848,19 +9850,25 @@ var mParticle = (function () {
|
|
|
9848
9850
|
return clonedEvent;
|
|
9849
9851
|
};
|
|
9850
9852
|
KitBlocker.prototype.transformProductAttributes = function (event) {
|
|
9851
|
-
var _a;
|
|
9852
9853
|
var clonedEvent = __assign({}, event);
|
|
9853
9854
|
var baseEvent = convertEvent(clonedEvent);
|
|
9854
9855
|
var matchKey = this.getProductAttributeMatchKey(baseEvent);
|
|
9855
9856
|
var matchedEvent = this.dataPlanMatchLookups[matchKey];
|
|
9856
|
-
function
|
|
9857
|
-
productList.
|
|
9857
|
+
function withPlannedAttributesOnly(plannedAttributes, productList) {
|
|
9858
|
+
return productList === null || productList === void 0 ? void 0 : productList.map(function (product) {
|
|
9859
|
+
if (!product.Attributes) {
|
|
9860
|
+
return product;
|
|
9861
|
+
}
|
|
9862
|
+
var attributes = {};
|
|
9858
9863
|
for (var _i = 0, _a = Object.keys(product.Attributes); _i < _a.length; _i++) {
|
|
9859
9864
|
var productKey = _a[_i];
|
|
9860
|
-
if (
|
|
9861
|
-
|
|
9865
|
+
if (plannedAttributes[productKey] === true) {
|
|
9866
|
+
attributes[productKey] = product.Attributes[productKey];
|
|
9862
9867
|
}
|
|
9863
9868
|
}
|
|
9869
|
+
return __assign(__assign({}, product), {
|
|
9870
|
+
Attributes: attributes
|
|
9871
|
+
});
|
|
9864
9872
|
});
|
|
9865
9873
|
}
|
|
9866
9874
|
if (this.blockEvents) {
|
|
@@ -9882,17 +9890,18 @@ var mParticle = (function () {
|
|
|
9882
9890
|
return clonedEvent;
|
|
9883
9891
|
}
|
|
9884
9892
|
if (matchedEvent) {
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
clonedEvent.
|
|
9888
|
-
|
|
9893
|
+
if (clonedEvent.ProductAction) {
|
|
9894
|
+
clonedEvent.ProductAction = __assign(__assign({}, clonedEvent.ProductAction), {
|
|
9895
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, clonedEvent.ProductAction.ProductList)
|
|
9896
|
+
});
|
|
9897
|
+
} else if (clonedEvent.ProductImpressions) {
|
|
9898
|
+
clonedEvent.ProductImpressions = clonedEvent.ProductImpressions.map(function (impression) {
|
|
9899
|
+
return __assign(__assign({}, impression), {
|
|
9900
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, impression.ProductList)
|
|
9889
9901
|
});
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
break;
|
|
9894
|
-
default:
|
|
9895
|
-
this.mpInstance.Logger.warning('Product Not Supported ');
|
|
9902
|
+
});
|
|
9903
|
+
} else {
|
|
9904
|
+
this.mpInstance.Logger.warning('Product Not Supported ');
|
|
9896
9905
|
}
|
|
9897
9906
|
return clonedEvent;
|
|
9898
9907
|
} else {
|
|
@@ -10458,34 +10467,11 @@ var mParticle = (function () {
|
|
|
10458
10467
|
var queryParams = this.captureQueryParams() || {};
|
|
10459
10468
|
var cookies = this.captureCookies() || {};
|
|
10460
10469
|
var localStorage = this.captureLocalStorage() || {};
|
|
10461
|
-
this.
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
delete cookies['_fbc'];
|
|
10467
|
-
}
|
|
10468
|
-
// ROKT Rules
|
|
10469
|
-
// If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
|
|
10470
|
-
// If RoktTransactionId is present in both cookies and localStorage,
|
|
10471
|
-
// prioritize localStorage
|
|
10472
|
-
var hasQueryParamId = queryParams['rtid'] || queryParams['rclid'];
|
|
10473
|
-
var hasLocalStorageId = localStorage['RoktTransactionId'];
|
|
10474
|
-
var hasCookieId = cookies['RoktTransactionId'];
|
|
10475
|
-
if (hasQueryParamId) {
|
|
10476
|
-
// Query param takes precedence, remove both localStorage and cookie if present
|
|
10477
|
-
if (hasLocalStorageId) {
|
|
10478
|
-
delete localStorage['RoktTransactionId'];
|
|
10479
|
-
}
|
|
10480
|
-
if (hasCookieId) {
|
|
10481
|
-
delete cookies['RoktTransactionId'];
|
|
10482
|
-
}
|
|
10483
|
-
} else if (hasLocalStorageId && hasCookieId) {
|
|
10484
|
-
// No query param, but both localStorage and cookie exist
|
|
10485
|
-
// localStorage takes precedence over cookie
|
|
10486
|
-
delete cookies['RoktTransactionId'];
|
|
10487
|
-
}
|
|
10488
|
-
this.clickIds = __assign(__assign(__assign(__assign({}, this.clickIds), queryParams), localStorage), cookies);
|
|
10470
|
+
this.normalizePinterestClickId(queryParams);
|
|
10471
|
+
this.normalizePinterestClickId(localStorage);
|
|
10472
|
+
this.normalizePinterestClickId(cookies);
|
|
10473
|
+
this.applySourcePrecedence([queryParams, localStorage, cookies, this.clickIds || {}]);
|
|
10474
|
+
this.clickIds = __assign(__assign(__assign(__assign({}, this.clickIds), cookies), localStorage), queryParams);
|
|
10489
10475
|
};
|
|
10490
10476
|
/**
|
|
10491
10477
|
* Captures cookies based on the integration ID mapping.
|
|
@@ -10593,30 +10579,25 @@ var mParticle = (function () {
|
|
|
10593
10579
|
delete clickIds['epik'];
|
|
10594
10580
|
}
|
|
10595
10581
|
};
|
|
10596
|
-
IntegrationCapture.prototype.
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
return;
|
|
10616
|
-
}
|
|
10617
|
-
if (this.hasPinterestAlias(localStorage)) {
|
|
10618
|
-
delete cookies['epik'];
|
|
10619
|
-
delete cookies['_epik'];
|
|
10582
|
+
IntegrationCapture.prototype.applySourcePrecedence = function (sourcesInPrecedenceOrder) {
|
|
10583
|
+
var mapping = this.getActiveIntegrationMapping();
|
|
10584
|
+
var outputOf = function outputOf(key) {
|
|
10585
|
+
var _a;
|
|
10586
|
+
return ((_a = mapping[key]) === null || _a === void 0 ? void 0 : _a.mappedKey) || key;
|
|
10587
|
+
};
|
|
10588
|
+
var outputsHeldByHigherSources = [];
|
|
10589
|
+
for (var _i = 0, sourcesInPrecedenceOrder_1 = sourcesInPrecedenceOrder; _i < sourcesInPrecedenceOrder_1.length; _i++) {
|
|
10590
|
+
var source = sourcesInPrecedenceOrder_1[_i];
|
|
10591
|
+
var outputsHeldBySource = [];
|
|
10592
|
+
for (var key in source) {
|
|
10593
|
+
var output = outputOf(key);
|
|
10594
|
+
if (outputsHeldByHigherSources.indexOf(output) !== -1) {
|
|
10595
|
+
delete source[key];
|
|
10596
|
+
} else if (!isEmpty(source[key])) {
|
|
10597
|
+
outputsHeldBySource.push(output);
|
|
10598
|
+
}
|
|
10599
|
+
}
|
|
10600
|
+
outputsHeldByHigherSources.push.apply(outputsHeldByHigherSources, outputsHeldBySource);
|
|
10620
10601
|
}
|
|
10621
10602
|
};
|
|
10622
10603
|
IntegrationCapture.prototype.applyProcessors = function (clickIds, url, timestamp) {
|
|
@@ -66,8 +66,7 @@ export default class IntegrationCapture {
|
|
|
66
66
|
getClickIdsAsIntegrationAttributes(): IntegrationAttributes;
|
|
67
67
|
private getClickIds;
|
|
68
68
|
private normalizePinterestClickId;
|
|
69
|
-
private
|
|
70
|
-
private applyPinterestRules;
|
|
69
|
+
private applySourcePrecedence;
|
|
71
70
|
private applyProcessors;
|
|
72
71
|
private filterMappings;
|
|
73
72
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "mParticle core SDK for web applications",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"gts:check": "gts check",
|
|
86
86
|
"gts:fix": "gts fix",
|
|
87
87
|
"prettier": "node_modules/.bin/prettier --check \"**/*.js\"",
|
|
88
|
+
"typecheck:v3-candidate": "tsc -p tsconfig.candidate.json",
|
|
88
89
|
"uglify": "npx uglify-js dist/mparticle.js --output dist/mparticle.min.js",
|
|
89
90
|
"gzip": "gzip -c dist/mparticle.min.js > dist/mparticle.min.js.gz",
|
|
90
91
|
"bundle": "npm run uglify && npm run gzip",
|
|
@@ -186,42 +186,17 @@ export default class IntegrationCapture {
|
|
|
186
186
|
const cookies = this.captureCookies() || {};
|
|
187
187
|
const localStorage = this.captureLocalStorage() || {};
|
|
188
188
|
|
|
189
|
-
this.
|
|
189
|
+
this.normalizePinterestClickId(queryParams);
|
|
190
|
+
this.normalizePinterestClickId(localStorage);
|
|
191
|
+
this.normalizePinterestClickId(cookies);
|
|
190
192
|
|
|
191
|
-
|
|
192
|
-
// Exclude _fbc if fbclid is present
|
|
193
|
-
// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#retrieve-from-fbclid-url-query-parameter
|
|
194
|
-
if (queryParams['fbclid'] && cookies['_fbc']) {
|
|
195
|
-
delete cookies['_fbc'];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// ROKT Rules
|
|
199
|
-
// If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
|
|
200
|
-
// If RoktTransactionId is present in both cookies and localStorage,
|
|
201
|
-
// prioritize localStorage
|
|
202
|
-
const hasQueryParamId = queryParams['rtid'] || queryParams['rclid'];
|
|
203
|
-
const hasLocalStorageId = localStorage['RoktTransactionId'];
|
|
204
|
-
const hasCookieId = cookies['RoktTransactionId'];
|
|
205
|
-
|
|
206
|
-
if (hasQueryParamId) {
|
|
207
|
-
// Query param takes precedence, remove both localStorage and cookie if present
|
|
208
|
-
if (hasLocalStorageId) {
|
|
209
|
-
delete localStorage['RoktTransactionId'];
|
|
210
|
-
}
|
|
211
|
-
if (hasCookieId) {
|
|
212
|
-
delete cookies['RoktTransactionId'];
|
|
213
|
-
}
|
|
214
|
-
} else if (hasLocalStorageId && hasCookieId) {
|
|
215
|
-
// No query param, but both localStorage and cookie exist
|
|
216
|
-
// localStorage takes precedence over cookie
|
|
217
|
-
delete cookies['RoktTransactionId'];
|
|
218
|
-
}
|
|
193
|
+
this.applySourcePrecedence([queryParams, localStorage, cookies, this.clickIds || {}]);
|
|
219
194
|
|
|
220
195
|
this.clickIds = {
|
|
221
196
|
...this.clickIds,
|
|
222
|
-
...
|
|
197
|
+
...cookies,
|
|
223
198
|
...localStorage,
|
|
224
|
-
...
|
|
199
|
+
...queryParams,
|
|
225
200
|
};
|
|
226
201
|
}
|
|
227
202
|
|
|
@@ -345,41 +320,22 @@ export default class IntegrationCapture {
|
|
|
345
320
|
}
|
|
346
321
|
}
|
|
347
322
|
|
|
348
|
-
private
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
this.hasPinterestAlias(queryParams) ||
|
|
365
|
-
this.hasPinterestAlias(localStorage) ||
|
|
366
|
-
this.hasPinterestAlias(cookies)
|
|
367
|
-
) {
|
|
368
|
-
delete this.clickIds?.['epik'];
|
|
369
|
-
delete this.clickIds?.['_epik'];
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (this.hasPinterestAlias(queryParams)) {
|
|
373
|
-
delete cookies['epik'];
|
|
374
|
-
delete cookies['_epik'];
|
|
375
|
-
delete localStorage['epik'];
|
|
376
|
-
delete localStorage['_epik'];
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (this.hasPinterestAlias(localStorage)) {
|
|
381
|
-
delete cookies['epik'];
|
|
382
|
-
delete cookies['_epik'];
|
|
323
|
+
private applySourcePrecedence(sourcesInPrecedenceOrder: Dictionary<string>[]): void {
|
|
324
|
+
const mapping = this.getActiveIntegrationMapping();
|
|
325
|
+
const outputOf = (key: string): string => mapping[key]?.mappedKey || key;
|
|
326
|
+
const outputsHeldByHigherSources: string[] = [];
|
|
327
|
+
|
|
328
|
+
for (const source of sourcesInPrecedenceOrder) {
|
|
329
|
+
const outputsHeldBySource: string[] = [];
|
|
330
|
+
for (const key in source) {
|
|
331
|
+
const output = outputOf(key);
|
|
332
|
+
if (outputsHeldByHigherSources.indexOf(output) !== -1) {
|
|
333
|
+
delete source[key];
|
|
334
|
+
} else if (!isEmpty(source[key])) {
|
|
335
|
+
outputsHeldBySource.push(output);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
outputsHeldByHigherSources.push(...outputsHeldBySource);
|
|
383
339
|
}
|
|
384
340
|
}
|
|
385
341
|
|
package/src/kitBlocking.ts
CHANGED
|
@@ -364,7 +364,7 @@ export default class KitBlocker {
|
|
|
364
364
|
return clonedEvent;
|
|
365
365
|
}
|
|
366
366
|
if (matchedEvent) {
|
|
367
|
-
for (const key of Object.keys(clonedEvent.EventAttributes)) {
|
|
367
|
+
for (const key of Object.keys(clonedEvent.EventAttributes ?? {})) {
|
|
368
368
|
if (!matchedEvent[key]) {
|
|
369
369
|
delete clonedEvent.EventAttributes[key];
|
|
370
370
|
}
|
|
@@ -384,13 +384,18 @@ export default class KitBlocker {
|
|
|
384
384
|
const matchKey: string = this.getProductAttributeMatchKey(baseEvent);
|
|
385
385
|
const matchedEvent = this.dataPlanMatchLookups[matchKey];
|
|
386
386
|
|
|
387
|
-
function
|
|
388
|
-
productList
|
|
387
|
+
function withPlannedAttributesOnly(plannedAttributes: { [key: string]: boolean }, productList: SDKProduct[]): SDKProduct[] {
|
|
388
|
+
return productList?.map(product => {
|
|
389
|
+
if (!product.Attributes) {
|
|
390
|
+
return product;
|
|
391
|
+
}
|
|
392
|
+
const attributes = {};
|
|
389
393
|
for (const productKey of Object.keys(product.Attributes)) {
|
|
390
|
-
if (
|
|
391
|
-
|
|
394
|
+
if (plannedAttributes[productKey] === true) {
|
|
395
|
+
attributes[productKey] = product.Attributes[productKey];
|
|
392
396
|
}
|
|
393
397
|
}
|
|
398
|
+
return { ...product, Attributes: attributes };
|
|
394
399
|
});
|
|
395
400
|
}
|
|
396
401
|
|
|
@@ -414,17 +419,18 @@ export default class KitBlocker {
|
|
|
414
419
|
return clonedEvent;
|
|
415
420
|
}
|
|
416
421
|
if (matchedEvent) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
clonedEvent.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
422
|
+
if (clonedEvent.ProductAction) {
|
|
423
|
+
clonedEvent.ProductAction = {
|
|
424
|
+
...clonedEvent.ProductAction,
|
|
425
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, clonedEvent.ProductAction.ProductList),
|
|
426
|
+
};
|
|
427
|
+
} else if (clonedEvent.ProductImpressions) {
|
|
428
|
+
clonedEvent.ProductImpressions = clonedEvent.ProductImpressions.map(impression => ({
|
|
429
|
+
...impression,
|
|
430
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, impression.ProductList),
|
|
431
|
+
}));
|
|
432
|
+
} else {
|
|
433
|
+
this.mpInstance.Logger.warning('Product Not Supported ')
|
|
428
434
|
}
|
|
429
435
|
|
|
430
436
|
return clonedEvent;
|
|
@@ -133,6 +133,7 @@ export function convertEvents(
|
|
|
133
133
|
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
134
134
|
|
|
135
135
|
if (isIntegrationCaptureEnabled) {
|
|
136
|
+
_IntegrationCapture?.capture();
|
|
136
137
|
const capturedPartnerIdentities: PartnerIdentities = _IntegrationCapture?.getClickIdsAsPartnerIdentities();
|
|
137
138
|
if (!isEmpty(capturedPartnerIdentities)) {
|
|
138
139
|
upload.partner_identities = capturedPartnerIdentities;
|