@mparticle/web-sdk 2.73.0 → 2.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.73.0";
18
+ var version = "2.73.1";
19
19
 
20
20
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",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/"},// These are the paths that are used to construct the CNAME urls
@@ -194,7 +194,8 @@ return _typeof$1(a)},obfuscateDevData=function(a,b){return b?a:obfuscateData(a)}
194
194
  */ // Standalone version of jQuery.extend, from https://github.com/dansdom/extend
195
195
  // https://go.mparticle.com/work/SQDSDKS-6047
196
196
  function extend(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];var c,d,e,f,g,h,j={hasOwn:Object.prototype.hasOwnProperty,class2type:{},type:function type(a){return null==a?a+"":j.class2type[Object.prototype.toString.call(a)]||"object"},isPlainObject:function isPlainObject(a){if(!a||"object"!==j.type(a)||a.nodeType||j.isWindow(a))return !1;try{if(a.constructor&&!j.hasOwn.call(a,"constructor")&&!j.hasOwn.call(a.constructor.prototype,"isPrototypeOf"))return !1}catch(a){return !1}for(var b in a);// eslint-disable-line no-empty
197
- return b===void 0||j.hasOwn.call(a,b)},isArray:Array.isArray||function(a){return "array"===j.type(a)},isFunction:function(a){return "function"===j.type(a)},isWindow:function isWindow(a){return null!=a&&a==a.window}},k=a[0]||{},l=1,m=!1,n=a.length;for("boolean"==typeof k&&(m=k,k=a[1]||{},l=2),"object"===_typeof$1(k)||j.isFunction(k)||(k={}),n===l&&(k={},--l);l<n;l++)if(null!=(c=a[l]))for(d in c)"__proto__"!==d&&"constructor"!==d&&"prototype"!==d&&Object.prototype.hasOwnProperty.call(c,d)&&(e=k[d],f=c[d],k!==f)&&(m&&f&&(j.isPlainObject(f)||(g=j.isArray(f)))?(g?(g=!1,h=e&&j.isArray(e)?e:[]):h=e&&j.isPlainObject(e)?e:{},k[d]=extend(m,h,f)):void 0!==f&&(k[d]=f));return k}
197
+ return b===void 0||j.hasOwn.call(a,b)},isArray:Array.isArray||function(a){return "array"===j.type(a)},isFunction:function(a){return "function"===j.type(a)},isWindow:function isWindow(a){return null!=a&&a==a.window}},k=a[0]||{},l=1,m=!1,n=a.length;for("boolean"==typeof k&&(m=k,k=a[1]||{},l=2),"object"===_typeof$1(k)||j.isFunction(k)||(k={}),n===l&&(k={},--l);l<n;l++)if(null!=(c=a[l]))for(d in c)"__proto__"!==d&&"constructor"!==d&&"prototype"!==d&&Object.prototype.hasOwnProperty.call(c,d)&&(e=k[d],f=c[d],k!==f)&&(m&&f&&(j.isPlainObject(f)||(g=j.isArray(f)))?(g?(g=!1,h=e&&j.isArray(e)?e:[]):h=e&&j.isPlainObject(e)?e:{},k[d]=extend(m,h,f)):void 0!==f&&(k[d]=f));return k}var getErrorMessage=function(a,b){return void 0===b&&(b="unknown error"),a instanceof Error?a.message:"string"==typeof a?a:a&&"object"===_typeof$1(a)&&"string"==typeof a.message?a.message:b;// fetch-mock and some network libs reject with { message } rather than Error
198
+ };
198
199
 
199
200
  var MessageType$1={SessionStart:1,SessionEnd:2,PageView:3,PageEvent:4,CrashReport:5,OptOut:6,AppStateTransition:10,Profile:14,Commerce:16,Media:20,UserAttributeChange:17,UserIdentityChange:18};var EventType={Unknown:0,Navigation:1,Location:2,Search:3,Transaction:4,UserContent:5,UserPreference:6,Social:7,Other:8,Media:9,getName:function getName(a){return a===EventType.Unknown?"Unknown":a===EventType.Navigation?"Navigation":a===EventType.Location?"Location":a===EventType.Search?"Search":a===EventType.Transaction?"Transaction":a===EventType.UserContent?"User Content":a===EventType.UserPreference?"User Preference":a===EventType.Social?"Social":a===CommerceEventType.ProductAddToCart?"Product Added to Cart":a===CommerceEventType.ProductAddToWishlist?"Product Added to Wishlist":a===CommerceEventType.ProductCheckout?"Product Checkout":a===CommerceEventType.ProductCheckoutOption?"Product Checkout Options":a===CommerceEventType.ProductClick?"Product Click":a===CommerceEventType.ProductImpression?"Product Impression":a===CommerceEventType.ProductPurchase?"Product Purchased":a===CommerceEventType.ProductRefund?"Product Refunded":a===CommerceEventType.ProductRemoveFromCart?"Product Removed From Cart":a===CommerceEventType.ProductRemoveFromWishlist?"Product Removed from Wishlist":a===CommerceEventType.ProductViewDetail?"Product View Details":a===CommerceEventType.PromotionClick?"Promotion Click":a===CommerceEventType.PromotionView?"Promotion View":"Other"}};// Continuation of EventType enum above, but in seperate object since we don't expose these to end user
200
201
  var CommerceEventType={ProductAddToCart:10,ProductRemoveFromCart:11,ProductCheckout:12,ProductCheckoutOption:13,ProductClick:14,ProductViewDetail:15,ProductPurchase:16,ProductRefund:17,PromotionView:18,PromotionClick:19,ProductAddToWishlist:20,ProductRemoveFromWishlist:21,ProductImpression:22};var IdentityType={Other:0,CustomerId:1,Facebook:2,Twitter:3,Google:4,Microsoft:5,Yahoo:6,Email:7,FacebookCustomAudienceId:9,Other2:10,Other3:11,Other4:12,Other5:13,Other6:14,Other7:15,Other8:16,Other9:17,Other10:18,MobileNumber:19,PhoneNumber2:20,PhoneNumber3:21,isValid:function isValid(a){if("number"==typeof a)for(var b in IdentityType)if(IdentityType.hasOwnProperty(b)&&IdentityType[b]===a)return !0;return !1},getName:function getName(a){return a===window.mParticle.IdentityType.CustomerId?"Customer ID":a===window.mParticle.IdentityType.Facebook?"Facebook ID":a===window.mParticle.IdentityType.Twitter?"Twitter ID":a===window.mParticle.IdentityType.Google?"Google ID":a===window.mParticle.IdentityType.Microsoft?"Microsoft ID":a===window.mParticle.IdentityType.Yahoo?"Yahoo ID":a===window.mParticle.IdentityType.Email?"Email":a===window.mParticle.IdentityType.FacebookCustomAudienceId?"Facebook App User ID":"Other ID"},getIdentityType:function getIdentityType(a){return "other"===a?IdentityType.Other:"customerid"===a?IdentityType.CustomerId:"facebook"===a?IdentityType.Facebook:"twitter"===a?IdentityType.Twitter:"google"===a?IdentityType.Google:"microsoft"===a?IdentityType.Microsoft:"yahoo"===a?IdentityType.Yahoo:"email"===a?IdentityType.Email:"facebookcustomaudienceid"===a?IdentityType.FacebookCustomAudienceId:"other2"===a?IdentityType.Other2:"other3"===a?IdentityType.Other3:"other4"===a?IdentityType.Other4:"other5"===a?IdentityType.Other5:"other6"===a?IdentityType.Other6:"other7"===a?IdentityType.Other7:"other8"===a?IdentityType.Other8:"other9"===a?IdentityType.Other9:"other10"===a?IdentityType.Other10:"mobile_number"===a?IdentityType.MobileNumber:"phone_number_2"===a?IdentityType.PhoneNumber2:"phone_number_3"===a?IdentityType.PhoneNumber3:"email_sha256"===a?IdentityType.Other:!("mobile_sha256"!=a)&&IdentityType.Other2},getIdentityName:function getIdentityName(a){return a===IdentityType.Other?"other":a===IdentityType.CustomerId?"customerid":a===IdentityType.Facebook?"facebook":a===IdentityType.Twitter?"twitter":a===IdentityType.Google?"google":a===IdentityType.Microsoft?"microsoft":a===IdentityType.Yahoo?"yahoo":a===IdentityType.Email?"email":a===IdentityType.FacebookCustomAudienceId?"facebookcustomaudienceid":a===IdentityType.Other2?"other2":a===IdentityType.Other3?"other3":a===IdentityType.Other4?"other4":a===IdentityType.Other5?"other5":a===IdentityType.Other6?"other6":a===IdentityType.Other7?"other7":a===IdentityType.Other8?"other8":a===IdentityType.Other9?"other9":a===IdentityType.Other10?"other10":a===IdentityType.MobileNumber?"mobile_number":a===IdentityType.PhoneNumber2?"phone_number_2":a===IdentityType.PhoneNumber3?"phone_number_3":null},// Strips out functions from Identity Types for easier lookups
@@ -547,8 +548,8 @@ var HTTPCodes$4=Constants.HTTPCodes;/**
547
548
  // to deliver a result to, so log and bail out without invoking anything.
548
549
  if(!isFunction(e))return f.error("search called without a callback function; skipping request."),[2/*return*/];// No usable identifier -> deliver httpCode: noHttpCoverage so callers
549
550
  // waiting on the callback (e.g. to clear a loading state) don't hang.
550
- if(i=function(a){try{e(a);}catch(a){f.error("Error invoking search callback: "+((null===a||void 0===a?void 0:a.message)||a+""));}},j=Validators.removeFalsyIdentityValues({userIdentities:null!==a&&void 0!==a?a:{}},f).userIdentities,!Object.values(null!==j&&void 0!==j?j:{}).some(function(a){return "string"==typeof a&&0<a.length}))return f.verbose("Identity search called with empty identifiers; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];// No API key -> same: deliver noHttpCoverage rather than hanging.
551
- if(!b)return f.verbose("search called without a workspace API key; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];v.label=1;case 1:return v.trys.push([1,9,,10]),k=c(),l=__assign(__assign({},k),{known_identities:__assign({},j)}),m={method:"post",headers:{Accept:"application/json","Content-Type":"application/json","x-mp-key":b},body:JSON.stringify(l)},n=g||(window.fetch?new FetchUploader(d):new XHRUploader(d)),f.verbose("Sending search request to "+d),[4/*yield*/,n.upload(m,d)];case 2:if(o=v.sent(),p=void 0,!isFunction(o.json))return [3/*break*/,7];v.label=3;case 3:return v.trys.push([3,5,,6]),[4/*yield*/,o.json()];case 4:return p=v.sent(),[3/*break*/,6];case 5:return v.sent(),f.verbose("search response had no parseable JSON body."),[3/*break*/,6];case 6:return [3/*break*/,8];case 7:if(r=o,null===r||void 0===r?void 0:r.responseText)try{p=JSON.parse(r.responseText);}catch(a){f.verbose("search XHR response was not valid JSON.");}v.label=8;case 8:return o.status===HTTP_OK?f.verbose("search received 200 OK."):o.status===HTTP_NOT_FOUND?f.verbose("search received 404 (no match)."):f.verbose("search received non-success status "+o.status),i({httpCode:o.status,body:p}),[3/*break*/,10];case 9:return s=v.sent(),t=(null===s||void 0===s?void 0:s.message)||s+"",u="Error sending search request: "+t,f.error(u),null===h||void 0===h?void 0:h.report({message:u,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),i({httpCode:HTTPCodes$4.noHttpCoverage}),[3/*break*/,10];case 10:return [2/*return*/]}})})};
551
+ if(i=function(a){try{e(a);}catch(a){f.error("Error invoking search callback: "+getErrorMessage(a));}},j=Validators.removeFalsyIdentityValues({userIdentities:null!==a&&void 0!==a?a:{}},f).userIdentities,!Object.values(null!==j&&void 0!==j?j:{}).some(function(a){return "string"==typeof a&&0<a.length}))return f.verbose("Identity search called with empty identifiers; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];// No API key -> same: deliver noHttpCoverage rather than hanging.
552
+ if(!b)return f.verbose("search called without a workspace API key; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];v.label=1;case 1:return v.trys.push([1,9,,10]),k=c(),l=__assign(__assign({},k),{known_identities:__assign({},j)}),m={method:"post",headers:{Accept:"application/json","Content-Type":"application/json","x-mp-key":b},body:JSON.stringify(l)},n=g||(window.fetch?new FetchUploader(d):new XHRUploader(d)),f.verbose("Sending search request to "+d),[4/*yield*/,n.upload(m,d)];case 2:if(o=v.sent(),p=void 0,!isFunction(o.json))return [3/*break*/,7];v.label=3;case 3:return v.trys.push([3,5,,6]),[4/*yield*/,o.json()];case 4:return p=v.sent(),[3/*break*/,6];case 5:return v.sent(),f.verbose("search response had no parseable JSON body."),[3/*break*/,6];case 6:return [3/*break*/,8];case 7:if(r=o,null===r||void 0===r?void 0:r.responseText)try{p=JSON.parse(r.responseText);}catch(a){f.verbose("search XHR response was not valid JSON.");}v.label=8;case 8:return o.status===HTTP_OK?f.verbose("search received 200 OK."):o.status===HTTP_NOT_FOUND?f.verbose("search received 404 (no match)."):f.verbose("search received non-success status "+o.status),i({httpCode:o.status,body:p}),[3/*break*/,10];case 9:return s=v.sent(),t=getErrorMessage(s),u="Error sending search request: "+t,f.error(u),null===h||void 0===h?void 0:h.report({message:u,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),i({httpCode:HTTPCodes$4.noHttpCoverage}),[3/*break*/,10];case 10:return [2/*return*/]}})})};
552
553
 
553
554
  var _a=Constants.IdentityMethods,Identify$2=_a.Identify,Modify$3=_a.Modify,Login$2=_a.Login,Logout$2=_a.Logout,HTTPCodes$3=Constants.HTTPCodes,Messages$9=Constants.Messages;var CACHE_HEADER="x-mp-max-age";var cacheOrClearIdCache=function(a,b,c,d,e){// when parsing a response that has already been cached, simply return instead of attempting another cache
554
555
  if(!e){// default the expire timestamp to one day in milliseconds unless a header comes back
@@ -593,7 +594,7 @@ var identitiesEqual=function(c,a){var b=Object.keys(null!==c&&void 0!==c?c:{}),d
593
594
  * builds the `/v1/search` URL and request envelope, and dispatches.
594
595
  * Lives here so the SDK glue (URL building, opt-out gate, dispatcher
595
596
  * plumbing) is type-checked instead of being expressed in plain JS.
596
- */var executeSearchRequest=function(a,b,c,d){var e=a._Helpers,f=a._Store,g=a.Logger,h=a._ErrorReportingDispatcher,i=f.SDKConfig,j=i.identityUrl,k=i.isDevelopmentMode;if(!e.canLog()){if(g.verbose(Messages$9.InformationMessages.AbandonLogEvent),isFunction(d))try{d({httpCode:HTTPCodes$3.loggingDisabledOrMissingAPIKey});}catch(a){g.error("Error invoking search callback: "+((null===a||void 0===a?void 0:a.message)||a+""));}return}// The Search endpoint is colocated with /v1/identify under
597
+ */var executeSearchRequest=function(a,b,c,d){var e=a._Helpers,f=a._Store,g=a.Logger,h=a._ErrorReportingDispatcher,i=f.SDKConfig,j=i.identityUrl,k=i.isDevelopmentMode;if(!e.canLog()){if(g.verbose(Messages$9.InformationMessages.AbandonLogEvent),isFunction(d))try{d({httpCode:HTTPCodes$3.loggingDisabledOrMissingAPIKey});}catch(a){g.error("Error invoking search callback: "+getErrorMessage(a));}return}// The Search endpoint is colocated with /v1/identify under
597
598
  // identityUrl, so we reuse the same service URL builder. We do
598
599
  // NOT append the apiKey to the URL — auth is done via x-mp-key.
599
600
  var l=e.createServiceUrl(j),m=k?"development":"production";sendSearchRequest(c,b,function(){return buildIdentitySearchEnvelope(m)},l+"search?cb=1",d,g,void 0,h);};
@@ -1260,12 +1261,17 @@ function _defineProperty(obj, key, value) {
1260
1261
  var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
1261
1262
  throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
1262
1263
 
1263
- var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){// Operate on a copy of the queued item. The ready queue can be drained more
1264
- // than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
1265
- // before the outer drain resets the queue). Splicing the shared item array in
1266
- // place would corrupt it on the second pass — ["Identity.login", opts] becomes
1267
- // [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
1268
- // throws. Copying keeps the original item intact for any repeat pass.
1264
+ var processReadyQueue=function(a,b){if(isEmpty(a))return [];// Without draining first, sync re-entry (cache-hit identify →
1265
+ // parseIdentityResponse → processReadyQueue) re-iterates the same array:
1266
+ // callers only replace `_preInit.readyQueue` with [] after we return, so the
1267
+ // nested call still sees every entry. That duplicates Identity/event calls
1268
+ // and can nest "Unable to compute proper mParticle function" wraps.
1269
+ // Splice the queue empty up front so a nested call observes [].
1270
+ var c=a.splice(0,a.length);// Isolate each item so one throw cannot abort the rest of this pass.
1271
+ // Drain-first already removed siblings from the shared queue; without a
1272
+ // per-item catch they would be lost forever when forEach aborts.
1273
+ return c.forEach(function(a){try{isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}catch(a){b.error("Error processing ready queue item: "+getErrorMessage(a));}}),[]};var processPreloadedItem=function(a){// Operate on a copy so processPreloadedItem never mutates the caller's
1274
+ // queued item array (defensive; the queue itself is drained above).
1269
1275
  var b=a.slice(),c=b.splice(0,1)[0];// Skip malformed queue entries (empty array or non-string method) instead of
1270
1276
  // throwing an uncaught TypeError from method.split() below.
1271
1277
  if("string"==typeof c&&0!==c.length)// if the first argument is a method on the base mParticle object, run it
@@ -1464,7 +1470,7 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
1464
1470
  // attribute must be in the store before that happens so
1465
1471
  // appendUserInfo picks it up.
1466
1472
  null===(A=t._CookieConsentManager)||void 0===A||A.syncNoTargetingAttribute(y),n.sendUserIdentityChangeEvent(P,o,p.mpid,f);}if(a){var w=0===r.status?HTTPCodes$2.noHttpCoverage:r.status;t._Helpers.invokeCallback(a,w,p||null,y);}else p&&!isEmpty(p.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
1467
- t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(S=t._APIClient)||void 0===S||S.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.onIdentityComplete(),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
1473
+ t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(S=t._APIClient)||void 0===S||S.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.onIdentityComplete(),t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue,t.Logger);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
1468
1474
  {// https://go.mparticle.com/work/SQDSDKS-6354
1469
1475
  var a=this.IdentityAPI.getUser(s);for(var d in e)// Verifies a change actually happened
1470
1476
  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
@@ -1568,7 +1574,7 @@ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Bl
1568
1574
  var buildUrl=function(a,b,c,d){var e=d?"1":"0",f=["env=".concat(e)],g=c||{},h=g.planId,i=g.planVersion;return h&&f.push("plan_id=".concat(h)),i&&f.push("plan_version=".concat(i)),"".concat(a+b+"/config","?").concat(f.join("&"))};function ConfigAPIClient(a,b,c){var d=this,e="https://"+c._Store.SDKConfig.configUrl,f=b.isDevelopmentMode,g=b.dataPlan,h=buildUrl(e,a,g,f),i=window.fetch?new FetchUploader(h):new XHRUploader(h);this.getSDKConfiguration=function(){return __awaiter(d,void 0,void 0,function(){var a,d,e,f,h,j,k;return __generator(this,function(l){switch(l.label){case 0:d={method:"get",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"text/plain;charset=UTF-8"},body:null},l.label=1;case 1:return l.trys.push([1,6,,7]),[4/*yield*/,i.upload(d)];case 2:return (e=l.sent(),200!==e.status)?[3/*break*/,5]:(null===(h=null===c||void 0===c?void 0:c.Logger)||void 0===h?void 0:h.verbose("Successfully received configuration from server"),e.json?[4/*yield*/,e.json()]:[3/*break*/,4]);case 3:return a=l.sent(),[2/*return*/,a];case 4:return f=e,a=JSON.parse(f.responseText),[2/*return*/,a];case 5:return null===(j=null===c||void 0===c?void 0:c.Logger)||void 0===j?void 0:j.verbose("Issue with receiving configuration from server, received HTTP Code of "+e.statusText),[3/*break*/,7];case 6:return l.sent(),null===(k=null===c||void 0===c?void 0:c.Logger)||void 0===k?void 0:k.error("Error getting forwarder configuration from mParticle servers."),[3/*break*/,7];case 7:// Returns the original config object if we cannot retrieve the remote config
1569
1575
  return [2/*return*/,b]}})})};}
1570
1576
 
1571
- var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k,l;return __awaiter(this,void 0,void 0,function(){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,A,m,E,m,A,F;return __generator(this,function(G){switch(G.label){case 0:if((null===(i=a._RoktManager)||void 0===i?void 0:i.isInitialized)&&(a._Store.identifyRequestCount=(a._Store.identifyRequestCount||0)+1,m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestStart"))),n=a._Helpers.invokeCallback,o=a.Logger,p=a._ErrorReportingDispatcher,o.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return o.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(o.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return n(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];q=g||null,r=this.getUploadUrl(c,g),s=window.fetch?new FetchUploader(r):new XHRUploader(r),t={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,G.label=1;case 1:return G.trys.push([1,9,,10]),[4/*yield*/,s.upload(t)];case 2:return u=G.sent(),v=void 0,w=void 0,x=u.status,x===HTTP_ACCEPTED?[3/*break*/,3]:x===HTTP_OK?[3/*break*/,3]:x===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return u.json?[4/*yield*/,u.json()]:[3/*break*/,5];case 4:return y=G.sent(),v=this.getIdentityResponseFromFetch(u,y),[3/*break*/,6];case 5:v=this.getIdentityResponseFromXHR(u),G.label=6;case 6:return v.status===HTTP_BAD_REQUEST?(z=v.responseText,w="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+v.status,(null===z||void 0===z?void 0:z.Errors)&&(A=z.Errors.map(function(a){return a.message}).join(", "),w+=" - "+A)):o.isVerbose()&&(B=v.responseText,C=a._Store.SDKConfig.isDevelopmentMode,D=B,!C&&(null===B||void 0===B?void 0:B.matched_identities)&&(D=__assign(__assign({},B),{matched_identities:obfuscateData(B.matched_identities)})),w="Received Identity Response from server: "+JSON.stringify(D)),[3/*break*/,8];case 7:{if(u.status>=HTTP_SERVER_ERROR)throw new Error("Received HTTP Code of "+u.status);return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,A="Received HTTP Code of "+u.status,o.error("Error sending identity request to servers - "+A),n(d,HTTPCodes$1.noHttpCoverage,A),[2/*return*/]}case 8:return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,w&&o.verbose(w),(null===(j=a._RoktManager)||void 0===j?void 0:j.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),f(v,q,d,e,c,h,!1),[3/*break*/,10];case 9:return E=G.sent(),a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!0,(null===(k=a._RoktManager)||void 0===k?void 0:k.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),A=E.message||E.toString(),F="Error sending identity request to servers - "+A,o.error(F),null===p||void 0===p?void 0:p.report({message:F,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),null===(l=a.processQueueOnIdentityFailure)||void 0===l?void 0:l.call(a),n(d,HTTPCodes$1.noHttpCoverage,A),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
1577
+ var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=getErrorMessage(s),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k,l;return __awaiter(this,void 0,void 0,function(){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,A,m,E,m,A,F;return __generator(this,function(G){switch(G.label){case 0:if((null===(i=a._RoktManager)||void 0===i?void 0:i.isInitialized)&&(a._Store.identifyRequestCount=(a._Store.identifyRequestCount||0)+1,m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestStart"))),n=a._Helpers.invokeCallback,o=a.Logger,p=a._ErrorReportingDispatcher,o.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return o.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(o.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return n(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];q=g||null,r=this.getUploadUrl(c,g),s=window.fetch?new FetchUploader(r):new XHRUploader(r),t={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,G.label=1;case 1:return G.trys.push([1,9,,10]),[4/*yield*/,s.upload(t)];case 2:return u=G.sent(),v=void 0,w=void 0,x=u.status,x===HTTP_ACCEPTED?[3/*break*/,3]:x===HTTP_OK?[3/*break*/,3]:x===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return u.json?[4/*yield*/,u.json()]:[3/*break*/,5];case 4:return y=G.sent(),v=this.getIdentityResponseFromFetch(u,y),[3/*break*/,6];case 5:v=this.getIdentityResponseFromXHR(u),G.label=6;case 6:return v.status===HTTP_BAD_REQUEST?(z=v.responseText,w="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+v.status,(null===z||void 0===z?void 0:z.Errors)&&(A=z.Errors.map(function(a){return a.message}).join(", "),w+=" - "+A)):o.isVerbose()&&(B=v.responseText,C=a._Store.SDKConfig.isDevelopmentMode,D=B,!C&&(null===B||void 0===B?void 0:B.matched_identities)&&(D=__assign(__assign({},B),{matched_identities:obfuscateData(B.matched_identities)})),w="Received Identity Response from server: "+JSON.stringify(D)),[3/*break*/,8];case 7:{if(u.status>=HTTP_SERVER_ERROR)throw new Error("Received HTTP Code of "+u.status);return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,A="Received HTTP Code of "+u.status,o.error("Error sending identity request to servers - "+A),n(d,HTTPCodes$1.noHttpCoverage,A),[2/*return*/]}case 8:return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,w&&o.verbose(w),(null===(j=a._RoktManager)||void 0===j?void 0:j.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),f(v,q,d,e,c,h,!1),[3/*break*/,10];case 9:return E=G.sent(),a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!0,(null===(k=a._RoktManager)||void 0===k?void 0:k.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),A=getErrorMessage(E),F="Error sending identity request to servers - "+A,o.error(F),null===p||void 0===p?void 0:p.report({message:F,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),null===(l=a.processQueueOnIdentityFailure)||void 0===l?void 0:l.call(a),n(d,HTTPCodes$1.noHttpCoverage,A),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
1572
1578
 
1573
1579
  // The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
1574
1580
  // - version is always this prefix: fb
@@ -1618,12 +1624,12 @@ var PASSBACK_CONVERSION_TRACKING_ID="passbackconversiontrackingid",ON_SHOPPABLE_
1618
1624
  // as that is independent of this setting, though they share the same name.
1619
1625
  var s=(null===f||void 0===f?void 0:f.sandbox)||!1,t=normalizeRoktLauncherOptions(null===f||void 0===f?void 0:f.launcherOptions);// Launcher options are set here for the kit to pick up and pass through
1620
1626
  // to the Rokt Launcher.
1621
- this.launcherOptions=__assign({sandbox:s},t),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c,d,f;this.kit=a,(null===(b=a.settings)||void 0===b?void 0:b.accountId)&&this.store.setRoktAccountId(a.settings.accountId),a.integrationName&&(null===(c=this.store)||void 0===c?void 0:c.setIntegrationName(a.integrationName)),this.processMessageQueue();try{null===(d=this.onReadyCallback)||void 0===d?void 0:d.call(this);}catch(a){null===(f=this.logger)||void 0===f?void 0:f.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;return __awaiter(this,void 0,void 0,function(){var n,o,p,q,r,s,t,u,v,w,x,y,z,A,A,B,C,D,E,F,G,H,I=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
1627
+ this.launcherOptions=__assign({sandbox:s},t),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c,d,f;this.kit=a,(null===(b=a.settings)||void 0===b?void 0:b.accountId)&&this.store.setRoktAccountId(a.settings.accountId),a.integrationName&&(null===(c=this.store)||void 0===c?void 0:c.setIntegrationName(a.integrationName)),this.processMessageQueue();try{null===(d=this.onReadyCallback)||void 0===d?void 0:d.call(this);}catch(a){null===(f=this.logger)||void 0===f?void 0:f.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;return __awaiter(this,void 0,void 0,function(){var n,o,p,q,r,s,t,u,v,w,x,y,z,A,A,B,C,D,E,F,G,H=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
1622
1628
  if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];try{if(n=a.attributes,o=(null===n||void 0===n?void 0:n.sandbox)||null,p=this.mapPlacementAttributes(n,this.placementAttributesMapping),(null===(d=this.logger)||void 0===d?void 0:d.isVerbose())&&(q=obfuscateDevData(n,null===(f=null===(e=this.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode),this.logger.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(q,null,2)))),this.currentUser=this.identityService.getCurrentUser(),r=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},s=r.email,t=p.email,u=void 0,v=void 0,w=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),w&&(u=r[this.mappedEmailShaIdentityType],v=p.emailsha256||p[this.mappedEmailShaIdentityType]||void 0),x=this.hasIdentityChanged(s,t),y=this.hasIdentityChanged(u,v),z={},x&&(z.email=t,t&&(A="Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(i=this.errorReporter)||void 0===i?void 0:i.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING}))),y&&(z[this.mappedEmailShaIdentityType]=v,A="emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(j=this.errorReporter)||void 0===j?void 0:j.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING})),!isEmpty(z))// Fire-and-forget identify — best-effort, does not block selectPlacements
1623
- try{this.identityService.identify({userIdentities:__assign(__assign({},r),z)},function(a){var b=+(null===a||void 0===a?void 0:a.httpCode);b&&(400<=b||0>b)&&I.logger.error("Background identify failed with HTTP "+b),I.processMessageQueue();});}catch(a){B=a instanceof Error?a.message:JSON.stringify(a),this.logger.error("Background identify threw an error: "+B);}return C=__assign(__assign({},r),z),this.setUserAttributes(p),D=__assign(__assign({},p),null===o?{}:{sandbox:o}),C.email&&!D.email&&(D.email=C.email),w&&(E=C[this.mappedEmailShaIdentityType],E&&!D.emailsha256&&!D[this.mappedEmailShaIdentityType]&&(D.emailsha256=E)),D[PASSBACK_CONVERSION_TRACKING_ID]||(null===(k=this.integrationCapture)||void 0===k?void 0:k.capture(),F=null===(l=this.integrationCapture)||void 0===l?void 0:l.getClickIdsAsIntegrationAttributes(),G=null===(m=null===F||void 0===F?void 0:F[PARTNER_MODULE_IDS.Rokt])||void 0===m?void 0:m[PASSBACK_CONVERSION_TRACKING_ID],G&&(D[PASSBACK_CONVERSION_TRACKING_ID]=G)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,H=__assign(__assign({},a),{attributes:D}),[2/*return*/,this.kit.selectPlacements(H)]}catch(a){return [2/*return*/,Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))]}return [2/*return*/]})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:return (o.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(n,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=o.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=o.sent(),m=l instanceof Error?l.message:l+"",this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(m)),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",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.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.onShoppableAdsReady=function(a){if(!this.kit||!this.isShoppableAdsLoaded)return void this.deferredCall("onShoppableAdsReady",a);try{this.kit.onShoppableAdsReady(a);}catch(a){var b=a instanceof Error?a.message:a+"";this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(b));}},a.prototype.flushOnShoppableAdsReadyMessageQueue=function(a){var b=this;this.kit=a,this.messageQueue.forEach(function(c,d){var f;if(c.methodName===ON_SHOPPABLE_ADS_READY_METHOD){try{a.onShoppableAdsReady(c.payload);}catch(a){null===(f=b.logger)||void 0===f?void 0:f.error("RoktManager: Error flushing onShoppableAdsReady: "+a);}b.messageQueue["delete"](d);}}),this.isShoppableAdsLoaded=!0;},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];e.label=1;case 1:return e.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,e.sent()];case 3:return c=e.sent(),d=c instanceof Error?c.message:c+"",this.logger.error("Failed to hashSha256, returning undefined: ".concat(d)),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1629
+ try{this.identityService.identify({userIdentities:__assign(__assign({},r),z)},function(a){var b=+(null===a||void 0===a?void 0:a.httpCode);b&&(400<=b||0>b)&&H.logger.error("Background identify failed with HTTP "+b),H.processMessageQueue();});}catch(a){this.logger.error("Background identify threw an error: "+getErrorMessage(a));}return B=__assign(__assign({},r),z),this.setUserAttributes(p),C=__assign(__assign({},p),null===o?{}:{sandbox:o}),B.email&&!C.email&&(C.email=B.email),w&&(D=B[this.mappedEmailShaIdentityType],D&&!C.emailsha256&&!C[this.mappedEmailShaIdentityType]&&(C.emailsha256=D)),C[PASSBACK_CONVERSION_TRACKING_ID]||(null===(k=this.integrationCapture)||void 0===k?void 0:k.capture(),E=null===(l=this.integrationCapture)||void 0===l?void 0:l.getClickIdsAsIntegrationAttributes(),F=null===(m=null===E||void 0===E?void 0:E[PARTNER_MODULE_IDS.Rokt])||void 0===m?void 0:m[PASSBACK_CONVERSION_TRACKING_ID],F&&(C[PASSBACK_CONVERSION_TRACKING_ID]=F)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,G=__assign(__assign({},a),{attributes:C}),[2/*return*/,this.kit.selectPlacements(G)]}catch(a){return [2/*return*/,Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))]}return [2/*return*/]})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m=this;return __generator(this,function(n){switch(n.label){case 0:return (n.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(m,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=n.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=n.sent(),this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(getErrorMessage(l))),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",a);try{this.kit.setExtensionData(a);}catch(a){throw new Error("Error setting extension data: "+getErrorMessage(a))}},a.prototype.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.onShoppableAdsReady=function(a){if(!this.kit||!this.isShoppableAdsLoaded)return void this.deferredCall("onShoppableAdsReady",a);try{this.kit.onShoppableAdsReady(a);}catch(a){this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(getErrorMessage(a)));}},a.prototype.flushOnShoppableAdsReadyMessageQueue=function(a){var b=this;this.kit=a,this.messageQueue.forEach(function(c,d){var f;if(c.methodName===ON_SHOPPABLE_ADS_READY_METHOD){try{a.onShoppableAdsReady(c.payload);}catch(a){null===(f=b.logger)||void 0===f?void 0:f.error("RoktManager: Error flushing onShoppableAdsReady: "+a);}b.messageQueue["delete"](d);}}),this.isShoppableAdsLoaded=!0;},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c;return __generator(this,function(d){switch(d.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];d.label=1;case 1:return d.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,d.sent()];case 3:return c=d.sent(),this.logger.error("Failed to hashSha256, returning undefined: ".concat(getErrorMessage(c))),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1624
1630
  return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)if(a.hasOwnProperty(d)&&-1===b.indexOf(d)){var e=a[d];c[d]=Array.isArray(e)?JSON.stringify(e):e;}try{this.currentUser.setUserAttributes(c);}catch(a){this.logger.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.onIdentityComplete=function(){this.isReady()&&(this.currentUser=this.identityService.getCurrentUser(),this.processMessageQueue());},a.prototype.processMessageQueue=function(){var a,b=this;if(this.isReady()&&0!==this.messageQueue.size){null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages"));var c=Array.from(this.messageQueue.values());// Clear the queue immediately to prevent re-processing
1625
1631
  this.messageQueue.clear(),c.forEach(function(a){var c,d,e,f;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));if(null===(d=b.logger)||void 0===d?void 0:d.isVerbose()){var g=obfuscateDevData(a.payload,null===(f=null===(e=b.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode);b.logger.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(g)));}// Capture resolve/reject functions before async processing
1626
- var h=a.resolve,i=a.reject,j=function(c){var d,e=c instanceof Error?c.message:c+"";null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(e)),i&&i(c);};try{var k=b[a.methodName](a.payload);// Handle both sync and async methods
1632
+ var h=a.resolve,i=a.reject,j=function(c){var d;null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(getErrorMessage(c))),i&&i(c);};try{var k=b[a.methodName](a.payload);// Handle both sync and async methods
1627
1633
  Promise.resolve(k).then(function(a){h&&h(a);})["catch"](j);}catch(a){j(a);}});}},a.prototype.queueMessage=function(a){this.messageQueue.set(a.messageId,a);},a.prototype.deferredCall=function(a,b){var c=this;return new Promise(function(d,e){var f="".concat(a,"_").concat(generateUniqueId());c.queueMessage({messageId:f,methodName:a,payload:b,resolve:d,reject:e});})},a.prototype.sha256Hex=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:return b=new TextEncoder,c=b.encode(a),[4/*yield*/,crypto.subtle.digest("SHA-256",c)];case 1:return d=e.sent(),[2/*return*/,this.arrayBufferToHex(d)]}})})},a.prototype.arrayBufferToHex=function(a){for(var b,c=new Uint8Array(a),d="",e=0;e<c.length;e++)b=c[e].toString(16).padStart(2,"0"),d+=b;return d},a.prototype.hasIdentityChanged=function(a,b){return !!b&&(!a||a!==b);// Values are the same
1628
1634
  },a}();// The purpose of this class is to create a link between the Core mParticle SDK and the
1629
1635
 
@@ -1656,7 +1662,7 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
1656
1662
  *
1657
1663
  * @class mParticle & mParticleInstance
1658
1664
  */function mParticleInstance(a){var b=this;// These classes are for internal use only. Not documented for public consumption
1659
- this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._ErrorReportingDispatcher=new ErrorReportingDispatcher,this._LoggingDispatcher=new LoggingDispatcher,this._RoktManager=new RoktManager,this._RoktManager.setOnReadyCallback(function(){b.processQueueOnIdentityFailure();}),this.processQueueOnIdentityFailure=function(){var a,c,d;(null===(a=b._Store)||void 0===a?void 0:a.isInitialized)||(null===(c=b._Store)||void 0===c?void 0:c.identityCallFailed)&&(null===(d=b._RoktManager)||void 0===d?void 0:d.isReady())&&(b._RoktManager.processMessageQueue(),b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue));},this.processQueueOnNoFunctional=function(){var a,c;if(!(null!==(a=b._Store)&&void 0!==a)||!a.isInitialized){var d=(null===(c=b._CookieConsentManager)||void 0===c?void 0:c.getNoFunctional())&&!hasExplicitIdentifier(b._Store);d&&(b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue));}},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this.RoktEvents=RoktEvents,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
1665
+ this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._ErrorReportingDispatcher=new ErrorReportingDispatcher,this._LoggingDispatcher=new LoggingDispatcher,this._RoktManager=new RoktManager,this._RoktManager.setOnReadyCallback(function(){b.processQueueOnIdentityFailure();}),this.processQueueOnIdentityFailure=function(){var a,c,d;(null===(a=b._Store)||void 0===a?void 0:a.isInitialized)||(null===(c=b._Store)||void 0===c?void 0:c.identityCallFailed)&&(null===(d=b._RoktManager)||void 0===d?void 0:d.isReady())&&(b._RoktManager.processMessageQueue(),b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue,b.Logger));},this.processQueueOnNoFunctional=function(){var a,c;if(!(null!==(a=b._Store)&&void 0!==a)||!a.isInitialized){var d=(null===(c=b._CookieConsentManager)||void 0===c?void 0:c.getNoFunctional())&&!hasExplicitIdentifier(b._Store);d&&(b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue,b.Logger));}},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this.RoktEvents=RoktEvents,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
1660
1666
  // Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
1661
1667
  // to it for it to be run after fetched
1662
1668
  if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c._ErrorReportingDispatcher=new ErrorReportingDispatcher,c._LoggingDispatcher=new LoggingDispatcher,c.Logger=new Logger(a),c._ErrorReportingDispatcher.logger=c.Logger,c._LoggingDispatcher.logger=c.Logger,c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){var c,d,e,f=(null===(c=b._CookieConsentManager)||void 0===c?void 0:c.getNoFunctional())&&!hasExplicitIdentifier(b._Store),g=isFunction(a)&&((null===(d=b._Store)||void 0===d?void 0:d.isInitialized)||(null===(e=b._Store)||void 0===e?void 0:e.identityCallFailed)&&b._RoktManager.isReady()||f);g?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
@@ -1823,7 +1829,7 @@ var m=i(CaptureIntegrationSpecificIds),n=i(CaptureIntegrationSpecificIdsV2),o=n&
1823
1829
  var q=parseConfig(b,"Rokt",181);if(q){var r=null===(e=q.settings)||void 0===e?void 0:e.accountId;c._Store.setRoktAccountId(r);var s=q.userAttributeFilters,t=filteredMparticleUser(k,{userAttributeFilters:s},c),u={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};// https://go.mparticle.com/work/SQDSDKS-7339
1824
1830
  c._RoktManager.init(q,t,c.Identity,c._Store,c.Logger,u,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher,c._IntegrationCapture);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,j,k,l);}// We will continue to clear out the ready queue as part of the initial init flow
1825
1831
  // if an identify request is unnecessary, such as if there is an existing session
1826
- (c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,null===(f=c._CookieConsentManager)||void 0===f?void 0:f.syncNoTargetingAttribute(c.Identity.getCurrentUser()),c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),null===(g=c.processQueueOnNoFunctional)||void 0===g?void 0:g.call(c),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
1832
+ (c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,null===(f=c._CookieConsentManager)||void 0===f?void 0:f.syncNoTargetingAttribute(c.Identity.getCurrentUser()),c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue,c.Logger)),null===(g=c.processQueueOnNoFunctional)||void 0===g?void 0:g.call(c),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
1827
1833
  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:
1828
1834
  1. Manually via config.dataPlanOptions (this takes priority)
1829
1835
  If not passed in manually, we user the server provided via either
@@ -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.73.0";
18
+ var version = "2.73.1";
19
19
 
20
20
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",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/"},// These are the paths that are used to construct the CNAME urls
@@ -194,7 +194,8 @@ return _typeof$1(a)},obfuscateDevData=function(a,b){return b?a:obfuscateData(a)}
194
194
  */ // Standalone version of jQuery.extend, from https://github.com/dansdom/extend
195
195
  // https://go.mparticle.com/work/SQDSDKS-6047
196
196
  function extend(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];var c,d,e,f,g,h,j={hasOwn:Object.prototype.hasOwnProperty,class2type:{},type:function type(a){return null==a?a+"":j.class2type[Object.prototype.toString.call(a)]||"object"},isPlainObject:function isPlainObject(a){if(!a||"object"!==j.type(a)||a.nodeType||j.isWindow(a))return !1;try{if(a.constructor&&!j.hasOwn.call(a,"constructor")&&!j.hasOwn.call(a.constructor.prototype,"isPrototypeOf"))return !1}catch(a){return !1}for(var b in a);// eslint-disable-line no-empty
197
- return b===void 0||j.hasOwn.call(a,b)},isArray:Array.isArray||function(a){return "array"===j.type(a)},isFunction:function(a){return "function"===j.type(a)},isWindow:function isWindow(a){return null!=a&&a==a.window}},k=a[0]||{},l=1,m=!1,n=a.length;for("boolean"==typeof k&&(m=k,k=a[1]||{},l=2),"object"===_typeof$1(k)||j.isFunction(k)||(k={}),n===l&&(k={},--l);l<n;l++)if(null!=(c=a[l]))for(d in c)"__proto__"!==d&&"constructor"!==d&&"prototype"!==d&&Object.prototype.hasOwnProperty.call(c,d)&&(e=k[d],f=c[d],k!==f)&&(m&&f&&(j.isPlainObject(f)||(g=j.isArray(f)))?(g?(g=!1,h=e&&j.isArray(e)?e:[]):h=e&&j.isPlainObject(e)?e:{},k[d]=extend(m,h,f)):void 0!==f&&(k[d]=f));return k}
197
+ return b===void 0||j.hasOwn.call(a,b)},isArray:Array.isArray||function(a){return "array"===j.type(a)},isFunction:function(a){return "function"===j.type(a)},isWindow:function isWindow(a){return null!=a&&a==a.window}},k=a[0]||{},l=1,m=!1,n=a.length;for("boolean"==typeof k&&(m=k,k=a[1]||{},l=2),"object"===_typeof$1(k)||j.isFunction(k)||(k={}),n===l&&(k={},--l);l<n;l++)if(null!=(c=a[l]))for(d in c)"__proto__"!==d&&"constructor"!==d&&"prototype"!==d&&Object.prototype.hasOwnProperty.call(c,d)&&(e=k[d],f=c[d],k!==f)&&(m&&f&&(j.isPlainObject(f)||(g=j.isArray(f)))?(g?(g=!1,h=e&&j.isArray(e)?e:[]):h=e&&j.isPlainObject(e)?e:{},k[d]=extend(m,h,f)):void 0!==f&&(k[d]=f));return k}var getErrorMessage=function(a,b){return void 0===b&&(b="unknown error"),a instanceof Error?a.message:"string"==typeof a?a:a&&"object"===_typeof$1(a)&&"string"==typeof a.message?a.message:b;// fetch-mock and some network libs reject with { message } rather than Error
198
+ };
198
199
 
199
200
  var MessageType$1={SessionStart:1,SessionEnd:2,PageView:3,PageEvent:4,CrashReport:5,OptOut:6,AppStateTransition:10,Profile:14,Commerce:16,Media:20,UserAttributeChange:17,UserIdentityChange:18};var EventType={Unknown:0,Navigation:1,Location:2,Search:3,Transaction:4,UserContent:5,UserPreference:6,Social:7,Other:8,Media:9,getName:function getName(a){return a===EventType.Unknown?"Unknown":a===EventType.Navigation?"Navigation":a===EventType.Location?"Location":a===EventType.Search?"Search":a===EventType.Transaction?"Transaction":a===EventType.UserContent?"User Content":a===EventType.UserPreference?"User Preference":a===EventType.Social?"Social":a===CommerceEventType.ProductAddToCart?"Product Added to Cart":a===CommerceEventType.ProductAddToWishlist?"Product Added to Wishlist":a===CommerceEventType.ProductCheckout?"Product Checkout":a===CommerceEventType.ProductCheckoutOption?"Product Checkout Options":a===CommerceEventType.ProductClick?"Product Click":a===CommerceEventType.ProductImpression?"Product Impression":a===CommerceEventType.ProductPurchase?"Product Purchased":a===CommerceEventType.ProductRefund?"Product Refunded":a===CommerceEventType.ProductRemoveFromCart?"Product Removed From Cart":a===CommerceEventType.ProductRemoveFromWishlist?"Product Removed from Wishlist":a===CommerceEventType.ProductViewDetail?"Product View Details":a===CommerceEventType.PromotionClick?"Promotion Click":a===CommerceEventType.PromotionView?"Promotion View":"Other"}};// Continuation of EventType enum above, but in seperate object since we don't expose these to end user
200
201
  var CommerceEventType={ProductAddToCart:10,ProductRemoveFromCart:11,ProductCheckout:12,ProductCheckoutOption:13,ProductClick:14,ProductViewDetail:15,ProductPurchase:16,ProductRefund:17,PromotionView:18,PromotionClick:19,ProductAddToWishlist:20,ProductRemoveFromWishlist:21,ProductImpression:22};var IdentityType={Other:0,CustomerId:1,Facebook:2,Twitter:3,Google:4,Microsoft:5,Yahoo:6,Email:7,FacebookCustomAudienceId:9,Other2:10,Other3:11,Other4:12,Other5:13,Other6:14,Other7:15,Other8:16,Other9:17,Other10:18,MobileNumber:19,PhoneNumber2:20,PhoneNumber3:21,isValid:function isValid(a){if("number"==typeof a)for(var b in IdentityType)if(IdentityType.hasOwnProperty(b)&&IdentityType[b]===a)return !0;return !1},getName:function getName(a){return a===window.mParticle.IdentityType.CustomerId?"Customer ID":a===window.mParticle.IdentityType.Facebook?"Facebook ID":a===window.mParticle.IdentityType.Twitter?"Twitter ID":a===window.mParticle.IdentityType.Google?"Google ID":a===window.mParticle.IdentityType.Microsoft?"Microsoft ID":a===window.mParticle.IdentityType.Yahoo?"Yahoo ID":a===window.mParticle.IdentityType.Email?"Email":a===window.mParticle.IdentityType.FacebookCustomAudienceId?"Facebook App User ID":"Other ID"},getIdentityType:function getIdentityType(a){return "other"===a?IdentityType.Other:"customerid"===a?IdentityType.CustomerId:"facebook"===a?IdentityType.Facebook:"twitter"===a?IdentityType.Twitter:"google"===a?IdentityType.Google:"microsoft"===a?IdentityType.Microsoft:"yahoo"===a?IdentityType.Yahoo:"email"===a?IdentityType.Email:"facebookcustomaudienceid"===a?IdentityType.FacebookCustomAudienceId:"other2"===a?IdentityType.Other2:"other3"===a?IdentityType.Other3:"other4"===a?IdentityType.Other4:"other5"===a?IdentityType.Other5:"other6"===a?IdentityType.Other6:"other7"===a?IdentityType.Other7:"other8"===a?IdentityType.Other8:"other9"===a?IdentityType.Other9:"other10"===a?IdentityType.Other10:"mobile_number"===a?IdentityType.MobileNumber:"phone_number_2"===a?IdentityType.PhoneNumber2:"phone_number_3"===a?IdentityType.PhoneNumber3:"email_sha256"===a?IdentityType.Other:!("mobile_sha256"!=a)&&IdentityType.Other2},getIdentityName:function getIdentityName(a){return a===IdentityType.Other?"other":a===IdentityType.CustomerId?"customerid":a===IdentityType.Facebook?"facebook":a===IdentityType.Twitter?"twitter":a===IdentityType.Google?"google":a===IdentityType.Microsoft?"microsoft":a===IdentityType.Yahoo?"yahoo":a===IdentityType.Email?"email":a===IdentityType.FacebookCustomAudienceId?"facebookcustomaudienceid":a===IdentityType.Other2?"other2":a===IdentityType.Other3?"other3":a===IdentityType.Other4?"other4":a===IdentityType.Other5?"other5":a===IdentityType.Other6?"other6":a===IdentityType.Other7?"other7":a===IdentityType.Other8?"other8":a===IdentityType.Other9?"other9":a===IdentityType.Other10?"other10":a===IdentityType.MobileNumber?"mobile_number":a===IdentityType.PhoneNumber2?"phone_number_2":a===IdentityType.PhoneNumber3?"phone_number_3":null},// Strips out functions from Identity Types for easier lookups
@@ -547,8 +548,8 @@ var HTTPCodes$4=Constants.HTTPCodes;/**
547
548
  // to deliver a result to, so log and bail out without invoking anything.
548
549
  if(!isFunction(e))return f.error("search called without a callback function; skipping request."),[2/*return*/];// No usable identifier -> deliver httpCode: noHttpCoverage so callers
549
550
  // waiting on the callback (e.g. to clear a loading state) don't hang.
550
- if(i=function(a){try{e(a);}catch(a){f.error("Error invoking search callback: "+((null===a||void 0===a?void 0:a.message)||a+""));}},j=Validators.removeFalsyIdentityValues({userIdentities:null!==a&&void 0!==a?a:{}},f).userIdentities,!Object.values(null!==j&&void 0!==j?j:{}).some(function(a){return "string"==typeof a&&0<a.length}))return f.verbose("Identity search called with empty identifiers; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];// No API key -> same: deliver noHttpCoverage rather than hanging.
551
- if(!b)return f.verbose("search called without a workspace API key; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];v.label=1;case 1:return v.trys.push([1,9,,10]),k=c(),l=__assign(__assign({},k),{known_identities:__assign({},j)}),m={method:"post",headers:{Accept:"application/json","Content-Type":"application/json","x-mp-key":b},body:JSON.stringify(l)},n=g||(window.fetch?new FetchUploader(d):new XHRUploader(d)),f.verbose("Sending search request to "+d),[4/*yield*/,n.upload(m,d)];case 2:if(o=v.sent(),p=void 0,!isFunction(o.json))return [3/*break*/,7];v.label=3;case 3:return v.trys.push([3,5,,6]),[4/*yield*/,o.json()];case 4:return p=v.sent(),[3/*break*/,6];case 5:return v.sent(),f.verbose("search response had no parseable JSON body."),[3/*break*/,6];case 6:return [3/*break*/,8];case 7:if(r=o,null===r||void 0===r?void 0:r.responseText)try{p=JSON.parse(r.responseText);}catch(a){f.verbose("search XHR response was not valid JSON.");}v.label=8;case 8:return o.status===HTTP_OK?f.verbose("search received 200 OK."):o.status===HTTP_NOT_FOUND?f.verbose("search received 404 (no match)."):f.verbose("search received non-success status "+o.status),i({httpCode:o.status,body:p}),[3/*break*/,10];case 9:return s=v.sent(),t=(null===s||void 0===s?void 0:s.message)||s+"",u="Error sending search request: "+t,f.error(u),null===h||void 0===h?void 0:h.report({message:u,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),i({httpCode:HTTPCodes$4.noHttpCoverage}),[3/*break*/,10];case 10:return [2/*return*/]}})})};
551
+ if(i=function(a){try{e(a);}catch(a){f.error("Error invoking search callback: "+getErrorMessage(a));}},j=Validators.removeFalsyIdentityValues({userIdentities:null!==a&&void 0!==a?a:{}},f).userIdentities,!Object.values(null!==j&&void 0!==j?j:{}).some(function(a){return "string"==typeof a&&0<a.length}))return f.verbose("Identity search called with empty identifiers; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];// No API key -> same: deliver noHttpCoverage rather than hanging.
552
+ if(!b)return f.verbose("search called without a workspace API key; skipping request."),i({httpCode:HTTPCodes$4.noHttpCoverage}),[2/*return*/];v.label=1;case 1:return v.trys.push([1,9,,10]),k=c(),l=__assign(__assign({},k),{known_identities:__assign({},j)}),m={method:"post",headers:{Accept:"application/json","Content-Type":"application/json","x-mp-key":b},body:JSON.stringify(l)},n=g||(window.fetch?new FetchUploader(d):new XHRUploader(d)),f.verbose("Sending search request to "+d),[4/*yield*/,n.upload(m,d)];case 2:if(o=v.sent(),p=void 0,!isFunction(o.json))return [3/*break*/,7];v.label=3;case 3:return v.trys.push([3,5,,6]),[4/*yield*/,o.json()];case 4:return p=v.sent(),[3/*break*/,6];case 5:return v.sent(),f.verbose("search response had no parseable JSON body."),[3/*break*/,6];case 6:return [3/*break*/,8];case 7:if(r=o,null===r||void 0===r?void 0:r.responseText)try{p=JSON.parse(r.responseText);}catch(a){f.verbose("search XHR response was not valid JSON.");}v.label=8;case 8:return o.status===HTTP_OK?f.verbose("search received 200 OK."):o.status===HTTP_NOT_FOUND?f.verbose("search received 404 (no match)."):f.verbose("search received non-success status "+o.status),i({httpCode:o.status,body:p}),[3/*break*/,10];case 9:return s=v.sent(),t=getErrorMessage(s),u="Error sending search request: "+t,f.error(u),null===h||void 0===h?void 0:h.report({message:u,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),i({httpCode:HTTPCodes$4.noHttpCoverage}),[3/*break*/,10];case 10:return [2/*return*/]}})})};
552
553
 
553
554
  var _a=Constants.IdentityMethods,Identify$2=_a.Identify,Modify$3=_a.Modify,Login$2=_a.Login,Logout$2=_a.Logout,HTTPCodes$3=Constants.HTTPCodes,Messages$9=Constants.Messages;var CACHE_HEADER="x-mp-max-age";var cacheOrClearIdCache=function(a,b,c,d,e){// when parsing a response that has already been cached, simply return instead of attempting another cache
554
555
  if(!e){// default the expire timestamp to one day in milliseconds unless a header comes back
@@ -593,7 +594,7 @@ var identitiesEqual=function(c,a){var b=Object.keys(null!==c&&void 0!==c?c:{}),d
593
594
  * builds the `/v1/search` URL and request envelope, and dispatches.
594
595
  * Lives here so the SDK glue (URL building, opt-out gate, dispatcher
595
596
  * plumbing) is type-checked instead of being expressed in plain JS.
596
- */var executeSearchRequest=function(a,b,c,d){var e=a._Helpers,f=a._Store,g=a.Logger,h=a._ErrorReportingDispatcher,i=f.SDKConfig,j=i.identityUrl,k=i.isDevelopmentMode;if(!e.canLog()){if(g.verbose(Messages$9.InformationMessages.AbandonLogEvent),isFunction(d))try{d({httpCode:HTTPCodes$3.loggingDisabledOrMissingAPIKey});}catch(a){g.error("Error invoking search callback: "+((null===a||void 0===a?void 0:a.message)||a+""));}return}// The Search endpoint is colocated with /v1/identify under
597
+ */var executeSearchRequest=function(a,b,c,d){var e=a._Helpers,f=a._Store,g=a.Logger,h=a._ErrorReportingDispatcher,i=f.SDKConfig,j=i.identityUrl,k=i.isDevelopmentMode;if(!e.canLog()){if(g.verbose(Messages$9.InformationMessages.AbandonLogEvent),isFunction(d))try{d({httpCode:HTTPCodes$3.loggingDisabledOrMissingAPIKey});}catch(a){g.error("Error invoking search callback: "+getErrorMessage(a));}return}// The Search endpoint is colocated with /v1/identify under
597
598
  // identityUrl, so we reuse the same service URL builder. We do
598
599
  // NOT append the apiKey to the URL — auth is done via x-mp-key.
599
600
  var l=e.createServiceUrl(j),m=k?"development":"production";sendSearchRequest(c,b,function(){return buildIdentitySearchEnvelope(m)},l+"search?cb=1",d,g,void 0,h);};
@@ -1260,12 +1261,17 @@ function _defineProperty(obj, key, value) {
1260
1261
  var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
1261
1262
  throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
1262
1263
 
1263
- var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){// Operate on a copy of the queued item. The ready queue can be drained more
1264
- // than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
1265
- // before the outer drain resets the queue). Splicing the shared item array in
1266
- // place would corrupt it on the second pass — ["Identity.login", opts] becomes
1267
- // [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
1268
- // throws. Copying keeps the original item intact for any repeat pass.
1264
+ var processReadyQueue=function(a,b){if(isEmpty(a))return [];// Without draining first, sync re-entry (cache-hit identify →
1265
+ // parseIdentityResponse → processReadyQueue) re-iterates the same array:
1266
+ // callers only replace `_preInit.readyQueue` with [] after we return, so the
1267
+ // nested call still sees every entry. That duplicates Identity/event calls
1268
+ // and can nest "Unable to compute proper mParticle function" wraps.
1269
+ // Splice the queue empty up front so a nested call observes [].
1270
+ var c=a.splice(0,a.length);// Isolate each item so one throw cannot abort the rest of this pass.
1271
+ // Drain-first already removed siblings from the shared queue; without a
1272
+ // per-item catch they would be lost forever when forEach aborts.
1273
+ return c.forEach(function(a){try{isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}catch(a){b.error("Error processing ready queue item: "+getErrorMessage(a));}}),[]};var processPreloadedItem=function(a){// Operate on a copy so processPreloadedItem never mutates the caller's
1274
+ // queued item array (defensive; the queue itself is drained above).
1269
1275
  var b=a.slice(),c=b.splice(0,1)[0];// Skip malformed queue entries (empty array or non-string method) instead of
1270
1276
  // throwing an uncaught TypeError from method.split() below.
1271
1277
  if("string"==typeof c&&0!==c.length)// if the first argument is a method on the base mParticle object, run it
@@ -1464,7 +1470,7 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
1464
1470
  // attribute must be in the store before that happens so
1465
1471
  // appendUserInfo picks it up.
1466
1472
  null===(A=t._CookieConsentManager)||void 0===A||A.syncNoTargetingAttribute(y),n.sendUserIdentityChangeEvent(P,o,p.mpid,f);}if(a){var w=0===r.status?HTTPCodes$2.noHttpCoverage:r.status;t._Helpers.invokeCallback(a,w,p||null,y);}else p&&!isEmpty(p.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
1467
- t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(S=t._APIClient)||void 0===S||S.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.onIdentityComplete(),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
1473
+ t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(S=t._APIClient)||void 0===S||S.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.onIdentityComplete(),t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue,t.Logger);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
1468
1474
  {// https://go.mparticle.com/work/SQDSDKS-6354
1469
1475
  var a=this.IdentityAPI.getUser(s);for(var d in e)// Verifies a change actually happened
1470
1476
  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
@@ -1568,7 +1574,7 @@ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Bl
1568
1574
  var buildUrl=function(a,b,c,d){var e=d?"1":"0",f=["env=".concat(e)],g=c||{},h=g.planId,i=g.planVersion;return h&&f.push("plan_id=".concat(h)),i&&f.push("plan_version=".concat(i)),"".concat(a+b+"/config","?").concat(f.join("&"))};function ConfigAPIClient(a,b,c){var d=this,e="https://"+c._Store.SDKConfig.configUrl,f=b.isDevelopmentMode,g=b.dataPlan,h=buildUrl(e,a,g,f),i=window.fetch?new FetchUploader(h):new XHRUploader(h);this.getSDKConfiguration=function(){return __awaiter(d,void 0,void 0,function(){var a,d,e,f,h,j,k;return __generator(this,function(l){switch(l.label){case 0:d={method:"get",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"text/plain;charset=UTF-8"},body:null},l.label=1;case 1:return l.trys.push([1,6,,7]),[4/*yield*/,i.upload(d)];case 2:return (e=l.sent(),200!==e.status)?[3/*break*/,5]:(null===(h=null===c||void 0===c?void 0:c.Logger)||void 0===h?void 0:h.verbose("Successfully received configuration from server"),e.json?[4/*yield*/,e.json()]:[3/*break*/,4]);case 3:return a=l.sent(),[2/*return*/,a];case 4:return f=e,a=JSON.parse(f.responseText),[2/*return*/,a];case 5:return null===(j=null===c||void 0===c?void 0:c.Logger)||void 0===j?void 0:j.verbose("Issue with receiving configuration from server, received HTTP Code of "+e.statusText),[3/*break*/,7];case 6:return l.sent(),null===(k=null===c||void 0===c?void 0:c.Logger)||void 0===k?void 0:k.error("Error getting forwarder configuration from mParticle servers."),[3/*break*/,7];case 7:// Returns the original config object if we cannot retrieve the remote config
1569
1575
  return [2/*return*/,b]}})})};}
1570
1576
 
1571
- var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k,l;return __awaiter(this,void 0,void 0,function(){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,A,m,E,m,A,F;return __generator(this,function(G){switch(G.label){case 0:if((null===(i=a._RoktManager)||void 0===i?void 0:i.isInitialized)&&(a._Store.identifyRequestCount=(a._Store.identifyRequestCount||0)+1,m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestStart"))),n=a._Helpers.invokeCallback,o=a.Logger,p=a._ErrorReportingDispatcher,o.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return o.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(o.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return n(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];q=g||null,r=this.getUploadUrl(c,g),s=window.fetch?new FetchUploader(r):new XHRUploader(r),t={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,G.label=1;case 1:return G.trys.push([1,9,,10]),[4/*yield*/,s.upload(t)];case 2:return u=G.sent(),v=void 0,w=void 0,x=u.status,x===HTTP_ACCEPTED?[3/*break*/,3]:x===HTTP_OK?[3/*break*/,3]:x===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return u.json?[4/*yield*/,u.json()]:[3/*break*/,5];case 4:return y=G.sent(),v=this.getIdentityResponseFromFetch(u,y),[3/*break*/,6];case 5:v=this.getIdentityResponseFromXHR(u),G.label=6;case 6:return v.status===HTTP_BAD_REQUEST?(z=v.responseText,w="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+v.status,(null===z||void 0===z?void 0:z.Errors)&&(A=z.Errors.map(function(a){return a.message}).join(", "),w+=" - "+A)):o.isVerbose()&&(B=v.responseText,C=a._Store.SDKConfig.isDevelopmentMode,D=B,!C&&(null===B||void 0===B?void 0:B.matched_identities)&&(D=__assign(__assign({},B),{matched_identities:obfuscateData(B.matched_identities)})),w="Received Identity Response from server: "+JSON.stringify(D)),[3/*break*/,8];case 7:{if(u.status>=HTTP_SERVER_ERROR)throw new Error("Received HTTP Code of "+u.status);return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,A="Received HTTP Code of "+u.status,o.error("Error sending identity request to servers - "+A),n(d,HTTPCodes$1.noHttpCoverage,A),[2/*return*/]}case 8:return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,w&&o.verbose(w),(null===(j=a._RoktManager)||void 0===j?void 0:j.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),f(v,q,d,e,c,h,!1),[3/*break*/,10];case 9:return E=G.sent(),a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!0,(null===(k=a._RoktManager)||void 0===k?void 0:k.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),A=E.message||E.toString(),F="Error sending identity request to servers - "+A,o.error(F),null===p||void 0===p?void 0:p.report({message:F,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),null===(l=a.processQueueOnIdentityFailure)||void 0===l?void 0:l.call(a),n(d,HTTPCodes$1.noHttpCoverage,A),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
1577
+ var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=getErrorMessage(s),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k,l;return __awaiter(this,void 0,void 0,function(){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,A,m,E,m,A,F;return __generator(this,function(G){switch(G.label){case 0:if((null===(i=a._RoktManager)||void 0===i?void 0:i.isInitialized)&&(a._Store.identifyRequestCount=(a._Store.identifyRequestCount||0)+1,m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestStart"))),n=a._Helpers.invokeCallback,o=a.Logger,p=a._ErrorReportingDispatcher,o.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return o.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(o.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return n(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];q=g||null,r=this.getUploadUrl(c,g),s=window.fetch?new FetchUploader(r):new XHRUploader(r),t={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,G.label=1;case 1:return G.trys.push([1,9,,10]),[4/*yield*/,s.upload(t)];case 2:return u=G.sent(),v=void 0,w=void 0,x=u.status,x===HTTP_ACCEPTED?[3/*break*/,3]:x===HTTP_OK?[3/*break*/,3]:x===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return u.json?[4/*yield*/,u.json()]:[3/*break*/,5];case 4:return y=G.sent(),v=this.getIdentityResponseFromFetch(u,y),[3/*break*/,6];case 5:v=this.getIdentityResponseFromXHR(u),G.label=6;case 6:return v.status===HTTP_BAD_REQUEST?(z=v.responseText,w="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+v.status,(null===z||void 0===z?void 0:z.Errors)&&(A=z.Errors.map(function(a){return a.message}).join(", "),w+=" - "+A)):o.isVerbose()&&(B=v.responseText,C=a._Store.SDKConfig.isDevelopmentMode,D=B,!C&&(null===B||void 0===B?void 0:B.matched_identities)&&(D=__assign(__assign({},B),{matched_identities:obfuscateData(B.matched_identities)})),w="Received Identity Response from server: "+JSON.stringify(D)),[3/*break*/,8];case 7:{if(u.status>=HTTP_SERVER_ERROR)throw new Error("Received HTTP Code of "+u.status);return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,A="Received HTTP Code of "+u.status,o.error("Error sending identity request to servers - "+A),n(d,HTTPCodes$1.noHttpCoverage,A),[2/*return*/]}case 8:return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,w&&o.verbose(w),(null===(j=a._RoktManager)||void 0===j?void 0:j.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),f(v,q,d,e,c,h,!1),[3/*break*/,10];case 9:return E=G.sent(),a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!0,(null===(k=a._RoktManager)||void 0===k?void 0:k.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),A=getErrorMessage(E),F="Error sending identity request to servers - "+A,o.error(F),null===p||void 0===p?void 0:p.report({message:F,code:ErrorCodes.IDENTITY_REQUEST,severity:WSDKErrorSeverity.ERROR}),null===(l=a.processQueueOnIdentityFailure)||void 0===l?void 0:l.call(a),n(d,HTTPCodes$1.noHttpCoverage,A),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
1572
1578
 
1573
1579
  // The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
1574
1580
  // - version is always this prefix: fb
@@ -1618,12 +1624,12 @@ var PASSBACK_CONVERSION_TRACKING_ID="passbackconversiontrackingid",ON_SHOPPABLE_
1618
1624
  // as that is independent of this setting, though they share the same name.
1619
1625
  var s=(null===f||void 0===f?void 0:f.sandbox)||!1,t=normalizeRoktLauncherOptions(null===f||void 0===f?void 0:f.launcherOptions);// Launcher options are set here for the kit to pick up and pass through
1620
1626
  // to the Rokt Launcher.
1621
- this.launcherOptions=__assign({sandbox:s},t),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c,d,f;this.kit=a,(null===(b=a.settings)||void 0===b?void 0:b.accountId)&&this.store.setRoktAccountId(a.settings.accountId),a.integrationName&&(null===(c=this.store)||void 0===c?void 0:c.setIntegrationName(a.integrationName)),this.processMessageQueue();try{null===(d=this.onReadyCallback)||void 0===d?void 0:d.call(this);}catch(a){null===(f=this.logger)||void 0===f?void 0:f.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;return __awaiter(this,void 0,void 0,function(){var n,o,p,q,r,s,t,u,v,w,x,y,z,A,A,B,C,D,E,F,G,H,I=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
1627
+ this.launcherOptions=__assign({sandbox:s},t),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c,d,f;this.kit=a,(null===(b=a.settings)||void 0===b?void 0:b.accountId)&&this.store.setRoktAccountId(a.settings.accountId),a.integrationName&&(null===(c=this.store)||void 0===c?void 0:c.setIntegrationName(a.integrationName)),this.processMessageQueue();try{null===(d=this.onReadyCallback)||void 0===d?void 0:d.call(this);}catch(a){null===(f=this.logger)||void 0===f?void 0:f.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;return __awaiter(this,void 0,void 0,function(){var n,o,p,q,r,s,t,u,v,w,x,y,z,A,A,B,C,D,E,F,G,H=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
1622
1628
  if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];try{if(n=a.attributes,o=(null===n||void 0===n?void 0:n.sandbox)||null,p=this.mapPlacementAttributes(n,this.placementAttributesMapping),(null===(d=this.logger)||void 0===d?void 0:d.isVerbose())&&(q=obfuscateDevData(n,null===(f=null===(e=this.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode),this.logger.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(q,null,2)))),this.currentUser=this.identityService.getCurrentUser(),r=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},s=r.email,t=p.email,u=void 0,v=void 0,w=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),w&&(u=r[this.mappedEmailShaIdentityType],v=p.emailsha256||p[this.mappedEmailShaIdentityType]||void 0),x=this.hasIdentityChanged(s,t),y=this.hasIdentityChanged(u,v),z={},x&&(z.email=t,t&&(A="Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(i=this.errorReporter)||void 0===i?void 0:i.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING}))),y&&(z[this.mappedEmailShaIdentityType]=v,A="emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(j=this.errorReporter)||void 0===j?void 0:j.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING})),!isEmpty(z))// Fire-and-forget identify — best-effort, does not block selectPlacements
1623
- try{this.identityService.identify({userIdentities:__assign(__assign({},r),z)},function(a){var b=+(null===a||void 0===a?void 0:a.httpCode);b&&(400<=b||0>b)&&I.logger.error("Background identify failed with HTTP "+b),I.processMessageQueue();});}catch(a){B=a instanceof Error?a.message:JSON.stringify(a),this.logger.error("Background identify threw an error: "+B);}return C=__assign(__assign({},r),z),this.setUserAttributes(p),D=__assign(__assign({},p),null===o?{}:{sandbox:o}),C.email&&!D.email&&(D.email=C.email),w&&(E=C[this.mappedEmailShaIdentityType],E&&!D.emailsha256&&!D[this.mappedEmailShaIdentityType]&&(D.emailsha256=E)),D[PASSBACK_CONVERSION_TRACKING_ID]||(null===(k=this.integrationCapture)||void 0===k?void 0:k.capture(),F=null===(l=this.integrationCapture)||void 0===l?void 0:l.getClickIdsAsIntegrationAttributes(),G=null===(m=null===F||void 0===F?void 0:F[PARTNER_MODULE_IDS.Rokt])||void 0===m?void 0:m[PASSBACK_CONVERSION_TRACKING_ID],G&&(D[PASSBACK_CONVERSION_TRACKING_ID]=G)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,H=__assign(__assign({},a),{attributes:D}),[2/*return*/,this.kit.selectPlacements(H)]}catch(a){return [2/*return*/,Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))]}return [2/*return*/]})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:return (o.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(n,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=o.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=o.sent(),m=l instanceof Error?l.message:l+"",this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(m)),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",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.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.onShoppableAdsReady=function(a){if(!this.kit||!this.isShoppableAdsLoaded)return void this.deferredCall("onShoppableAdsReady",a);try{this.kit.onShoppableAdsReady(a);}catch(a){var b=a instanceof Error?a.message:a+"";this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(b));}},a.prototype.flushOnShoppableAdsReadyMessageQueue=function(a){var b=this;this.kit=a,this.messageQueue.forEach(function(c,d){var f;if(c.methodName===ON_SHOPPABLE_ADS_READY_METHOD){try{a.onShoppableAdsReady(c.payload);}catch(a){null===(f=b.logger)||void 0===f?void 0:f.error("RoktManager: Error flushing onShoppableAdsReady: "+a);}b.messageQueue["delete"](d);}}),this.isShoppableAdsLoaded=!0;},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];e.label=1;case 1:return e.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,e.sent()];case 3:return c=e.sent(),d=c instanceof Error?c.message:c+"",this.logger.error("Failed to hashSha256, returning undefined: ".concat(d)),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1629
+ try{this.identityService.identify({userIdentities:__assign(__assign({},r),z)},function(a){var b=+(null===a||void 0===a?void 0:a.httpCode);b&&(400<=b||0>b)&&H.logger.error("Background identify failed with HTTP "+b),H.processMessageQueue();});}catch(a){this.logger.error("Background identify threw an error: "+getErrorMessage(a));}return B=__assign(__assign({},r),z),this.setUserAttributes(p),C=__assign(__assign({},p),null===o?{}:{sandbox:o}),B.email&&!C.email&&(C.email=B.email),w&&(D=B[this.mappedEmailShaIdentityType],D&&!C.emailsha256&&!C[this.mappedEmailShaIdentityType]&&(C.emailsha256=D)),C[PASSBACK_CONVERSION_TRACKING_ID]||(null===(k=this.integrationCapture)||void 0===k?void 0:k.capture(),E=null===(l=this.integrationCapture)||void 0===l?void 0:l.getClickIdsAsIntegrationAttributes(),F=null===(m=null===E||void 0===E?void 0:E[PARTNER_MODULE_IDS.Rokt])||void 0===m?void 0:m[PASSBACK_CONVERSION_TRACKING_ID],F&&(C[PASSBACK_CONVERSION_TRACKING_ID]=F)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,G=__assign(__assign({},a),{attributes:C}),[2/*return*/,this.kit.selectPlacements(G)]}catch(a){return [2/*return*/,Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))]}return [2/*return*/]})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m=this;return __generator(this,function(n){switch(n.label){case 0:return (n.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(m,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=n.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=n.sent(),this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(getErrorMessage(l))),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",a);try{this.kit.setExtensionData(a);}catch(a){throw new Error("Error setting extension data: "+getErrorMessage(a))}},a.prototype.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.onShoppableAdsReady=function(a){if(!this.kit||!this.isShoppableAdsLoaded)return void this.deferredCall("onShoppableAdsReady",a);try{this.kit.onShoppableAdsReady(a);}catch(a){this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(getErrorMessage(a)));}},a.prototype.flushOnShoppableAdsReadyMessageQueue=function(a){var b=this;this.kit=a,this.messageQueue.forEach(function(c,d){var f;if(c.methodName===ON_SHOPPABLE_ADS_READY_METHOD){try{a.onShoppableAdsReady(c.payload);}catch(a){null===(f=b.logger)||void 0===f?void 0:f.error("RoktManager: Error flushing onShoppableAdsReady: "+a);}b.messageQueue["delete"](d);}}),this.isShoppableAdsLoaded=!0;},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c;return __generator(this,function(d){switch(d.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];d.label=1;case 1:return d.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,d.sent()];case 3:return c=d.sent(),this.logger.error("Failed to hashSha256, returning undefined: ".concat(getErrorMessage(c))),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
1624
1630
  return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)if(a.hasOwnProperty(d)&&-1===b.indexOf(d)){var e=a[d];c[d]=Array.isArray(e)?JSON.stringify(e):e;}try{this.currentUser.setUserAttributes(c);}catch(a){this.logger.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.onIdentityComplete=function(){this.isReady()&&(this.currentUser=this.identityService.getCurrentUser(),this.processMessageQueue());},a.prototype.processMessageQueue=function(){var a,b=this;if(this.isReady()&&0!==this.messageQueue.size){null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages"));var c=Array.from(this.messageQueue.values());// Clear the queue immediately to prevent re-processing
1625
1631
  this.messageQueue.clear(),c.forEach(function(a){var c,d,e,f;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));if(null===(d=b.logger)||void 0===d?void 0:d.isVerbose()){var g=obfuscateDevData(a.payload,null===(f=null===(e=b.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode);b.logger.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(g)));}// Capture resolve/reject functions before async processing
1626
- var h=a.resolve,i=a.reject,j=function(c){var d,e=c instanceof Error?c.message:c+"";null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(e)),i&&i(c);};try{var k=b[a.methodName](a.payload);// Handle both sync and async methods
1632
+ var h=a.resolve,i=a.reject,j=function(c){var d;null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(getErrorMessage(c))),i&&i(c);};try{var k=b[a.methodName](a.payload);// Handle both sync and async methods
1627
1633
  Promise.resolve(k).then(function(a){h&&h(a);})["catch"](j);}catch(a){j(a);}});}},a.prototype.queueMessage=function(a){this.messageQueue.set(a.messageId,a);},a.prototype.deferredCall=function(a,b){var c=this;return new Promise(function(d,e){var f="".concat(a,"_").concat(generateUniqueId());c.queueMessage({messageId:f,methodName:a,payload:b,resolve:d,reject:e});})},a.prototype.sha256Hex=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:return b=new TextEncoder,c=b.encode(a),[4/*yield*/,crypto.subtle.digest("SHA-256",c)];case 1:return d=e.sent(),[2/*return*/,this.arrayBufferToHex(d)]}})})},a.prototype.arrayBufferToHex=function(a){for(var b,c=new Uint8Array(a),d="",e=0;e<c.length;e++)b=c[e].toString(16).padStart(2,"0"),d+=b;return d},a.prototype.hasIdentityChanged=function(a,b){return !!b&&(!a||a!==b);// Values are the same
1628
1634
  },a}();// The purpose of this class is to create a link between the Core mParticle SDK and the
1629
1635
 
@@ -1656,7 +1662,7 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
1656
1662
  *
1657
1663
  * @class mParticle & mParticleInstance
1658
1664
  */function mParticleInstance(a){var b=this;// These classes are for internal use only. Not documented for public consumption
1659
- this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._ErrorReportingDispatcher=new ErrorReportingDispatcher,this._LoggingDispatcher=new LoggingDispatcher,this._RoktManager=new RoktManager,this._RoktManager.setOnReadyCallback(function(){b.processQueueOnIdentityFailure();}),this.processQueueOnIdentityFailure=function(){var a,c,d;(null===(a=b._Store)||void 0===a?void 0:a.isInitialized)||(null===(c=b._Store)||void 0===c?void 0:c.identityCallFailed)&&(null===(d=b._RoktManager)||void 0===d?void 0:d.isReady())&&(b._RoktManager.processMessageQueue(),b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue));},this.processQueueOnNoFunctional=function(){var a,c;if(!(null!==(a=b._Store)&&void 0!==a)||!a.isInitialized){var d=(null===(c=b._CookieConsentManager)||void 0===c?void 0:c.getNoFunctional())&&!hasExplicitIdentifier(b._Store);d&&(b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue));}},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this.RoktEvents=RoktEvents,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
1665
+ this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._ErrorReportingDispatcher=new ErrorReportingDispatcher,this._LoggingDispatcher=new LoggingDispatcher,this._RoktManager=new RoktManager,this._RoktManager.setOnReadyCallback(function(){b.processQueueOnIdentityFailure();}),this.processQueueOnIdentityFailure=function(){var a,c,d;(null===(a=b._Store)||void 0===a?void 0:a.isInitialized)||(null===(c=b._Store)||void 0===c?void 0:c.identityCallFailed)&&(null===(d=b._RoktManager)||void 0===d?void 0:d.isReady())&&(b._RoktManager.processMessageQueue(),b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue,b.Logger));},this.processQueueOnNoFunctional=function(){var a,c;if(!(null!==(a=b._Store)&&void 0!==a)||!a.isInitialized){var d=(null===(c=b._CookieConsentManager)||void 0===c?void 0:c.getNoFunctional())&&!hasExplicitIdentifier(b._Store);d&&(b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue,b.Logger));}},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this.RoktEvents=RoktEvents,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
1660
1666
  // Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
1661
1667
  // to it for it to be run after fetched
1662
1668
  if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c._ErrorReportingDispatcher=new ErrorReportingDispatcher,c._LoggingDispatcher=new LoggingDispatcher,c.Logger=new Logger(a),c._ErrorReportingDispatcher.logger=c.Logger,c._LoggingDispatcher.logger=c.Logger,c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){var c,d,e,f=(null===(c=b._CookieConsentManager)||void 0===c?void 0:c.getNoFunctional())&&!hasExplicitIdentifier(b._Store),g=isFunction(a)&&((null===(d=b._Store)||void 0===d?void 0:d.isInitialized)||(null===(e=b._Store)||void 0===e?void 0:e.identityCallFailed)&&b._RoktManager.isReady()||f);g?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
@@ -1823,7 +1829,7 @@ var m=i(CaptureIntegrationSpecificIds),n=i(CaptureIntegrationSpecificIdsV2),o=n&
1823
1829
  var q=parseConfig(b,"Rokt",181);if(q){var r=null===(e=q.settings)||void 0===e?void 0:e.accountId;c._Store.setRoktAccountId(r);var s=q.userAttributeFilters,t=filteredMparticleUser(k,{userAttributeFilters:s},c),u={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};// https://go.mparticle.com/work/SQDSDKS-7339
1824
1830
  c._RoktManager.init(q,t,c.Identity,c._Store,c.Logger,u,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher,c._IntegrationCapture);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,j,k,l);}// We will continue to clear out the ready queue as part of the initial init flow
1825
1831
  // if an identify request is unnecessary, such as if there is an existing session
1826
- (c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,null===(f=c._CookieConsentManager)||void 0===f?void 0:f.syncNoTargetingAttribute(c.Identity.getCurrentUser()),c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),null===(g=c.processQueueOnNoFunctional)||void 0===g?void 0:g.call(c),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
1832
+ (c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,null===(f=c._CookieConsentManager)||void 0===f?void 0:f.syncNoTargetingAttribute(c.Identity.getCurrentUser()),c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue,c.Logger)),null===(g=c.processQueueOnNoFunctional)||void 0===g?void 0:g.call(c),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
1827
1833
  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:
1828
1834
  1. Manually via config.dataPlanOptions (this takes priority)
1829
1835
  If not passed in manually, we user the server provided via either
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.73.0";
206
+ var version = "2.73.1";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -1013,6 +1013,22 @@ var mParticle = (function () {
1013
1013
  }
1014
1014
  return target;
1015
1015
  }
1016
+ var getErrorMessage = function getErrorMessage(e, fallback) {
1017
+ if (fallback === void 0) {
1018
+ fallback = 'unknown error';
1019
+ }
1020
+ if (e instanceof Error) {
1021
+ return e.message;
1022
+ }
1023
+ if (typeof e === 'string') {
1024
+ return e;
1025
+ }
1026
+ // fetch-mock and some network libs reject with { message } rather than Error
1027
+ if (e && _typeof$1(e) === 'object' && typeof e.message === 'string') {
1028
+ return e.message;
1029
+ }
1030
+ return fallback;
1031
+ };
1016
1032
 
1017
1033
  var MessageType$1 = {
1018
1034
  SessionStart: 1,
@@ -3234,7 +3250,7 @@ var mParticle = (function () {
3234
3250
  try {
3235
3251
  callback(result);
3236
3252
  } catch (e) {
3237
- logger.error('Error invoking search callback: ' + ((e === null || e === void 0 ? void 0 : e.message) || String(e)));
3253
+ logger.error('Error invoking search callback: ' + getErrorMessage(e));
3238
3254
  }
3239
3255
  };
3240
3256
  cleanedKnownIdentities = Validators.removeFalsyIdentityValues({
@@ -3323,7 +3339,7 @@ var mParticle = (function () {
3323
3339
  return [3 /*break*/, 10];
3324
3340
  case 9:
3325
3341
  e_2 = _a.sent();
3326
- message = (e_2 === null || e_2 === void 0 ? void 0 : e_2.message) || String(e_2);
3342
+ message = getErrorMessage(e_2);
3327
3343
  reportMessage = 'Error sending search request: ' + message;
3328
3344
  logger.error(reportMessage);
3329
3345
  // Mirror the identity-route pattern in identityApiClient.ts: log to
@@ -3589,7 +3605,7 @@ var mParticle = (function () {
3589
3605
  httpCode: HTTPCodes$3.loggingDisabledOrMissingAPIKey
3590
3606
  });
3591
3607
  } catch (e) {
3592
- Logger.error('Error invoking search callback: ' + ((e === null || e === void 0 ? void 0 : e.message) || String(e)));
3608
+ Logger.error('Error invoking search callback: ' + getErrorMessage(e));
3593
3609
  }
3594
3610
  }
3595
3611
  return;
@@ -7911,25 +7927,36 @@ var mParticle = (function () {
7911
7927
  return AudienceManager;
7912
7928
  }();
7913
7929
 
7914
- var processReadyQueue = function processReadyQueue(readyQueue) {
7915
- if (!isEmpty(readyQueue)) {
7916
- readyQueue.forEach(function (readyQueueItem) {
7930
+ var processReadyQueue = function processReadyQueue(readyQueue, logger) {
7931
+ if (isEmpty(readyQueue)) {
7932
+ return [];
7933
+ }
7934
+ // Without draining first, sync re-entry (cache-hit identify →
7935
+ // parseIdentityResponse → processReadyQueue) re-iterates the same array:
7936
+ // callers only replace `_preInit.readyQueue` with [] after we return, so the
7937
+ // nested call still sees every entry. That duplicates Identity/event calls
7938
+ // and can nest "Unable to compute proper mParticle function" wraps.
7939
+ // Splice the queue empty up front so a nested call observes [].
7940
+ var items = readyQueue.splice(0, readyQueue.length);
7941
+ // Isolate each item so one throw cannot abort the rest of this pass.
7942
+ // Drain-first already removed siblings from the shared queue; without a
7943
+ // per-item catch they would be lost forever when forEach aborts.
7944
+ items.forEach(function (readyQueueItem) {
7945
+ try {
7917
7946
  if (isFunction(readyQueueItem)) {
7918
7947
  readyQueueItem();
7919
7948
  } else if (Array.isArray(readyQueueItem)) {
7920
7949
  processPreloadedItem(readyQueueItem);
7921
7950
  }
7922
- });
7923
- }
7951
+ } catch (e) {
7952
+ logger.error('Error processing ready queue item: ' + getErrorMessage(e));
7953
+ }
7954
+ });
7924
7955
  return [];
7925
7956
  };
7926
7957
  var processPreloadedItem = function processPreloadedItem(readyQueueItem) {
7927
- // Operate on a copy of the queued item. The ready queue can be drained more
7928
- // than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
7929
- // before the outer drain resets the queue). Splicing the shared item array in
7930
- // place would corrupt it on the second pass — ["Identity.login", opts] becomes
7931
- // [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
7932
- // throws. Copying keeps the original item intact for any repeat pass.
7958
+ // Operate on a copy so processPreloadedItem never mutates the caller's
7959
+ // queued item array (defensive; the queue itself is drained above).
7933
7960
  var args = readyQueueItem.slice();
7934
7961
  var method = args.splice(0, 1)[0];
7935
7962
  // Skip malformed queue entries (empty array or non-string method) instead of
@@ -8949,7 +8976,7 @@ var mParticle = (function () {
8949
8976
  }
8950
8977
  mpInstance._Store.isInitialized = true;
8951
8978
  mpInstance._RoktManager.onIdentityComplete();
8952
- mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
8979
+ mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue, mpInstance.Logger);
8953
8980
  };
8954
8981
 
8955
8982
  // send a user identity change request on identify, login, logout, modify when any values change.
@@ -9975,7 +10002,7 @@ var mParticle = (function () {
9975
10002
  return [3 /*break*/, 14];
9976
10003
  case 13:
9977
10004
  e_2 = _b.sent();
9978
- errorMessage = e_2.message || e_2.toString();
10005
+ errorMessage = getErrorMessage(e_2);
9979
10006
  Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
9980
10007
  invokeAliasCallback(aliasCallback, HTTPCodes$1.noHttpCoverage, errorMessage);
9981
10008
  return [3 /*break*/, 14];
@@ -10107,7 +10134,7 @@ var mParticle = (function () {
10107
10134
  requestCount = mpInstance._Store.identifyRequestCount;
10108
10135
  mpInstance.captureTiming("".concat(requestCount, "-identityRequestEnd"));
10109
10136
  }
10110
- errorMessage = err_1.message || err_1.toString();
10137
+ errorMessage = getErrorMessage(err_1);
10111
10138
  msg = 'Error sending identity request to servers' + ' - ' + errorMessage;
10112
10139
  Logger.error(msg);
10113
10140
  errorReporter === null || errorReporter === void 0 ? void 0 : errorReporter.report({
@@ -10576,7 +10603,7 @@ var mParticle = (function () {
10576
10603
  RoktManager.prototype.selectPlacements = function (options) {
10577
10604
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
10578
10605
  return __awaiter(this, void 0, void 0, function () {
10579
- var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg, errorMessage, finalUserIdentities, enrichedAttributes, hashedEmail, capturedAttrs, passbackId, enrichedOptions;
10606
+ var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg, finalUserIdentities, enrichedAttributes, hashedEmail, capturedAttrs, passbackId, enrichedOptions;
10580
10607
  var _this = this;
10581
10608
  return __generator(this, function (_o) {
10582
10609
  (_a = this.captureTiming) === null || _a === void 0 ? void 0 : _a.call(this, PerformanceMarkType.JointSdkSelectPlacements);
@@ -10644,8 +10671,7 @@ var mParticle = (function () {
10644
10671
  _this.processMessageQueue();
10645
10672
  });
10646
10673
  } catch (error) {
10647
- errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
10648
- this.logger.error('Background identify threw an error: ' + errorMessage);
10674
+ this.logger.error('Background identify threw an error: ' + getErrorMessage(error));
10649
10675
  }
10650
10676
  }
10651
10677
  finalUserIdentities = __assign(__assign({}, currentUserIdentities), newIdentities);
@@ -10695,7 +10721,7 @@ var mParticle = (function () {
10695
10721
  */
10696
10722
  RoktManager.prototype.hashAttributes = function (attributes) {
10697
10723
  return __awaiter(this, void 0, void 0, function () {
10698
- var keys, hashPromises, results, hashedAttributes, _i, results_1, _a, key, attributeValue, hashedValue, error_1, errorMessage;
10724
+ var keys, hashPromises, results, hashedAttributes, _i, results_1, _a, key, attributeValue, hashedValue, error_1;
10699
10725
  var _this = this;
10700
10726
  return __generator(this, function (_b) {
10701
10727
  switch (_b.label) {
@@ -10741,8 +10767,7 @@ var mParticle = (function () {
10741
10767
  return [2 /*return*/, hashedAttributes];
10742
10768
  case 2:
10743
10769
  error_1 = _b.sent();
10744
- errorMessage = error_1 instanceof Error ? error_1.message : String(error_1);
10745
- this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(errorMessage));
10770
+ this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(getErrorMessage(error_1)));
10746
10771
  return [2 /*return*/, {}];
10747
10772
  case 3:
10748
10773
  return [2 /*return*/];
@@ -10759,8 +10784,7 @@ var mParticle = (function () {
10759
10784
  try {
10760
10785
  this.kit.setExtensionData(extensionData);
10761
10786
  } catch (error) {
10762
- var errorMessage = error instanceof Error ? error.message : String(error);
10763
- throw new Error('Error setting extension data: ' + errorMessage);
10787
+ throw new Error('Error setting extension data: ' + getErrorMessage(error));
10764
10788
  }
10765
10789
  };
10766
10790
  RoktManager.prototype.use = function (name) {
@@ -10781,8 +10805,7 @@ var mParticle = (function () {
10781
10805
  try {
10782
10806
  this.kit.onShoppableAdsReady(callback);
10783
10807
  } catch (error) {
10784
- var errorMessage = error instanceof Error ? error.message : String(error);
10785
- this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(errorMessage));
10808
+ this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(getErrorMessage(error)));
10786
10809
  }
10787
10810
  };
10788
10811
  RoktManager.prototype.flushOnShoppableAdsReadyMessageQueue = function (kit) {
@@ -10810,7 +10833,7 @@ var mParticle = (function () {
10810
10833
  */
10811
10834
  RoktManager.prototype.hashSha256 = function (attribute) {
10812
10835
  return __awaiter(this, void 0, void 0, function () {
10813
- var normalizedValue, error_2, errorMessage;
10836
+ var normalizedValue, error_2;
10814
10837
  return __generator(this, function (_a) {
10815
10838
  switch (_a.label) {
10816
10839
  case 0:
@@ -10827,8 +10850,7 @@ var mParticle = (function () {
10827
10850
  return [2 /*return*/, _a.sent()];
10828
10851
  case 3:
10829
10852
  error_2 = _a.sent();
10830
- errorMessage = error_2 instanceof Error ? error_2.message : String(error_2);
10831
- this.logger.error("Failed to hashSha256, returning undefined: ".concat(errorMessage));
10853
+ this.logger.error("Failed to hashSha256, returning undefined: ".concat(getErrorMessage(error_2)));
10832
10854
  return [2 /*return*/, undefined];
10833
10855
  case 4:
10834
10856
  return [2 /*return*/];
@@ -10909,8 +10931,7 @@ var mParticle = (function () {
10909
10931
  var reject = message.reject;
10910
10932
  var handleError = function handleError(error) {
10911
10933
  var _a;
10912
- var errorMessage = error instanceof Error ? error.message : String(error);
10913
- (_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(errorMessage));
10934
+ (_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(getErrorMessage(error)));
10914
10935
  if (reject) {
10915
10936
  reject(error);
10916
10937
  }
@@ -11148,7 +11169,7 @@ var mParticle = (function () {
11148
11169
  }
11149
11170
  if (((_b = self._Store) === null || _b === void 0 ? void 0 : _b.identityCallFailed) && ((_c = self._RoktManager) === null || _c === void 0 ? void 0 : _c.isReady())) {
11150
11171
  self._RoktManager.processMessageQueue();
11151
- self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
11172
+ self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue, self.Logger);
11152
11173
  }
11153
11174
  };
11154
11175
  /**
@@ -11161,7 +11182,7 @@ var mParticle = (function () {
11161
11182
  }
11162
11183
  var noFunctionalWithoutId = ((_b = self._CookieConsentManager) === null || _b === void 0 ? void 0 : _b.getNoFunctional()) && !hasExplicitIdentifier(self._Store);
11163
11184
  if (noFunctionalWithoutId) {
11164
- self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
11185
+ self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue, self.Logger);
11165
11186
  }
11166
11187
  };
11167
11188
  // required for forwarders once they reference the mparticle instance
@@ -12178,7 +12199,7 @@ var mParticle = (function () {
12178
12199
  // Sync $NoTargeting user attribute on re-init when no identity call is made
12179
12200
  // if for some reason there was a change in boolean between init calls
12180
12201
  (_c = mpInstance._CookieConsentManager) === null || _c === void 0 ? void 0 : _c.syncNoTargetingAttribute(mpInstance.Identity.getCurrentUser());
12181
- mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
12202
+ mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue, mpInstance.Logger);
12182
12203
  }
12183
12204
  // For noFunctional sessions with no identity, drain any pre-init ready callbacks
12184
12205
  // that were queued before _CookieConsentManager was available to evaluate the condition.
@@ -1,6 +1,7 @@
1
1
  import { IPixelConfiguration } from './cookieSyncManager';
2
2
  import { MPForwarder } from './forwarders.interfaces';
3
3
  import { IntegrationDelays } from './mp-instance';
4
+ import { SDKLoggerApi } from './sdkRuntimeModels';
4
5
  export interface IPreInit {
5
6
  readyQueue: Function[] | any[];
6
7
  integrationDelays: IntegrationDelays;
@@ -8,4 +9,4 @@ export interface IPreInit {
8
9
  pixelConfigurations?: IPixelConfiguration[];
9
10
  isDevelopmentMode?: boolean;
10
11
  }
11
- export declare const processReadyQueue: (readyQueue: any) => Function[];
12
+ export declare const processReadyQueue: (readyQueue: any, logger: SDKLoggerApi) => Function[];
@@ -80,4 +80,5 @@ declare const obfuscateData: (value: any) => any;
80
80
  */
81
81
  declare const obfuscateDevData: (data: any, isDevelopmentMode?: boolean) => any;
82
82
  declare function extend(...args: any[]): any;
83
- export { createCookieString, revertCookieString, createCookieSyncUrl, valueof, AttributeValue, converted, decoded, obfuscateDevData, filterDictionaryWithHash, findKeyInObject, generateDeprecationMessage, generateHash, generateUniqueId, getRampNumber, inArray, isObject, isStringOrNumber, obfuscateData, parseConfig, parseNumber, parseSettingsString, parseStringOrNumber, replaceCommasWithPipes, replacePipesWithCommas, replaceApostrophesWithQuotes, replaceQuotesWithApostrophes, returnConvertedBoolean, toDataPlanSlug, isString, isNumber, isFunction, isDataPlanSlug, isEmpty, isValidAttributeValue, isValidCustomFlagProperty, mergeObjects, moveElementToEnd, queryStringParser, getCookies, getHref, replaceMPID, replaceAmpWithAmpersand, extend, };
83
+ declare const getErrorMessage: (e: unknown, fallback?: string) => string;
84
+ export { createCookieString, revertCookieString, createCookieSyncUrl, valueof, AttributeValue, converted, decoded, obfuscateDevData, filterDictionaryWithHash, findKeyInObject, generateDeprecationMessage, generateHash, generateUniqueId, getErrorMessage, getRampNumber, inArray, isObject, isStringOrNumber, obfuscateData, parseConfig, parseNumber, parseSettingsString, parseStringOrNumber, replaceCommasWithPipes, replacePipesWithCommas, replaceApostrophesWithQuotes, replaceQuotesWithApostrophes, returnConvertedBoolean, toDataPlanSlug, isString, isNumber, isFunction, isDataPlanSlug, isEmpty, isValidAttributeValue, isValidCustomFlagProperty, mergeObjects, moveElementToEnd, queryStringParser, getCookies, getHref, replaceMPID, replaceAmpWithAmpersand, extend, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.73.0",
3
+ "version": "2.73.1",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  import Constants, { HTTP_OK, HTTP_NOT_FOUND } from '../constants';
2
2
  import { SDKLoggerApi } from '../sdkRuntimeModels';
3
- import { Environment, isFunction } from '../utils';
3
+ import { Environment, isFunction, getErrorMessage } from '../utils';
4
4
  import {
5
5
  AsyncUploader,
6
6
  FetchUploader,
@@ -111,8 +111,7 @@ export const sendSearchRequest = async (
111
111
  callback(result);
112
112
  } catch (e) {
113
113
  logger.error(
114
- 'Error invoking search callback: ' +
115
- ((e as Error)?.message || String(e)),
114
+ 'Error invoking search callback: ' + getErrorMessage(e),
116
115
  );
117
116
  }
118
117
  };
@@ -216,7 +215,7 @@ export const sendSearchRequest = async (
216
215
 
217
216
  safeInvoke({ httpCode: response.status, body });
218
217
  } catch (e) {
219
- const message = (e as Error)?.message || String(e);
218
+ const message = getErrorMessage(e);
220
219
  const reportMessage = 'Error sending search request: ' + message;
221
220
  logger.error(reportMessage);
222
221
  // Mirror the identity-route pattern in identityApiClient.ts: log to
@@ -1,5 +1,5 @@
1
1
  import Constants, { ONE_DAY_IN_SECONDS, MILLIS_IN_ONE_SEC } from './constants';
2
- import { Dictionary, Environment, parseNumber, isObject, generateHash, generateUniqueId, isEmpty, isFunction } from './utils';
2
+ import { Dictionary, Environment, parseNumber, isObject, generateHash, generateUniqueId, isEmpty, isFunction, getErrorMessage } from './utils';
3
3
  import { BaseVault } from './vault';
4
4
  import Types from './types';
5
5
  import {
@@ -414,8 +414,7 @@ export const executeSearchRequest = (
414
414
  });
415
415
  } catch (e) {
416
416
  Logger.error(
417
- 'Error invoking search callback: ' +
418
- ((e as Error)?.message || String(e)),
417
+ 'Error invoking search callback: ' + getErrorMessage(e),
419
418
  );
420
419
  }
421
420
  }
package/src/identity.js CHANGED
@@ -1657,7 +1657,8 @@ export default function Identity(mpInstance) {
1657
1657
  mpInstance._RoktManager.onIdentityComplete();
1658
1658
 
1659
1659
  mpInstance._preInit.readyQueue = processReadyQueue(
1660
- mpInstance._preInit.readyQueue
1660
+ mpInstance._preInit.readyQueue,
1661
+ mpInstance.Logger
1661
1662
  );
1662
1663
  };
1663
1664
 
@@ -6,7 +6,7 @@ import {
6
6
  IFetchPayload,
7
7
  } from './uploaders';
8
8
  import { CACHE_HEADER } from './identity-utils';
9
- import { obfuscateData, parseNumber, valueof } from './utils';
9
+ import { obfuscateData, parseNumber, valueof, getErrorMessage } from './utils';
10
10
  import {
11
11
  IAliasCallback,
12
12
  IAliasRequest,
@@ -175,7 +175,7 @@ export default function IdentityAPIClient(
175
175
  Logger.verbose(message);
176
176
  invokeAliasCallback(aliasCallback, response.status, errorMessage);
177
177
  } catch (e) {
178
- const errorMessage = (e as Error).message || e.toString();
178
+ const errorMessage = getErrorMessage(e);
179
179
  Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
180
180
  invokeAliasCallback(
181
181
  aliasCallback,
@@ -338,7 +338,7 @@ export default function IdentityAPIClient(
338
338
  mpInstance.captureTiming(`${requestCount}-identityRequestEnd`);
339
339
  }
340
340
 
341
- const errorMessage = (err as Error).message || err.toString();
341
+ const errorMessage = getErrorMessage(err);
342
342
  const msg = 'Error sending identity request to servers' + ' - ' + errorMessage;
343
343
  Logger.error(msg);
344
344
  errorReporter?.report({
@@ -162,7 +162,10 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
162
162
 
163
163
  if (self._Store?.identityCallFailed && self._RoktManager?.isReady()) {
164
164
  self._RoktManager.processMessageQueue();
165
- self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
165
+ self._preInit.readyQueue = processReadyQueue(
166
+ self._preInit.readyQueue,
167
+ self.Logger
168
+ );
166
169
  }
167
170
  };
168
171
 
@@ -179,7 +182,10 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
179
182
  !hasExplicitIdentifier(self._Store);
180
183
 
181
184
  if (noFunctionalWithoutId) {
182
- self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
185
+ self._preInit.readyQueue = processReadyQueue(
186
+ self._preInit.readyQueue,
187
+ self.Logger
188
+ );
183
189
  }
184
190
  };
185
191
 
@@ -1599,7 +1605,8 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1599
1605
  );
1600
1606
 
1601
1607
  mpInstance._preInit.readyQueue = processReadyQueue(
1602
- mpInstance._preInit.readyQueue
1608
+ mpInstance._preInit.readyQueue,
1609
+ mpInstance.Logger
1603
1610
  );
1604
1611
  }
1605
1612
 
@@ -1,7 +1,8 @@
1
1
  import { IPixelConfiguration } from './cookieSyncManager';
2
2
  import { MPForwarder } from './forwarders.interfaces';
3
3
  import { IntegrationDelays } from './mp-instance';
4
- import { isEmpty, isFunction } from './utils';
4
+ import { SDKLoggerApi } from './sdkRuntimeModels';
5
+ import { isEmpty, isFunction, getErrorMessage } from './utils';
5
6
 
6
7
  export interface IPreInit {
7
8
  readyQueue: Function[] | any[];
@@ -11,26 +12,45 @@ export interface IPreInit {
11
12
  isDevelopmentMode?: boolean;
12
13
  }
13
14
 
14
- export const processReadyQueue = (readyQueue): Function[] => {
15
- if (!isEmpty(readyQueue)) {
16
- readyQueue.forEach(readyQueueItem => {
15
+ export const processReadyQueue = (
16
+ readyQueue,
17
+ logger: SDKLoggerApi
18
+ ): Function[] => {
19
+ if (isEmpty(readyQueue)) {
20
+ return [];
21
+ }
22
+
23
+ // Without draining first, sync re-entry (cache-hit identify →
24
+ // parseIdentityResponse → processReadyQueue) re-iterates the same array:
25
+ // callers only replace `_preInit.readyQueue` with [] after we return, so the
26
+ // nested call still sees every entry. That duplicates Identity/event calls
27
+ // and can nest "Unable to compute proper mParticle function" wraps.
28
+ // Splice the queue empty up front so a nested call observes [].
29
+ const items = readyQueue.splice(0, readyQueue.length);
30
+
31
+ // Isolate each item so one throw cannot abort the rest of this pass.
32
+ // Drain-first already removed siblings from the shared queue; without a
33
+ // per-item catch they would be lost forever when forEach aborts.
34
+ items.forEach(readyQueueItem => {
35
+ try {
17
36
  if (isFunction(readyQueueItem)) {
18
37
  readyQueueItem();
19
38
  } else if (Array.isArray(readyQueueItem)) {
20
39
  processPreloadedItem(readyQueueItem);
21
40
  }
22
- });
23
- }
41
+ } catch (e) {
42
+ logger.error(
43
+ 'Error processing ready queue item: ' + getErrorMessage(e)
44
+ );
45
+ }
46
+ });
47
+
24
48
  return [];
25
49
  };
26
50
 
27
51
  const processPreloadedItem = (readyQueueItem): void => {
28
- // Operate on a copy of the queued item. The ready queue can be drained more
29
- // than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
30
- // before the outer drain resets the queue). Splicing the shared item array in
31
- // place would corrupt it on the second pass — ["Identity.login", opts] becomes
32
- // [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
33
- // throws. Copying keeps the original item intact for any repeat pass.
52
+ // Operate on a copy so processPreloadedItem never mutates the caller's
53
+ // queued item array (defensive; the queue itself is drained above).
34
54
  const args = readyQueueItem.slice();
35
55
  const method = args.splice(0, 1)[0];
36
56
 
@@ -10,6 +10,7 @@ import {
10
10
  AttributeValue,
11
11
  isEmpty,
12
12
  obfuscateDevData,
13
+ getErrorMessage,
13
14
  } from "./utils";
14
15
  import { SDKIdentityApi } from "./identity.interfaces";
15
16
  import { SDKLoggerApi } from "./sdkRuntimeModels";
@@ -338,8 +339,10 @@ export default class RoktManager {
338
339
  }
339
340
  );
340
341
  } catch (error) {
341
- const errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
342
- this.logger.error('Background identify threw an error: ' + errorMessage);
342
+ this.logger.error(
343
+ 'Background identify threw an error: ' +
344
+ getErrorMessage(error)
345
+ );
343
346
  }
344
347
  }
345
348
 
@@ -437,8 +440,9 @@ export default class RoktManager {
437
440
  return hashedAttributes;
438
441
 
439
442
  } catch (error) {
440
- const errorMessage = error instanceof Error ? error.message : String(error);
441
- this.logger.error(`Failed to hashAttributes, returning an empty object: ${errorMessage}`);
443
+ this.logger.error(
444
+ `Failed to hashAttributes, returning an empty object: ${getErrorMessage(error)}`
445
+ );
442
446
  return {};
443
447
  }
444
448
  }
@@ -452,8 +456,9 @@ export default class RoktManager {
452
456
  try {
453
457
  this.kit.setExtensionData<T>(extensionData);
454
458
  } catch (error) {
455
- const errorMessage = error instanceof Error ? error.message : String(error);
456
- throw new Error('Error setting extension data: ' + errorMessage);
459
+ throw new Error(
460
+ 'Error setting extension data: ' + getErrorMessage(error)
461
+ );
457
462
  }
458
463
  }
459
464
 
@@ -478,8 +483,9 @@ export default class RoktManager {
478
483
  try {
479
484
  this.kit.onShoppableAdsReady(callback);
480
485
  } catch (error) {
481
- const errorMessage = error instanceof Error ? error.message : String(error);
482
- this.logger.error(`Failed to register onShoppableAdsReady callback: ${errorMessage}`);
486
+ this.logger.error(
487
+ `Failed to register onShoppableAdsReady callback: ${getErrorMessage(error)}`
488
+ );
483
489
  }
484
490
  }
485
491
 
@@ -517,8 +523,9 @@ export default class RoktManager {
517
523
  const normalizedValue = String(attribute).trim().toLocaleLowerCase();
518
524
  return await this.sha256Hex(normalizedValue);
519
525
  } catch (error) {
520
- const errorMessage = error instanceof Error ? error.message : String(error);
521
- this.logger.error(`Failed to hashSha256, returning undefined: ${errorMessage}`);
526
+ this.logger.error(
527
+ `Failed to hashSha256, returning undefined: ${getErrorMessage(error)}`
528
+ );
522
529
  return undefined;
523
530
  }
524
531
  }
@@ -607,8 +614,9 @@ export default class RoktManager {
607
614
  const reject = message.reject;
608
615
 
609
616
  const handleError = (error: unknown) => {
610
- const errorMessage = error instanceof Error ? error.message : String(error);
611
- this.logger?.error(`RoktManager: Error processing message '${message.methodName}': ${errorMessage}`);
617
+ this.logger?.error(
618
+ `RoktManager: Error processing message '${message.methodName}': ${getErrorMessage(error)}`
619
+ );
612
620
  if (reject) {
613
621
  reject(error);
614
622
  }
package/src/utils.ts CHANGED
@@ -625,6 +625,27 @@ function extend(...args: any[]): any {
625
625
  return target;
626
626
  }
627
627
 
628
+ const getErrorMessage = (
629
+ e: unknown,
630
+ fallback = 'unknown error'
631
+ ): string => {
632
+ if (e instanceof Error) {
633
+ return e.message;
634
+ }
635
+ if (typeof e === 'string') {
636
+ return e;
637
+ }
638
+ // fetch-mock and some network libs reject with { message } rather than Error
639
+ if (
640
+ e &&
641
+ typeof e === 'object' &&
642
+ typeof (e as { message?: unknown }).message === 'string'
643
+ ) {
644
+ return (e as { message: string }).message;
645
+ }
646
+ return fallback;
647
+ };
648
+
628
649
  export {
629
650
  createCookieString,
630
651
  revertCookieString,
@@ -639,6 +660,7 @@ export {
639
660
  generateDeprecationMessage,
640
661
  generateHash,
641
662
  generateUniqueId,
663
+ getErrorMessage,
642
664
  getRampNumber,
643
665
  inArray,
644
666
  isObject,