@mparticle/web-sdk 2.35.0 → 2.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
15
15
  filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
16
16
  isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
17
17
 
18
- var version = "2.35.0";
18
+ var version = "2.35.2";
19
19
 
20
20
  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
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/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
@@ -1087,8 +1087,11 @@ if(h){var i=getCachedIdentity(g,a,b);return c(i,d,e,f,g,a,!0),!0}return !1};var
1087
1087
  var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
1088
1088
  throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
1089
1089
 
1090
- var _this=undefined;var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){var b=a,c=b.splice(0,1)[0];// if the first argument is a method on the base mParticle object, run it
1091
- if("undefined"!=typeof window&&window.mParticle&&window.mParticle[b[0]])window.mParticle[c].apply(_this,b);else {var d=c.split(".");try{for(var e,f=window.mParticle,g=0,h=d;g<h.length;g++)e=h[g],f=f[e];f.apply(_this,b);}catch(a){throw new Error("Unable to compute proper mParticle function "+a)}}};
1090
+ var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){var b=a,c=b.splice(0,1)[0];// if the first argument is a method on the base mParticle object, run it
1091
+ if("undefined"!=typeof window&&window.mParticle&&window.mParticle[b[0]])window.mParticle[c].apply(window.mParticle,b);else {var d=c.split(".");try{// Track both the function and its context
1092
+ for(var e,f=window.mParticle,g=window.mParticle,h=0,i=d;h<i.length;h++)// Keep track of the parent object
1093
+ e=i[h],g=f,f=f[e];// Apply the function with its proper context
1094
+ f.apply(g,b);}catch(a){throw new Error("Unable to compute proper mParticle function "+a)}}};
1092
1095
 
1093
1096
  var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1=Constants.FeatureFlags,IdentityMethods$1=Constants.IdentityMethods,ErrorMessages=Messages$2.ErrorMessages,CacheIdentity=FeatureFlags$1.CacheIdentity,Identify=IdentityMethods$1.Identify,Modify$1=IdentityMethods$1.Modify,Login=IdentityMethods$1.Login,Logout=IdentityMethods$1.Logout;function Identity(t){var r=t._Helpers,s=r.getFeatureFlag,i=r.extend,n=this;// https://go.mparticle.com/work/SQDSDKS-6353
1094
1097
  /**
@@ -1386,12 +1389,17 @@ var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_
1386
1389
  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
1387
1390
  gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},// Rokt
1388
1391
  // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
1389
- rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},// TIKTOK
1392
+ // https://go.mparticle.com/work/SQDSDKS-7167
1393
+ 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},// TIKTOK
1390
1394
  ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES},// Snapchat
1391
1395
  // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
1392
1396
  ScCid:{mappedKey:"SnapchatConversions.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now(),this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
1393
1397
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
1394
- */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};a.fbclid&&b._fbc&&delete b._fbc,a.rtid&&c.RoktTransactionId&&b.RoktTransactionId?(delete c.RoktTransactionId,delete b.RoktTransactionId):a.rtid&&c.RoktTransactionId?delete c.RoktTransactionId:a.rtid&&b.RoktTransactionId?delete b.RoktTransactionId:c.RoktTransactionId&&b.RoktTransactionId&&delete b.RoktTransactionId,this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),a),c),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){var a={};for(var b in integrationMapping){var c=localStorage.getItem(b);c&&(a[b]=c);}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.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
1398
+ */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};a.fbclid&&b._fbc&&delete b._fbc;// ROKT Rules
1399
+ // If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
1400
+ // If RoktTransactionId is present in both cookies and localStorage,
1401
+ // prioritize localStorage
1402
+ 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=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){var a={};for(var b in integrationMapping){var c=localStorage.getItem(b);c&&(a[b]=c);}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.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
1395
1403
  // {
1396
1404
  // "integration_attributes": {
1397
1405
  // "<moduleId>": {
@@ -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 = "2.35.0";
18
+ var version = "2.35.2";
19
19
 
20
20
  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
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/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
@@ -1087,8 +1087,11 @@ if(h){var i=getCachedIdentity(g,a,b);return c(i,d,e,f,g,a,!0),!0}return !1};var
1087
1087
  var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
1088
1088
  throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
1089
1089
 
1090
- var _this=undefined;var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){var b=a,c=b.splice(0,1)[0];// if the first argument is a method on the base mParticle object, run it
1091
- if("undefined"!=typeof window&&window.mParticle&&window.mParticle[b[0]])window.mParticle[c].apply(_this,b);else {var d=c.split(".");try{for(var e,f=window.mParticle,g=0,h=d;g<h.length;g++)e=h[g],f=f[e];f.apply(_this,b);}catch(a){throw new Error("Unable to compute proper mParticle function "+a)}}};
1090
+ var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){var b=a,c=b.splice(0,1)[0];// if the first argument is a method on the base mParticle object, run it
1091
+ if("undefined"!=typeof window&&window.mParticle&&window.mParticle[b[0]])window.mParticle[c].apply(window.mParticle,b);else {var d=c.split(".");try{// Track both the function and its context
1092
+ for(var e,f=window.mParticle,g=window.mParticle,h=0,i=d;h<i.length;h++)// Keep track of the parent object
1093
+ e=i[h],g=f,f=f[e];// Apply the function with its proper context
1094
+ f.apply(g,b);}catch(a){throw new Error("Unable to compute proper mParticle function "+a)}}};
1092
1095
 
1093
1096
  var Messages$2=Constants.Messages,HTTPCodes$2=Constants.HTTPCodes,FeatureFlags$1=Constants.FeatureFlags,IdentityMethods$1=Constants.IdentityMethods,ErrorMessages=Messages$2.ErrorMessages,CacheIdentity=FeatureFlags$1.CacheIdentity,Identify=IdentityMethods$1.Identify,Modify$1=IdentityMethods$1.Modify,Login=IdentityMethods$1.Login,Logout=IdentityMethods$1.Logout;function Identity(t){var r=t._Helpers,s=r.getFeatureFlag,i=r.extend,n=this;// https://go.mparticle.com/work/SQDSDKS-6353
1094
1097
  /**
@@ -1386,12 +1389,17 @@ var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_
1386
1389
  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
1387
1390
  gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},// Rokt
1388
1391
  // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
1389
- rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},// TIKTOK
1392
+ // https://go.mparticle.com/work/SQDSDKS-7167
1393
+ 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},// TIKTOK
1390
1394
  ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES},// Snapchat
1391
1395
  // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
1392
1396
  ScCid:{mappedKey:"SnapchatConversions.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now(),this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
1393
1397
  * Captures Integration Ids from cookies and query params and stores them in clickIds object
1394
- */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};a.fbclid&&b._fbc&&delete b._fbc,a.rtid&&c.RoktTransactionId&&b.RoktTransactionId?(delete c.RoktTransactionId,delete b.RoktTransactionId):a.rtid&&c.RoktTransactionId?delete c.RoktTransactionId:a.rtid&&b.RoktTransactionId?delete b.RoktTransactionId:c.RoktTransactionId&&b.RoktTransactionId&&delete b.RoktTransactionId,this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),a),c),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){var a={};for(var b in integrationMapping){var c=localStorage.getItem(b);c&&(a[b]=c);}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.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
1398
+ */return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};a.fbclid&&b._fbc&&delete b._fbc;// ROKT Rules
1399
+ // If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
1400
+ // If RoktTransactionId is present in both cookies and localStorage,
1401
+ // prioritize localStorage
1402
+ 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=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){var a={};for(var b in integrationMapping){var c=localStorage.getItem(b);c&&(a[b]=c);}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.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
1395
1403
  // {
1396
1404
  // "integration_attributes": {
1397
1405
  // "<moduleId>": {
package/dist/mparticle.js CHANGED
@@ -203,7 +203,7 @@ var mParticle = (function () {
203
203
  Base64: Base64$1
204
204
  };
205
205
 
206
- var version = "2.35.0";
206
+ var version = "2.35.2";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -7164,7 +7164,6 @@ var mParticle = (function () {
7164
7164
  return AudienceManager;
7165
7165
  }();
7166
7166
 
7167
- var _this = undefined;
7168
7167
  var processReadyQueue = function processReadyQueue(readyQueue) {
7169
7168
  if (!isEmpty(readyQueue)) {
7170
7169
  readyQueue.forEach(function (readyQueueItem) {
@@ -7182,17 +7181,21 @@ var mParticle = (function () {
7182
7181
  var method = args.splice(0, 1)[0];
7183
7182
  // if the first argument is a method on the base mParticle object, run it
7184
7183
  if (typeof window !== 'undefined' && window.mParticle && window.mParticle[args[0]]) {
7185
- window.mParticle[method].apply(_this, args);
7184
+ window.mParticle[method].apply(window.mParticle, args);
7186
7185
  // otherwise, the method is on either eCommerce or Identity objects, ie. "eCommerce.setCurrencyCode", "Identity.login"
7187
7186
  } else {
7188
7187
  var methodArray = method.split('.');
7189
7188
  try {
7190
7189
  var computedMPFunction = window.mParticle;
7190
+ var context_1 = window.mParticle;
7191
+ // Track both the function and its context
7191
7192
  for (var _i = 0, methodArray_1 = methodArray; _i < methodArray_1.length; _i++) {
7192
7193
  var currentMethod = methodArray_1[_i];
7194
+ context_1 = computedMPFunction; // Keep track of the parent object
7193
7195
  computedMPFunction = computedMPFunction[currentMethod];
7194
7196
  }
7195
- computedMPFunction.apply(_this, args);
7197
+ // Apply the function with its proper context
7198
+ computedMPFunction.apply(context_1, args);
7196
7199
  } catch (e) {
7197
7200
  throw new Error('Unable to compute proper mParticle function ' + e);
7198
7201
  }
@@ -9424,11 +9427,17 @@ var mParticle = (function () {
9424
9427
  },
9425
9428
  // Rokt
9426
9429
  // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
9430
+ // https://go.mparticle.com/work/SQDSDKS-7167
9427
9431
  rtid: {
9428
9432
  mappedKey: 'passbackconversiontrackingid',
9429
9433
  output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
9430
9434
  moduleId: 1277
9431
9435
  },
9436
+ rclid: {
9437
+ mappedKey: 'passbackconversiontrackingid',
9438
+ output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
9439
+ moduleId: 1277
9440
+ },
9432
9441
  RoktTransactionId: {
9433
9442
  mappedKey: 'passbackconversiontrackingid',
9434
9443
  output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
@@ -9465,22 +9474,30 @@ var mParticle = (function () {
9465
9474
  var queryParams = this.captureQueryParams() || {};
9466
9475
  var cookies = this.captureCookies() || {};
9467
9476
  var localStorage = this.captureLocalStorage() || {};
9477
+ // Facebook Rules
9468
9478
  // Exclude _fbc if fbclid is present
9469
9479
  // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#retrieve-from-fbclid-url-query-parameter
9470
9480
  if (queryParams['fbclid'] && cookies['_fbc']) {
9471
9481
  delete cookies['_fbc'];
9472
9482
  }
9473
- // If both rtid and RoktTransactionId are present, prioritize rtid
9483
+ // ROKT Rules
9484
+ // If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
9474
9485
  // If RoktTransactionId is present in both cookies and localStorage,
9475
9486
  // prioritize localStorage
9476
- if (queryParams['rtid'] && localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
9477
- delete localStorage['RoktTransactionId'];
9478
- delete cookies['RoktTransactionId'];
9479
- } else if (queryParams['rtid'] && localStorage['RoktTransactionId']) {
9480
- delete localStorage['RoktTransactionId'];
9481
- } else if (queryParams['rtid'] && cookies['RoktTransactionId']) {
9482
- delete cookies['RoktTransactionId'];
9483
- } else if (localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
9487
+ var hasQueryParamId = queryParams['rtid'] || queryParams['rclid'];
9488
+ var hasLocalStorageId = localStorage['RoktTransactionId'];
9489
+ var hasCookieId = cookies['RoktTransactionId'];
9490
+ if (hasQueryParamId) {
9491
+ // Query param takes precedence, remove both localStorage and cookie if present
9492
+ if (hasLocalStorageId) {
9493
+ delete localStorage['RoktTransactionId'];
9494
+ }
9495
+ if (hasCookieId) {
9496
+ delete cookies['RoktTransactionId'];
9497
+ }
9498
+ } else if (hasLocalStorageId && hasCookieId) {
9499
+ // No query param, but both localStorage and cookie exist
9500
+ // localStorage takes precedence over cookie
9484
9501
  delete cookies['RoktTransactionId'];
9485
9502
  }
9486
9503
  this.clickIds = __assign(__assign(__assign(__assign({}, this.clickIds), queryParams), localStorage), cookies);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.35.0",
3
+ "version": "2.35.2",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -105,11 +105,17 @@ const integrationMapping: IntegrationIdMapping = {
105
105
 
106
106
  // Rokt
107
107
  // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
108
+ // https://go.mparticle.com/work/SQDSDKS-7167
108
109
  rtid: {
109
110
  mappedKey: 'passbackconversiontrackingid',
110
111
  output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
111
112
  moduleId: 1277,
112
113
  },
114
+ rclid: {
115
+ mappedKey: 'passbackconversiontrackingid',
116
+ output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
117
+ moduleId: 1277,
118
+ },
113
119
  RoktTransactionId: {
114
120
  mappedKey: 'passbackconversiontrackingid',
115
121
  output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
@@ -158,27 +164,41 @@ export default class IntegrationCapture {
158
164
  const cookies = this.captureCookies() || {};
159
165
  const localStorage = this.captureLocalStorage() || {};
160
166
 
167
+ // Facebook Rules
161
168
  // Exclude _fbc if fbclid is present
162
169
  // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#retrieve-from-fbclid-url-query-parameter
163
170
  if (queryParams['fbclid'] && cookies['_fbc']) {
164
171
  delete cookies['_fbc'];
165
172
  }
166
173
 
167
- // If both rtid and RoktTransactionId are present, prioritize rtid
174
+ // ROKT Rules
175
+ // If both rtid or rclid and RoktTransactionId are present, prioritize rtid/rclid
168
176
  // If RoktTransactionId is present in both cookies and localStorage,
169
177
  // prioritize localStorage
170
- if (queryParams['rtid'] && localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
171
- delete localStorage['RoktTransactionId'];
172
- delete cookies['RoktTransactionId'];
173
- } else if (queryParams['rtid'] && localStorage['RoktTransactionId']) {
174
- delete localStorage['RoktTransactionId'];
175
- } else if (queryParams['rtid'] && cookies['RoktTransactionId']) {
176
- delete cookies['RoktTransactionId'];
177
- } else if (localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
178
+ const hasQueryParamId = queryParams['rtid'] || queryParams['rclid'];
179
+ const hasLocalStorageId = localStorage['RoktTransactionId'];
180
+ const hasCookieId = cookies['RoktTransactionId'];
181
+
182
+ if (hasQueryParamId) {
183
+ // Query param takes precedence, remove both localStorage and cookie if present
184
+ if (hasLocalStorageId) {
185
+ delete localStorage['RoktTransactionId'];
186
+ }
187
+ if (hasCookieId) {
188
+ delete cookies['RoktTransactionId'];
189
+ }
190
+ } else if (hasLocalStorageId && hasCookieId) {
191
+ // No query param, but both localStorage and cookie exist
192
+ // localStorage takes precedence over cookie
178
193
  delete cookies['RoktTransactionId'];
179
194
  }
180
195
 
181
- this.clickIds = { ...this.clickIds, ...queryParams, ...localStorage, ...cookies };
196
+ this.clickIds = {
197
+ ...this.clickIds,
198
+ ...queryParams,
199
+ ...localStorage,
200
+ ...cookies
201
+ };
182
202
  }
183
203
 
184
204
  /**
@@ -30,16 +30,22 @@ const processPreloadedItem = (readyQueueItem): void => {
30
30
 
31
31
  // if the first argument is a method on the base mParticle object, run it
32
32
  if (typeof window !== 'undefined' && window.mParticle && window.mParticle[args[0]]) {
33
- window.mParticle[method].apply(this, args);
33
+ window.mParticle[method].apply(window.mParticle, args);
34
34
  // otherwise, the method is on either eCommerce or Identity objects, ie. "eCommerce.setCurrencyCode", "Identity.login"
35
35
  } else {
36
36
  const methodArray = method.split('.');
37
37
  try {
38
38
  let computedMPFunction = window.mParticle;
39
+ let context = window.mParticle;
40
+
41
+ // Track both the function and its context
39
42
  for (const currentMethod of methodArray) {
43
+ context = computedMPFunction; // Keep track of the parent object
40
44
  computedMPFunction = computedMPFunction[currentMethod];
41
45
  }
42
- ((computedMPFunction as unknown) as Function).apply(this, args);
46
+
47
+ // Apply the function with its proper context
48
+ ((computedMPFunction as unknown) as Function).apply(context, args);
43
49
  } catch (e) {
44
50
  throw new Error('Unable to compute proper mParticle function ' + e);
45
51
  }