@mparticle/web-sdk 2.35.2 → 2.36.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.36.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 +
@@ -131,7 +131,7 @@ return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"
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,16 @@ 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.filteredUser=null,this.messageQueue=[];}return a.prototype.init=function(a,b){var c=(a||{}).userAttributeFilters;this.filters={userAttributeFilters:c,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.kit.selectPlacements(a)}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
1421
+ return !!(this.kit&&this.kit.launcher)},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
1422
 
1414
1423
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1415
1424
  * <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 +1755,8 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
1746
1755
  // responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
1747
1756
  // persistence or Identity directly.
1748
1757
  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
1758
+ 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 filtered user
1759
+ var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c);c._RoktManager.init(h,j);}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
1760
  // if an identify request is unnecessary, such as if there is an existing session
1751
1761
  (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
1762
  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.36.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 +
@@ -131,7 +131,7 @@ return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"
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,16 @@ 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.filteredUser=null,this.messageQueue=[];}return a.prototype.init=function(a,b){var c=(a||{}).userAttributeFilters;this.filters={userAttributeFilters:c,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.kit.selectPlacements(a)}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
1421
+ return !!(this.kit&&this.kit.launcher)},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
1422
 
1414
1423
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
1415
1424
  * <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 +1755,8 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
1746
1755
  // responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
1747
1756
  // persistence or Identity directly.
1748
1757
  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
1758
+ 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 filtered user
1759
+ var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c);c._RoktManager.init(h,j);}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
1760
  // if an identify request is unnecessary, such as if there is an existing session
1751
1761
  (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
1762
  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.36.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;
@@ -770,6 +773,26 @@ var mParticle = (function () {
770
773
  var getHref = function getHref() {
771
774
  return typeof window !== 'undefined' && window.location ? window.location.href : '';
772
775
  };
776
+ var filterDictionaryWithHash = function filterDictionaryWithHash(dictionary, filterList, hashFn) {
777
+ var filtered = {};
778
+ if (!isEmpty(dictionary)) {
779
+ for (var key in dictionary) {
780
+ if (dictionary.hasOwnProperty(key)) {
781
+ var hashedKey = hashFn(key);
782
+ if (!inArray(filterList, hashedKey)) {
783
+ filtered[key] = dictionary[key];
784
+ }
785
+ }
786
+ }
787
+ }
788
+ return filtered;
789
+ };
790
+ var parseConfig = function parseConfig(config, moduleName, moduleId) {
791
+ var _a;
792
+ return ((_a = config.kitConfigs) === null || _a === void 0 ? void 0 : _a.find(function (kitConfig) {
793
+ return kitConfig.name === moduleName && kitConfig.moduleId === moduleId;
794
+ })) || null;
795
+ };
773
796
 
774
797
  var MessageType$1 = {
775
798
  SessionStart: 1,
@@ -2907,6 +2930,22 @@ var mParticle = (function () {
2907
2930
  KitFilterHelper.hashConsentPurposeConditionalForwarding = function (prefix, purpose) {
2908
2931
  return this.hashConsentPurpose(prefix, purpose).toString();
2909
2932
  };
2933
+ var _a;
2934
+ _a = KitFilterHelper;
2935
+ KitFilterHelper.filterUserAttributes = function (userAttributes, filterList) {
2936
+ return filterDictionaryWithHash(userAttributes, filterList, function (key) {
2937
+ return _a.hashUserAttribute(key);
2938
+ });
2939
+ };
2940
+ KitFilterHelper.filterUserIdentities = function (userIdentities, filterList) {
2941
+ return filterDictionaryWithHash(userIdentities, filterList, function (key) {
2942
+ return _a.hashUserIdentity(IdentityType.getIdentityType(key));
2943
+ });
2944
+ };
2945
+ KitFilterHelper.isFilteredUserAttribute = function (userAttributeKey, filterList) {
2946
+ var hashedUserAttribute = _a.hashUserAttribute(userAttributeKey);
2947
+ return filterList && inArray(filterList, hashedUserAttribute);
2948
+ };
2910
2949
  return KitFilterHelper;
2911
2950
  }();
2912
2951
 
@@ -3135,38 +3174,8 @@ var mParticle = (function () {
3135
3174
  }
3136
3175
  return filteredUserIdentities;
3137
3176
  };
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
- };
3177
+ this.filterUserIdentitiesForForwarders = KitFilterHelper.filterUserIdentities;
3178
+ this.filterUserAttributes = KitFilterHelper.filterUserAttributes;
3170
3179
  this.isEventType = function (type) {
3171
3180
  for (var prop in Types.EventType) {
3172
3181
  if (Types.EventType.hasOwnProperty(prop)) {
@@ -6325,7 +6334,7 @@ var mParticle = (function () {
6325
6334
  }
6326
6335
  mpInstance._Store.activeForwarders.forEach(function (forwarder) {
6327
6336
  var forwarderFunction = forwarder[functionNameKey];
6328
- if (!forwarderFunction || mpInstance._Helpers.isFilteredUserAttribute(key, forwarder.userAttributeFilters)) {
6337
+ if (!forwarderFunction || KitFilterHelper.isFilteredUserAttribute(key, forwarder.userAttributeFilters)) {
6329
6338
  return;
6330
6339
  }
6331
6340
  try {
@@ -9621,18 +9630,36 @@ var mParticle = (function () {
9621
9630
  return IntegrationCapture;
9622
9631
  }();
9623
9632
 
9633
+ // The purpose of this class is to create a link between the Core mParticle SDK and the
9634
+ // Rokt Web SDK via a Web Kit.
9635
+ // The Rokt Manager should load before the Web Kit and stubs out many of the
9636
+ // Rokt Web SDK functions with an internal message queue in case a Rokt function
9637
+ // is requested before the Rokt Web Kit or SDK is finished loaded.
9638
+ // Once the Rokt Kit is attached to the Rokt Manager, we can consider the
9639
+ // Rokt Manager in a "ready" state and it can begin sending data to the kit.
9640
+ //
9641
+ // https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
9624
9642
  var RoktManager = /** @class */function () {
9625
9643
  function RoktManager() {
9626
- this.launcher = null;
9644
+ this.kit = null;
9645
+ this.filters = {};
9646
+ this.filteredUser = null;
9627
9647
  this.messageQueue = [];
9628
- this.launcher = null;
9629
9648
  }
9630
- RoktManager.prototype.attachLauncher = function (launcher) {
9631
- this.setLauncher(launcher);
9649
+ RoktManager.prototype.init = function (roktConfig, filteredUser) {
9650
+ var userAttributeFilters = (roktConfig || {}).userAttributeFilters;
9651
+ this.filters = {
9652
+ userAttributeFilters: userAttributeFilters,
9653
+ filterUserAttributes: KitFilterHelper.filterUserAttributes,
9654
+ filteredUser: filteredUser
9655
+ };
9656
+ };
9657
+ RoktManager.prototype.attachKit = function (kit) {
9658
+ this.kit = kit;
9632
9659
  this.processMessageQueue();
9633
9660
  };
9634
9661
  RoktManager.prototype.selectPlacements = function (options) {
9635
- if (!this.launcher) {
9662
+ if (!this.isReady()) {
9636
9663
  this.queueMessage({
9637
9664
  methodName: 'selectPlacements',
9638
9665
  payload: options
@@ -9640,21 +9667,25 @@ var mParticle = (function () {
9640
9667
  return Promise.resolve({});
9641
9668
  }
9642
9669
  try {
9643
- return this.launcher.selectPlacements(options);
9670
+ return this.kit.selectPlacements(options);
9644
9671
  } catch (error) {
9645
9672
  return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
9646
9673
  }
9647
9674
  };
9675
+ RoktManager.prototype.isReady = function () {
9676
+ // The Rokt Manager is ready when a kit is attached and has a launcher
9677
+ return Boolean(this.kit && this.kit.launcher);
9678
+ };
9648
9679
  RoktManager.prototype.processMessageQueue = function () {
9649
9680
  var _this = this;
9650
- if (this.messageQueue.length > 0) {
9681
+ if (this.messageQueue.length > 0 && this.isReady()) {
9651
9682
  this.messageQueue.forEach(function (message) {
9652
9683
  return __awaiter(_this, void 0, void 0, function () {
9653
9684
  return __generator(this, function (_a) {
9654
9685
  switch (_a.label) {
9655
9686
  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)];
9687
+ if (!(this.kit && message.methodName in this.kit)) return [3 /*break*/, 2];
9688
+ return [4 /*yield*/, this.kit[message.methodName](message.payload)];
9658
9689
  case 1:
9659
9690
  _a.sent();
9660
9691
  _a.label = 2;
@@ -9671,9 +9702,6 @@ var mParticle = (function () {
9671
9702
  RoktManager.prototype.queueMessage = function (message) {
9672
9703
  this.messageQueue.push(message);
9673
9704
  };
9674
- RoktManager.prototype.setLauncher = function (launcher) {
9675
- this.launcher = launcher;
9676
- };
9677
9705
  return RoktManager;
9678
9706
  }();
9679
9707
 
@@ -10647,6 +10675,15 @@ var mParticle = (function () {
10647
10675
  if (mpInstance._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)) {
10648
10676
  mpInstance._IntegrationCapture.capture();
10649
10677
  }
10678
+ // Configure Rokt Manager with filtered user
10679
+ var roktConfig = parseConfig(config, 'Rokt', 181);
10680
+ if (roktConfig) {
10681
+ var userAttributeFilters = roktConfig.userAttributeFilters;
10682
+ var roktFilteredUser = filteredMparticleUser(currentUserMPID, {
10683
+ userAttributeFilters: userAttributeFilters
10684
+ }, mpInstance);
10685
+ mpInstance._RoktManager.init(roktConfig, roktFilteredUser);
10686
+ }
10650
10687
  mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
10651
10688
  mpInstance._Forwarders.processPixelConfigs(config);
10652
10689
  // 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.36.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';
@@ -50,6 +50,7 @@ import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
50
50
  import { IPersistence } from './persistence.interfaces';
51
51
  import ForegroundTimer from './foregroundTimeTracker';
52
52
  import RoktManager from './roktManager';
53
+ import filteredMparticleUser from './filteredMparticleUser';
53
54
 
54
55
  export interface IErrorLogMessage {
55
56
  message?: string;
@@ -1393,6 +1394,18 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1393
1394
  mpInstance._IntegrationCapture.capture();
1394
1395
  }
1395
1396
 
1397
+ // Configure Rokt Manager with 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
+ mpInstance._RoktManager.init(roktConfig, roktFilteredUser);
1407
+ }
1408
+
1396
1409
  mpInstance._Forwarders.processForwarders(
1397
1410
  config,
1398
1411
  mpInstance._APIClient.prepareForwardingStats
@@ -1574,3 +1587,4 @@ function queueIfNotInitialized(func, self) {
1574
1587
  }
1575
1588
  return false;
1576
1589
  }
1590
+
@@ -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 } 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,53 @@ 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
+ // The purpose of this class is to create a link between the Core mParticle SDK and the
49
+ // Rokt Web SDK via a Web Kit.
50
+ // The Rokt Manager should load before the Web Kit and stubs out many of the
51
+ // Rokt Web SDK functions with an internal message queue in case a Rokt function
52
+ // is requested before the Rokt Web Kit or SDK is finished loaded.
53
+ // Once the Rokt Kit is attached to the Rokt Manager, we can consider the
54
+ // Rokt Manager in a "ready" state and it can begin sending data to the kit.
55
+ //
56
+ // https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
28
57
  export default class RoktManager {
29
- public launcher: IRoktLauncher | null = null;
58
+ public kit: IRoktKit = null;
59
+ public filters: RoktKitFilterSettings = {};
60
+
61
+ private filteredUser: IMParticleUser | null = null;
30
62
  private messageQueue: IRoktMessage[] = [];
31
63
 
32
- constructor() {
33
- this.launcher = null;
64
+ public init(roktConfig: IKitConfigs, filteredUser?: IMParticleUser): void {
65
+ const { userAttributeFilters } = roktConfig || {};
66
+
67
+ this.filters = {
68
+ userAttributeFilters,
69
+ filterUserAttributes: KitFilterHelper.filterUserAttributes,
70
+ filteredUser: filteredUser,
71
+ };
34
72
  }
35
73
 
36
- public attachLauncher(launcher: IRoktLauncher): void {
37
- this.setLauncher(launcher);
74
+ public attachKit(kit: IRoktKit): void {
75
+ this.kit = kit;
38
76
  this.processMessageQueue();
39
77
  }
40
78
 
41
79
  public selectPlacements(options: IRoktSelectPlacementsOptions): Promise<IRoktSelection> {
42
- if (!this.launcher) {
80
+ if (!this.isReady()) {
43
81
  this.queueMessage({
44
82
  methodName: 'selectPlacements',
45
83
  payload: options,
@@ -48,29 +86,29 @@ export default class RoktManager {
48
86
  }
49
87
 
50
88
  try {
51
- return this.launcher.selectPlacements(options);
89
+ return this.kit.selectPlacements(options);
52
90
  } catch (error) {
53
91
  return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
54
92
  }
55
93
  }
56
94
 
95
+ private isReady(): boolean {
96
+ // The Rokt Manager is ready when a kit is attached and has a launcher
97
+ return Boolean(this.kit && this.kit.launcher);
98
+ }
99
+
57
100
  private processMessageQueue(): void {
58
- if (this.messageQueue.length > 0) {
101
+ if (this.messageQueue.length > 0 && this.isReady()) {
59
102
  this.messageQueue.forEach(async (message) => {
60
- if (this.launcher && message.methodName in this.launcher) {
61
- await (this.launcher[message.methodName] as Function)(message.payload);
103
+ if (this.kit && message.methodName in this.kit) {
104
+ await (this.kit[message.methodName] as Function)(message.payload);
62
105
  }
63
106
  });
64
107
  this.messageQueue = [];
65
108
  }
66
109
  }
67
-
68
110
 
69
111
  private queueMessage(message: IRoktMessage): void {
70
112
  this.messageQueue.push(message);
71
113
  }
72
-
73
- private setLauncher(launcher: IRoktLauncher): void {
74
- this.launcher = launcher;
75
- }
76
114
  }
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) {
@@ -360,6 +366,34 @@ const getHref = (): string => {
360
366
  : '';
361
367
  };
362
368
 
369
+ const filterDictionaryWithHash = <T>(
370
+ dictionary: Dictionary<T>,
371
+ filterList: any[],
372
+ hashFn: (key: string) => any
373
+ ): Dictionary<T> => {
374
+ const filtered = {};
375
+
376
+ if (!isEmpty(dictionary)) {
377
+ for (const key in dictionary) {
378
+ if (dictionary.hasOwnProperty(key)) {
379
+ const hashedKey = hashFn(key);
380
+ if (!inArray(filterList, hashedKey)) {
381
+ filtered[key] = dictionary[key];
382
+ }
383
+ }
384
+ }
385
+ }
386
+
387
+ return filtered;
388
+ }
389
+
390
+ const parseConfig = (config: SDKInitConfig, moduleName: string, moduleId: number): IKitConfigs | null => {
391
+ return config.kitConfigs?.find((kitConfig: IKitConfigs) =>
392
+ kitConfig.name === moduleName &&
393
+ kitConfig.moduleId === moduleId
394
+ ) || null;
395
+ }
396
+
363
397
  export {
364
398
  createCookieString,
365
399
  revertCookieString,
@@ -367,6 +401,7 @@ export {
367
401
  valueof,
368
402
  converted,
369
403
  decoded,
404
+ filterDictionaryWithHash,
370
405
  findKeyInObject,
371
406
  generateDeprecationMessage,
372
407
  generateHash,
@@ -375,6 +410,7 @@ export {
375
410
  inArray,
376
411
  isObject,
377
412
  isStringOrNumber,
413
+ parseConfig,
378
414
  parseNumber,
379
415
  parseStringOrNumber,
380
416
  replaceCommasWithPipes,