@mparticle/web-sdk 2.35.2 → 2.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
15
15
  filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
16
16
  isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
17
17
 
18
- var version = "2.35.2";
18
+ var version = "2.37.0";
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
@@ -117,7 +117,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
117
117
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
118
118
  };
119
119
 
120
- var Messages$9=Constants.Messages,createCookieString=function(a){return replaceCommasWithPipes(replaceQuotesWithApostrophes(a))},revertCookieString=function(a){return replacePipesWithCommas(replaceApostrophesWithQuotes(a))},inArray=function(a,b){var c=0;if(Array.prototype.indexOf)return 0<=a.indexOf(b,0);for(var d=a.length;c<d;c++)if(c in a&&a[c]===b)return !0;return !1},findKeyInObject=function(a,b){if(b&&a)for(var c in a)if(a.hasOwnProperty(c)&&c.toLowerCase()===b.toLowerCase())return c;return null},generateDeprecationMessage=function(a,b){var c=[a,Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix];return b&&(c.push(b),c.push(Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix)),c.join(" ")};function generateHash(a){var b,c=0;if(void 0===a||null===a)return 0;if(a=a.toString().toLowerCase(),Array.prototype.reduce)return a.split("").reduce(function(c,d){return c=(c<<5)-c+d.charCodeAt(0),c&c},0);if(0===a.length)return c;for(var d=0;d<a.length;d++)b=a.charCodeAt(d),c=(c<<5)-c+b,c&=c;return c}var generateRandomValue=function(){var b,c;return window.crypto&&window.crypto.getRandomValues&&(b=window.crypto.getRandomValues(new Uint8Array(1))),b?(c^b[0]%16>>c/4).toString(16):(c^16*Math.random()>>c/4).toString(16)},generateUniqueId=function(b){return void 0===b&&(b=""),b// if the placeholder was passed, return
120
+ var Messages$9=Constants.Messages,createCookieString=function(a){return replaceCommasWithPipes(replaceQuotesWithApostrophes(a))},revertCookieString=function(a){return replacePipesWithCommas(replaceApostrophesWithQuotes(a))},inArray=function(a,b){if(!a)return !1;var c=0;if(Array.prototype.indexOf)return 0<=a.indexOf(b,0);for(var d=a.length;c<d;c++)if(c in a&&a[c]===b)return !0;return !1},findKeyInObject=function(a,b){if(b&&a)for(var c in a)if(a.hasOwnProperty(c)&&c.toLowerCase()===b.toLowerCase())return c;return null},generateDeprecationMessage=function(a,b){var c=[a,Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix];return b&&(c.push(b),c.push(Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix)),c.join(" ")};function generateHash(a){var b,c=0;if(void 0===a||null===a)return 0;if(a=a.toString().toLowerCase(),Array.prototype.reduce)return a.split("").reduce(function(c,d){return c=(c<<5)-c+d.charCodeAt(0),c&c},0);if(0===a.length)return c;for(var d=0;d<a.length;d++)b=a.charCodeAt(d),c=(c<<5)-c+b,c&=c;return c}var generateRandomValue=function(){var b,c;return window.crypto&&window.crypto.getRandomValues&&(b=window.crypto.getRandomValues(new Uint8Array(1))),b?(c^b[0]%16>>c/4).toString(16):(c^16*Math.random()>>c/4).toString(16)},generateUniqueId=function(b){return void 0===b&&(b=""),b// if the placeholder was passed, return
121
121
  ?generateRandomValue()// if the placeholder was passed, return
122
122
  :// [1e7] -> // 10000000 +
123
123
  // -1e3 -> // -1000 +
@@ -126,12 +126,12 @@ var Messages$9=Constants.Messages,createCookieString=function(a){return replaceC
126
126
  // -1e11 -> //-100000000000,
127
127
  "".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,// zeroes, ones, and eights with
128
128
  generateUniqueId// random hex digits
129
- )},getRampNumber=function(a){if(!a)return 100;var b=generateHash(a);return Math.abs(b%100)+1},isObject=function(a){var b=Object.prototype.toString.call(a);return "[object Object]"===b||"[object Error]"===b},parseNumber=function(a){if(isNaN(a)||!isFinite(a))return 0;var b=parseFloat(a);return isNaN(b)?0:b},parseStringOrNumber=function(a){return isStringOrNumber(a)?a:null},replaceCommasWithPipes=function(a){return a.replace(/,/g,"|")},replacePipesWithCommas=function(a){return a.replace(/\|/g,",")},replaceApostrophesWithQuotes=function(a){return a.replace(/\'/g,"\"")},replaceQuotesWithApostrophes=function(a){return a.replace(/\"/g,"'")},replaceMPID=function(a,b){return a.replace("%%mpid%%",b)},replaceAmpWithAmpersand=function(a){return a.replace(/&amp;/g,"&")},createCookieSyncUrl=function(a,b,c){var d=replaceAmpWithAmpersand(b),e=c?replaceAmpWithAmpersand(c):null,f=replaceMPID(d,a),g=e?replaceMPID(e,a):"";return f+encodeURIComponent(g)},returnConvertedBoolean=function(a){return "false"!==a&&"0"!==a&&!!a},decoded=function(a){return decodeURIComponent(a.replace(/\+/g," "))},converted=function(a){return 0===a.indexOf("\"")&&(a=a.slice(1,-1).replace(/\\"/g,"\"").replace(/\\\\/g,"\\")),a},isString=function(a){return "string"==typeof a},isNumber=function(a){return "number"==typeof a},isBoolean=function(a){return "boolean"==typeof a},isFunction=function(a){return "function"==typeof a},isValidCustomFlagProperty=function(a){return isNumber(a)||isString(a)||isBoolean(a)},toDataPlanSlug=function(a){// Make sure we are only acting on strings or numbers
129
+ )},getRampNumber=function(a){if(!a)return 100;var b=generateHash(a);return Math.abs(b%100)+1},isObject=function(a){var b=Object.prototype.toString.call(a);return "[object Object]"===b||"[object Error]"===b},parseNumber=function(a){if(isNaN(a)||!isFinite(a))return 0;var b=parseFloat(a);return isNaN(b)?0:b},parseSettingsString=function(a){try{return a?JSON.parse(a.replace(/&quot;/g,"\"")):[]}catch(a){throw new Error("Settings string contains invalid JSON")}},parseStringOrNumber=function(a){return isStringOrNumber(a)?a:null},replaceCommasWithPipes=function(a){return a.replace(/,/g,"|")},replacePipesWithCommas=function(a){return a.replace(/\|/g,",")},replaceApostrophesWithQuotes=function(a){return a.replace(/\'/g,"\"")},replaceQuotesWithApostrophes=function(a){return a.replace(/\"/g,"'")},replaceMPID=function(a,b){return a.replace("%%mpid%%",b)},replaceAmpWithAmpersand=function(a){return a.replace(/&amp;/g,"&")},createCookieSyncUrl=function(a,b,c){var d=replaceAmpWithAmpersand(b),e=c?replaceAmpWithAmpersand(c):null,f=replaceMPID(d,a),g=e?replaceMPID(e,a):"";return f+encodeURIComponent(g)},returnConvertedBoolean=function(a){return "false"!==a&&"0"!==a&&!!a},decoded=function(a){return decodeURIComponent(a.replace(/\+/g," "))},converted=function(a){return 0===a.indexOf("\"")&&(a=a.slice(1,-1).replace(/\\"/g,"\"").replace(/\\\\/g,"\\")),a},isString=function(a){return "string"==typeof a},isNumber=function(a){return "number"==typeof a},isBoolean=function(a){return "boolean"==typeof a},isFunction=function(a){return "function"==typeof a},isValidCustomFlagProperty=function(a){return isNumber(a)||isString(a)||isBoolean(a)},toDataPlanSlug=function(a){// Make sure we are only acting on strings or numbers
130
130
  return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"_"):""},isDataPlanSlug=function(a){return a===toDataPlanSlug(a)},isStringOrNumber=function(a){return isString(a)||isNumber(a)},isEmpty=function(a){return null==a||!(Object.keys(a)||a).length},moveElementToEnd=function(a,b){return a.slice(0,b).concat(a.slice(b+1),a[b])},queryStringParser=function(a,b){void 0===b&&(b=[]);var c,d={};if(!a)return d;if("undefined"!=typeof URL&&"undefined"!=typeof URLSearchParams){var e=new URL(a);c=new URLSearchParams(e.search);}else c=queryStringParserFallback(a);return isEmpty(b)?c.forEach(function(a,b){d[b]=a;}):b.forEach(function(a){var b=c.get(a);b&&(d[a]=b);}),d},queryStringParserFallback=function(a){var b={},c=a.split("?")[1]||"",d=c.split("&");return d.forEach(function(a){var c=a.split("="),d=c[0],e=c.slice(1),f=e.join("=");if(d&&void 0!==f)try{b[d]=decodeURIComponent(f||"");}catch(a){console.error("Failed to decode value for key ".concat(d,": ").concat(a));}}),{get:function get(a){return b[a]},forEach:function forEach(a){for(var c in b)b.hasOwnProperty(c)&&a(b[c],c);}}},getCookies=function(a){// Helper function to parse cookies from document.cookie
131
131
  var b=function parseCookies(){return "undefined"==typeof window?[]:window.document.cookie.split(";").map(function(a){return a.trim()})}();// Helper function to filter cookies by keys
132
132
  // Parse cookies from document.cookie
133
133
  // Filter cookies by keys if provided
134
- return function filterCookies(a,b){for(var c={},d=0,e=a;d<e.length;d++){var f=e[d],g=f.split("="),h=g[0],i=g[1];(!b||b.includes(h))&&(c[h]=i);}return c}(b,a)},getHref=function(){return "undefined"!=typeof window&&window.location?window.location.href:""};/**
134
+ return function filterCookies(a,b){for(var c={},d=0,e=a;d<e.length;d++){var f=e[d],g=f.split("="),h=g[0],i=g[1];(!b||b.includes(h))&&(c[h]=i);}return c}(b,a)},getHref=function(){return "undefined"!=typeof window&&window.location?window.location.href:""},filterDictionaryWithHash=function(a,b,c){var d={};if(!isEmpty(a))for(var e in a)if(a.hasOwnProperty(e)){var f=c(e);inArray(b,f)||(d[e]=a[e]);}return d},parseConfig=function(a,b,c){var d;return (null===(d=a.kitConfigs)||void 0===d?void 0:d.find(function(a){return a.name===b&&a.moduleId===c}))||null};/**
135
135
  * Returns a value between 1-100 inclusive.
136
136
  */ // FIXME: REFACTOR for V3
137
137
 
@@ -467,7 +467,7 @@ isValidKeyValue:function isValidKeyValue(a){return !(!a||isObject(a)||Array.isAr
467
467
  if(void 0===a.userIdentities)return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentities};// identityApiData.userIdentities can be null, but if it isn't null or undefined (above conditional), it must be an object
468
468
  if(null!==a.userIdentities&&!isObject(a.userIdentities))return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentities};if(isObject(a.userIdentities)&&Object.keys(a.userIdentities).length)for(var e in a.userIdentities)if(a.userIdentities.hasOwnProperty(e)){if(!1===Types.IdentityType.getIdentityType(e))return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentitiesInvalidKey};if("string"!=typeof a.userIdentities[e]&&null!==a.userIdentities[e])return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentitiesInvalidValues}}}return {valid:!0}}};
469
469
 
470
- var KitFilterHelper=/** @class */function(){function a(){}return a.hashEventType=function(a){return generateHash(a)},a.hashEventName=function(a,b){return generateHash(b+a)},(a.hashEventAttributeKey=function(a,b,c){return generateHash(a+b+c)},a.hashUserAttribute=function(a){return generateHash(a)},a.hashUserIdentity=function(a){return a},a.hashConsentPurpose=function(a,b){return generateHash(a+b)},a.hashAttributeConditionalForwarding=function(a){return generateHash(a).toString()},a.hashConsentPurposeConditionalForwarding=function(a,b){return this.hashConsentPurpose(a,b).toString()},a)}();
470
+ var KitFilterHelper=/** @class */function(){function a(){}a.hashEventType=function(a){return generateHash(a)},a.hashEventName=function(a,b){return generateHash(b+a)},a.hashEventAttributeKey=function(a,b,c){return generateHash(a+b+c)},a.hashUserAttribute=function(a){return generateHash(a)},a.hashUserIdentity=function(a){return a},a.hashConsentPurpose=function(a,b){return generateHash(a+b)},a.hashAttributeConditionalForwarding=function(a){return generateHash(a).toString()},a.hashConsentPurposeConditionalForwarding=function(a,b){return this.hashConsentPurpose(a,b).toString()};var b;return b=a,a.filterUserAttributes=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserAttribute(a)})},a.filterUserIdentities=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserIdentity(IdentityType.getIdentityType(a))})},a.isFilteredUserAttribute=function(a,c){var d=b.hashUserAttribute(a);return c&&inArray(c,d)},a}();
471
471
 
472
472
  var StorageNames$1=Constants.StorageNames;function Helpers(a){var b=this;// https://go.mparticle.com/work/SQDSDKS-6047
473
473
  // Standalone version of jQuery.extend, from https://github.com/dansdom/extend
@@ -484,7 +484,7 @@ if(null!=(a=arguments[j]))// Extend the base object
484
484
  for(c in a)// Prevent never-ending loop
485
485
  (d=h[c],e=a[c],h!==e)&&(l&&e&&(m.isPlainObject(e)||(f=m.isArray(e)))?(f?(f=!1,g=d&&m.isArray(d)?d:[]):g=d&&m.isPlainObject(d)?d:{},h[c]=b.extend(l,g,e)):void 0!==e&&(h[c]=e));// Recurse if we're merging plain objects or arrays
486
486
  // Return the modified object
487
- return h},this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){var d=[];if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);if(!b.inArray(c,f)){var g={Type:f,Identity:a[e]};f===Types.IdentityType.CustomerId?d.unshift(g):d.push(g);}}return d},this.filterUserIdentitiesForForwarders=function(a,c){var d={};if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=KitFilterHelper.hashUserIdentity(Types.IdentityType.getIdentityType(e));b.inArray(c,f)||(d[e]=a[e]);}return d},this.filterUserAttributes=function(a,c){var d={};if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=KitFilterHelper.hashUserAttribute(e);b.inArray(c,f)||(d[e]=a[e]);}return d},this.isFilteredUserAttribute=function(a,c){var d=KitFilterHelper.hashUserAttribute(a);return c&&b.inArray(c,d)},this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
487
+ return h},this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){var d=[];if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);if(!b.inArray(c,f)){var g={Type:f,Identity:a[e]};f===Types.IdentityType.CustomerId?d.unshift(g):d.push(g);}}return d},this.filterUserIdentitiesForForwarders=KitFilterHelper.filterUserIdentities,this.filterUserAttributes=KitFilterHelper.filterUserAttributes,this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
488
488
  c.hasOwnProperty(f)&&b.Validators.isValidAttributeValue(c[f])?e[f]=c[f]:a.Logger.warning("For '"+d+"', the corresponding attribute value of '"+f+"' must be a string, number, boolean, or null.");return e},this.isDelayedByIntegration=function(b,c,d){if(d-c>a._Store.SDKConfig.integrationDelayTimeout)return !1;for(var e in b){if(!0===b[e])return !0;continue}return !1},this.createMainStorageName=function(a){return a?StorageNames$1.currentStorageName+"_"+a:StorageNames$1.currentStorageName},this.createProductStorageName=function(a){return a?StorageNames$1.currentStorageProductsName+"_"+a:StorageNames$1.currentStorageProductsName},this.converted=converted,this.findKeyInObject=findKeyInObject,this.parseNumber=parseNumber,this.inArray=inArray,this.isObject=isObject,this.decoded=decoded,this.parseStringOrNumber=parseStringOrNumber,this.generateHash=generateHash,this.generateUniqueId=generateUniqueId,this.Validators=Validators;}
489
489
 
490
490
  var Messages$8=Constants.Messages,androidBridgeNameBase="mParticleAndroid",iosBridgeNameBase="mParticle";function NativeSdkHelpers(a){var b=this;this.initializeSessionAttributes=function(a){var c=Constants.NativeSdkPaths.SetSessionAttribute,d=JSON.stringify({key:"$src_env",value:"webview"}),e=JSON.stringify({key:"$src_key",value:a});b.sendToNative(c,d),a&&b.sendToNative(c,e);},this.isBridgeV2Available=function(a){if(!a)return !1;var b=iosBridgeNameBase+"_"+a+"_v2";// iOS v2 bridge
@@ -1029,7 +1029,7 @@ if(-1<j.indexOf(b.EventDataType)&&a._Store.activeForwarders[k].filteringEventAtt
1029
1029
  if(b.EventAttributes)for(var m in b.EventAttributes){var n;if(n=KitFilterHelper.hashAttributeConditionalForwarding(m),n===a._Store.activeForwarders[k].filteringEventAttributeValue.eventAttributeName&&(l={name:n,value:KitFilterHelper.hashAttributeConditionalForwarding(b.EventAttributes[m])}),l)break}var o=null!==l&&l.value===a._Store.activeForwarders[k].filteringEventAttributeValue.eventAttributeValue,p=!0===a._Store.activeForwarders[k].filteringEventAttributeValue.includeOnMatch?o:!o;if(!p)continue}// Clone the event object, as we could be sending different attributes to each forwarder
1030
1030
  // Check event filtering rules
1031
1031
  if(c={},c=a._Helpers.extend(!0,c,b),b.EventDataType===Types.MessageType.PageEvent&&(h(a._Store.activeForwarders[k].eventNameFilters,d)||h(a._Store.activeForwarders[k].eventTypeFilters,e)))continue;else if(b.EventDataType===Types.MessageType.Commerce&&h(a._Store.activeForwarders[k].eventTypeFilters,e))continue;else if(b.EventDataType===Types.MessageType.PageView&&h(a._Store.activeForwarders[k].screenNameFilters,d))continue;// Check attribute filtering rules
1032
- if(c.EventAttributes&&(b.EventDataType===Types.MessageType.PageEvent?g(c,a._Store.activeForwarders[k].attributeFilters):b.EventDataType===Types.MessageType.PageView&&g(c,a._Store.activeForwarders[k].screenAttributeFilters)),f(c,a._Store.activeForwarders[k].userIdentityFilters),c.UserAttributes=a._Helpers.filterUserAttributes(c.UserAttributes,a._Store.activeForwarders[k].userAttributeFilters),a._Store.activeForwarders[k].process){a.Logger.verbose("Sending message to forwarder: "+a._Store.activeForwarders[k].name);var q=a._Store.activeForwarders[k].process(c);q&&a.Logger.verbose(q);}}}},this.handleForwarderUserAttributes=function(c,d,f){b&&b.isAttributeKeyBlocked(d)||!a._Store.activeForwarders.length||a._Store.activeForwarders.forEach(function(b){var g=b[c];if(g&&!a._Helpers.isFilteredUserAttribute(d,b.userAttributeFilters))try{var h;c===e.setUserAttribute?h=b.setUserAttribute(d,f):c===e.removeUserAttribute&&(h=b.removeUserAttribute(d)),h&&a.Logger.verbose(h);}catch(b){a.Logger.error(b);}});},this.setForwarderUserIdentities=function(b){a._Store.activeForwarders.forEach(function(c){var d=a._Helpers.filterUserIdentities(b,c.userIdentityFilters);c.setUserIdentity&&d.forEach(function(b){var d=c.setUserIdentity(b.Identity,b.Type);d&&a.Logger.verbose(d);});});},this.setForwarderOnUserIdentified=function(c){a._Store.activeForwarders.forEach(function(d){var e=filteredMparticleUser(c.getMPID(),d,a,b);if(d.onUserIdentified){var f=d.onUserIdentified(e);f&&a.Logger.verbose(f);}});},this.setForwarderOnIdentityComplete=function(c,d){var e;a._Store.activeForwarders.forEach(function(f){var g=filteredMparticleUser(c.getMPID(),f,a,b),h=g.getUserIdentities();d===Identify$2?f.onIdentifyComplete&&(e=f.onIdentifyComplete(g,h),e&&a.Logger.verbose(e)):d===Login$2?f.onLoginComplete&&(e=f.onLoginComplete(g,h),e&&a.Logger.verbose(e)):d===Logout$2?f.onLogoutComplete&&(e=f.onLogoutComplete(g,h),e&&a.Logger.verbose(e)):d===Modify$3&&f.onModifyComplete&&(e=f.onModifyComplete(g,h),e&&a.Logger.verbose(e));});},this.getForwarderStatsQueue=function(){return a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue},this.setForwarderStatsQueue=function(b){a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=b;},this.processForwarders=function(b,c){b?(this.processUIEnabledKits(b),this.processSideloadedKits(b),d.initForwarders(a._Store.SDKConfig.identifyRequest.userIdentities,c)):a.Logger.warning("No config was passed. Cannot process forwarders");},this.processUIEnabledKits=function(b){var c=this.returnKitConstructors();try{Array.isArray(b.kitConfigs)&&b.kitConfigs.length&&b.kitConfigs.forEach(function(a){d.configureUIEnabledKit(a,c);});}catch(b){a.Logger.error("MP Kits not configured propertly. Kits may not be initialized. "+b);}},this.returnKitConstructors=function(){var b={};// If there are kits inside of mpInstance._Store.SDKConfig.kits, then mParticle is self hosted
1032
+ if(c.EventAttributes&&(b.EventDataType===Types.MessageType.PageEvent?g(c,a._Store.activeForwarders[k].attributeFilters):b.EventDataType===Types.MessageType.PageView&&g(c,a._Store.activeForwarders[k].screenAttributeFilters)),f(c,a._Store.activeForwarders[k].userIdentityFilters),c.UserAttributes=a._Helpers.filterUserAttributes(c.UserAttributes,a._Store.activeForwarders[k].userAttributeFilters),a._Store.activeForwarders[k].process){a.Logger.verbose("Sending message to forwarder: "+a._Store.activeForwarders[k].name);var q=a._Store.activeForwarders[k].process(c);q&&a.Logger.verbose(q);}}}},this.handleForwarderUserAttributes=function(c,d,f){b&&b.isAttributeKeyBlocked(d)||!a._Store.activeForwarders.length||a._Store.activeForwarders.forEach(function(b){var g=b[c];if(g&&!KitFilterHelper.isFilteredUserAttribute(d,b.userAttributeFilters))try{var h;c===e.setUserAttribute?h=b.setUserAttribute(d,f):c===e.removeUserAttribute&&(h=b.removeUserAttribute(d)),h&&a.Logger.verbose(h);}catch(b){a.Logger.error(b);}});},this.setForwarderUserIdentities=function(b){a._Store.activeForwarders.forEach(function(c){var d=a._Helpers.filterUserIdentities(b,c.userIdentityFilters);c.setUserIdentity&&d.forEach(function(b){var d=c.setUserIdentity(b.Identity,b.Type);d&&a.Logger.verbose(d);});});},this.setForwarderOnUserIdentified=function(c){a._Store.activeForwarders.forEach(function(d){var e=filteredMparticleUser(c.getMPID(),d,a,b);if(d.onUserIdentified){var f=d.onUserIdentified(e);f&&a.Logger.verbose(f);}});},this.setForwarderOnIdentityComplete=function(c,d){var e;a._Store.activeForwarders.forEach(function(f){var g=filteredMparticleUser(c.getMPID(),f,a,b),h=g.getUserIdentities();d===Identify$2?f.onIdentifyComplete&&(e=f.onIdentifyComplete(g,h),e&&a.Logger.verbose(e)):d===Login$2?f.onLoginComplete&&(e=f.onLoginComplete(g,h),e&&a.Logger.verbose(e)):d===Logout$2?f.onLogoutComplete&&(e=f.onLogoutComplete(g,h),e&&a.Logger.verbose(e)):d===Modify$3&&f.onModifyComplete&&(e=f.onModifyComplete(g,h),e&&a.Logger.verbose(e));});},this.getForwarderStatsQueue=function(){return a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue},this.setForwarderStatsQueue=function(b){a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=b;},this.processForwarders=function(b,c){b?(this.processUIEnabledKits(b),this.processSideloadedKits(b),d.initForwarders(a._Store.SDKConfig.identifyRequest.userIdentities,c)):a.Logger.warning("No config was passed. Cannot process forwarders");},this.processUIEnabledKits=function(b){var c=this.returnKitConstructors();try{Array.isArray(b.kitConfigs)&&b.kitConfigs.length&&b.kitConfigs.forEach(function(a){d.configureUIEnabledKit(a,c);});}catch(b){a.Logger.error("MP Kits not configured propertly. Kits may not be initialized. "+b);}},this.returnKitConstructors=function(){var b={};// If there are kits inside of mpInstance._Store.SDKConfig.kits, then mParticle is self hosted
1033
1033
  return isEmpty(a._Store.SDKConfig.kits)?!isEmpty(a._preInit.forwarderConstructors)&&a._preInit.forwarderConstructors.forEach(function(a){// A suffix is added to a kitConstructor and kit config if there are multiple different
1034
1034
  // versions of a client kit. This matches the suffix in the DB. As an example
1035
1035
  // the GA4 kit has a client kit and a server side kit which has a client side
@@ -1409,7 +1409,25 @@ var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c
1409
1409
  // }
1410
1410
  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.applyProcessors=function(a,b,c){var d,e={};for(var f in a)if(a.hasOwnProperty(f)){var g=a[f],h=null===(d=integrationMapping[f])||void 0===d?void 0:d.processor;e[f]=h?h(g,b,c):g;}return e},a.prototype.filterMappings=function(a){var b={};for(var c in integrationMapping)integrationMapping[c].output===a&&(b[c]=integrationMapping[c]);return b},a}();
1411
1411
 
1412
- var RoktManager=/** @class */function(){function a(){this.launcher=null,this.messageQueue=[],this.launcher=null;}return a.prototype.attachLauncher=function(a){this.setLauncher(a),this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.launcher)return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.launcher.selectPlacements(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.processMessageQueue=function(){var a=this;0<this.messageQueue.length&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.launcher&&b.methodName in this.launcher?[4/*yield*/,this.launcher[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a.prototype.setLauncher=function(a){this.launcher=a;},a}();
1412
+ // Rokt Web SDK via a Web Kit.
1413
+ // The Rokt Manager should load before the Web Kit and stubs out many of the
1414
+ // Rokt Web SDK functions with an internal message queue in case a Rokt function
1415
+ // is requested before the Rokt Web Kit or SDK is finished loaded.
1416
+ // Once the Rokt Kit is attached to the Rokt Manager, we can consider the
1417
+ // Rokt Manager in a "ready" state and it can begin sending data to the kit.
1418
+ //
1419
+ // https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
1420
+ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.filteredUser=null,this.messageQueue=[],this.sandbox=null,this.userAttributeMapping=[];}/**
1421
+ * Initializes the RoktManager with configuration settings and user data.
1422
+ *
1423
+ * @param {IKitConfigs} roktConfig - Configuration object containing user attribute filters and settings
1424
+ * @param {IMParticleUser} filteredUser - User object with filtered attributes
1425
+ * @param {IMParticleUser} currentUser - Current mParticle user object
1426
+ * @param {IRoktManagerOptions} options - Options for the RoktManager
1427
+ *
1428
+ * @throws Logs error to console if userAttributeMapping parsing fails
1429
+ */return a.prototype.init=function(a,b,c,d){var e=a||{},f=e.userAttributeFilters,g=e.settings,h=(g||{}).userAttributeMapping;try{this.userAttributeMapping=parseSettingsString(h);}catch(a){console.error("Error parsing user attribute mapping from config",a);}this.currentUser=c,this.filters={userAttributeFilters:f,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b},this.sandbox=null===d||void 0===d?void 0:d.sandbox;},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b;if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{var c=a.attributes,d=null!==(b=null===c||void 0===c?void 0:c.sandbox)&&void 0!==b?b:this.sandbox,e=this.mapUserAttributes(c,this.userAttributeMapping);this.setUserAttributes(e);var f=__assign(__assign({},e),null===d?{}:{sandbox:d}),g=__assign(__assign({},a),{attributes:f});return this.kit.selectPlacements(g)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1430
+ return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)a.hasOwnProperty(d)&&-1===b.indexOf(d)&&(c[d]=a[d]);try{this.currentUser.setUserAttributes(c);}catch(a){console.error("Error setting user attributes",a);}},a.prototype.mapUserAttributes=function(a,b){for(var c,d={},e=0,f=b;e<f.length;e++)c=f[e],d[c.map]=c.value;var g={};for(var h in a)if(a.hasOwnProperty(h)){var i=d[h]||h;g[i]=a[h];}return g},a.prototype.processMessageQueue=function(){var a=this;0<this.messageQueue.length&&this.isReady()&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.kit&&b.methodName in this.kit?[4/*yield*/,this.kit[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a}();
1413
1431
 
1414
1432
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1415
1433
  * <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
@@ -1746,7 +1764,8 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
1746
1764
  // responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
1747
1765
  // persistence or Identity directly.
1748
1766
  if(c._APIClient=new APIClient(c,d),c._Forwarders=new Forwarders(c,d),c._Store.processConfig(b),c._Identity.idCache=createIdentityCache(c),removeExpiredIdentityCacheDates(c._Identity.idCache),c._Store.webviewBridgeEnabled)c._NativeSdkHelpers.initializeSessionAttributes(a);else {c._Persistence.initializeStorage(),c._Store.syncPersistenceData();// Set up user identitiy variables for later use
1749
- var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture(),c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
1767
+ var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture();// Configure Rokt Manager with user and filtered user
1768
+ var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:b.isDevelopmentMode};c._RoktManager.init(h,j,e,k);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
1750
1769
  // if an identify request is unnecessary, such as if there is an existing session
1751
1770
  (c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
1752
1771
  function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan object for blocking can be passed to the SDK:
@@ -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.2";
18
+ var version = "2.37.0";
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
@@ -117,7 +117,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
117
117
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
118
118
  };
119
119
 
120
- var Messages$9=Constants.Messages,createCookieString=function(a){return replaceCommasWithPipes(replaceQuotesWithApostrophes(a))},revertCookieString=function(a){return replacePipesWithCommas(replaceApostrophesWithQuotes(a))},inArray=function(a,b){var c=0;if(Array.prototype.indexOf)return 0<=a.indexOf(b,0);for(var d=a.length;c<d;c++)if(c in a&&a[c]===b)return !0;return !1},findKeyInObject=function(a,b){if(b&&a)for(var c in a)if(a.hasOwnProperty(c)&&c.toLowerCase()===b.toLowerCase())return c;return null},generateDeprecationMessage=function(a,b){var c=[a,Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix];return b&&(c.push(b),c.push(Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix)),c.join(" ")};function generateHash(a){var b,c=0;if(void 0===a||null===a)return 0;if(a=a.toString().toLowerCase(),Array.prototype.reduce)return a.split("").reduce(function(c,d){return c=(c<<5)-c+d.charCodeAt(0),c&c},0);if(0===a.length)return c;for(var d=0;d<a.length;d++)b=a.charCodeAt(d),c=(c<<5)-c+b,c&=c;return c}var generateRandomValue=function(){var b,c;return window.crypto&&window.crypto.getRandomValues&&(b=window.crypto.getRandomValues(new Uint8Array(1))),b?(c^b[0]%16>>c/4).toString(16):(c^16*Math.random()>>c/4).toString(16)},generateUniqueId=function(b){return void 0===b&&(b=""),b// if the placeholder was passed, return
120
+ var Messages$9=Constants.Messages,createCookieString=function(a){return replaceCommasWithPipes(replaceQuotesWithApostrophes(a))},revertCookieString=function(a){return replacePipesWithCommas(replaceApostrophesWithQuotes(a))},inArray=function(a,b){if(!a)return !1;var c=0;if(Array.prototype.indexOf)return 0<=a.indexOf(b,0);for(var d=a.length;c<d;c++)if(c in a&&a[c]===b)return !0;return !1},findKeyInObject=function(a,b){if(b&&a)for(var c in a)if(a.hasOwnProperty(c)&&c.toLowerCase()===b.toLowerCase())return c;return null},generateDeprecationMessage=function(a,b){var c=[a,Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix];return b&&(c.push(b),c.push(Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix)),c.join(" ")};function generateHash(a){var b,c=0;if(void 0===a||null===a)return 0;if(a=a.toString().toLowerCase(),Array.prototype.reduce)return a.split("").reduce(function(c,d){return c=(c<<5)-c+d.charCodeAt(0),c&c},0);if(0===a.length)return c;for(var d=0;d<a.length;d++)b=a.charCodeAt(d),c=(c<<5)-c+b,c&=c;return c}var generateRandomValue=function(){var b,c;return window.crypto&&window.crypto.getRandomValues&&(b=window.crypto.getRandomValues(new Uint8Array(1))),b?(c^b[0]%16>>c/4).toString(16):(c^16*Math.random()>>c/4).toString(16)},generateUniqueId=function(b){return void 0===b&&(b=""),b// if the placeholder was passed, return
121
121
  ?generateRandomValue()// if the placeholder was passed, return
122
122
  :// [1e7] -> // 10000000 +
123
123
  // -1e3 -> // -1000 +
@@ -126,12 +126,12 @@ var Messages$9=Constants.Messages,createCookieString=function(a){return replaceC
126
126
  // -1e11 -> //-100000000000,
127
127
  "".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,// zeroes, ones, and eights with
128
128
  generateUniqueId// random hex digits
129
- )},getRampNumber=function(a){if(!a)return 100;var b=generateHash(a);return Math.abs(b%100)+1},isObject=function(a){var b=Object.prototype.toString.call(a);return "[object Object]"===b||"[object Error]"===b},parseNumber=function(a){if(isNaN(a)||!isFinite(a))return 0;var b=parseFloat(a);return isNaN(b)?0:b},parseStringOrNumber=function(a){return isStringOrNumber(a)?a:null},replaceCommasWithPipes=function(a){return a.replace(/,/g,"|")},replacePipesWithCommas=function(a){return a.replace(/\|/g,",")},replaceApostrophesWithQuotes=function(a){return a.replace(/\'/g,"\"")},replaceQuotesWithApostrophes=function(a){return a.replace(/\"/g,"'")},replaceMPID=function(a,b){return a.replace("%%mpid%%",b)},replaceAmpWithAmpersand=function(a){return a.replace(/&amp;/g,"&")},createCookieSyncUrl=function(a,b,c){var d=replaceAmpWithAmpersand(b),e=c?replaceAmpWithAmpersand(c):null,f=replaceMPID(d,a),g=e?replaceMPID(e,a):"";return f+encodeURIComponent(g)},returnConvertedBoolean=function(a){return "false"!==a&&"0"!==a&&!!a},decoded=function(a){return decodeURIComponent(a.replace(/\+/g," "))},converted=function(a){return 0===a.indexOf("\"")&&(a=a.slice(1,-1).replace(/\\"/g,"\"").replace(/\\\\/g,"\\")),a},isString=function(a){return "string"==typeof a},isNumber=function(a){return "number"==typeof a},isBoolean=function(a){return "boolean"==typeof a},isFunction=function(a){return "function"==typeof a},isValidCustomFlagProperty=function(a){return isNumber(a)||isString(a)||isBoolean(a)},toDataPlanSlug=function(a){// Make sure we are only acting on strings or numbers
129
+ )},getRampNumber=function(a){if(!a)return 100;var b=generateHash(a);return Math.abs(b%100)+1},isObject=function(a){var b=Object.prototype.toString.call(a);return "[object Object]"===b||"[object Error]"===b},parseNumber=function(a){if(isNaN(a)||!isFinite(a))return 0;var b=parseFloat(a);return isNaN(b)?0:b},parseSettingsString=function(a){try{return a?JSON.parse(a.replace(/&quot;/g,"\"")):[]}catch(a){throw new Error("Settings string contains invalid JSON")}},parseStringOrNumber=function(a){return isStringOrNumber(a)?a:null},replaceCommasWithPipes=function(a){return a.replace(/,/g,"|")},replacePipesWithCommas=function(a){return a.replace(/\|/g,",")},replaceApostrophesWithQuotes=function(a){return a.replace(/\'/g,"\"")},replaceQuotesWithApostrophes=function(a){return a.replace(/\"/g,"'")},replaceMPID=function(a,b){return a.replace("%%mpid%%",b)},replaceAmpWithAmpersand=function(a){return a.replace(/&amp;/g,"&")},createCookieSyncUrl=function(a,b,c){var d=replaceAmpWithAmpersand(b),e=c?replaceAmpWithAmpersand(c):null,f=replaceMPID(d,a),g=e?replaceMPID(e,a):"";return f+encodeURIComponent(g)},returnConvertedBoolean=function(a){return "false"!==a&&"0"!==a&&!!a},decoded=function(a){return decodeURIComponent(a.replace(/\+/g," "))},converted=function(a){return 0===a.indexOf("\"")&&(a=a.slice(1,-1).replace(/\\"/g,"\"").replace(/\\\\/g,"\\")),a},isString=function(a){return "string"==typeof a},isNumber=function(a){return "number"==typeof a},isBoolean=function(a){return "boolean"==typeof a},isFunction=function(a){return "function"==typeof a},isValidCustomFlagProperty=function(a){return isNumber(a)||isString(a)||isBoolean(a)},toDataPlanSlug=function(a){// Make sure we are only acting on strings or numbers
130
130
  return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"_"):""},isDataPlanSlug=function(a){return a===toDataPlanSlug(a)},isStringOrNumber=function(a){return isString(a)||isNumber(a)},isEmpty=function(a){return null==a||!(Object.keys(a)||a).length},moveElementToEnd=function(a,b){return a.slice(0,b).concat(a.slice(b+1),a[b])},queryStringParser=function(a,b){void 0===b&&(b=[]);var c,d={};if(!a)return d;if("undefined"!=typeof URL&&"undefined"!=typeof URLSearchParams){var e=new URL(a);c=new URLSearchParams(e.search);}else c=queryStringParserFallback(a);return isEmpty(b)?c.forEach(function(a,b){d[b]=a;}):b.forEach(function(a){var b=c.get(a);b&&(d[a]=b);}),d},queryStringParserFallback=function(a){var b={},c=a.split("?")[1]||"",d=c.split("&");return d.forEach(function(a){var c=a.split("="),d=c[0],e=c.slice(1),f=e.join("=");if(d&&void 0!==f)try{b[d]=decodeURIComponent(f||"");}catch(a){console.error("Failed to decode value for key ".concat(d,": ").concat(a));}}),{get:function get(a){return b[a]},forEach:function forEach(a){for(var c in b)b.hasOwnProperty(c)&&a(b[c],c);}}},getCookies=function(a){// Helper function to parse cookies from document.cookie
131
131
  var b=function parseCookies(){return "undefined"==typeof window?[]:window.document.cookie.split(";").map(function(a){return a.trim()})}();// Helper function to filter cookies by keys
132
132
  // Parse cookies from document.cookie
133
133
  // Filter cookies by keys if provided
134
- return function filterCookies(a,b){for(var c={},d=0,e=a;d<e.length;d++){var f=e[d],g=f.split("="),h=g[0],i=g[1];(!b||b.includes(h))&&(c[h]=i);}return c}(b,a)},getHref=function(){return "undefined"!=typeof window&&window.location?window.location.href:""};/**
134
+ return function filterCookies(a,b){for(var c={},d=0,e=a;d<e.length;d++){var f=e[d],g=f.split("="),h=g[0],i=g[1];(!b||b.includes(h))&&(c[h]=i);}return c}(b,a)},getHref=function(){return "undefined"!=typeof window&&window.location?window.location.href:""},filterDictionaryWithHash=function(a,b,c){var d={};if(!isEmpty(a))for(var e in a)if(a.hasOwnProperty(e)){var f=c(e);inArray(b,f)||(d[e]=a[e]);}return d},parseConfig=function(a,b,c){var d;return (null===(d=a.kitConfigs)||void 0===d?void 0:d.find(function(a){return a.name===b&&a.moduleId===c}))||null};/**
135
135
  * Returns a value between 1-100 inclusive.
136
136
  */ // FIXME: REFACTOR for V3
137
137
 
@@ -467,7 +467,7 @@ isValidKeyValue:function isValidKeyValue(a){return !(!a||isObject(a)||Array.isAr
467
467
  if(void 0===a.userIdentities)return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentities};// identityApiData.userIdentities can be null, but if it isn't null or undefined (above conditional), it must be an object
468
468
  if(null!==a.userIdentities&&!isObject(a.userIdentities))return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentities};if(isObject(a.userIdentities)&&Object.keys(a.userIdentities).length)for(var e in a.userIdentities)if(a.userIdentities.hasOwnProperty(e)){if(!1===Types.IdentityType.getIdentityType(e))return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentitiesInvalidKey};if("string"!=typeof a.userIdentities[e]&&null!==a.userIdentities[e])return {valid:!1,error:Constants.Messages.ValidationMessages.UserIdentitiesInvalidValues}}}return {valid:!0}}};
469
469
 
470
- var KitFilterHelper=/** @class */function(){function a(){}return a.hashEventType=function(a){return generateHash(a)},a.hashEventName=function(a,b){return generateHash(b+a)},(a.hashEventAttributeKey=function(a,b,c){return generateHash(a+b+c)},a.hashUserAttribute=function(a){return generateHash(a)},a.hashUserIdentity=function(a){return a},a.hashConsentPurpose=function(a,b){return generateHash(a+b)},a.hashAttributeConditionalForwarding=function(a){return generateHash(a).toString()},a.hashConsentPurposeConditionalForwarding=function(a,b){return this.hashConsentPurpose(a,b).toString()},a)}();
470
+ var KitFilterHelper=/** @class */function(){function a(){}a.hashEventType=function(a){return generateHash(a)},a.hashEventName=function(a,b){return generateHash(b+a)},a.hashEventAttributeKey=function(a,b,c){return generateHash(a+b+c)},a.hashUserAttribute=function(a){return generateHash(a)},a.hashUserIdentity=function(a){return a},a.hashConsentPurpose=function(a,b){return generateHash(a+b)},a.hashAttributeConditionalForwarding=function(a){return generateHash(a).toString()},a.hashConsentPurposeConditionalForwarding=function(a,b){return this.hashConsentPurpose(a,b).toString()};var b;return b=a,a.filterUserAttributes=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserAttribute(a)})},a.filterUserIdentities=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserIdentity(IdentityType.getIdentityType(a))})},a.isFilteredUserAttribute=function(a,c){var d=b.hashUserAttribute(a);return c&&inArray(c,d)},a}();
471
471
 
472
472
  var StorageNames$1=Constants.StorageNames;function Helpers(a){var b=this;// https://go.mparticle.com/work/SQDSDKS-6047
473
473
  // Standalone version of jQuery.extend, from https://github.com/dansdom/extend
@@ -484,7 +484,7 @@ if(null!=(a=arguments[j]))// Extend the base object
484
484
  for(c in a)// Prevent never-ending loop
485
485
  (d=h[c],e=a[c],h!==e)&&(l&&e&&(m.isPlainObject(e)||(f=m.isArray(e)))?(f?(f=!1,g=d&&m.isArray(d)?d:[]):g=d&&m.isPlainObject(d)?d:{},h[c]=b.extend(l,g,e)):void 0!==e&&(h[c]=e));// Recurse if we're merging plain objects or arrays
486
486
  // Return the modified object
487
- return h},this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){var d=[];if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);if(!b.inArray(c,f)){var g={Type:f,Identity:a[e]};f===Types.IdentityType.CustomerId?d.unshift(g):d.push(g);}}return d},this.filterUserIdentitiesForForwarders=function(a,c){var d={};if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=KitFilterHelper.hashUserIdentity(Types.IdentityType.getIdentityType(e));b.inArray(c,f)||(d[e]=a[e]);}return d},this.filterUserAttributes=function(a,c){var d={};if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=KitFilterHelper.hashUserAttribute(e);b.inArray(c,f)||(d[e]=a[e]);}return d},this.isFilteredUserAttribute=function(a,c){var d=KitFilterHelper.hashUserAttribute(a);return c&&b.inArray(c,d)},this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
487
+ return h},this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){var d=[];if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);if(!b.inArray(c,f)){var g={Type:f,Identity:a[e]};f===Types.IdentityType.CustomerId?d.unshift(g):d.push(g);}}return d},this.filterUserIdentitiesForForwarders=KitFilterHelper.filterUserIdentities,this.filterUserAttributes=KitFilterHelper.filterUserAttributes,this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
488
488
  c.hasOwnProperty(f)&&b.Validators.isValidAttributeValue(c[f])?e[f]=c[f]:a.Logger.warning("For '"+d+"', the corresponding attribute value of '"+f+"' must be a string, number, boolean, or null.");return e},this.isDelayedByIntegration=function(b,c,d){if(d-c>a._Store.SDKConfig.integrationDelayTimeout)return !1;for(var e in b){if(!0===b[e])return !0;continue}return !1},this.createMainStorageName=function(a){return a?StorageNames$1.currentStorageName+"_"+a:StorageNames$1.currentStorageName},this.createProductStorageName=function(a){return a?StorageNames$1.currentStorageProductsName+"_"+a:StorageNames$1.currentStorageProductsName},this.converted=converted,this.findKeyInObject=findKeyInObject,this.parseNumber=parseNumber,this.inArray=inArray,this.isObject=isObject,this.decoded=decoded,this.parseStringOrNumber=parseStringOrNumber,this.generateHash=generateHash,this.generateUniqueId=generateUniqueId,this.Validators=Validators;}
489
489
 
490
490
  var Messages$8=Constants.Messages,androidBridgeNameBase="mParticleAndroid",iosBridgeNameBase="mParticle";function NativeSdkHelpers(a){var b=this;this.initializeSessionAttributes=function(a){var c=Constants.NativeSdkPaths.SetSessionAttribute,d=JSON.stringify({key:"$src_env",value:"webview"}),e=JSON.stringify({key:"$src_key",value:a});b.sendToNative(c,d),a&&b.sendToNative(c,e);},this.isBridgeV2Available=function(a){if(!a)return !1;var b=iosBridgeNameBase+"_"+a+"_v2";// iOS v2 bridge
@@ -1029,7 +1029,7 @@ if(-1<j.indexOf(b.EventDataType)&&a._Store.activeForwarders[k].filteringEventAtt
1029
1029
  if(b.EventAttributes)for(var m in b.EventAttributes){var n;if(n=KitFilterHelper.hashAttributeConditionalForwarding(m),n===a._Store.activeForwarders[k].filteringEventAttributeValue.eventAttributeName&&(l={name:n,value:KitFilterHelper.hashAttributeConditionalForwarding(b.EventAttributes[m])}),l)break}var o=null!==l&&l.value===a._Store.activeForwarders[k].filteringEventAttributeValue.eventAttributeValue,p=!0===a._Store.activeForwarders[k].filteringEventAttributeValue.includeOnMatch?o:!o;if(!p)continue}// Clone the event object, as we could be sending different attributes to each forwarder
1030
1030
  // Check event filtering rules
1031
1031
  if(c={},c=a._Helpers.extend(!0,c,b),b.EventDataType===Types.MessageType.PageEvent&&(h(a._Store.activeForwarders[k].eventNameFilters,d)||h(a._Store.activeForwarders[k].eventTypeFilters,e)))continue;else if(b.EventDataType===Types.MessageType.Commerce&&h(a._Store.activeForwarders[k].eventTypeFilters,e))continue;else if(b.EventDataType===Types.MessageType.PageView&&h(a._Store.activeForwarders[k].screenNameFilters,d))continue;// Check attribute filtering rules
1032
- if(c.EventAttributes&&(b.EventDataType===Types.MessageType.PageEvent?g(c,a._Store.activeForwarders[k].attributeFilters):b.EventDataType===Types.MessageType.PageView&&g(c,a._Store.activeForwarders[k].screenAttributeFilters)),f(c,a._Store.activeForwarders[k].userIdentityFilters),c.UserAttributes=a._Helpers.filterUserAttributes(c.UserAttributes,a._Store.activeForwarders[k].userAttributeFilters),a._Store.activeForwarders[k].process){a.Logger.verbose("Sending message to forwarder: "+a._Store.activeForwarders[k].name);var q=a._Store.activeForwarders[k].process(c);q&&a.Logger.verbose(q);}}}},this.handleForwarderUserAttributes=function(c,d,f){b&&b.isAttributeKeyBlocked(d)||!a._Store.activeForwarders.length||a._Store.activeForwarders.forEach(function(b){var g=b[c];if(g&&!a._Helpers.isFilteredUserAttribute(d,b.userAttributeFilters))try{var h;c===e.setUserAttribute?h=b.setUserAttribute(d,f):c===e.removeUserAttribute&&(h=b.removeUserAttribute(d)),h&&a.Logger.verbose(h);}catch(b){a.Logger.error(b);}});},this.setForwarderUserIdentities=function(b){a._Store.activeForwarders.forEach(function(c){var d=a._Helpers.filterUserIdentities(b,c.userIdentityFilters);c.setUserIdentity&&d.forEach(function(b){var d=c.setUserIdentity(b.Identity,b.Type);d&&a.Logger.verbose(d);});});},this.setForwarderOnUserIdentified=function(c){a._Store.activeForwarders.forEach(function(d){var e=filteredMparticleUser(c.getMPID(),d,a,b);if(d.onUserIdentified){var f=d.onUserIdentified(e);f&&a.Logger.verbose(f);}});},this.setForwarderOnIdentityComplete=function(c,d){var e;a._Store.activeForwarders.forEach(function(f){var g=filteredMparticleUser(c.getMPID(),f,a,b),h=g.getUserIdentities();d===Identify$2?f.onIdentifyComplete&&(e=f.onIdentifyComplete(g,h),e&&a.Logger.verbose(e)):d===Login$2?f.onLoginComplete&&(e=f.onLoginComplete(g,h),e&&a.Logger.verbose(e)):d===Logout$2?f.onLogoutComplete&&(e=f.onLogoutComplete(g,h),e&&a.Logger.verbose(e)):d===Modify$3&&f.onModifyComplete&&(e=f.onModifyComplete(g,h),e&&a.Logger.verbose(e));});},this.getForwarderStatsQueue=function(){return a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue},this.setForwarderStatsQueue=function(b){a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=b;},this.processForwarders=function(b,c){b?(this.processUIEnabledKits(b),this.processSideloadedKits(b),d.initForwarders(a._Store.SDKConfig.identifyRequest.userIdentities,c)):a.Logger.warning("No config was passed. Cannot process forwarders");},this.processUIEnabledKits=function(b){var c=this.returnKitConstructors();try{Array.isArray(b.kitConfigs)&&b.kitConfigs.length&&b.kitConfigs.forEach(function(a){d.configureUIEnabledKit(a,c);});}catch(b){a.Logger.error("MP Kits not configured propertly. Kits may not be initialized. "+b);}},this.returnKitConstructors=function(){var b={};// If there are kits inside of mpInstance._Store.SDKConfig.kits, then mParticle is self hosted
1032
+ if(c.EventAttributes&&(b.EventDataType===Types.MessageType.PageEvent?g(c,a._Store.activeForwarders[k].attributeFilters):b.EventDataType===Types.MessageType.PageView&&g(c,a._Store.activeForwarders[k].screenAttributeFilters)),f(c,a._Store.activeForwarders[k].userIdentityFilters),c.UserAttributes=a._Helpers.filterUserAttributes(c.UserAttributes,a._Store.activeForwarders[k].userAttributeFilters),a._Store.activeForwarders[k].process){a.Logger.verbose("Sending message to forwarder: "+a._Store.activeForwarders[k].name);var q=a._Store.activeForwarders[k].process(c);q&&a.Logger.verbose(q);}}}},this.handleForwarderUserAttributes=function(c,d,f){b&&b.isAttributeKeyBlocked(d)||!a._Store.activeForwarders.length||a._Store.activeForwarders.forEach(function(b){var g=b[c];if(g&&!KitFilterHelper.isFilteredUserAttribute(d,b.userAttributeFilters))try{var h;c===e.setUserAttribute?h=b.setUserAttribute(d,f):c===e.removeUserAttribute&&(h=b.removeUserAttribute(d)),h&&a.Logger.verbose(h);}catch(b){a.Logger.error(b);}});},this.setForwarderUserIdentities=function(b){a._Store.activeForwarders.forEach(function(c){var d=a._Helpers.filterUserIdentities(b,c.userIdentityFilters);c.setUserIdentity&&d.forEach(function(b){var d=c.setUserIdentity(b.Identity,b.Type);d&&a.Logger.verbose(d);});});},this.setForwarderOnUserIdentified=function(c){a._Store.activeForwarders.forEach(function(d){var e=filteredMparticleUser(c.getMPID(),d,a,b);if(d.onUserIdentified){var f=d.onUserIdentified(e);f&&a.Logger.verbose(f);}});},this.setForwarderOnIdentityComplete=function(c,d){var e;a._Store.activeForwarders.forEach(function(f){var g=filteredMparticleUser(c.getMPID(),f,a,b),h=g.getUserIdentities();d===Identify$2?f.onIdentifyComplete&&(e=f.onIdentifyComplete(g,h),e&&a.Logger.verbose(e)):d===Login$2?f.onLoginComplete&&(e=f.onLoginComplete(g,h),e&&a.Logger.verbose(e)):d===Logout$2?f.onLogoutComplete&&(e=f.onLogoutComplete(g,h),e&&a.Logger.verbose(e)):d===Modify$3&&f.onModifyComplete&&(e=f.onModifyComplete(g,h),e&&a.Logger.verbose(e));});},this.getForwarderStatsQueue=function(){return a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue},this.setForwarderStatsQueue=function(b){a._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=b;},this.processForwarders=function(b,c){b?(this.processUIEnabledKits(b),this.processSideloadedKits(b),d.initForwarders(a._Store.SDKConfig.identifyRequest.userIdentities,c)):a.Logger.warning("No config was passed. Cannot process forwarders");},this.processUIEnabledKits=function(b){var c=this.returnKitConstructors();try{Array.isArray(b.kitConfigs)&&b.kitConfigs.length&&b.kitConfigs.forEach(function(a){d.configureUIEnabledKit(a,c);});}catch(b){a.Logger.error("MP Kits not configured propertly. Kits may not be initialized. "+b);}},this.returnKitConstructors=function(){var b={};// If there are kits inside of mpInstance._Store.SDKConfig.kits, then mParticle is self hosted
1033
1033
  return isEmpty(a._Store.SDKConfig.kits)?!isEmpty(a._preInit.forwarderConstructors)&&a._preInit.forwarderConstructors.forEach(function(a){// A suffix is added to a kitConstructor and kit config if there are multiple different
1034
1034
  // versions of a client kit. This matches the suffix in the DB. As an example
1035
1035
  // the GA4 kit has a client kit and a server side kit which has a client side
@@ -1409,7 +1409,25 @@ var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c
1409
1409
  // }
1410
1410
  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.applyProcessors=function(a,b,c){var d,e={};for(var f in a)if(a.hasOwnProperty(f)){var g=a[f],h=null===(d=integrationMapping[f])||void 0===d?void 0:d.processor;e[f]=h?h(g,b,c):g;}return e},a.prototype.filterMappings=function(a){var b={};for(var c in integrationMapping)integrationMapping[c].output===a&&(b[c]=integrationMapping[c]);return b},a}();
1411
1411
 
1412
- var RoktManager=/** @class */function(){function a(){this.launcher=null,this.messageQueue=[],this.launcher=null;}return a.prototype.attachLauncher=function(a){this.setLauncher(a),this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.launcher)return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.launcher.selectPlacements(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.processMessageQueue=function(){var a=this;0<this.messageQueue.length&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.launcher&&b.methodName in this.launcher?[4/*yield*/,this.launcher[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a.prototype.setLauncher=function(a){this.launcher=a;},a}();
1412
+ // Rokt Web SDK via a Web Kit.
1413
+ // The Rokt Manager should load before the Web Kit and stubs out many of the
1414
+ // Rokt Web SDK functions with an internal message queue in case a Rokt function
1415
+ // is requested before the Rokt Web Kit or SDK is finished loaded.
1416
+ // Once the Rokt Kit is attached to the Rokt Manager, we can consider the
1417
+ // Rokt Manager in a "ready" state and it can begin sending data to the kit.
1418
+ //
1419
+ // https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
1420
+ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.filteredUser=null,this.messageQueue=[],this.sandbox=null,this.userAttributeMapping=[];}/**
1421
+ * Initializes the RoktManager with configuration settings and user data.
1422
+ *
1423
+ * @param {IKitConfigs} roktConfig - Configuration object containing user attribute filters and settings
1424
+ * @param {IMParticleUser} filteredUser - User object with filtered attributes
1425
+ * @param {IMParticleUser} currentUser - Current mParticle user object
1426
+ * @param {IRoktManagerOptions} options - Options for the RoktManager
1427
+ *
1428
+ * @throws Logs error to console if userAttributeMapping parsing fails
1429
+ */return a.prototype.init=function(a,b,c,d){var e=a||{},f=e.userAttributeFilters,g=e.settings,h=(g||{}).userAttributeMapping;try{this.userAttributeMapping=parseSettingsString(h);}catch(a){console.error("Error parsing user attribute mapping from config",a);}this.currentUser=c,this.filters={userAttributeFilters:f,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b},this.sandbox=null===d||void 0===d?void 0:d.sandbox;},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b;if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{var c=a.attributes,d=null!==(b=null===c||void 0===c?void 0:c.sandbox)&&void 0!==b?b:this.sandbox,e=this.mapUserAttributes(c,this.userAttributeMapping);this.setUserAttributes(e);var f=__assign(__assign({},e),null===d?{}:{sandbox:d}),g=__assign(__assign({},a),{attributes:f});return this.kit.selectPlacements(g)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1430
+ return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)a.hasOwnProperty(d)&&-1===b.indexOf(d)&&(c[d]=a[d]);try{this.currentUser.setUserAttributes(c);}catch(a){console.error("Error setting user attributes",a);}},a.prototype.mapUserAttributes=function(a,b){for(var c,d={},e=0,f=b;e<f.length;e++)c=f[e],d[c.map]=c.value;var g={};for(var h in a)if(a.hasOwnProperty(h)){var i=d[h]||h;g[i]=a[h];}return g},a.prototype.processMessageQueue=function(){var a=this;0<this.messageQueue.length&&this.isReady()&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.kit&&b.methodName in this.kit?[4/*yield*/,this.kit[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a}();
1413
1431
 
1414
1432
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1415
1433
  * <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
@@ -1746,7 +1764,8 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
1746
1764
  // responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
1747
1765
  // persistence or Identity directly.
1748
1766
  if(c._APIClient=new APIClient(c,d),c._Forwarders=new Forwarders(c,d),c._Store.processConfig(b),c._Identity.idCache=createIdentityCache(c),removeExpiredIdentityCacheDates(c._Identity.idCache),c._Store.webviewBridgeEnabled)c._NativeSdkHelpers.initializeSessionAttributes(a);else {c._Persistence.initializeStorage(),c._Store.syncPersistenceData();// Set up user identitiy variables for later use
1749
- var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture(),c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
1767
+ var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture();// Configure Rokt Manager with user and filtered user
1768
+ var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:b.isDevelopmentMode};c._RoktManager.init(h,j,e,k);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
1750
1769
  // if an identify request is unnecessary, such as if there is an existing session
1751
1770
  (c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
1752
1771
  function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan object for blocking can be passed to the SDK:
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.2";
206
+ var version = "2.37.0";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -490,6 +490,9 @@ var mParticle = (function () {
490
490
  return replacePipesWithCommas(replaceApostrophesWithQuotes(value));
491
491
  };
492
492
  var inArray = function inArray(items, name) {
493
+ if (!items) {
494
+ return false;
495
+ }
493
496
  var i = 0;
494
497
  if (Array.prototype.indexOf) {
495
498
  return items.indexOf(name, 0) >= 0;
@@ -597,6 +600,13 @@ var mParticle = (function () {
597
600
  var floatValue = parseFloat(value);
598
601
  return isNaN(floatValue) ? 0 : floatValue;
599
602
  };
603
+ var parseSettingsString = function parseSettingsString(settingsString) {
604
+ try {
605
+ return settingsString ? JSON.parse(settingsString.replace(/&quot;/g, '"')) : [];
606
+ } catch (error) {
607
+ throw new Error('Settings string contains invalid JSON');
608
+ }
609
+ };
600
610
  var parseStringOrNumber = function parseStringOrNumber(value) {
601
611
  if (isStringOrNumber(value)) {
602
612
  return value;
@@ -770,6 +780,26 @@ var mParticle = (function () {
770
780
  var getHref = function getHref() {
771
781
  return typeof window !== 'undefined' && window.location ? window.location.href : '';
772
782
  };
783
+ var filterDictionaryWithHash = function filterDictionaryWithHash(dictionary, filterList, hashFn) {
784
+ var filtered = {};
785
+ if (!isEmpty(dictionary)) {
786
+ for (var key in dictionary) {
787
+ if (dictionary.hasOwnProperty(key)) {
788
+ var hashedKey = hashFn(key);
789
+ if (!inArray(filterList, hashedKey)) {
790
+ filtered[key] = dictionary[key];
791
+ }
792
+ }
793
+ }
794
+ }
795
+ return filtered;
796
+ };
797
+ var parseConfig = function parseConfig(config, moduleName, moduleId) {
798
+ var _a;
799
+ return ((_a = config.kitConfigs) === null || _a === void 0 ? void 0 : _a.find(function (kitConfig) {
800
+ return kitConfig.name === moduleName && kitConfig.moduleId === moduleId;
801
+ })) || null;
802
+ };
773
803
 
774
804
  var MessageType$1 = {
775
805
  SessionStart: 1,
@@ -2907,6 +2937,22 @@ var mParticle = (function () {
2907
2937
  KitFilterHelper.hashConsentPurposeConditionalForwarding = function (prefix, purpose) {
2908
2938
  return this.hashConsentPurpose(prefix, purpose).toString();
2909
2939
  };
2940
+ var _a;
2941
+ _a = KitFilterHelper;
2942
+ KitFilterHelper.filterUserAttributes = function (userAttributes, filterList) {
2943
+ return filterDictionaryWithHash(userAttributes, filterList, function (key) {
2944
+ return _a.hashUserAttribute(key);
2945
+ });
2946
+ };
2947
+ KitFilterHelper.filterUserIdentities = function (userIdentities, filterList) {
2948
+ return filterDictionaryWithHash(userIdentities, filterList, function (key) {
2949
+ return _a.hashUserIdentity(IdentityType.getIdentityType(key));
2950
+ });
2951
+ };
2952
+ KitFilterHelper.isFilteredUserAttribute = function (userAttributeKey, filterList) {
2953
+ var hashedUserAttribute = _a.hashUserAttribute(userAttributeKey);
2954
+ return filterList && inArray(filterList, hashedUserAttribute);
2955
+ };
2910
2956
  return KitFilterHelper;
2911
2957
  }();
2912
2958
 
@@ -3135,38 +3181,8 @@ var mParticle = (function () {
3135
3181
  }
3136
3182
  return filteredUserIdentities;
3137
3183
  };
3138
- this.filterUserIdentitiesForForwarders = function (userIdentitiesObject, filterList) {
3139
- var filteredUserIdentities = {};
3140
- if (userIdentitiesObject && Object.keys(userIdentitiesObject).length) {
3141
- for (var userIdentityName in userIdentitiesObject) {
3142
- if (userIdentitiesObject.hasOwnProperty(userIdentityName)) {
3143
- var userIdentityType = KitFilterHelper.hashUserIdentity(Types.IdentityType.getIdentityType(userIdentityName));
3144
- if (!self.inArray(filterList, userIdentityType)) {
3145
- filteredUserIdentities[userIdentityName] = userIdentitiesObject[userIdentityName];
3146
- }
3147
- }
3148
- }
3149
- }
3150
- return filteredUserIdentities;
3151
- };
3152
- this.filterUserAttributes = function (userAttributes, filterList) {
3153
- var filteredUserAttributes = {};
3154
- if (userAttributes && Object.keys(userAttributes).length) {
3155
- for (var userAttribute in userAttributes) {
3156
- if (userAttributes.hasOwnProperty(userAttribute)) {
3157
- var hashedUserAttribute = KitFilterHelper.hashUserAttribute(userAttribute);
3158
- if (!self.inArray(filterList, hashedUserAttribute)) {
3159
- filteredUserAttributes[userAttribute] = userAttributes[userAttribute];
3160
- }
3161
- }
3162
- }
3163
- }
3164
- return filteredUserAttributes;
3165
- };
3166
- this.isFilteredUserAttribute = function (userAttributeKey, filterList) {
3167
- var hashedUserAttribute = KitFilterHelper.hashUserAttribute(userAttributeKey);
3168
- return filterList && self.inArray(filterList, hashedUserAttribute);
3169
- };
3184
+ this.filterUserIdentitiesForForwarders = KitFilterHelper.filterUserIdentities;
3185
+ this.filterUserAttributes = KitFilterHelper.filterUserAttributes;
3170
3186
  this.isEventType = function (type) {
3171
3187
  for (var prop in Types.EventType) {
3172
3188
  if (Types.EventType.hasOwnProperty(prop)) {
@@ -6325,7 +6341,7 @@ var mParticle = (function () {
6325
6341
  }
6326
6342
  mpInstance._Store.activeForwarders.forEach(function (forwarder) {
6327
6343
  var forwarderFunction = forwarder[functionNameKey];
6328
- if (!forwarderFunction || mpInstance._Helpers.isFilteredUserAttribute(key, forwarder.userAttributeFilters)) {
6344
+ if (!forwarderFunction || KitFilterHelper.isFilteredUserAttribute(key, forwarder.userAttributeFilters)) {
6329
6345
  return;
6330
6346
  }
6331
6347
  try {
@@ -9621,18 +9637,60 @@ var mParticle = (function () {
9621
9637
  return IntegrationCapture;
9622
9638
  }();
9623
9639
 
9640
+ // The purpose of this class is to create a link between the Core mParticle SDK and the
9641
+ // Rokt Web SDK via a Web Kit.
9642
+ // The Rokt Manager should load before the Web Kit and stubs out many of the
9643
+ // Rokt Web SDK functions with an internal message queue in case a Rokt function
9644
+ // is requested before the Rokt Web Kit or SDK is finished loaded.
9645
+ // Once the Rokt Kit is attached to the Rokt Manager, we can consider the
9646
+ // Rokt Manager in a "ready" state and it can begin sending data to the kit.
9647
+ //
9648
+ // https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
9624
9649
  var RoktManager = /** @class */function () {
9625
9650
  function RoktManager() {
9626
- this.launcher = null;
9651
+ this.kit = null;
9652
+ this.filters = {};
9653
+ this.currentUser = null;
9654
+ this.filteredUser = null;
9627
9655
  this.messageQueue = [];
9628
- this.launcher = null;
9656
+ this.sandbox = null;
9657
+ this.userAttributeMapping = [];
9629
9658
  }
9630
- RoktManager.prototype.attachLauncher = function (launcher) {
9631
- this.setLauncher(launcher);
9659
+ /**
9660
+ * Initializes the RoktManager with configuration settings and user data.
9661
+ *
9662
+ * @param {IKitConfigs} roktConfig - Configuration object containing user attribute filters and settings
9663
+ * @param {IMParticleUser} filteredUser - User object with filtered attributes
9664
+ * @param {IMParticleUser} currentUser - Current mParticle user object
9665
+ * @param {IRoktManagerOptions} options - Options for the RoktManager
9666
+ *
9667
+ * @throws Logs error to console if userAttributeMapping parsing fails
9668
+ */
9669
+ RoktManager.prototype.init = function (roktConfig, filteredUser, currentUser, options) {
9670
+ var _a = roktConfig || {},
9671
+ userAttributeFilters = _a.userAttributeFilters,
9672
+ settings = _a.settings;
9673
+ var userAttributeMapping = (settings || {}).userAttributeMapping;
9674
+ try {
9675
+ this.userAttributeMapping = parseSettingsString(userAttributeMapping);
9676
+ } catch (error) {
9677
+ console.error('Error parsing user attribute mapping from config', error);
9678
+ }
9679
+ this.currentUser = currentUser;
9680
+ this.filters = {
9681
+ userAttributeFilters: userAttributeFilters,
9682
+ filterUserAttributes: KitFilterHelper.filterUserAttributes,
9683
+ filteredUser: filteredUser
9684
+ };
9685
+ this.sandbox = options === null || options === void 0 ? void 0 : options.sandbox;
9686
+ };
9687
+ RoktManager.prototype.attachKit = function (kit) {
9688
+ this.kit = kit;
9632
9689
  this.processMessageQueue();
9633
9690
  };
9634
9691
  RoktManager.prototype.selectPlacements = function (options) {
9635
- if (!this.launcher) {
9692
+ var _a;
9693
+ if (!this.isReady()) {
9636
9694
  this.queueMessage({
9637
9695
  methodName: 'selectPlacements',
9638
9696
  payload: options
@@ -9640,21 +9698,64 @@ var mParticle = (function () {
9640
9698
  return Promise.resolve({});
9641
9699
  }
9642
9700
  try {
9643
- return this.launcher.selectPlacements(options);
9701
+ var attributes = options.attributes;
9702
+ var sandboxValue = (_a = attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) !== null && _a !== void 0 ? _a : this.sandbox;
9703
+ var mappedAttributes = this.mapUserAttributes(attributes, this.userAttributeMapping);
9704
+ this.setUserAttributes(mappedAttributes);
9705
+ var enrichedAttributes = __assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
9706
+ sandbox: sandboxValue
9707
+ } : {});
9708
+ var enrichedOptions = __assign(__assign({}, options), {
9709
+ attributes: enrichedAttributes
9710
+ });
9711
+ return this.kit.selectPlacements(enrichedOptions);
9644
9712
  } catch (error) {
9645
9713
  return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
9646
9714
  }
9647
9715
  };
9716
+ RoktManager.prototype.isReady = function () {
9717
+ // The Rokt Manager is ready when a kit is attached and has a launcher
9718
+ return Boolean(this.kit && this.kit.launcher);
9719
+ };
9720
+ RoktManager.prototype.setUserAttributes = function (attributes) {
9721
+ var reservedAttributes = ['sandbox'];
9722
+ var filteredAttributes = {};
9723
+ for (var key in attributes) {
9724
+ if (attributes.hasOwnProperty(key) && reservedAttributes.indexOf(key) === -1) {
9725
+ filteredAttributes[key] = attributes[key];
9726
+ }
9727
+ }
9728
+ try {
9729
+ this.currentUser.setUserAttributes(filteredAttributes);
9730
+ } catch (error) {
9731
+ console.error('Error setting user attributes', error);
9732
+ }
9733
+ };
9734
+ RoktManager.prototype.mapUserAttributes = function (attributes, userAttributeMapping) {
9735
+ var mappingLookup = {};
9736
+ for (var _i = 0, userAttributeMapping_1 = userAttributeMapping; _i < userAttributeMapping_1.length; _i++) {
9737
+ var mapping = userAttributeMapping_1[_i];
9738
+ mappingLookup[mapping.map] = mapping.value;
9739
+ }
9740
+ var mappedAttributes = {};
9741
+ for (var key in attributes) {
9742
+ if (attributes.hasOwnProperty(key)) {
9743
+ var newKey = mappingLookup[key] || key;
9744
+ mappedAttributes[newKey] = attributes[key];
9745
+ }
9746
+ }
9747
+ return mappedAttributes;
9748
+ };
9648
9749
  RoktManager.prototype.processMessageQueue = function () {
9649
9750
  var _this = this;
9650
- if (this.messageQueue.length > 0) {
9751
+ if (this.messageQueue.length > 0 && this.isReady()) {
9651
9752
  this.messageQueue.forEach(function (message) {
9652
9753
  return __awaiter(_this, void 0, void 0, function () {
9653
9754
  return __generator(this, function (_a) {
9654
9755
  switch (_a.label) {
9655
9756
  case 0:
9656
- if (!(this.launcher && message.methodName in this.launcher)) return [3 /*break*/, 2];
9657
- return [4 /*yield*/, this.launcher[message.methodName](message.payload)];
9757
+ if (!(this.kit && message.methodName in this.kit)) return [3 /*break*/, 2];
9758
+ return [4 /*yield*/, this.kit[message.methodName](message.payload)];
9658
9759
  case 1:
9659
9760
  _a.sent();
9660
9761
  _a.label = 2;
@@ -9671,9 +9772,6 @@ var mParticle = (function () {
9671
9772
  RoktManager.prototype.queueMessage = function (message) {
9672
9773
  this.messageQueue.push(message);
9673
9774
  };
9674
- RoktManager.prototype.setLauncher = function (launcher) {
9675
- this.launcher = launcher;
9676
- };
9677
9775
  return RoktManager;
9678
9776
  }();
9679
9777
 
@@ -10647,6 +10745,18 @@ var mParticle = (function () {
10647
10745
  if (mpInstance._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)) {
10648
10746
  mpInstance._IntegrationCapture.capture();
10649
10747
  }
10748
+ // Configure Rokt Manager with user and filtered user
10749
+ var roktConfig = parseConfig(config, 'Rokt', 181);
10750
+ if (roktConfig) {
10751
+ var userAttributeFilters = roktConfig.userAttributeFilters;
10752
+ var roktFilteredUser = filteredMparticleUser(currentUserMPID, {
10753
+ userAttributeFilters: userAttributeFilters
10754
+ }, mpInstance);
10755
+ var roktOptions = {
10756
+ sandbox: config.isDevelopmentMode
10757
+ };
10758
+ mpInstance._RoktManager.init(roktConfig, roktFilteredUser, currentUser, roktOptions);
10759
+ }
10650
10760
  mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
10651
10761
  mpInstance._Forwarders.processPixelConfigs(config);
10652
10762
  // Checks if session is created, resumed, or needs to be ended
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.35.2",
3
+ "version": "2.37.0",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -1,7 +1,7 @@
1
1
  import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels';
2
2
  import { Dictionary } from './utils';
3
3
  import { IKitConfigs, IKitFilterSettings } from './configAPIClient';
4
- import { IdentityApiData } from '@mparticle/web-sdk';
4
+ import { IdentityApiData, IdentityType } from '@mparticle/web-sdk';
5
5
  import {
6
6
  IMParticleUser,
7
7
  ISDKUserIdentity,
@@ -12,16 +12,26 @@ import {
12
12
  export type MPForwarder = Dictionary;
13
13
 
14
14
  // The state of the kit when accessed via window.KitName via CDN
15
- // or imported as an NPM package
15
+ // or imported as an NPM package but before it goes through the registration process
16
+ // This also applies to sideloaded kits which have not yet been registered
16
17
  export interface UnregisteredKit {
17
18
  constructor: () => void;
18
19
  register(config: KitRegistrationConfig): void;
19
20
  name: string;
21
+
22
+ // Optional Attributes that are not used for sideloaded kits
23
+
24
+ // Module ID is used for kits that are provided via CDN or NPM
25
+ moduleId?: number;
26
+
27
+ // Suffix is used for kits that are provided via CDN or NPM
28
+ // and is used for version pinning of the SDK
20
29
  suffix?: string;
21
30
  }
22
31
 
23
32
  // The state of the kit after being added to forwarderConstructors in the CDN
24
33
  // or after registered to SDKConfig.kits via NPM
34
+ // Sideloaded Kits would also be considered registered
25
35
  export interface RegisteredKit {
26
36
  constructor: () => void;
27
37
 
@@ -81,6 +91,8 @@ export interface ConfiguredKit
81
91
 
82
92
  export type UserIdentityId = string;
83
93
  export type UserIdentityType = number;
94
+ export type UserAttributeFilters = number[];
95
+ export type UserIdentityFilters = typeof IdentityType[];
84
96
 
85
97
  export type forwardingStatsCallback = (
86
98
  forwarder: ConfiguredKit,
package/src/forwarders.js CHANGED
@@ -417,7 +417,7 @@ export default function Forwarders(mpInstance, kitBlocker) {
417
417
  const forwarderFunction = forwarder[functionNameKey];
418
418
  if (
419
419
  !forwarderFunction ||
420
- mpInstance._Helpers.isFilteredUserAttribute(
420
+ KitFilterHelper.isFilteredUserAttribute(
421
421
  key,
422
422
  forwarder.userAttributeFilters
423
423
  )
package/src/helpers.js CHANGED
@@ -304,55 +304,9 @@ export default function Helpers(mpInstance) {
304
304
  return filteredUserIdentities;
305
305
  };
306
306
 
307
- this.filterUserIdentitiesForForwarders = function(
308
- userIdentitiesObject,
309
- filterList
310
- ) {
311
- const filteredUserIdentities = {};
312
-
313
- if (userIdentitiesObject && Object.keys(userIdentitiesObject).length) {
314
- for (const userIdentityName in userIdentitiesObject) {
315
- if (userIdentitiesObject.hasOwnProperty(userIdentityName)) {
316
- const userIdentityType = KitFilterHelper.hashUserIdentity(
317
- Types.IdentityType.getIdentityType(userIdentityName)
318
- );
319
- if (!self.inArray(filterList, userIdentityType)) {
320
- filteredUserIdentities[userIdentityName] =
321
- userIdentitiesObject[userIdentityName];
322
- }
323
- }
324
- }
325
- }
326
-
327
- return filteredUserIdentities;
328
- };
329
-
330
- this.filterUserAttributes = function(userAttributes, filterList) {
331
- var filteredUserAttributes = {};
332
-
333
- if (userAttributes && Object.keys(userAttributes).length) {
334
- for (var userAttribute in userAttributes) {
335
- if (userAttributes.hasOwnProperty(userAttribute)) {
336
- const hashedUserAttribute = KitFilterHelper.hashUserAttribute(
337
- userAttribute
338
- );
339
- if (!self.inArray(filterList, hashedUserAttribute)) {
340
- filteredUserAttributes[userAttribute] =
341
- userAttributes[userAttribute];
342
- }
343
- }
344
- }
345
- }
346
-
347
- return filteredUserAttributes;
348
- };
349
-
350
- this.isFilteredUserAttribute = function(userAttributeKey, filterList) {
351
- const hashedUserAttribute = KitFilterHelper.hashUserAttribute(
352
- userAttributeKey
353
- );
354
- return filterList && self.inArray(filterList, hashedUserAttribute);
355
- };
307
+ this.filterUserIdentitiesForForwarders =
308
+ KitFilterHelper.filterUserIdentities;
309
+ this.filterUserAttributes = KitFilterHelper.filterUserAttributes;
356
310
 
357
311
  this.isEventType = function(type) {
358
312
  for (var prop in Types.EventType) {
@@ -1,4 +1,4 @@
1
- import { generateHash, valueof } from "./utils";
1
+ import { Dictionary, generateHash, inArray, valueof, filterDictionaryWithHash } from "./utils";
2
2
  // TODO: https://mparticle-eng.atlassian.net/browse/SQDSDKS-5381
3
3
  import { EventType, IdentityType } from "./types";
4
4
 
@@ -43,4 +43,20 @@ export default class KitFilterHelper {
43
43
  static hashConsentPurposeConditionalForwarding(prefix: string, purpose: string): string {
44
44
  return this.hashConsentPurpose(prefix, purpose).toString();
45
45
  }
46
+
47
+ static readonly filterUserAttributes = (userAttributes: Dictionary<string>, filterList: number[]): Dictionary<string> => {
48
+ return filterDictionaryWithHash(userAttributes, filterList, (key: string) => this.hashUserAttribute(key));
49
+ }
50
+
51
+ static readonly filterUserIdentities = (userIdentities: Dictionary<string>, filterList: number[]): Dictionary<string> => {
52
+ return filterDictionaryWithHash(userIdentities, filterList, (key: string) => this.hashUserIdentity(
53
+ IdentityType.getIdentityType(key)
54
+ ));
55
+ }
56
+
57
+ static readonly isFilteredUserAttribute = (userAttributeKey: string, filterList: number[]): boolean => {
58
+ const hashedUserAttribute = this.hashUserAttribute(userAttributeKey);
59
+ return filterList && inArray(filterList, hashedUserAttribute);
60
+ }
61
+
46
62
  }
@@ -34,9 +34,9 @@ import ForwardingStatsUploader from './forwardingStatsUploader';
34
34
  import Identity from './identity';
35
35
  import Consent, { IConsent } from './consent';
36
36
  import KitBlocker from './kitBlocking';
37
- import ConfigAPIClient from './configAPIClient';
37
+ import ConfigAPIClient, { IKitConfigs } from './configAPIClient';
38
38
  import IdentityAPIClient from './identityApiClient';
39
- import { isFunction, valueof } from './utils';
39
+ import { isFunction, parseConfig } from './utils';
40
40
  import { LocalStorageVault } from './vault';
41
41
  import { removeExpiredIdentityCacheDates } from './identity-utils';
42
42
  import IntegrationCapture from './integrationCapture';
@@ -49,7 +49,8 @@ import { IECommerce } from './ecommerce.interfaces';
49
49
  import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
50
50
  import { IPersistence } from './persistence.interfaces';
51
51
  import ForegroundTimer from './foregroundTimeTracker';
52
- import RoktManager from './roktManager';
52
+ import RoktManager, { IRoktManagerOptions } from './roktManager';
53
+ import filteredMparticleUser from './filteredMparticleUser';
53
54
 
54
55
  export interface IErrorLogMessage {
55
56
  message?: string;
@@ -1393,6 +1394,21 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1393
1394
  mpInstance._IntegrationCapture.capture();
1394
1395
  }
1395
1396
 
1397
+ // Configure Rokt Manager with user and filtered user
1398
+ const roktConfig: IKitConfigs = parseConfig(config, 'Rokt', 181);
1399
+ if (roktConfig) {
1400
+ const { userAttributeFilters } = roktConfig;
1401
+ const roktFilteredUser = filteredMparticleUser(
1402
+ currentUserMPID,
1403
+ { userAttributeFilters },
1404
+ mpInstance
1405
+ );
1406
+ const roktOptions: IRoktManagerOptions = {
1407
+ sandbox: config.isDevelopmentMode,
1408
+ };
1409
+ mpInstance._RoktManager.init(roktConfig, roktFilteredUser, currentUser, roktOptions);
1410
+ }
1411
+
1396
1412
  mpInstance._Forwarders.processForwarders(
1397
1413
  config,
1398
1414
  mpInstance._APIClient.prepareForwardingStats
@@ -1574,3 +1590,4 @@ function queueIfNotInitialized(func, self) {
1574
1590
  }
1575
1591
  return false;
1576
1592
  }
1593
+
@@ -1,3 +1,9 @@
1
+ import { IKitConfigs } from "./configAPIClient";
2
+ import { UserAttributeFilters } from "./forwarders.interfaces";
3
+ import { IMParticleUser } from "./identity-user-interfaces";
4
+ import KitFilterHelper from "./kitFilterHelper";
5
+ import { Dictionary, parseSettingsString } from "./utils";
6
+
1
7
  // https://docs.rokt.com/developers/integration-guides/web/library/attributes
2
8
  export interface IRoktPartnerAttributes {
3
9
  [key: string]: string | number | boolean | undefined | null;
@@ -25,21 +31,81 @@ export interface IRoktMessage {
25
31
  payload: any;
26
32
  }
27
33
 
34
+ export interface RoktKitFilterSettings {
35
+ userAttributeFilters?: UserAttributeFilters;
36
+ filterUserAttributes?: (userAttributes: Dictionary<string>, filterList: number[]) => Dictionary<string>;
37
+ filteredUser?: IMParticleUser | null;
38
+ }
39
+
40
+ export interface IRoktKit {
41
+ filters: RoktKitFilterSettings;
42
+ filteredUser: IMParticleUser | null;
43
+ launcher: IRoktLauncher | null;
44
+ userAttributes: Dictionary<string>;
45
+ selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
46
+ }
47
+
48
+ export interface IRoktManagerOptions {
49
+ sandbox?: boolean;
50
+ }
51
+
52
+ // The purpose of this class is to create a link between the Core mParticle SDK and the
53
+ // Rokt Web SDK via a Web Kit.
54
+ // The Rokt Manager should load before the Web Kit and stubs out many of the
55
+ // Rokt Web SDK functions with an internal message queue in case a Rokt function
56
+ // is requested before the Rokt Web Kit or SDK is finished loaded.
57
+ // Once the Rokt Kit is attached to the Rokt Manager, we can consider the
58
+ // Rokt Manager in a "ready" state and it can begin sending data to the kit.
59
+ //
60
+ // https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
28
61
  export default class RoktManager {
29
- public launcher: IRoktLauncher | null = null;
62
+ public kit: IRoktKit = null;
63
+ public filters: RoktKitFilterSettings = {};
64
+
65
+ private currentUser: IMParticleUser | null = null;
66
+ private filteredUser: IMParticleUser | null = null;
30
67
  private messageQueue: IRoktMessage[] = [];
68
+ private sandbox: boolean | null = null;
69
+ private userAttributeMapping: Dictionary<string>[] = [];
70
+
71
+ /**
72
+ * Initializes the RoktManager with configuration settings and user data.
73
+ *
74
+ * @param {IKitConfigs} roktConfig - Configuration object containing user attribute filters and settings
75
+ * @param {IMParticleUser} filteredUser - User object with filtered attributes
76
+ * @param {IMParticleUser} currentUser - Current mParticle user object
77
+ * @param {IRoktManagerOptions} options - Options for the RoktManager
78
+ *
79
+ * @throws Logs error to console if userAttributeMapping parsing fails
80
+ */
81
+ public init(roktConfig: IKitConfigs, filteredUser: IMParticleUser, currentUser: IMParticleUser, options?: IRoktManagerOptions): void {
82
+ const { userAttributeFilters, settings } = roktConfig || {};
83
+ const { userAttributeMapping } = settings || {};
31
84
 
32
- constructor() {
33
- this.launcher = null;
85
+ try {
86
+ this.userAttributeMapping = parseSettingsString(userAttributeMapping);
87
+ } catch (error) {
88
+ console.error('Error parsing user attribute mapping from config', error);
89
+ }
90
+
91
+ this.currentUser = currentUser;
92
+
93
+ this.filters = {
94
+ userAttributeFilters,
95
+ filterUserAttributes: KitFilterHelper.filterUserAttributes,
96
+ filteredUser: filteredUser,
97
+ };
98
+
99
+ this.sandbox = options?.sandbox;
34
100
  }
35
101
 
36
- public attachLauncher(launcher: IRoktLauncher): void {
37
- this.setLauncher(launcher);
102
+ public attachKit(kit: IRoktKit): void {
103
+ this.kit = kit;
38
104
  this.processMessageQueue();
39
105
  }
40
106
 
41
107
  public selectPlacements(options: IRoktSelectPlacementsOptions): Promise<IRoktSelection> {
42
- if (!this.launcher) {
108
+ if (!this.isReady()) {
43
109
  this.queueMessage({
44
110
  methodName: 'selectPlacements',
45
111
  payload: options,
@@ -48,29 +114,78 @@ export default class RoktManager {
48
114
  }
49
115
 
50
116
  try {
51
- return this.launcher.selectPlacements(options);
117
+ const { attributes } = options;
118
+ const sandboxValue = attributes?.sandbox ?? this.sandbox;
119
+ const mappedAttributes = this.mapUserAttributes(attributes, this.userAttributeMapping);
120
+
121
+ this.setUserAttributes(mappedAttributes);
122
+
123
+ const enrichedAttributes = {
124
+ ...mappedAttributes,
125
+ ...(sandboxValue !== null ? { sandbox: sandboxValue } : {}),
126
+ };
127
+
128
+ const enrichedOptions = {
129
+ ...options,
130
+ attributes: enrichedAttributes,
131
+ };
132
+
133
+ return this.kit.selectPlacements(enrichedOptions);
52
134
  } catch (error) {
53
135
  return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
54
136
  }
55
137
  }
56
138
 
139
+ private isReady(): boolean {
140
+ // The Rokt Manager is ready when a kit is attached and has a launcher
141
+ return Boolean(this.kit && this.kit.launcher);
142
+ }
143
+
144
+ private setUserAttributes(attributes: IRoktPartnerAttributes): void {
145
+ const reservedAttributes = ['sandbox'];
146
+ const filteredAttributes = {};
147
+
148
+ for (const key in attributes) {
149
+ if (attributes.hasOwnProperty(key) && reservedAttributes.indexOf(key) === -1) {
150
+ filteredAttributes[key] = attributes[key];
151
+ }
152
+ }
153
+
154
+ try {
155
+ this.currentUser.setUserAttributes(filteredAttributes);
156
+ } catch (error) {
157
+ console.error('Error setting user attributes', error);
158
+ }
159
+ }
160
+
161
+ private mapUserAttributes(attributes: IRoktPartnerAttributes, userAttributeMapping: Dictionary<string>[]): IRoktPartnerAttributes {
162
+ const mappingLookup: { [key: string]: string } = {};
163
+ for (const mapping of userAttributeMapping) {
164
+ mappingLookup[mapping.map] = mapping.value;
165
+ }
166
+
167
+ const mappedAttributes: IRoktPartnerAttributes = {};
168
+ for (const key in attributes) {
169
+ if (attributes.hasOwnProperty(key)) {
170
+ const newKey = mappingLookup[key] || key;
171
+ mappedAttributes[newKey] = attributes[key];
172
+ }
173
+ }
174
+ return mappedAttributes;
175
+ }
176
+
57
177
  private processMessageQueue(): void {
58
- if (this.messageQueue.length > 0) {
178
+ if (this.messageQueue.length > 0 && this.isReady()) {
59
179
  this.messageQueue.forEach(async (message) => {
60
- if (this.launcher && message.methodName in this.launcher) {
61
- await (this.launcher[message.methodName] as Function)(message.payload);
180
+ if (this.kit && message.methodName in this.kit) {
181
+ await (this.kit[message.methodName] as Function)(message.payload);
62
182
  }
63
183
  });
64
184
  this.messageQueue = [];
65
185
  }
66
186
  }
67
-
68
187
 
69
188
  private queueMessage(message: IRoktMessage): void {
70
189
  this.messageQueue.push(message);
71
190
  }
72
-
73
- private setLauncher(launcher: IRoktLauncher): void {
74
- this.launcher = launcher;
75
- }
76
191
  }
package/src/utils.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { MPID } from '@mparticle/web-sdk';
2
2
  import Constants from './constants';
3
+ import { SDKInitConfig } from './sdkRuntimeModels';
4
+ import { IKitConfigs } from './configAPIClient';
3
5
 
4
6
  const { Messages } = Constants;
5
7
 
@@ -16,7 +18,11 @@ const createCookieString = (value: string): string =>
16
18
  const revertCookieString = (value: string): string =>
17
19
  replacePipesWithCommas(replaceApostrophesWithQuotes(value));
18
20
 
19
- const inArray = (items: any[], name: string): boolean => {
21
+ const inArray = (items: any[], name: any): boolean => {
22
+ if (!items) {
23
+ return false;
24
+ }
25
+
20
26
  let i = 0;
21
27
 
22
28
  if (Array.prototype.indexOf) {
@@ -154,6 +160,14 @@ const parseNumber = (value: string | number): number => {
154
160
  return isNaN(floatValue) ? 0 : floatValue;
155
161
  };
156
162
 
163
+ const parseSettingsString = (settingsString: string): Dictionary<string>[] => {
164
+ try {
165
+ return settingsString ? JSON.parse(settingsString.replace(/&quot;/g, '"')) : [];
166
+ } catch (error) {
167
+ throw new Error('Settings string contains invalid JSON');
168
+ }
169
+ };
170
+
157
171
  const parseStringOrNumber = (
158
172
  value: string | number
159
173
  ): string | number | null => {
@@ -360,6 +374,34 @@ const getHref = (): string => {
360
374
  : '';
361
375
  };
362
376
 
377
+ const filterDictionaryWithHash = <T>(
378
+ dictionary: Dictionary<T>,
379
+ filterList: any[],
380
+ hashFn: (key: string) => any
381
+ ): Dictionary<T> => {
382
+ const filtered = {};
383
+
384
+ if (!isEmpty(dictionary)) {
385
+ for (const key in dictionary) {
386
+ if (dictionary.hasOwnProperty(key)) {
387
+ const hashedKey = hashFn(key);
388
+ if (!inArray(filterList, hashedKey)) {
389
+ filtered[key] = dictionary[key];
390
+ }
391
+ }
392
+ }
393
+ }
394
+
395
+ return filtered;
396
+ }
397
+
398
+ const parseConfig = (config: SDKInitConfig, moduleName: string, moduleId: number): IKitConfigs | null => {
399
+ return config.kitConfigs?.find((kitConfig: IKitConfigs) =>
400
+ kitConfig.name === moduleName &&
401
+ kitConfig.moduleId === moduleId
402
+ ) || null;
403
+ }
404
+
363
405
  export {
364
406
  createCookieString,
365
407
  revertCookieString,
@@ -367,6 +409,7 @@ export {
367
409
  valueof,
368
410
  converted,
369
411
  decoded,
412
+ filterDictionaryWithHash,
370
413
  findKeyInObject,
371
414
  generateDeprecationMessage,
372
415
  generateHash,
@@ -375,7 +418,9 @@ export {
375
418
  inArray,
376
419
  isObject,
377
420
  isStringOrNumber,
421
+ parseConfig,
378
422
  parseNumber,
423
+ parseSettingsString,
379
424
  parseStringOrNumber,
380
425
  replaceCommasWithPipes,
381
426
  replacePipesWithCommas,