@mparticle/web-sdk 2.40.0 → 2.41.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.40.0";
18
+ var version = "2.41.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
@@ -1265,7 +1265,7 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
1265
1265
  * @deprecated
1266
1266
  */getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(r,i,a,d,o,g,l){var u,p,y,c=t.Identity.getUser(i),I=c?c.getMPID():null,_=c?c.getUserIdentities().userIdentities:{},v={};t._Store.identityCallInFlight=!1;try{var m,S,b;if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),p=null!==(m=r.responseText)&&void 0!==m?m:null,t._Store.isLoggedIn=(null===(S=p)||void 0===S?void 0:S.is_logged_in)||!1,hasMPIDChanged(c,p)&&(t._Store.mpid=p.mpid,c&&t._Persistence.setLastSeenTime(i),u=!t._Persistence.getFirstSeenTime(p.mpid),t._Persistence.setFirstSeenTime(p.mpid)),r.status===HTTP_OK){s(CacheIdentity)&&cacheOrClearIdCache(o,g,n.idCache,r,l);var A=n.IdentityAPI.getUser(p.mpid),P=A?A.getUserIdentities().userIdentities:{};o===Modify$1?(v=t._Identity.IdentityRequest.combineUserIdentities(_,d.userIdentities),t._Store.setUserIdentities(i,v)):(o===Identify&&c&&p.mpid===I&&t._Persistence.setFirstSeenTime(p.mpid),t._Store.addMpidToSessionHistory(p.mpid,i),t._CookieSyncManager.attemptCookieSync(p.mpid,u),t._Persistence.swapCurrentUser(i,p.mpid,t._Store.currentSessionMPIDs),d&&!isEmpty(d.userIdentities)&&(v=n.IdentityRequest.combineUserIdentities(P,d.userIdentities)),t._Store.setUserIdentities(p.mpid,v),t._Persistence.update(),t._Store.syncPersistenceData(),t._Persistence.findPrevCookiesBasedOnUI(d),t._Store.context=p.context||t._Store.context),y=t.Identity.getCurrentUser(),tryOnUserAlias(c,y,d,t.Logger);var U=t._Persistence.getPersistence();y&&(t._Persistence.storeDataInMemory(U,y.getMPID()),n.reinitForwardersOnUserChange(c,y),n.setForwarderCallbacks(y,o));var C=IdentityType.getNewIdentitiesByName(v),k=o===Modify$1?_:P;// https://go.mparticle.com/work/SQDSDKS-6501
1267
1267
  n.sendUserIdentityChangeEvent(C,o,p.mpid,k);}if(a){var f=0===r.status?HTTPCodes$2.noHttpCoverage:r.status;t._Helpers.invokeCallback(a,f,p||null,y);}else p&&!isEmpty(p.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
1268
- t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
1268
+ t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._RoktManager.isReady()&&(t._RoktManager.currentUser=t.Identity.getCurrentUser()),t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
1269
1269
  {// https://go.mparticle.com/work/SQDSDKS-6354
1270
1270
  var a=this.IdentityAPI.getUser(s);for(var d in e)// Verifies a change actually happened
1271
1271
  if(i[d]!==e[d]){var o,g=!i[d],l=n.createUserIdentityChange(d,e[d],i[d],g,a);// If a new identity type was introduced when the identity changes
@@ -1424,10 +1424,10 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
1424
1424
  * @param {IMParticleUser} filteredUser - User object with filtered attributes
1425
1425
  * @param {SDKIdentityApi} identityService - The mParticle Identity instance
1426
1426
  * @param {SDKLoggerApi} logger - The mParticle Logger instance
1427
- * @param {IRoktManagerOptions} options - Options for the RoktManager
1427
+ * @param {IRoktOptions} options - Options for the RoktManager
1428
1428
  *
1429
1429
  * @throws Logs error to console if placementAttributesMapping parsing fails
1430
- */return a.prototype.init=function(a,b,c,d,e){var f=a||{},g=f.userAttributeFilters,h=f.settings,i=(h||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(i);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:g,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b},this.sandbox=null===e||void 0===e?void 0:e.sandbox;},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c,d;return __awaiter(this,void 0,void 0,function(){var e,f,g,h,i,j,k,l,m,n,o=this;return __generator(this,function(p){switch(p.label){case 0:if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),[2/*return*/,Promise.resolve({})];p.label=1;case 1:if(p.trys.push([1,6,,7]),e=a.attributes,f=null!==(b=null===e||void 0===e?void 0:e.sandbox)&&void 0!==b?b:this.sandbox,g=this.mapPlacementAttributes(e,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),h=(null===(d=null===(c=this.currentUser)||void 0===c?void 0:c.getUserIdentities())||void 0===d?void 0:d.userIdentities)||{},i=h.email,j=g.email,!j||i&&i===j)return [3/*break*/,5];i&&i!==j&&this.logger.warning("Email mismatch detected. Current email, ".concat(i," differs from email passed to selectPlacements call, ").concat(j,". Proceeding to call identify with ").concat(j,". Please verify your implementation.")),p.label=2;case 2:return p.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){o.identityService.identify({userIdentities:__assign(__assign({},h),{email:j})},function(){a();});})];case 3:return p.sent(),[3/*break*/,5];case 4:return k=p.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(k)),[3/*break*/,5];case 5:return this.setUserAttributes(g),l=__assign(__assign({},g),null===f?{}:{sandbox:f}),m=__assign(__assign({},a),{attributes:l}),[2/*return*/,this.kit.selectPlacements(m)];case 6:return n=p.sent(),[2/*return*/,Promise.reject(n instanceof Error?n:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){if(!this.isReady())return this.queueMessage({methodName:"hashAttributes",payload:a}),Promise.resolve({});try{return this.kit.hashAttributes(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.queueMessage({methodName:"setExtensionData",payload:a});try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1430
+ */return a.prototype.init=function(a,b,c,d,e){var f,g=a||{},h=g.userAttributeFilters,i=g.settings,j=(i||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(j);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:h,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b},this.sandbox=null===(f=null===e||void 0===e?void 0:e.managerOptions)||void 0===f?void 0:f.sandbox,this.launcherOptions=null===e||void 0===e?void 0:e.launcherOptions;},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c;return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),[2/*return*/,Promise.resolve({})];o.label=1;case 1:if(o.trys.push([1,6,,7]),d=a.attributes,e=(null===d||void 0===d?void 0:d.sandbox)||null,f=this.mapPlacementAttributes(d,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),g=(null===(c=null===(b=this.currentUser)||void 0===b?void 0:b.getUserIdentities())||void 0===c?void 0:c.userIdentities)||{},h=g.email,i=f.email,!i||h&&h===i)return [3/*break*/,5];h&&h!==i&&this.logger.warning("Email mismatch detected. Current email, ".concat(h," differs from email passed to selectPlacements call, ").concat(i,". Proceeding to call identify with ").concat(i,". Please verify your implementation.")),o.label=2;case 2:return o.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){n.identityService.identify({userIdentities:__assign(__assign({},g),{email:i})},function(){a();});})];case 3:return o.sent(),[3/*break*/,5];case 4:return j=o.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(j)),[3/*break*/,5];case 5:return this.setUserAttributes(f),k=__assign(__assign({},f),null===e?{}:{sandbox:e}),l=__assign(__assign({},a),{attributes:k}),[2/*return*/,this.kit.selectPlacements(l)];case 6:return m=o.sent(),[2/*return*/,Promise.reject(m instanceof Error?m:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){if(!this.isReady())return this.queueMessage({methodName:"hashAttributes",payload:a}),Promise.resolve({});try{return this.kit.hashAttributes(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.queueMessage({methodName:"setExtensionData",payload:a});try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1431
1431
  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.mapPlacementAttributes=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}();
1432
1432
 
1433
1433
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
@@ -1765,9 +1765,9 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
1765
1765
  // responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
1766
1766
  // persistence or Identity directly.
1767
1767
  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
1768
- 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();// Configure Rokt Manager with user and filtered user
1769
- var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:b.isDevelopmentMode};// https://go.mparticle.com/work/SQDSDKS-7339
1770
- c._RoktManager.init(h,j,c.Identity,c.Logger,k);}processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
1768
+ 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
1769
+ var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={managerOptions:{sandbox:b.isDevelopmentMode},launcherOptions:null===b||void 0===b?void 0:b.launcherOptions};// https://go.mparticle.com/work/SQDSDKS-7339
1770
+ c._RoktManager.init(h,j,c.Identity,c.Logger,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
1771
1771
  // if an identify request is unnecessary, such as if there is an existing session
1772
1772
  (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
1773
1773
  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.40.0";
18
+ var version = "2.41.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
@@ -1265,7 +1265,7 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
1265
1265
  * @deprecated
1266
1266
  */getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(r,i,a,d,o,g,l){var u,p,y,c=t.Identity.getUser(i),I=c?c.getMPID():null,_=c?c.getUserIdentities().userIdentities:{},v={};t._Store.identityCallInFlight=!1;try{var m,S,b;if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),p=null!==(m=r.responseText)&&void 0!==m?m:null,t._Store.isLoggedIn=(null===(S=p)||void 0===S?void 0:S.is_logged_in)||!1,hasMPIDChanged(c,p)&&(t._Store.mpid=p.mpid,c&&t._Persistence.setLastSeenTime(i),u=!t._Persistence.getFirstSeenTime(p.mpid),t._Persistence.setFirstSeenTime(p.mpid)),r.status===HTTP_OK){s(CacheIdentity)&&cacheOrClearIdCache(o,g,n.idCache,r,l);var A=n.IdentityAPI.getUser(p.mpid),P=A?A.getUserIdentities().userIdentities:{};o===Modify$1?(v=t._Identity.IdentityRequest.combineUserIdentities(_,d.userIdentities),t._Store.setUserIdentities(i,v)):(o===Identify&&c&&p.mpid===I&&t._Persistence.setFirstSeenTime(p.mpid),t._Store.addMpidToSessionHistory(p.mpid,i),t._CookieSyncManager.attemptCookieSync(p.mpid,u),t._Persistence.swapCurrentUser(i,p.mpid,t._Store.currentSessionMPIDs),d&&!isEmpty(d.userIdentities)&&(v=n.IdentityRequest.combineUserIdentities(P,d.userIdentities)),t._Store.setUserIdentities(p.mpid,v),t._Persistence.update(),t._Store.syncPersistenceData(),t._Persistence.findPrevCookiesBasedOnUI(d),t._Store.context=p.context||t._Store.context),y=t.Identity.getCurrentUser(),tryOnUserAlias(c,y,d,t.Logger);var U=t._Persistence.getPersistence();y&&(t._Persistence.storeDataInMemory(U,y.getMPID()),n.reinitForwardersOnUserChange(c,y),n.setForwarderCallbacks(y,o));var C=IdentityType.getNewIdentitiesByName(v),k=o===Modify$1?_:P;// https://go.mparticle.com/work/SQDSDKS-6501
1267
1267
  n.sendUserIdentityChangeEvent(C,o,p.mpid,k);}if(a){var f=0===r.status?HTTPCodes$2.noHttpCoverage:r.status;t._Helpers.invokeCallback(a,f,p||null,y);}else p&&!isEmpty(p.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
1268
- t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
1268
+ t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._RoktManager.isReady()&&(t._RoktManager.currentUser=t.Identity.getCurrentUser()),t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
1269
1269
  {// https://go.mparticle.com/work/SQDSDKS-6354
1270
1270
  var a=this.IdentityAPI.getUser(s);for(var d in e)// Verifies a change actually happened
1271
1271
  if(i[d]!==e[d]){var o,g=!i[d],l=n.createUserIdentityChange(d,e[d],i[d],g,a);// If a new identity type was introduced when the identity changes
@@ -1424,10 +1424,10 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
1424
1424
  * @param {IMParticleUser} filteredUser - User object with filtered attributes
1425
1425
  * @param {SDKIdentityApi} identityService - The mParticle Identity instance
1426
1426
  * @param {SDKLoggerApi} logger - The mParticle Logger instance
1427
- * @param {IRoktManagerOptions} options - Options for the RoktManager
1427
+ * @param {IRoktOptions} options - Options for the RoktManager
1428
1428
  *
1429
1429
  * @throws Logs error to console if placementAttributesMapping parsing fails
1430
- */return a.prototype.init=function(a,b,c,d,e){var f=a||{},g=f.userAttributeFilters,h=f.settings,i=(h||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(i);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:g,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b},this.sandbox=null===e||void 0===e?void 0:e.sandbox;},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c,d;return __awaiter(this,void 0,void 0,function(){var e,f,g,h,i,j,k,l,m,n,o=this;return __generator(this,function(p){switch(p.label){case 0:if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),[2/*return*/,Promise.resolve({})];p.label=1;case 1:if(p.trys.push([1,6,,7]),e=a.attributes,f=null!==(b=null===e||void 0===e?void 0:e.sandbox)&&void 0!==b?b:this.sandbox,g=this.mapPlacementAttributes(e,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),h=(null===(d=null===(c=this.currentUser)||void 0===c?void 0:c.getUserIdentities())||void 0===d?void 0:d.userIdentities)||{},i=h.email,j=g.email,!j||i&&i===j)return [3/*break*/,5];i&&i!==j&&this.logger.warning("Email mismatch detected. Current email, ".concat(i," differs from email passed to selectPlacements call, ").concat(j,". Proceeding to call identify with ").concat(j,". Please verify your implementation.")),p.label=2;case 2:return p.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){o.identityService.identify({userIdentities:__assign(__assign({},h),{email:j})},function(){a();});})];case 3:return p.sent(),[3/*break*/,5];case 4:return k=p.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(k)),[3/*break*/,5];case 5:return this.setUserAttributes(g),l=__assign(__assign({},g),null===f?{}:{sandbox:f}),m=__assign(__assign({},a),{attributes:l}),[2/*return*/,this.kit.selectPlacements(m)];case 6:return n=p.sent(),[2/*return*/,Promise.reject(n instanceof Error?n:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){if(!this.isReady())return this.queueMessage({methodName:"hashAttributes",payload:a}),Promise.resolve({});try{return this.kit.hashAttributes(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.queueMessage({methodName:"setExtensionData",payload:a});try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1430
+ */return a.prototype.init=function(a,b,c,d,e){var f,g=a||{},h=g.userAttributeFilters,i=g.settings,j=(i||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(j);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:h,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b},this.sandbox=null===(f=null===e||void 0===e?void 0:e.managerOptions)||void 0===f?void 0:f.sandbox,this.launcherOptions=null===e||void 0===e?void 0:e.launcherOptions;},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c;return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),[2/*return*/,Promise.resolve({})];o.label=1;case 1:if(o.trys.push([1,6,,7]),d=a.attributes,e=(null===d||void 0===d?void 0:d.sandbox)||null,f=this.mapPlacementAttributes(d,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),g=(null===(c=null===(b=this.currentUser)||void 0===b?void 0:b.getUserIdentities())||void 0===c?void 0:c.userIdentities)||{},h=g.email,i=f.email,!i||h&&h===i)return [3/*break*/,5];h&&h!==i&&this.logger.warning("Email mismatch detected. Current email, ".concat(h," differs from email passed to selectPlacements call, ").concat(i,". Proceeding to call identify with ").concat(i,". Please verify your implementation.")),o.label=2;case 2:return o.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){n.identityService.identify({userIdentities:__assign(__assign({},g),{email:i})},function(){a();});})];case 3:return o.sent(),[3/*break*/,5];case 4:return j=o.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(j)),[3/*break*/,5];case 5:return this.setUserAttributes(f),k=__assign(__assign({},f),null===e?{}:{sandbox:e}),l=__assign(__assign({},a),{attributes:k}),[2/*return*/,this.kit.selectPlacements(l)];case 6:return m=o.sent(),[2/*return*/,Promise.reject(m instanceof Error?m:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){if(!this.isReady())return this.queueMessage({methodName:"hashAttributes",payload:a}),Promise.resolve({});try{return this.kit.hashAttributes(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.queueMessage({methodName:"setExtensionData",payload:a});try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1431
1431
  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.mapPlacementAttributes=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}();
1432
1432
 
1433
1433
  var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
@@ -1765,9 +1765,9 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
1765
1765
  // responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
1766
1766
  // persistence or Identity directly.
1767
1767
  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
1768
- 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();// Configure Rokt Manager with user and filtered user
1769
- var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:b.isDevelopmentMode};// https://go.mparticle.com/work/SQDSDKS-7339
1770
- c._RoktManager.init(h,j,c.Identity,c.Logger,k);}processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
1768
+ 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
1769
+ var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={managerOptions:{sandbox:b.isDevelopmentMode},launcherOptions:null===b||void 0===b?void 0:b.launcherOptions};// https://go.mparticle.com/work/SQDSDKS-7339
1770
+ c._RoktManager.init(h,j,c.Identity,c.Logger,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
1771
1771
  // if an identify request is unnecessary, such as if there is an existing session
1772
1772
  (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
1773
1773
  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.40.0";
206
+ var version = "2.41.0";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -8236,6 +8236,9 @@ var mParticle = (function () {
8236
8236
  mpInstance.Logger.error('Error parsing JSON response from Identity server: ' + e);
8237
8237
  }
8238
8238
  mpInstance._Store.isInitialized = true;
8239
+ if (mpInstance._RoktManager.isReady()) {
8240
+ mpInstance._RoktManager.currentUser = mpInstance.Identity.getCurrentUser();
8241
+ }
8239
8242
  mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
8240
8243
  };
8241
8244
 
@@ -9675,14 +9678,15 @@ var mParticle = (function () {
9675
9678
  * @param {IMParticleUser} filteredUser - User object with filtered attributes
9676
9679
  * @param {SDKIdentityApi} identityService - The mParticle Identity instance
9677
9680
  * @param {SDKLoggerApi} logger - The mParticle Logger instance
9678
- * @param {IRoktManagerOptions} options - Options for the RoktManager
9681
+ * @param {IRoktOptions} options - Options for the RoktManager
9679
9682
  *
9680
9683
  * @throws Logs error to console if placementAttributesMapping parsing fails
9681
9684
  */
9682
9685
  RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, logger, options) {
9683
- var _a = roktConfig || {},
9684
- userAttributeFilters = _a.userAttributeFilters,
9685
- settings = _a.settings;
9686
+ var _a;
9687
+ var _b = roktConfig || {},
9688
+ userAttributeFilters = _b.userAttributeFilters,
9689
+ settings = _b.settings;
9686
9690
  var placementAttributesMapping = (settings || {}).placementAttributesMapping;
9687
9691
  try {
9688
9692
  this.placementAttributesMapping = parseSettingsString(placementAttributesMapping);
@@ -9696,7 +9700,14 @@ var mParticle = (function () {
9696
9700
  filterUserAttributes: KitFilterHelper.filterUserAttributes,
9697
9701
  filteredUser: filteredUser
9698
9702
  };
9699
- this.sandbox = options === null || options === void 0 ? void 0 : options.sandbox;
9703
+ // This is the global setting for sandbox mode
9704
+ // It is set here and passed in to the createLauncher method in the Rokt Kit
9705
+ // This is not to be confused for the `sandbox` flag in the selectPlacements attributes
9706
+ // as that is independent of this setting, though they share the same name.
9707
+ this.sandbox = (_a = options === null || options === void 0 ? void 0 : options.managerOptions) === null || _a === void 0 ? void 0 : _a.sandbox;
9708
+ // Launcher options are set here for the kit to pick up and pass through
9709
+ // to the Rokt Launcher.
9710
+ this.launcherOptions = options === null || options === void 0 ? void 0 : options.launcherOptions;
9700
9711
  };
9701
9712
  RoktManager.prototype.attachKit = function (kit) {
9702
9713
  this.kit = kit;
@@ -9718,12 +9729,12 @@ var mParticle = (function () {
9718
9729
  * });
9719
9730
  */
9720
9731
  RoktManager.prototype.selectPlacements = function (options) {
9721
- var _a, _b, _c;
9732
+ var _a, _b;
9722
9733
  return __awaiter(this, void 0, void 0, function () {
9723
9734
  var attributes, sandboxValue, mappedAttributes, currentUserIdentities_1, currentEmail, newEmail_1, error_1, enrichedAttributes, enrichedOptions, error_2;
9724
9735
  var _this = this;
9725
- return __generator(this, function (_d) {
9726
- switch (_d.label) {
9736
+ return __generator(this, function (_c) {
9737
+ switch (_c.label) {
9727
9738
  case 0:
9728
9739
  if (!this.isReady()) {
9729
9740
  this.queueMessage({
@@ -9732,24 +9743,24 @@ var mParticle = (function () {
9732
9743
  });
9733
9744
  return [2 /*return*/, Promise.resolve({})];
9734
9745
  }
9735
- _d.label = 1;
9746
+ _c.label = 1;
9736
9747
  case 1:
9737
- _d.trys.push([1, 6,, 7]);
9748
+ _c.trys.push([1, 6,, 7]);
9738
9749
  attributes = options.attributes;
9739
- sandboxValue = (_a = attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) !== null && _a !== void 0 ? _a : this.sandbox;
9750
+ sandboxValue = (attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) || null;
9740
9751
  mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
9741
9752
  // Get current user identities
9742
9753
  this.currentUser = this.identityService.getCurrentUser();
9743
- currentUserIdentities_1 = ((_c = (_b = this.currentUser) === null || _b === void 0 ? void 0 : _b.getUserIdentities()) === null || _c === void 0 ? void 0 : _c.userIdentities) || {};
9754
+ currentUserIdentities_1 = ((_b = (_a = this.currentUser) === null || _a === void 0 ? void 0 : _a.getUserIdentities()) === null || _b === void 0 ? void 0 : _b.userIdentities) || {};
9744
9755
  currentEmail = currentUserIdentities_1.email;
9745
9756
  newEmail_1 = mappedAttributes.email;
9746
9757
  if (!(newEmail_1 && (!currentEmail || currentEmail !== newEmail_1))) return [3 /*break*/, 5];
9747
9758
  if (currentEmail && currentEmail !== newEmail_1) {
9748
9759
  this.logger.warning("Email mismatch detected. Current email, ".concat(currentEmail, " differs from email passed to selectPlacements call, ").concat(newEmail_1, ". Proceeding to call identify with ").concat(newEmail_1, ". Please verify your implementation."));
9749
9760
  }
9750
- _d.label = 2;
9761
+ _c.label = 2;
9751
9762
  case 2:
9752
- _d.trys.push([2, 4,, 5]);
9763
+ _c.trys.push([2, 4,, 5]);
9753
9764
  return [4 /*yield*/, new Promise(function (resolve, reject) {
9754
9765
  _this.identityService.identify({
9755
9766
  userIdentities: __assign(__assign({}, currentUserIdentities_1), {
@@ -9760,10 +9771,10 @@ var mParticle = (function () {
9760
9771
  });
9761
9772
  })];
9762
9773
  case 3:
9763
- _d.sent();
9774
+ _c.sent();
9764
9775
  return [3 /*break*/, 5];
9765
9776
  case 4:
9766
- error_1 = _d.sent();
9777
+ error_1 = _c.sent();
9767
9778
  this.logger.error('Failed to identify user with new email: ' + JSON.stringify(error_1));
9768
9779
  return [3 /*break*/, 5];
9769
9780
  case 5:
@@ -9776,7 +9787,7 @@ var mParticle = (function () {
9776
9787
  });
9777
9788
  return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
9778
9789
  case 6:
9779
- error_2 = _d.sent();
9790
+ error_2 = _c.sent();
9780
9791
  return [2 /*return*/, Promise.reject(error_2 instanceof Error ? error_2 : new Error('Unknown error occurred'))];
9781
9792
  case 7:
9782
9793
  return [2 /*return*/];
@@ -10846,12 +10857,6 @@ var mParticle = (function () {
10846
10857
  if (mpInstance._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)) {
10847
10858
  mpInstance._IntegrationCapture.capture();
10848
10859
  }
10849
- mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
10850
- mpInstance._Forwarders.processPixelConfigs(config);
10851
- // Checks if session is created, resumed, or needs to be ended
10852
- // Logs a session start or session end event accordingly
10853
- mpInstance._SessionManager.initialize();
10854
- mpInstance._Events.logAST();
10855
10860
  // Configure Rokt Manager with user and filtered user
10856
10861
  var roktConfig = parseConfig(config, 'Rokt', 181);
10857
10862
  if (roktConfig) {
@@ -10860,11 +10865,20 @@ var mParticle = (function () {
10860
10865
  userAttributeFilters: userAttributeFilters
10861
10866
  }, mpInstance);
10862
10867
  var roktOptions = {
10863
- sandbox: config.isDevelopmentMode
10868
+ managerOptions: {
10869
+ sandbox: config.isDevelopmentMode
10870
+ },
10871
+ launcherOptions: config === null || config === void 0 ? void 0 : config.launcherOptions
10864
10872
  };
10865
10873
  // https://go.mparticle.com/work/SQDSDKS-7339
10866
10874
  mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance.Logger, roktOptions);
10867
10875
  }
10876
+ mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
10877
+ mpInstance._Forwarders.processPixelConfigs(config);
10878
+ // Checks if session is created, resumed, or needs to be ended
10879
+ // Logs a session start or session end event accordingly
10880
+ mpInstance._SessionManager.initialize();
10881
+ mpInstance._Events.logAST();
10868
10882
  processIdentityCallback(mpInstance, currentUser, currentUserMPID, currentUserIdentities);
10869
10883
  }
10870
10884
  // We will continue to clear out the ready queue as part of the initial init flow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.40.0",
3
+ "version": "2.41.0",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
package/src/identity.js CHANGED
@@ -1677,6 +1677,10 @@ export default function Identity(mpInstance) {
1677
1677
  }
1678
1678
  mpInstance._Store.isInitialized = true;
1679
1679
 
1680
+ if (mpInstance._RoktManager.isReady()) {
1681
+ mpInstance._RoktManager.currentUser = mpInstance.Identity.getCurrentUser();
1682
+ }
1683
+
1680
1684
  mpInstance._preInit.readyQueue = processReadyQueue(
1681
1685
  mpInstance._preInit.readyQueue
1682
1686
  );
@@ -49,7 +49,7 @@ 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, { IRoktManagerOptions } from './roktManager';
52
+ import RoktManager, { IRoktManagerOptions, IRoktOptions } from './roktManager';
53
53
  import filteredMparticleUser from './filteredMparticleUser';
54
54
 
55
55
  export interface IErrorLogMessage {
@@ -1394,17 +1394,6 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1394
1394
  mpInstance._IntegrationCapture.capture();
1395
1395
  }
1396
1396
 
1397
- mpInstance._Forwarders.processForwarders(
1398
- config,
1399
- mpInstance._APIClient.prepareForwardingStats
1400
- );
1401
- mpInstance._Forwarders.processPixelConfigs(config);
1402
-
1403
- // Checks if session is created, resumed, or needs to be ended
1404
- // Logs a session start or session end event accordingly
1405
- mpInstance._SessionManager.initialize();
1406
- mpInstance._Events.logAST();
1407
-
1408
1397
  // Configure Rokt Manager with user and filtered user
1409
1398
  const roktConfig: IKitConfigs = parseConfig(config, 'Rokt', 181);
1410
1399
  if (roktConfig) {
@@ -1414,10 +1403,12 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1414
1403
  { userAttributeFilters },
1415
1404
  mpInstance
1416
1405
  );
1417
- const roktOptions: IRoktManagerOptions = {
1418
- sandbox: config.isDevelopmentMode,
1406
+ const roktOptions: IRoktOptions = {
1407
+ managerOptions: {
1408
+ sandbox: config.isDevelopmentMode,
1409
+ },
1410
+ launcherOptions: config?.launcherOptions,
1419
1411
  };
1420
-
1421
1412
  // https://go.mparticle.com/work/SQDSDKS-7339
1422
1413
  mpInstance._RoktManager.init(
1423
1414
  roktConfig,
@@ -1428,6 +1419,17 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1428
1419
  );
1429
1420
  }
1430
1421
 
1422
+ mpInstance._Forwarders.processForwarders(
1423
+ config,
1424
+ mpInstance._APIClient.prepareForwardingStats
1425
+ );
1426
+ mpInstance._Forwarders.processPixelConfigs(config);
1427
+
1428
+ // Checks if session is created, resumed, or needs to be ended
1429
+ // Logs a session start or session end event accordingly
1430
+ mpInstance._SessionManager.initialize();
1431
+ mpInstance._Events.logAST();
1432
+
1431
1433
  processIdentityCallback(
1432
1434
  mpInstance,
1433
1435
  currentUser,
@@ -52,12 +52,19 @@ export interface IRoktKit {
52
52
  hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
53
53
  selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
54
54
  setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
55
+ launcherOptions?: Dictionary<any>;
55
56
  }
56
57
 
57
- export interface IRoktManagerOptions {
58
- sandbox?: boolean;
58
+ export interface IRoktOptions {
59
+ managerOptions?: IRoktManagerOptions;
60
+ launcherOptions?: IRoktLauncherOptions;
59
61
  }
60
62
 
63
+ export type IRoktLauncherOptions = Dictionary<any>;
64
+ export type IRoktManagerOptions = {
65
+ sandbox?: boolean;
66
+ };
67
+
61
68
  // The purpose of this class is to create a link between the Core mParticle SDK and the
62
69
  // Rokt Web SDK via a Web Kit.
63
70
  // The Rokt Manager should load before the Web Kit and stubs out many of the
@@ -75,8 +82,8 @@ export default class RoktManager {
75
82
  private sandbox: boolean | null = null;
76
83
  private placementAttributesMapping: Dictionary<string>[] = [];
77
84
  private identityService: SDKIdentityApi;
85
+ private launcherOptions?: IRoktLauncherOptions;
78
86
  private logger: SDKLoggerApi;
79
-
80
87
  /**
81
88
  * Initializes the RoktManager with configuration settings and user data.
82
89
  *
@@ -84,7 +91,7 @@ export default class RoktManager {
84
91
  * @param {IMParticleUser} filteredUser - User object with filtered attributes
85
92
  * @param {SDKIdentityApi} identityService - The mParticle Identity instance
86
93
  * @param {SDKLoggerApi} logger - The mParticle Logger instance
87
- * @param {IRoktManagerOptions} options - Options for the RoktManager
94
+ * @param {IRoktOptions} options - Options for the RoktManager
88
95
  *
89
96
  * @throws Logs error to console if placementAttributesMapping parsing fails
90
97
  */
@@ -93,7 +100,7 @@ export default class RoktManager {
93
100
  filteredUser: IMParticleUser,
94
101
  identityService: SDKIdentityApi,
95
102
  logger?: SDKLoggerApi,
96
- options?: IRoktManagerOptions
103
+ options?: IRoktOptions
97
104
  ): void {
98
105
  const { userAttributeFilters, settings } = roktConfig || {};
99
106
  const { placementAttributesMapping } = settings || {};
@@ -113,7 +120,15 @@ export default class RoktManager {
113
120
  filteredUser: filteredUser,
114
121
  };
115
122
 
116
- this.sandbox = options?.sandbox;
123
+ // This is the global setting for sandbox mode
124
+ // It is set here and passed in to the createLauncher method in the Rokt Kit
125
+ // This is not to be confused for the `sandbox` flag in the selectPlacements attributes
126
+ // as that is independent of this setting, though they share the same name.
127
+ this.sandbox = options?.managerOptions?.sandbox;
128
+
129
+ // Launcher options are set here for the kit to pick up and pass through
130
+ // to the Rokt Launcher.
131
+ this.launcherOptions = options?.launcherOptions;
117
132
  }
118
133
 
119
134
  public attachKit(kit: IRoktKit): void {
@@ -147,7 +162,7 @@ export default class RoktManager {
147
162
 
148
163
  try {
149
164
  const { attributes } = options;
150
- const sandboxValue = attributes?.sandbox ?? this.sandbox;
165
+ const sandboxValue = attributes?.sandbox || null;
151
166
  const mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
152
167
 
153
168
  // Get current user identities
@@ -39,7 +39,7 @@ import _BatchValidator from './mockBatchCreator';
39
39
  import { SDKECommerceAPI } from './ecommerce.interfaces';
40
40
  import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
41
41
  import Constants from './constants';
42
- import RoktManager from './roktManager';
42
+ import RoktManager, { IRoktLauncherOptions } from './roktManager';
43
43
 
44
44
  // TODO: Resolve this with version in @mparticle/web-sdk
45
45
  export type SDKEventCustomFlags = Dictionary<any>;
@@ -301,6 +301,8 @@ export interface SDKInitConfig
301
301
  // https://go.mparticle.com/work/SQDSDKS-6460
302
302
  identityCallback?: IdentityCallback;
303
303
 
304
+ launcherOptions?: IRoktLauncherOptions;
305
+
304
306
  rq?: Function[] | any[];
305
307
  }
306
308