@mparticle/web-sdk 3.11.1 → 3.12.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.
package/README.md CHANGED
@@ -171,16 +171,17 @@ workflows in order:
171
171
  immutable tag and resumes kits without republishing core.
172
172
  2. **Staging Release - Step 2: Publish SDK Release to Release Order Branch**
173
173
  (`staging-step-2.yml`, optional): select `master` for v2 or `main` for v3.
174
- The source-ref guard accepts either `master` or `main`, but use the track's
175
- matching trunk. For `releaseTag`, enter the exact Git tag created by the
176
- successful Step 1 run (for example, `v2.80.0` or `v3.0.1`). Choose
174
+ Every run, dry runs included, rejects a `v2.x` tag dispatched from anything
175
+ but `master` and a `v3.x` tag from anything but `main`. For `releaseTag`,
176
+ enter the exact Git tag created by the successful Step 1 run (for example,
177
+ `v2.80.0` or `v3.0.1`). Choose
177
178
  `release-order-a`, `-b`, or `-c` as `releaseOrderBranch`. For v3, that
178
179
  logical choice maps to the corresponding `v3-release-order-*` branch.
179
180
  `dryRun=true` validates the exact candidate and fast-forward without
180
181
  pushing; `dryRun=false` promotes it.
181
182
  3. **Staging Release - Step 3: Release to CDN and Synchronize Branches**
182
- (`staging-step-3.yml`): select `master` for v2 or `main` for v3 (the
183
- source-ref guard accepts either). For `releaseTag`, enter the same exact Git
183
+ (`staging-step-3.yml`): select `master` for v2 or `main` for v3, with the
184
+ same per-track rule as Step 2. For `releaseTag`, enter the same exact Git
184
185
  tag created by the successful Step 1 run. The workflow verifies that the tag
185
186
  matches `package.json`, resolves to the current track staging head, and can
186
187
  fast-forward every destination. It then uses one atomic push to synchronize
@@ -194,6 +195,15 @@ copy its release tag; optionally preview and run Step 2 for each needed
194
195
  release-order branch; finally run Step 3 with `dryRun=true`, then
195
196
  `dryRun=false`.
196
197
 
198
+ Shadow v3 candidate packaging: when the `V3_PACKAGE_CANDIDATE` repository
199
+ variable is `true`, a real `track=v3` Step 1 run also runs **Package V3
200
+ candidate (shadow)** after the release. It packages the release tag's committed
201
+ bundles into a `v3-candidate-<run id>-<run attempt>` artifact, kept for 7 days.
202
+ It never runs for v2 or dry runs, has read-only access, and its failure does
203
+ not fail the Step 1 run. It does keep the Step 1 run open until it finishes,
204
+ so wait for the whole run to finish before starting Step 2 or Step 3. To turn
205
+ it off, delete the variable or set it to anything other than `true`.
206
+
197
207
  ### Recover an incomplete v3 kit publication
198
208
 
199
209
  A real v3 Step 1 run can publish core and create the GitHub Release before all
@@ -227,19 +237,14 @@ If core's `next` tag changes without a corresponding Step 1 Git tag, do not use
227
237
  the bootstrap exception or guess a recovery tag. Stop releases and reconcile
228
238
  the unexpected npm and Git state before continuing.
229
239
 
230
- The release controls must remain synchronized across the v2 and v3 trunks.
231
- These files must be byte-for-byte identical on `master` and `main`:
232
-
233
- - `.github/workflows/staging-step-1.yml`
234
- - `.github/workflows/staging-step-2.yml`
235
- - `.github/workflows/staging-step-3.yml`
236
-
237
- Any change to any release step must be applied to both `master` and `main`
238
- before running a real release. Every `dryRun=false` workflow verifies all three
239
- files and rejects the release if either branch has a different version.
240
- Additionally, the current Step 1 workflow must be present on `staging` for v2
241
- and `v3-staging` for v3 because GitHub executes the workflow definition from
242
- the branch selected in the **Use workflow from** dropdown.
240
+ Each track's trunk owns its own copy of the release workflows: `master` for v2
241
+ and `main` for v3. The copies may differ, so a change to one track's release
242
+ steps does not need a twin on the other trunk. Steps 2 and 3 run from the
243
+ dispatching trunk, and the per-track rule above keeps each track on its own
244
+ trunk's copy. GitHub executes Step 1 from the branch selected in the **Use
245
+ workflow from** dropdown, so every `dryRun=false` Step 1 run rejects the
246
+ release unless `staging-step-1.yml` on the staging branch is identical to its
247
+ trunk's copy: `staging` to `master`, and `v3-staging` to `main`.
243
248
 
244
249
  ## Support
245
250
 
@@ -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 = "3.11.1";
18
+ var version = "3.12.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",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",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,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
@@ -648,7 +648,7 @@ return !(!(null!==(c=null===(b=window.webkit)||void 0===b?void 0:b.messageHandle
648
648
  // TODO: what to do about people setting things on mParticle itself?
649
649
  // android
650
650
  },this.isWebviewEnabled=function(c,d){return a._Store.bridgeV2Available=b.isBridgeV2Available(c),a._Store.bridgeV1Available=b.isBridgeV1Available(),2===d?a._Store.bridgeV2Available:!(window.mParticle&&window.mParticle.uiwebviewBridgeName&&window.mParticle.uiwebviewBridgeName!==iosBridgeNameBase+"_"+c+"_v2")&&!!(2>d)&&(a._Store.bridgeV2Available||a._Store.bridgeV1Available);// iOS BridgeV1 can be available via mParticle.isIOS, but return false if uiwebviewBridgeName doesn't match requiredWebviewBridgeName
651
- },this.isBridgeV1Available=function(){return !!(a._Store.SDKConfig.useNativeSdk||window.mParticleAndroid||a._Store.SDKConfig.isIOS)},this.sendToNative=function(c,d){return a._Store.bridgeV2Available&&2===a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV2Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV1Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV1(c,d):void 0},this.sendViaBridgeV1=function(c,d){window.mParticleAndroid&&window.mParticleAndroid.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),window.mParticleAndroid[c](d)):a._Store.SDKConfig.isIOS&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d));},this.sendViaIframeToIOS=function(a,b){var c=document.createElement("IFRAME");c.setAttribute("src","mp-sdk://"+a+"/"+encodeURIComponent(b)),document.documentElement.appendChild(c),c.parentNode.removeChild(c);},this.sendViaBridgeV2=function(c,d,e){var f,g;if(e){var h,i,j=getAndroidBridge(androidBridgeNameBase+"_"+e+"_v2"),k=iosBridgeNameBase+"_"+e+"_v2";return (null===(g=null===(f=window.webkit)||void 0===f?void 0:f.messageHandlers)||void 0===g?void 0:g[k])&&(h=window.webkit.messageHandlers[k]),a.uiwebviewBridgeName===k&&(i=getInstanceNamedValue(a,k)),j&&j.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),void j[c](d)):void(h?(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),h.postMessage(JSON.stringify({path:c,value:d?JSON.parse(d):null}))):i&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d)))}};}
651
+ },this.isBridgeV1Available=function(){return !!(a._Store.SDKConfig.useNativeSdk||getAndroidBridge(androidBridgeNameBase)||a._Store.SDKConfig.isIOS)},this.sendToNative=function(c,d){return a._Store.bridgeV2Available&&2===a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV2Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV1Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV1(c,d):void 0},this.sendViaBridgeV1=function(c,d){var e=getAndroidBridge(androidBridgeNameBase);e&&e.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),e[c](d)):a._Store.SDKConfig.isIOS&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d));},this.sendViaIframeToIOS=function(a,b){var c=document.createElement("IFRAME");c.setAttribute("src","mp-sdk://"+a+"/"+encodeURIComponent(b)),document.documentElement.appendChild(c),c.parentNode.removeChild(c);},this.sendViaBridgeV2=function(c,d,e){var f,g;if(e){var h,i,j=getAndroidBridge(androidBridgeNameBase+"_"+e+"_v2"),k=iosBridgeNameBase+"_"+e+"_v2";return (null===(g=null===(f=window.webkit)||void 0===f?void 0:f.messageHandlers)||void 0===g?void 0:g[k])&&(h=window.webkit.messageHandlers[k]),a.uiwebviewBridgeName===k&&(i=getInstanceNamedValue(a,k)),j&&j.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),void j[c](d)):void(h?(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),h.postMessage(JSON.stringify({path:c,value:d?JSON.parse(d):null}))):i&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d)))}};}
652
652
 
653
653
  var Messages$7=Constants.Messages,InformationMessages=Messages$7.InformationMessages;var DAYS_IN_MILLISECONDS=86400000;// Partner module IDs for cookie sync configurations
654
654
  var PARTNER_MODULE_IDS={AdobeEventForwarder:11,DoubleclickDFP:41,AppNexus:50,Lotame:58,TradeDesk:103,VerizonMedia:155,Rokt:1277};function CookieSyncManager(a){var b=this;// Public
@@ -757,11 +757,11 @@ var Base64=Polyfill.Base64,Messages$4=Constants.Messages,Base64CookieKeys=Consta
757
757
  // localStorage to cookies, then no mParticle cookie exists yet and there is
758
758
  // localStorage. Get the localStorage, set them to cookies, then delete the
759
759
  // localStorage item.
760
- function d(b,d,e){var f;return d?(f=c(d,e),b.removeItem(a._Store.storageName)):e&&(f=e),F.storeDataInMemory(f),f}// For migrating from cookie to localStorage -- If an instance is newly
760
+ function d(b,d,e){var f;return d?(f=c(d,e),b.removeItem(a._Store.storageName)):e&&(f=e),C.storeDataInMemory(f),f}// For migrating from cookie to localStorage -- If an instance is newly
761
761
  // switching from cookies to localStorage, then no mParticle localStorage
762
762
  // exists yet and there are cookies. Get the cookies, set them to
763
763
  // localStorage, then delete the cookies.
764
- function e(b,d){if(!d)return void F.storeDataInMemory(b);var e=c(b,d);return F.storeDataInMemory(e),F.expireCookies(a._Store.storageName),e}function f(b,c){return a._Store.isLocalStorageAvailable?a._Store.SDKConfig.useCookieStorage?d(window.localStorage,b,c):e(b,c):void F.storeDataInMemory(c)}function g(b){for(var c in b)b.hasOwnProperty(c)&&!SDKv2NonMPIDCookieKeys[c]&&(a._Store.nonCurrentUserMPIDs[c]=b[c]);}function h(){return F.useLocalStorage()&&a._Store.isLocalStorageAvailable?void localStorage.removeItem(a._Store.storageName):void F.expireCookies(a._Store.storageName)}function i(){a.Logger.verbose(Messages$4.InformationMessages.CookieNotFound),a._Store.clientId=a._Store.clientId||a._Helpers.generateUniqueId(),a._Store.deviceId=a._Store.deviceId||a._Helpers.generateUniqueId();}function j(b,c){// For most persistence values, we prioritize localstorage/cookie values over
764
+ function e(b,c){if(!c)return void C.storeDataInMemory(b);var d=b||c;return C.storeDataInMemory(d),C.expireCookies(a._Store.storageName),d}function f(b,c){return a._Store.isLocalStorageAvailable?a._Store.SDKConfig.useCookieStorage?d(window.localStorage,b,c):e(b,c):void C.storeDataInMemory(c)}function g(b){for(var c in b)b.hasOwnProperty(c)&&!SDKv2NonMPIDCookieKeys[c]&&(a._Store.nonCurrentUserMPIDs[c]=b[c]);}function h(b){return C.useLocalStorage()&&a._Store.isLocalStorageAvailable?void(b||localStorage.removeItem(a._Store.storageName)):void C.expireCookies(a._Store.storageName)}function i(){a.Logger.verbose(Messages$4.InformationMessages.CookieNotFound),a._Store.clientId=a._Store.clientId||a._Helpers.generateUniqueId(),a._Store.deviceId=a._Store.deviceId||a._Helpers.generateUniqueId();}function j(b,c){// For most persistence values, we prioritize localstorage/cookie values over
765
765
  // Store. However, we allow device ID to be overriden via a config value and
766
766
  // thus the priority of the deviceId value is
767
767
  // 1. value passed via config.deviceId
@@ -779,13 +779,9 @@ function k(b){var c=a._Store;return b.gs.sid=c.sessionId,b.gs.ie=c.isEnabled,b.g
779
779
  a. Remove at random MPIDs on the cookie that are not part of the currentSessionMPIDs
780
780
  b. Then remove MPIDs based on order in currentSessionMPIDs array, which
781
781
  stores MPIDs based on earliest login.
782
- */function l(a,b){return a.length>b}function m(a,b,c,d){var e;for(var f in a)a.hasOwnProperty(f)&&(e=s(a,b,c),!!l(e,d))&&(SDKv2NonMPIDCookieKeys[f]||f===a.cu||delete a[f]);return e}function n(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(SDKv2NonMPIDCookieKeys[c]||c===a.cu||(b[c]=1));return b}function o(a,b,c,d,e,f){var g;for(var h in b)(g=s(a,d,e),!!l(g,f))&&b.hasOwnProperty(h)&&-1===c.indexOf(h)&&delete a[h];return g}function p(b,c,d){return b[c]?(a.Logger.verbose("Size of new encoded cookie is larger than maxCookieSize setting of "+d+". Removing from cookie the earliest logged in MPID containing: "+JSON.stringify(b[c],null,2)),void delete b[c]):void a.Logger.error("Unable to save MPID data to cookies because the resulting encoded cookie is larger than the maxCookieSize setting of "+d+". We recommend using a maxCookieSize of 1500.")}function q(a,b,c,d,e){for(var f,g=0;g<b.length&&(f=s(a,c,d),!!l(f,e));g++)p(a,b[g],e);return f}function r(a){var b="https:"===window.location.protocol;window.document.cookie=b?a+";Secure":a;}function s(a,b,c){return F.encodePersistence(JSON.stringify(a))+";expires="+b+";path=/"+c}function t(a,b,c){for(var d in a)if(b===d&&c===a[d])return !0;return !1}function u(b,c,d){var e;for(var f in b)// any value in persistence that has an MPID key will be an MPID to search through
783
- // other keys on the cookie are currentSessionMPIDs and currentMPID which should not be searched
784
- a._Helpers.isObject(b[f])&&b[f].mpid&&t(b[f].ui,c,d)&&(e=f);return e}function v(a,b){var c;for(var d in b.userIdentities)if(a&&Object.keys(a).length){var e=u(a,d,b.userIdentities[d]);e&&(c=e);}return c}function w(b){return Array.isArray(b)?0<b.length:!!a._Helpers.isObject(b)&&0<Object.keys(b).length}function x(a,b){return a[b]&&w(a[b])?void(a[b]=Base64.encode(JSON.stringify(a[b]))):void delete a[b]}function y(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){x(a,b);continue}if("ie"==b){a[b]=a[b]?1:0;continue}a[b]||delete a[b];}}function z(b,c){var d=b[c];return a._Helpers.isObject(d)&&Object.keys(d).length?void(b[c]=Base64.encode(JSON.stringify(d))):void delete b[c]}function A(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&z(a,b);}function B(a){for(var b in a)a.hasOwnProperty(b)&&(SDKv2NonMPIDCookieKeys[b]||A(a[b]));}function C(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){a[b]=JSON.parse(Base64.decode(a[b])),"csm"!==b||Array.isArray(a[b])||delete a[b];continue}"ie"==b&&(a[b]=!!a[b]);}}function D(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&a[b].length&&(a[b]=JSON.parse(Base64.decode(a[b])));}function E(b){for(var c in b)if(b.hasOwnProperty(c)){if(!SDKv2NonMPIDCookieKeys[c]){// Written as an object by encodeMpidRecords, then read as one by
785
- // findMpidForRequestedIdentity and copied by copyNonCurrentUserMpids.
786
- if(!a._Helpers.isObject(b[c])){delete b[c];continue}D(b[c]);continue}"l"==c&&(b[c]=!!b[c]);}}// TODO: This should actually be decodePersistenceString or
782
+ */function l(a,b){return a.length>b}function m(a,b,c,d){var e;for(var f in a)a.hasOwnProperty(f)&&(e=s(a,b,c),!!l(e,d))&&(SDKv2NonMPIDCookieKeys[f]||f===a.cu||delete a[f]);return e}function n(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(SDKv2NonMPIDCookieKeys[c]||c===a.cu||(b[c]=1));return b}function o(a,b,c,d,e,f){var g;for(var h in b)(g=s(a,d,e),!!l(g,f))&&b.hasOwnProperty(h)&&-1===c.indexOf(h)&&delete a[h];return g}function p(b,c,d){return b[c]?(a.Logger.verbose("Size of new encoded cookie is larger than maxCookieSize setting of "+d+". Removing from cookie the earliest logged in MPID containing: "+JSON.stringify(b[c],null,2)),void delete b[c]):void a.Logger.error("Unable to save MPID data to cookies because the resulting encoded cookie is larger than the maxCookieSize setting of "+d+". We recommend using a maxCookieSize of 1500.")}function q(a,b,c,d,e){for(var f,g=0;g<b.length&&(f=s(a,c,d),!!l(f,e));g++)p(a,b[g],e);return f}function r(a){var b="https:"===window.location.protocol;window.document.cookie=b?a+";Secure":a;}function s(a,b,c){return C.encodePersistence(JSON.stringify(a))+";expires="+b+";path=/"+c}function t(b){return Array.isArray(b)?0<b.length:!!a._Helpers.isObject(b)&&0<Object.keys(b).length}function u(a,b){return a[b]&&t(a[b])?void(a[b]=Base64.encode(JSON.stringify(a[b]))):void delete a[b]}function v(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){u(a,b);continue}if("ie"==b){a[b]=a[b]?1:0;continue}a[b]||delete a[b];}}function w(b,c){var d=b[c];return a._Helpers.isObject(d)&&Object.keys(d).length?void(b[c]=Base64.encode(JSON.stringify(d))):void delete b[c]}function x(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&w(a,b);}function y(a){for(var b in a)a.hasOwnProperty(b)&&(SDKv2NonMPIDCookieKeys[b]||x(a[b]));}function z(a){for(var b in a)if(a.hasOwnProperty(b)){if(Base64CookieKeys[b]){a[b]=JSON.parse(Base64.decode(a[b])),"csm"!==b||Array.isArray(a[b])||delete a[b];continue}"ie"==b&&(a[b]=!!a[b]);}}function A(a){for(var b in a)a.hasOwnProperty(b)&&Base64CookieKeys[b]&&a[b].length&&(a[b]=JSON.parse(Base64.decode(a[b])));}function B(b){for(var c in b)if(b.hasOwnProperty(c)){if(!SDKv2NonMPIDCookieKeys[c]){if(!a._Helpers.isObject(b[c])){delete b[c];continue}A(b[c]);continue}"l"==c&&(b[c]=!!b[c]);}}// TODO: This should actually be decodePersistenceString or
787
783
  // we should refactor this to take a string and return an object
788
- var F=this;// https://go.mparticle.com/work/SQDSDKS-5022
784
+ var C=this;// https://go.mparticle.com/work/SQDSDKS-5022
789
785
  // https://go.mparticle.com/work/SQDSDKS-5022
790
786
  // https://go.mparticle.com/work/SQDSDKS-6021
791
787
  // https://go.mparticle.com/work/SQDSDKS-5022
@@ -805,17 +801,16 @@ var F=this;// https://go.mparticle.com/work/SQDSDKS-5022
805
801
  * time
806
802
  */ // https://go.mparticle.com/work/SQDSDKS-6045
807
803
  // Forwarder Batching Code
808
- this.useLocalStorage=function(){return !a._Store.SDKConfig.useCookieStorage&&a._Store.isLocalStorageAvailable},this.initializeStorage=function(){try{var c=F.getLocalStorage(),d=F.getCookie();// https://go.mparticle.com/work/SQDSDKS-6045
809
- b(c,d),a._Store.isLocalStorageAvailable||(a._Store.SDKConfig.useCookieStorage=!0);// https://go.mparticle.com/work/SQDSDKS-6046
810
- var e=f(c,d);g(e),F.update();}catch(b){// If cookies or local storage is corrupt, we want to remove it
804
+ this.useLocalStorage=function(){return !a._Store.SDKConfig.useCookieStorage&&a._Store.isLocalStorageAvailable},this.initializeStorage=function(){var c=null;try{var d=C.getLocalStorage();c=C.getCookie(),b(d,c),a._Store.isLocalStorageAvailable||(a._Store.SDKConfig.useCookieStorage=!0);// https://go.mparticle.com/work/SQDSDKS-6046
805
+ var e=f(d,c);g(e),C.update();}catch(b){// If cookies or local storage is corrupt, we want to remove it
811
806
  // so that in the future, initializeStorage will work
812
- h(),a.Logger.error("Error initializing storage: "+b);}},this.update=function(){a._Store.webviewBridgeEnabled||(a._Store.SDKConfig.useCookieStorage&&F.setCookie(),F.setLocalStorage());},this.storeDataInMemory=function(b,c){try{if(!b)return void i();j(b,c);}catch(b){a.Logger.error(Messages$4.ErrorMessages.CookieParseError);}},this.determineLocalStorageAvailability=function(a){var b=getMParticleManager();if(null===b||void 0===b?void 0:b._forceNoLocalStorage)return !1;try{a.setItem("mparticle","test");var c="test"===a.getItem("mparticle");return a.removeItem("mparticle"),!!(c&&a)}catch(a){return !1}},this.setLocalStorage=function(){var b;if(a._Store.isLocalStorageAvailable&&(null===(b=a._CookieConsentManager)||void 0===b||!b.getNoFunctional()))// Block mprtcl-v4 localStorage when noFunctional is true
813
- {var c=a._Store.storageName,d=F.getLocalStorage()||{},e=a.Identity.getCurrentUser(),f=e?e.getMPID():null;if(!a._Store.SDKConfig.useCookieStorage){d.gs=d.gs||{},d.l=a._Store.isLoggedIn?1:0,a._Store.sessionId&&(d.gs.csm=a._Store.currentSessionMPIDs),d.gs.ie=a._Store.isEnabled,f&&(d.cu=f),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(d=extend({},d,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),d=k(d);try{window.localStorage.setItem(encodeURIComponent(c),F.encodePersistence(JSON.stringify(d)));}catch(b){a.Logger.error("Error with setting localStorage item.");}}}},this.getLocalStorage=function(){if(!a._Store.isLocalStorageAvailable)return null;var b=a._Store.storageName,c=F.decodePersistence(window.localStorage.getItem(b));if(!c)return null;var d=JSON.parse(c),e={};for(var f in d)d.hasOwnProperty(f)&&(e[f]=d[f]);return Object.keys(e).length?e:null},this.expireCookies=function(a){var b,c,d,e=new Date;d=F.getCookieDomain(),c=""===d?"":";domain="+d,e.setTime(e.getTime()-86400000),b="; expires="+e.toUTCString(),r(a+"="+b+"; path=/"+c);},this.getCookie=function(){var b,c,d,e,f,g,h=a._Store.storageName,j=h?void 0:{};a.Logger.verbose(Messages$4.InformationMessages.CookieSearch);try{b=window.document.cookie.split("; ");}catch(b){return a.Logger.verbose("Unable to parse undefined cookie"),null}for(c=0,d=b.length;c<d;c++){try{e=b[c].split("="),f=e.shift(),g=e.join("=");}catch(b){a.Logger.verbose("Unable to parse cookie: "+f+". Skipping.");}if(h&&h===f){j=a._Helpers.converted(g);break}h||(j[f]=a._Helpers.converted(g));}return j?(a.Logger.verbose(Messages$4.InformationMessages.CookieFound),JSON.parse(F.decodePersistence(j))):null},this.setCookie=function(){var b;// Block mprtcl-v4 cookies when noFunctional is true
814
- if(!(null!==(b=a._CookieConsentManager)&&void 0!==b)||!b.getNoFunctional()){var c,d=a.Identity.getCurrentUser();d&&(c=d.getMPID());var e,f,g,h=new Date,i=a._Store.storageName,j=F.getCookie()||{},l=new Date(h.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString();e=F.getCookieDomain(),f=""===e?"":";domain="+e,j.gs=j.gs||{},a._Store.sessionId&&(j.gs.csm=a._Store.currentSessionMPIDs),c&&(j.cu=c),j.l=a._Store.isLoggedIn?1:0,j=k(j),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(j=extend({},j,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),g=F.reduceAndEncodePersistence(j,l,f,a._Store.SDKConfig.maxCookieSize),a.Logger.verbose(Messages$4.InformationMessages.CookieSet),r(encodeURIComponent(i)+"="+g);}},this.reduceAndEncodePersistence=function(a,b,c,d){var e=a.gs.csm?a.gs.csm:[];if(!e.length)return m(a,b,c,d);var f=n(a);return Object.keys(f).length&&o(a,f,e,b,c,d),q(a,e,b,c,d)},this.findPrevCookiesBasedOnUI=function(b){var c=a._Persistence.getPersistence();if(b){var d=v(c,b);d&&F.storeDataInMemory(c,d);}},this.encodePersistence=function(a){var b=JSON.parse(a);return y(b.gs),B(b),createCookieString(JSON.stringify(b))},this.decodePersistence=function(b){try{if(!b)return;var c=JSON.parse(revertCookieString(b));return a._Helpers.isObject(c)&&Object.keys(c).length&&(C(c.gs),E(c)),JSON.stringify(c)}catch(b){a.Logger.error("Problem with decoding cookie");}},this.getCookieDomain=function(){if(a._Store.SDKConfig.cookieDomain)return a._Store.SDKConfig.cookieDomain;var b=F.getDomain(document,location.hostname);return ""===b?"":"."+b},this.getDomain=function(a,b){var c,d,e=b.split(".");for(c=e.length-1;0<=c;c--)if(d=e.slice(c).join("."),a.cookie="mptest=cookie;domain=."+d+";",-1<a.cookie.indexOf("mptest=cookie"))return a.cookie="mptest=;domain=."+d+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",d;return ""},this.saveUserCookieSyncDatesToPersistence=function(b,c){if(c){var d=F.getPersistence();d&&(a._Helpers.isObject(d[b])?d[b].csd=c:d[b]={csd:c}),F.savePersistence(d);}},this.swapCurrentUser=function(a,b,c){if(a&&b&&a!==b){var d=F.getPersistence();d&&(d.cu=b,d.gs.csm=c,F.savePersistence(d));}},this.savePersistence=function(b){var c;// Block mprtcl-v4 persistence when noFunctional is true
815
- if(null===(c=a._CookieConsentManager)||void 0===c||!c.getNoFunctional()){var d,e=F.encodePersistence(JSON.stringify(b)),f=new Date,g=a._Store.storageName,h=new Date(f.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString(),i=F.getCookieDomain();if(d=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=F.reduceAndEncodePersistence(b,h,d,a._Store.SDKConfig.maxCookieSize);r(encodeURIComponent(g)+"="+j);}else if(a._Store.isLocalStorageAvailable)try{localStorage.setItem(a._Store.storageName,e);}catch(b){a.Logger.error("Error saving persistence to localStorage.");}}},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getFirstSeenTime=function(a){if(!a)return null;var b=F.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=F.getPersistence();d&&(!a._Helpers.isObject(d[b])&&(d[b]={}),!d[b].fst&&(d[b].fst=c,F.savePersistence(d)));}// https://go.mparticle.com/work/SQDSDKS-6329
807
+ h(!!c),a.Logger.error("Error initializing storage: "+b);}},this.update=function(){a._Store.webviewBridgeEnabled||(a._Store.SDKConfig.useCookieStorage&&C.setCookie(),C.setLocalStorage());},this.storeDataInMemory=function(b,c){try{if(!b)return void i();j(b,c);}catch(b){a.Logger.error(Messages$4.ErrorMessages.CookieParseError);}},this.determineLocalStorageAvailability=function(a){var b=getMParticleManager();if(null===b||void 0===b?void 0:b._forceNoLocalStorage)return !1;try{a.setItem("mparticle","test");var c="test"===a.getItem("mparticle");return a.removeItem("mparticle"),!!(c&&a)}catch(a){return !1}},this.setLocalStorage=function(){var b;if(a._Store.isLocalStorageAvailable&&(null===(b=a._CookieConsentManager)||void 0===b||!b.getNoFunctional()))// Block mprtcl-v4 localStorage when noFunctional is true
808
+ {var c=a._Store.storageName,d=C.getLocalStorage()||{},e=a.Identity.getCurrentUser(),f=e?e.getMPID():null;if(!a._Store.SDKConfig.useCookieStorage){d.gs=d.gs||{},d.l=a._Store.isLoggedIn?1:0,a._Store.sessionId&&(d.gs.csm=a._Store.currentSessionMPIDs),d.gs.ie=a._Store.isEnabled,f&&(d.cu=f),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(d=extend({},d,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),d=k(d);try{window.localStorage.setItem(encodeURIComponent(c),C.encodePersistence(JSON.stringify(d)));}catch(b){a.Logger.error("Error with setting localStorage item.");}}}},this.getLocalStorage=function(){if(!a._Store.isLocalStorageAvailable)return null;var b=a._Store.storageName,c=C.decodePersistence(window.localStorage.getItem(b));if(!c)return null;var d=JSON.parse(c),e={};for(var f in d)d.hasOwnProperty(f)&&(e[f]=d[f]);return Object.keys(e).length?e:null},this.expireCookies=function(a){var b,c,d,e=new Date;d=C.getCookieDomain(),c=""===d?"":";domain="+d,e.setTime(e.getTime()-86400000),b="; expires="+e.toUTCString(),r(a+"="+b+"; path=/"+c);},this.getCookie=function(){var b,c,d,e,f,g,h=a._Store.storageName;a.Logger.verbose(Messages$4.InformationMessages.CookieSearch);try{b=window.document.cookie.split("; ");}catch(b){return a.Logger.verbose("Unable to parse undefined cookie"),null}for(c=0,d=b.length;c<d;c++){try{e=b[c].split("="),f=e.shift(),g=e.join("=");}catch(b){a.Logger.verbose("Unable to parse cookie: "+f+". Skipping.");}if(h&&h===f){var j=C.decodePersistence(a._Helpers.converted(g)),k=j?JSON.parse(j):null;if(a._Helpers.isObject(k))return a.Logger.verbose(Messages$4.InformationMessages.CookieFound),k}}return null},this.setCookie=function(){var b;// Block mprtcl-v4 cookies when noFunctional is true
809
+ if(!(null!==(b=a._CookieConsentManager)&&void 0!==b)||!b.getNoFunctional()){var c,d=a.Identity.getCurrentUser();d&&(c=d.getMPID());var e,f,g,h=new Date,i=a._Store.storageName,j=C.getCookie()||{},l=new Date(h.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString();e=C.getCookieDomain(),f=""===e?"":";domain="+e,j.gs=j.gs||{},a._Store.sessionId&&(j.gs.csm=a._Store.currentSessionMPIDs),c&&(j.cu=c),j.l=a._Store.isLoggedIn?1:0,j=k(j),Object.keys(a._Store.nonCurrentUserMPIDs).length&&(j=extend({},j,a._Store.nonCurrentUserMPIDs),a._Store.nonCurrentUserMPIDs={}),g=C.reduceAndEncodePersistence(j,l,f,a._Store.SDKConfig.maxCookieSize),a.Logger.verbose(Messages$4.InformationMessages.CookieSet),r(encodeURIComponent(i)+"="+g);}},this.reduceAndEncodePersistence=function(a,b,c,d){var e=a.gs.csm?a.gs.csm:[];if(!e.length)return m(a,b,c,d);var f=n(a);return Object.keys(f).length&&o(a,f,e,b,c,d),q(a,e,b,c,d)},this.encodePersistence=function(a){var b=JSON.parse(a);return v(b.gs),y(b),createCookieString(JSON.stringify(b))},this.decodePersistence=function(b){try{if(!b)return;var c=JSON.parse(revertCookieString(b));return a._Helpers.isObject(c)&&Object.keys(c).length&&(z(c.gs),B(c)),JSON.stringify(c)}catch(b){a.Logger.error("Problem with decoding cookie");}},this.getCookieDomain=function(){if(a._Store.SDKConfig.cookieDomain)return a._Store.SDKConfig.cookieDomain;var b=C.getDomain(document,location.hostname);return ""===b?"":"."+b},this.getDomain=function(a,b){var c,d,e=b.split(".");for(c=e.length-1;0<=c;c--)if(d=e.slice(c).join("."),a.cookie="mptest=cookie;domain=."+d+";",-1<a.cookie.indexOf("mptest=cookie"))return a.cookie="mptest=;domain=."+d+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",d;return ""},this.saveUserCookieSyncDatesToPersistence=function(b,c){if(c){var d=C.getPersistence();d&&(a._Helpers.isObject(d[b])?d[b].csd=c:d[b]={csd:c}),C.savePersistence(d);}},this.swapCurrentUser=function(a,b,c){if(a&&b&&a!==b){var d=C.getPersistence();d&&(d.cu=b,d.gs.csm=c,C.savePersistence(d));}},this.savePersistence=function(b){var c;// Block mprtcl-v4 persistence when noFunctional is true
810
+ if(null===(c=a._CookieConsentManager)||void 0===c||!c.getNoFunctional()){var d,e=C.encodePersistence(JSON.stringify(b)),f=new Date,g=a._Store.storageName,h=new Date(f.getTime()+1e3*(60*(60*(24*a._Store.SDKConfig.cookieExpiration)))).toUTCString(),i=C.getCookieDomain();if(d=""===i?"":";domain="+i,a._Store.SDKConfig.useCookieStorage){var j=C.reduceAndEncodePersistence(b,h,d,a._Store.SDKConfig.maxCookieSize);r(encodeURIComponent(g)+"="+j);}else if(a._Store.isLocalStorageAvailable)try{localStorage.setItem(a._Store.storageName,e);}catch(b){a.Logger.error("Error saving persistence to localStorage.");}}},this.getPersistence=function(){var a=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return a},this.getFirstSeenTime=function(a){if(!a)return null;var b=C.getPersistence();return b&&b[a]&&b[a].fst?b[a].fst:null},this.setFirstSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=C.getPersistence();d&&(!a._Helpers.isObject(d[b])&&(d[b]={}),!d[b].fst&&(d[b].fst=c,C.savePersistence(d)));}// https://go.mparticle.com/work/SQDSDKS-6329
816
811
  },this.getLastSeenTime=function(b){if(!b)return null;if(b===a.Identity.getCurrentUser().getMPID())//if the mpid is the current user, its last seen time is the current time
817
- return new Date().getTime();var c=F.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=F.getPersistence();d&&a._Helpers.isObject(d[b])&&(d[b].lst=c,F.savePersistence(d));}// https://go.mparticle.com/work/SQDSDKS-6329
818
- },this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,F.update();},this.resetPersistence=function(){localStorage.clear(),F.expireCookies(StorageNames.cookieName),F.expireCookies(StorageNames.cookieNameV2),F.expireCookies(StorageNames.cookieNameV3),F.expireCookies(StorageNames.cookieNameV4),F.expireCookies(a._Store.storageName);var b=getMParticleManager();if(null===b||void 0===b?void 0:b._isTestEnv){localStorage.removeItem(a._Helpers.createMainStorageName("abcdef")),F.expireCookies(a._Helpers.createMainStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
812
+ return new Date().getTime();var c=C.getPersistence();return c&&c[b]&&c[b].lst?c[b].lst:null},this.setLastSeenTime=function(b,c){if(b){c||(c=new Date().getTime());var d=C.getPersistence();d&&a._Helpers.isObject(d[b])&&(d[b].lst=c,C.savePersistence(d));}// https://go.mparticle.com/work/SQDSDKS-6329
813
+ },this.getDeviceId=function(){return a._Store.deviceId},this.setDeviceId=function(b){a._Store.deviceId=b,C.update();},this.resetPersistence=function(){localStorage.clear(),C.expireCookies(StorageNames.cookieName),C.expireCookies(StorageNames.cookieNameV2),C.expireCookies(StorageNames.cookieNameV3),C.expireCookies(StorageNames.cookieNameV4),C.expireCookies(a._Store.storageName);var b=getMParticleManager();if(null===b||void 0===b?void 0:b._isTestEnv){localStorage.removeItem(a._Helpers.createMainStorageName("abcdef")),C.expireCookies(a._Helpers.createMainStorageName("abcdef"));}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]};}
819
814
 
820
815
  var HISTORY_METHODS=["pushState","replaceState"],WRAPPED_MARKER="__mpApvWrapped__";var supportsHistoryTracking=function(a){return !!a&&a.history!==void 0&&"function"==typeof a.history.pushState&&"function"==typeof a.addEventListener};// Wraps pushState/replaceState so `onNavigate` runs after the real method, and
821
816
  // returns the single function that undoes it — or null when nothing was
@@ -946,8 +941,8 @@ c(b),b=null,a._Store.isTracking=!1;}));else {var d={coords:{latitude:a._Store.cu
946
941
  // null, resulting in kit forwarding errors on the server.
947
942
  // The check for `ProductAction` is required to denote that these are
948
943
  // ProductAction events, and not impression or promotions
949
- if(a.Logger.verbose(Messages$3.InformationMessages.StartingLogCommerceEvent),b.ProductAction&&null===b.EventCategory)return void a.Logger.error("Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code.");var e=a._Helpers.sanitizeAttributes(c,b.EventName);a._Helpers.canLog()?(e&&(b.EventAttributes=e),b.ProductAction&&a._Ecommerce.calculateProductActionTotalAmount(b.ProductAction),a._APIClient.sendEventToServer(b,d),a._Persistence.update()):a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);},this.addEventHandler=function(c,d,f,g,h){var j,k,e=[],l=function handler(c){var d=function timeoutHandler(){j.href?window.location.href=j.href:j.submit&&j.submit();};a.Logger.verbose("DOM event triggered, handling event"),b.logEvent({messageType:Types.MessageType.PageEvent,name:"function"==typeof f?f(j):f,data:"function"==typeof g?g(j):g,eventType:h||Types.EventType.Other}),(j.href&&"_blank"!==j.target||j.submit)&&(c.preventDefault?c.preventDefault():c.returnValue=!1,setTimeout(d,a._Store.SDKConfig.timeout));};if(!d)return void a.Logger.error("Can't bind event, selector is required");// Handle a css selector string or a dom element
950
- if("string"==typeof d?e=document.querySelectorAll(d):d.nodeType&&(e=[d]),e.length)for(a.Logger.verbose("Found "+e.length+" element"+(1<e.length?"s":"")+", attaching event handlers"),k=0;k<e.length;k++)j=e[k],j.addEventListener?j.addEventListener(c,l,!1):j.attachEvent?j.attachEvent("on"+c,l):j["on"+c]=l;else a.Logger.verbose("No elements found");};}
944
+ if(a.Logger.verbose(Messages$3.InformationMessages.StartingLogCommerceEvent),b.ProductAction&&null===b.EventCategory)return void a.Logger.error("Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code.");var e=a._Helpers.sanitizeAttributes(c,b.EventName);a._Helpers.canLog()?(e&&(b.EventAttributes=e),b.ProductAction&&a._Ecommerce.calculateProductActionTotalAmount(b.ProductAction),a._APIClient.sendEventToServer(b,d),a._Persistence.update()):a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);},this.addEventHandler=function(c,d,f,g,h){var j,e=[],k=function handler(c,d){var e=function timeoutHandler(){d.href?window.location.href=d.href:d.submit&&d.submit();};a.Logger.verbose("DOM event triggered, handling event"),b.logEvent({messageType:Types.MessageType.PageEvent,name:"function"==typeof f?f(d):f,data:"function"==typeof g?g(d):g,eventType:h||Types.EventType.Other}),(d.href&&"_blank"!==d.target||d.submit)&&(c.preventDefault?c.preventDefault():c.returnValue=!1,setTimeout(e,a._Store.SDKConfig.timeout));};if(!d)return void a.Logger.error("Can't bind event, selector is required");// Handle a css selector string or a dom element
945
+ if("string"==typeof d?e=document.querySelectorAll(d):d.nodeType&&(e=[d]),e.length){a.Logger.verbose("Found "+e.length+" element"+(1<e.length?"s":"")+", attaching event handlers");var l=function _loop_1(){var a=e[j],b=function elementHandler(b){k(b,a);};a.addEventListener?a.addEventListener(c,b,!1):a.attachEvent?a.attachEvent("on"+c,b):a["on"+c]=b;};for(j=0;j<e.length;j++)l();}else a.Logger.verbose("No elements found");};}
951
946
 
952
947
  function isAttributeKeyAllowed(a,b){return !(null!==a&&void 0!==a)||!a.isAttributeKeyBlocked(b)}function isIdentityAllowed(a,b){return !(null!==a&&void 0!==a)||!a.isIdentityBlocked(b)}function copyUserAttributeValue(a){return Array.isArray(a)?a.slice():a}function buildUserAttributesCopy(a,b){var c={};if(!a)return c;for(var d in a)hasOwnProp(a,d)&&!isReservedStoredPropertyName(d)&&isAttributeKeyAllowed(b,d)&&(c[d]=copyUserAttributeValue(a[d]));return c}function buildUserAttributeLists(a,b){var c={};for(var d in a)hasOwnProp(a,d)&&!isReservedStoredPropertyName(d)&&Array.isArray(a[d])&&isAttributeKeyAllowed(b,d)&&(c[d]=a[d].slice());return c}function buildFilteredUserIdentities(a,b){var c={},d=a;for(var e in d)if(hasOwnProp(d,e)){var f=getIdentityTypeFromStoredKey(e);// Must be `=== null`: IdentityType.Other is 0, so a falsy check would
953
948
  // drop a valid stored Other identity.
@@ -1195,7 +1190,7 @@ if(l?(j=!1,h=g[l],delete g[l]):j=!0,g[c]=f,a._Store.setUserAttributes(b,g),!h||!
1195
1190
  * @param {Function} [callback] A callback function that is invoked when the user audience request completes
1196
1191
  */ // https://go.mparticle.com/work/SQDSDKS-6436
1197
1192
  getUserAudiences:function getUserAudiences(c){// user audience API is feature flagged
1198
- return a._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===e.audienceManager&&(e.audienceManager=new AudienceManager(a._Store.SDKConfig.userAudienceUrl,a._Store.devToken,a.Logger)),e.audienceManager.sendGetUserAudienceRequest(b,c)):void a.Logger.error(ErrorMessages.AudienceAPINotEnabled)}}},this.parseIdentityResponse=function(b,d,f,g,h,i,j){var k,l,m,n,o,p,q=a.Identity.getUser(d),r=q?q.getMPID():null,s=q?q.getUserIdentities().userIdentities:{},t={};a._Store.identityCallInFlight=!1;try{if(a.Logger.verbose("Parsing \""+h+"\" identity response from server"),o=null!==(k=b.responseText)&&void 0!==k?k:null,a._Store.isLoggedIn=(null===o||void 0===o?void 0:o.is_logged_in)||!1,hasMPIDChanged(q,o)&&(a._Store.mpid=o.mpid,q&&a._Persistence.setLastSeenTime(d),n=!a._Persistence.getFirstSeenTime(o.mpid),a._Persistence.setFirstSeenTime(o.mpid)),b.status===HTTP_OK){c(CacheIdentity)&&cacheOrClearIdCache(h,i,e.idCache,b,j);var u=e.IdentityAPI.getUser(o.mpid),v=u?u.getUserIdentities().userIdentities:{};h===Modify$1?(t=a._Identity.IdentityRequest.combineUserIdentities(s,g.userIdentities),a._Store.setUserIdentities(d,t)):(h===Identify&&q&&o.mpid===r&&a._Persistence.setFirstSeenTime(o.mpid),a._Store.addMpidToSessionHistory(o.mpid,d),a._CookieSyncManager.attemptCookieSync(o.mpid,n),a._Persistence.swapCurrentUser(d,o.mpid,a._Store.currentSessionMPIDs),g&&!isEmpty(g.userIdentities)&&(t=e.IdentityRequest.combineUserIdentities(v,g.userIdentities)),a._Store.setUserIdentities(o.mpid,t),a._Persistence.update(),a._Store.syncPersistenceData(),a._Persistence.findPrevCookiesBasedOnUI(g),a._Store.context=o.context||a._Store.context),p=a.Identity.getCurrentUser(),tryOnUserAlias(q,p,g,a.Logger,a._ErrorReportingDispatcher);var w=a._Persistence.getPersistence();p&&(a._Persistence.storeDataInMemory(w,p.getMPID()),e.reinitForwardersOnUserChange(q,p),e.setForwarderCallbacks(p,h));var x=IdentityType.getNewIdentitiesByName(t),y=h===Modify$1?s:v;// Sync $NoTargeting before sendUserIdentityChangeEvent
1193
+ return a._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===e.audienceManager&&(e.audienceManager=new AudienceManager(a._Store.SDKConfig.userAudienceUrl,a._Store.devToken,a.Logger)),e.audienceManager.sendGetUserAudienceRequest(b,c)):void a.Logger.error(ErrorMessages.AudienceAPINotEnabled)}}},this.parseIdentityResponse=function(b,d,f,g,h,i,j){var k,l,m,n,o,p,q=a.Identity.getUser(d),r=q?q.getMPID():null,s=q?q.getUserIdentities().userIdentities:{},t={};a._Store.identityCallInFlight=!1;try{if(a.Logger.verbose("Parsing \""+h+"\" identity response from server"),o=null!==(k=b.responseText)&&void 0!==k?k:null,a._Store.isLoggedIn=(null===o||void 0===o?void 0:o.is_logged_in)||!1,hasMPIDChanged(q,o)&&(a._Store.mpid=o.mpid,q&&a._Persistence.setLastSeenTime(d),n=!a._Persistence.getFirstSeenTime(o.mpid),a._Persistence.setFirstSeenTime(o.mpid)),b.status===HTTP_OK){c(CacheIdentity)&&cacheOrClearIdCache(h,i,e.idCache,b,j);var u=e.IdentityAPI.getUser(o.mpid),v=u?u.getUserIdentities().userIdentities:{};h===Modify$1?(t=a._Identity.IdentityRequest.combineUserIdentities(s,g.userIdentities),a._Store.setUserIdentities(d,t)):(h===Identify&&q&&o.mpid===r&&a._Persistence.setFirstSeenTime(o.mpid),a._Store.addMpidToSessionHistory(o.mpid,d),a._CookieSyncManager.attemptCookieSync(o.mpid,n),a._Persistence.swapCurrentUser(d,o.mpid,a._Store.currentSessionMPIDs),g&&!isEmpty(g.userIdentities)&&(t=e.IdentityRequest.combineUserIdentities(v,g.userIdentities)),a._Store.setUserIdentities(o.mpid,t),a._Persistence.update(),a._Store.syncPersistenceData(),a._Store.context=o.context||a._Store.context),p=a.Identity.getCurrentUser(),tryOnUserAlias(q,p,g,a.Logger,a._ErrorReportingDispatcher);var w=a._Persistence.getPersistence();p&&(a._Persistence.storeDataInMemory(w,p.getMPID()),e.reinitForwardersOnUserChange(q,p),e.setForwarderCallbacks(p,h));var x=IdentityType.getNewIdentitiesByName(t),y=h===Modify$1?s:v;// Sync $NoTargeting before sendUserIdentityChangeEvent
1199
1194
  // because UIC events call sendEventToServer which triggers
1200
1195
  // processQueuedEvents, draining the event queue. The
1201
1196
  // attribute must be in the store before that happens so
@@ -1212,14 +1207,14 @@ return g=a._ServerModel.createEventObject({messageType:Types.MessageType.UserIde
1212
1207
  null===(d=a._Forwarders)||void 0===d?void 0:d.setForwarderUserIdentities(b.getUserIdentities().userIdentities),null===(e=a._Forwarders)||void 0===e?void 0:e.setForwarderOnIdentityComplete(b,c),null===(f=a._Forwarders)||void 0===f?void 0:f.setForwarderOnUserIdentified(b);};}// https://go.mparticle.com/work/SQDSDKS-6359
1213
1208
  function tryOnUserAlias(a,b,c,d,e){if(c&&c.onUserAlias&&isFunction(c.onUserAlias))try{logDeprecatedMethodUsage({methodName:"onUserAlias",warningMessage:generateDeprecationMessage("onUserAlias")},d,e),c.onUserAlias(a,b);}catch(a){d.error("There was an error with your onUserAlias function - "+a);}}
1214
1209
 
1215
- var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){var b=this;// this function is called when consent is required to
1210
+ var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){function b(a){if(!isObject(a))return null;var b="object"===_typeof(a.ts)&&null!==a.ts;return b?null:c.createPrivacyConsent(a.c,a.ts,a.d,a.l,a.h)}// TODO: Refactor this method into a constructor
1211
+ var c=this;// this function is called when consent is required to
1216
1212
  // determine if a cookie sync should happen, or a
1217
1213
  // forwarder should be initialized
1218
- // TODO: Refactor this method into a constructor
1219
1214
  this.isEnabledForUserConsent=function(a,b){if(!a||!a.values||!a.values.length)return !0;if(!b)return !1;var c,d={},e=b.getConsentState();if(e){// the server hashes consent purposes in the following way:
1220
1215
  // GDPR - '1' + purpose name
1221
1216
  // CCPA - '2data_sale_opt_out' (there is only 1 purpose of data_sale_opt_out for CCPA)
1222
- var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("1",g),d[c]=f[g].Consented);var h=e.getCCPAConsentState();h&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("2",CCPAPurpose),d[c]=h.Consented);}var i=a.values.some(function(a){var b=a.consentPurpose,c=a.hasConsented;return !!d.hasOwnProperty(b)&&d[b]===c});return a.includeOnMatch===i},this.createPrivacyConsent=function(b,c,d,e,f){return "boolean"==typeof b?c&&isNaN(c)?(a.Logger.error("Timestamp must be a valid number when constructing a Consent object."),null):d&&"string"!=typeof d?(a.Logger.error("Document must be a valid string when constructing a Consent object."),null):e&&"string"!=typeof e?(a.Logger.error("Location must be a valid string when constructing a Consent object."),null):f&&"string"!=typeof f?(a.Logger.error("Hardware ID must be a valid string when constructing a Consent object."),null):{Consented:b,Timestamp:c||Date.now(),ConsentDocument:d,Location:e,HardwareId:f}:(a.Logger.error("Consented boolean is required when constructing a Consent object."),null)},this.ConsentSerialization={toMinifiedJsonObject:function toMinifiedJsonObject(a){var b,c={};if(a){var d=a.getGDPRConsentState();if(d)for(var e in c.gdpr={},d)if(d.hasOwnProperty(e)){var f=d[e];c.gdpr[e]={},"boolean"==typeof f.Consented&&(c.gdpr[e].c=f.Consented),"number"==typeof f.Timestamp&&(c.gdpr[e].ts=f.Timestamp),"string"==typeof f.ConsentDocument&&(c.gdpr[e].d=f.ConsentDocument),"string"==typeof f.Location&&(c.gdpr[e].l=f.Location),"string"==typeof f.HardwareId&&(c.gdpr[e].h=f.HardwareId);}var g=a.getCCPAConsentState();g&&(c.ccpa=(b={},b[CCPAPurpose]={},b),"boolean"==typeof g.Consented&&(c.ccpa[CCPAPurpose].c=g.Consented),"number"==typeof g.Timestamp&&(c.ccpa[CCPAPurpose].ts=g.Timestamp),"string"==typeof g.ConsentDocument&&(c.ccpa[CCPAPurpose].d=g.ConsentDocument),"string"==typeof g.Location&&(c.ccpa[CCPAPurpose].l=g.Location),"string"==typeof g.HardwareId&&(c.ccpa[CCPAPurpose].h=g.HardwareId));}return c},fromMinifiedJsonObject:function fromMinifiedJsonObject(a){var c=b.createConsentState();if(a.gdpr)for(var d in a.gdpr)if(hasOwnProp(a.gdpr,d)){var e=b.createPrivacyConsent(a.gdpr[d].c,a.gdpr[d].ts,a.gdpr[d].d,a.gdpr[d].l,a.gdpr[d].h);c.addGDPRConsentState(d,e);}if(a.ccpa&&hasOwnProp(a.ccpa,CCPAPurpose)){var f=b.createPrivacyConsent(a.ccpa[CCPAPurpose].c,a.ccpa[CCPAPurpose].ts,a.ccpa[CCPAPurpose].d,a.ccpa[CCPAPurpose].l,a.ccpa[CCPAPurpose].h);c.setCCPAConsentState(f);}return c}},this.createConsentState=function(c){function d(a){if("string"!=typeof a)return null;var b=a.trim();return b.length?b.toLowerCase():null}/**
1217
+ var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("1",g),d[c]=f[g].Consented);var h=e.getCCPAConsentState();h&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("2",CCPAPurpose),d[c]=h.Consented);}var i=a.values.some(function(a){var b=a.consentPurpose,c=a.hasConsented;return !!d.hasOwnProperty(b)&&d[b]===c});return a.includeOnMatch===i},this.createPrivacyConsent=function(b,c,d,e,f){return "boolean"==typeof b?c&&isNaN(c)?(a.Logger.error("Timestamp must be a valid number when constructing a Consent object."),null):d&&"string"!=typeof d?(a.Logger.error("Document must be a valid string when constructing a Consent object."),null):e&&"string"!=typeof e?(a.Logger.error("Location must be a valid string when constructing a Consent object."),null):f&&"string"!=typeof f?(a.Logger.error("Hardware ID must be a valid string when constructing a Consent object."),null):{Consented:b,Timestamp:c||Date.now(),ConsentDocument:d,Location:e,HardwareId:f}:(a.Logger.error("Consented boolean is required when constructing a Consent object."),null)},this.ConsentSerialization={toMinifiedJsonObject:function toMinifiedJsonObject(a){var b,c={};if(a){var d=a.getGDPRConsentState();if(d)for(var e in c.gdpr={},d)if(d.hasOwnProperty(e)){var f=d[e];c.gdpr[e]={},"boolean"==typeof f.Consented&&(c.gdpr[e].c=f.Consented),"number"==typeof f.Timestamp&&(c.gdpr[e].ts=f.Timestamp),"string"==typeof f.ConsentDocument&&(c.gdpr[e].d=f.ConsentDocument),"string"==typeof f.Location&&(c.gdpr[e].l=f.Location),"string"==typeof f.HardwareId&&(c.gdpr[e].h=f.HardwareId);}var g=a.getCCPAConsentState();g&&(c.ccpa=(b={},b[CCPAPurpose]={},b),"boolean"==typeof g.Consented&&(c.ccpa[CCPAPurpose].c=g.Consented),"number"==typeof g.Timestamp&&(c.ccpa[CCPAPurpose].ts=g.Timestamp),"string"==typeof g.ConsentDocument&&(c.ccpa[CCPAPurpose].d=g.ConsentDocument),"string"==typeof g.Location&&(c.ccpa[CCPAPurpose].l=g.Location),"string"==typeof g.HardwareId&&(c.ccpa[CCPAPurpose].h=g.HardwareId));}return c},fromMinifiedJsonObject:function fromMinifiedJsonObject(a){var d=c.createConsentState();if(!isObject(a))return d;if(isObject(a.gdpr))for(var e in a.gdpr)hasOwnProp(a.gdpr,e)&&d.addGDPRConsentState(e,b(a.gdpr[e]));return isObject(a.ccpa)&&hasOwnProp(a.ccpa,CCPAPurpose)&&d.setCCPAConsentState(b(a.ccpa[CCPAPurpose])),d}},this.createConsentState=function(b){function d(a){if("string"!=typeof a)return null;var b=a.trim();return b.length?b.toLowerCase():null}/**
1223
1218
  * Invoke these methods on a consent state object.
1224
1219
  * <p>
1225
1220
  * Usage: const consent = mParticle.Consent.createConsentState()
@@ -1233,7 +1228,7 @@ var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFil
1233
1228
  * @method addGDPRConsentState
1234
1229
  * @param purpose [String] Data processing purpose that describes the type of processing done on the data subject’s data
1235
1230
  * @param gdprConsent [Object] A GDPR consent object created via mParticle.Consent.createGDPRConsent(...)
1236
- */function e(c,e){var f=d(c);if(!f)return a.Logger.error("Purpose must be a string."),this;if(!isObject(e))return a.Logger.error("Invoked with a bad or empty consent object."),this;var g=b.createPrivacyConsent(e.Consented,e.Timestamp,e.ConsentDocument,e.Location,e.HardwareId);return g&&(k[f]=g),this}function f(a){if(!a)k={};else if(isObject(a))for(var b in k={},a)a.hasOwnProperty(b)&&this.addGDPRConsentState(b,a[b]);return this}/**
1231
+ */function e(b,e){var f=d(b);if(!f)return a.Logger.error("Purpose must be a string."),this;if(!isObject(e))return a.Logger.error("Invoked with a bad or empty consent object."),this;var g=c.createPrivacyConsent(e.Consented,e.Timestamp,e.ConsentDocument,e.Location,e.HardwareId);return g&&(k[f]=g),this}function f(a){if(!a)k={};else if(isObject(a))for(var b in k={},a)a.hasOwnProperty(b)&&this.addGDPRConsentState(b,a[b]);return this}/**
1237
1232
  * Remove a GDPR Consent State to the consent state object
1238
1233
  *
1239
1234
  * @method removeGDPRConsentState
@@ -1248,7 +1243,7 @@ var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFil
1248
1243
  *
1249
1244
  * @method setCCPAConsentState
1250
1245
  * @param {Object} ccpaConsent CCPA Consent State
1251
- */function i(c){if(!isObject(c))return a.Logger.error("Invoked with a bad or empty CCPA consent object."),this;var d=b.createPrivacyConsent(c.Consented,c.Timestamp,c.ConsentDocument,c.Location,c.HardwareId);return d&&(l[CCPAPurpose]=d),this}/**
1246
+ */function i(b){if(!isObject(b))return a.Logger.error("Invoked with a bad or empty CCPA consent object."),this;var d=c.createPrivacyConsent(b.Consented,b.Timestamp,b.ConsentDocument,b.Location,b.HardwareId);return d&&(l[CCPAPurpose]=d),this}/**
1252
1247
  * Gets the CCPA Consent State
1253
1248
  *
1254
1249
  * @method getCCPAConsentStatensent
@@ -1257,42 +1252,30 @@ var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFil
1257
1252
  * Removes CCPA from the consent state object
1258
1253
  *
1259
1254
  * @method removeCCPAConsentState
1260
- */function j(){return delete l[CCPAPurpose],this}var k={},l={};if(c){var m=b.createConsentState();return m.setGDPRConsentState(c.getGDPRConsentState()),m.setCCPAConsentState(c.getCCPAConsentState()),m}return {setGDPRConsentState:f,addGDPRConsentState:e,setCCPAConsentState:i,getCCPAConsentState:function a(){return l[CCPAPurpose]},getGDPRConsentState:h,removeGDPRConsentState:g,removeCCPAConsentState:j}};}
1255
+ */function j(){return delete l[CCPAPurpose],this}var k={},l={};if(b){var m=c.createConsentState();return m.setGDPRConsentState(b.getGDPRConsentState()),m.setCCPAConsentState(b.getCCPAConsentState()),m}return {setGDPRConsentState:f,addGDPRConsentState:e,setCCPAConsentState:i,getCCPAConsentState:function a(){return l[CCPAPurpose]},getGDPRConsentState:h,removeGDPRConsentState:g,removeCCPAConsentState:j}};}
1261
1256
 
1262
1257
  /*
1263
1258
  TODO: Including this as a workaround because attempting to import it from
1264
1259
  @mparticle/data-planning-models directly creates a build error.
1265
- */var DataPlanMatchType={ScreenView:"screen_view",CustomEvent:"custom_event",Commerce:"commerce",UserAttributes:"user_attributes",UserIdentities:"user_identities",ProductAction:"product_action",PromotionAction:"promotion_action",ProductImpression:"product_impression"},KitBlocker=/** @class */function(){function a(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=this;// if data plan is not requested, the data plan is {document: null}
1260
+ */var DataPlanMatchType={ScreenView:"screen_view",CustomEvent:"custom_event",Commerce:"commerce",UserAttributes:"user_attributes",UserIdentities:"user_identities",ProductAction:"product_action",PromotionAction:"promotion_action",ProductImpression:"product_impression"},withNoChange=function(a){return a},withoutUserAttributes=function(a){return __assign(__assign({},a),{UserAttributes:{}})},withoutUserIdentities=function(a){return __assign(__assign({},a),{UserIdentities:[]})},KitBlocker=/** @class */function(){function a(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=this;// if data plan is not requested, the data plan is {document: null}
1266
1261
  if(this.dataPlanMatchLookups={},this.blockEvents=!1,this.blockEventAttributes=!1,this.blockUserAttributes=!1,this.blockUserIdentities=!1,this.kitBlockingEnabled=!1,a&&!a.document)return void(this.kitBlockingEnabled=!1);this.kitBlockingEnabled=!0,this.mpInstance=b,this.blockEvents=null===(e=null===(d=null===(c=null===a||void 0===a?void 0:a.document)||void 0===c?void 0:c.dtpn)||void 0===d?void 0:d.blok)||void 0===e?void 0:e.ev,this.blockEventAttributes=null===(h=null===(g=null===(f=null===a||void 0===a?void 0:a.document)||void 0===f?void 0:f.dtpn)||void 0===g?void 0:g.blok)||void 0===h?void 0:h.ea,this.blockUserAttributes=null===(k=null===(j=null===(i=null===a||void 0===a?void 0:a.document)||void 0===i?void 0:i.dtpn)||void 0===j?void 0:j.blok)||void 0===k?void 0:k.ua,this.blockUserIdentities=null===(n=null===(m=null===(l=null===a||void 0===a?void 0:a.document)||void 0===l?void 0:l.dtpn)||void 0===m?void 0:m.blok)||void 0===n?void 0:n.id;var s=null===(q=null===(p=null===(o=null===a||void 0===a?void 0:a.document)||void 0===o?void 0:o.dtpn)||void 0===p?void 0:p.vers)||void 0===q?void 0:q.version_document,t=null===s||void 0===s?void 0:s.data_points;if(s)try{0<(null===t||void 0===t?void 0:t.length)&&t.forEach(function(a){return r.addToMatchLookups(a)});}catch(a){this.mpInstance.Logger.error("There was an issue with the data plan: "+a);}}return a.prototype.addToMatchLookups=function(a){var b,c,d;if(!a.match||!a.validator)return void this.mpInstance.Logger.warning("Data Plan Point is not valid' + ".concat(a));// match keys for non product custom attribute related data points
1267
1262
  var e=this.generateMatchKey(a.match),f=this.getPlannedProperties(a.match.type,a.validator);this.dataPlanMatchLookups[e]=f,((null===(b=null===a||void 0===a?void 0:a.match)||void 0===b?void 0:b.type)===DataPlanMatchType.ProductImpression||(null===(c=null===a||void 0===a?void 0:a.match)||void 0===c?void 0:c.type)===DataPlanMatchType.ProductAction||(null===(d=null===a||void 0===a?void 0:a.match)||void 0===d?void 0:d.type)===DataPlanMatchType.PromotionAction)&&(e=this.generateProductAttributeMatchKey(a.match),f=this.getProductProperties(a.match.type,a.validator),this.dataPlanMatchLookups[e]=f);},a.prototype.generateMatchKey=function(a){var b=a.criteria||"";switch(a.type){case DataPlanMatchType.CustomEvent:var c=b;return [DataPlanMatchType.CustomEvent,c.custom_event_type,c.event_name].join(":");case DataPlanMatchType.ScreenView:return [DataPlanMatchType.ScreenView,"",b.screen_name].join(":");case DataPlanMatchType.ProductAction:return [a.type,b.action].join(":");case DataPlanMatchType.PromotionAction:return [a.type,b.action].join(":");case DataPlanMatchType.ProductImpression:return [a.type,b.action].join(":");case DataPlanMatchType.UserIdentities:case DataPlanMatchType.UserAttributes:return [a.type].join(":");default:return null}},a.prototype.generateProductAttributeMatchKey=function(a){var b=a.criteria||"";switch(a.type){case DataPlanMatchType.ProductAction:return [a.type,b.action,"ProductAttributes"].join(":");case DataPlanMatchType.PromotionAction:return [a.type,b.action,"ProductAttributes"].join(":");case DataPlanMatchType.ProductImpression:return [a.type,"ProductAttributes"].join(":");default:return null}},a.prototype.getPlannedProperties=function(a,b){var c,d,e,f,g,h,i,j,k,l;switch(a){case DataPlanMatchType.CustomEvent:case DataPlanMatchType.ScreenView:case DataPlanMatchType.ProductAction:case DataPlanMatchType.PromotionAction:case DataPlanMatchType.ProductImpression:if(k=null===(f=null===(e=null===(d=null===(c=null===b||void 0===b?void 0:b.definition)||void 0===c?void 0:c.properties)||void 0===d?void 0:d.data)||void 0===e?void 0:e.properties)||void 0===f?void 0:f.custom_attributes,k){if(!0===k.additionalProperties||void 0===k.additionalProperties)return !0;for(var m,n={},o=0,p=Object.keys(k.properties);o<p.length;o++)m=p[o],n[m]=!0;return n}return !1!==(null===(i=null===(h=null===(g=null===b||void 0===b?void 0:b.definition)||void 0===g?void 0:g.properties)||void 0===h?void 0:h.data)||void 0===i?void 0:i.additionalProperties)||{};case DataPlanMatchType.UserAttributes:case DataPlanMatchType.UserIdentities:if(l=null===(j=null===b||void 0===b?void 0:b.definition)||void 0===j?void 0:j.additionalProperties,!0===l||void 0===l)return !0;for(var m,n={},q=b.definition.properties,r=0,s=Object.keys(q);r<s.length;r++)m=s[r],n[m]=!0;return n;default:return null}},a.prototype.getProductProperties=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v;switch(a){case DataPlanMatchType.ProductImpression://product item attributes
1268
1263
  if(v=null===(l=null===(k=null===(j=null===(i=null===(h=null===(g=null===(f=null===(e=null===(d=null===(c=null===b||void 0===b?void 0:b.definition)||void 0===c?void 0:c.properties)||void 0===d?void 0:d.data)||void 0===e?void 0:e.properties)||void 0===f?void 0:f.product_impressions)||void 0===g?void 0:g.items)||void 0===h?void 0:h.properties)||void 0===i?void 0:i.products)||void 0===j?void 0:j.items)||void 0===k?void 0:k.properties)||void 0===l?void 0:l.custom_attributes,!1===(null===v||void 0===v?void 0:v.additionalProperties)){for(var w,x={},y=0,z=Object.keys(null===v||void 0===v?void 0:v.properties);y<z.length;y++)w=z[y],x[w]=!0;return x}return !0;case DataPlanMatchType.ProductAction:case DataPlanMatchType.PromotionAction://product item attributes
1269
- if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null===(n=null===(m=null===b||void 0===b?void 0:b.definition)||void 0===m?void 0:m.properties)||void 0===n?void 0:n.data)||void 0===o?void 0:o.properties)||void 0===p?void 0:p.product_action)||void 0===q?void 0:q.properties)||void 0===r?void 0:r.products)||void 0===s?void 0:s.items)||void 0===t?void 0:t.properties)||void 0===u?void 0:u.custom_attributes,v&&!1===v.additionalProperties){for(var w,x={},A=0,B=Object.keys(null===v||void 0===v?void 0:v.properties);A<B.length;A++)w=B[A],x[w]=!0;return x}return !0;default:return null}},a.prototype.getMatchKey=function(a){switch(a.event_type){case dist.EventTypeEnum.screenView:var b=a;return b.data?["screen_view","",b.data.screen_name].join(":"):null;case dist.EventTypeEnum.commerceEvent:var c=a,d=[];if(c&&c.data){var e=c.data,f=e.product_action,g=e.product_impressions,h=e.promotion_action;f?(d.push(DataPlanMatchType.ProductAction),d.push(f.action)):h?(d.push(DataPlanMatchType.PromotionAction),d.push(h.action)):g&&d.push(DataPlanMatchType.ProductImpression);}return d.join(":");case dist.EventTypeEnum.customEvent:var i=a;return i.data?["custom_event",i.data.custom_event_type,i.data.event_name].join(":"):null;default:return null}},a.prototype.getProductAttributeMatchKey=function(a){switch(a.event_type){case dist.EventTypeEnum.commerceEvent:var b=[],c=a.data,d=c.product_action,e=c.product_impressions,f=c.promotion_action;return d?(b.push(DataPlanMatchType.ProductAction),b.push(d.action),b.push("ProductAttributes")):f?(b.push(DataPlanMatchType.PromotionAction),b.push(f.action),b.push("ProductAttributes")):e&&(b.push(DataPlanMatchType.ProductImpression),b.push("ProductAttributes")),b.join(":");default:return null}},a.prototype.createBlockedEvent=function(a){/*
1270
- return a transformed event based on event/event attributes,
1271
- then product attributes if applicable, then user attributes,
1272
- then the user identities
1273
- */try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b,c=__assign({},a),d=convertEvent(c),e=this.getMatchKey(d),f=this.dataPlanMatchLookups[e];if(this.blockEvents&&!f)/*
1264
+ if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null===(n=null===(m=null===b||void 0===b?void 0:b.definition)||void 0===m?void 0:m.properties)||void 0===n?void 0:n.data)||void 0===o?void 0:o.properties)||void 0===p?void 0:p.product_action)||void 0===q?void 0:q.properties)||void 0===r?void 0:r.products)||void 0===s?void 0:s.items)||void 0===t?void 0:t.properties)||void 0===u?void 0:u.custom_attributes,v&&!1===v.additionalProperties){for(var w,x={},A=0,B=Object.keys(null===v||void 0===v?void 0:v.properties);A<B.length;A++)w=B[A],x[w]=!0;return x}return !0;default:return null}},a.prototype.getMatchKey=function(a){switch(a.event_type){case dist.EventTypeEnum.screenView:var b=a;return b.data?["screen_view","",b.data.screen_name].join(":"):null;case dist.EventTypeEnum.commerceEvent:var c=a,d=[];if(c&&c.data){var e=c.data,f=e.product_action,g=e.product_impressions,h=e.promotion_action;f?(d.push(DataPlanMatchType.ProductAction),d.push(f.action)):h?(d.push(DataPlanMatchType.PromotionAction),d.push(h.action)):g&&d.push(DataPlanMatchType.ProductImpression);}return d.join(":");case dist.EventTypeEnum.customEvent:var i=a;return i.data?["custom_event",i.data.custom_event_type,i.data.event_name].join(":"):null;default:return null}},a.prototype.getProductAttributeMatchKey=function(a){switch(a.event_type){case dist.EventTypeEnum.commerceEvent:var b=[],c=a.data,d=c.product_action,e=c.product_impressions,f=c.promotion_action;return d?(b.push(DataPlanMatchType.ProductAction),b.push(d.action),b.push("ProductAttributes")):f?(b.push(DataPlanMatchType.PromotionAction),b.push(f.action),b.push("ProductAttributes")):e&&(b.push(DataPlanMatchType.ProductImpression),b.push("ProductAttributes")),b.join(":");default:return null}},a.prototype.createBlockedEvent=function(a){return a&&(a=this.applyBlockingStep("the event and its attributes",this.transformEventAndEventAttributes,a,withNoChange)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.applyBlockingStep("product attributes",this.transformProductAttributes,a,withNoChange)),a&&(a=this.applyBlockingStep("user attributes",this.transformUserAttributes,a,withoutUserAttributes),a=this.applyBlockingStep("user identities",this.transformUserIdentities,a,withoutUserIdentities)),a},a.prototype.applyBlockingStep=function(a,b,c,d){try{return b.call(this,c)}catch(b){var e=d(c);return this.reportFailedStep(a,b),e}},a.prototype.reportFailedStep=function(a,b){try{this.mpInstance.Logger.error("Kit blocking could not filter "+a+": "+b);}catch(a){// Best-effort: a logger or error value that throws must not stop the remaining steps.
1265
+ }},a.prototype.transformEventAndEventAttributes=function(a){var b,c=__assign({},a),d=convertEvent(c);if(!d)return c;var e=this.getMatchKey(d),f=this.dataPlanMatchLookups[e];if(this.blockEvents&&!f)/*
1274
1266
  If the event is not planned, it doesn't exist in dataPlanMatchLookups
1275
1267
  and should be blocked (return null to not send anything to forwarders)
1276
1268
  */return null;if(this.blockEventAttributes){/*
1277
1269
  matchedEvent is set to `true` if additionalProperties is `true`
1278
1270
  otherwise, delete attributes that exist on event.EventAttributes
1279
1271
  that aren't on
1280
- */if(!0===f)return c;if(f){for(var g,h=0,i=Object.keys(null!==(b=c.EventAttributes)&&void 0!==b?b:{});h<i.length;h++)g=i[h],f[g]||delete c.EventAttributes[g];return c}return c}return c},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
1281
- If the user attribute is not found in the matchedAttributes
1282
- then remove it from event.UserAttributes as it is blocked
1283
- */var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c))for(var d,e=0,f=Object.keys(b.UserAttributes);e<f.length;e++)d=f[e],c[d]||delete b.UserAttributes[d];}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;var b=this.dataPlanMatchLookups.user_attributes;// When additionalProperties is set to true, matchedAttributes
1272
+ */if(!0===f)return c;if(f){for(var g,h=0,i=Object.keys(null!==(b=c.EventAttributes)&&void 0!==b?b:{});h<i.length;h++)g=i[h],f[g]||delete c.EventAttributes[g];return c}return c}return c},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c)&&b.UserAttributes){for(var d,e={},f=0,g=Object.keys(b.UserAttributes);f<g.length;f++)d=g[f],!0===c[d]&&(e[d]=b.UserAttributes[d]);b.UserAttributes=e;}}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;var b=this.dataPlanMatchLookups.user_attributes;// When additionalProperties is set to true, matchedAttributes
1284
1273
  // will be a boolean, otherwise it will return an object
1285
1274
  return !("boolean"==typeof b&&b)&&"object"===_typeof(b)&&!0!==b[a];// When "Block unplanned user attributes" is enabled and "Allow unplanned user
1286
1275
  // attributes" is also enabled in the UI, allowing unplanned user attributes will be prioritized
1287
1276
  },a.prototype.isIdentityBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserIdentities)return !1;if(this.blockUserIdentities){var b=this.dataPlanMatchLookups.user_identities;// The lookup is absent, not empty, when the plan carries no
1288
1277
  // user_identities data point, and indexing it would throw.
1289
- if(!0===b||!b)return !1;if(!b[a])return !0}else return !1;return !1},a.prototype.transformUserIdentities=function(a){var b,c=this,d=__assign({},a);/*
1290
- If the user identity is not found in matchedIdentities
1291
- then remove it from event.UserIdentities as it is blocked.
1292
- event.UserIdentities is of type [{Identity: 'id1', Type: 7}, ...]
1293
- and so to compare properly in matchedIdentities, each Type needs
1294
- to be converted to an identityName
1295
- */if(this.blockUserIdentities){var e=this.dataPlanMatchLookups.user_identities;this.mpInstance._Helpers.isObject(e)&&(null===(b=null===d||void 0===d?void 0:d.UserIdentities)||void 0===b?void 0:b.length)&&d.UserIdentities.forEach(function(a,b){var f=Types.IdentityType.getIdentityName(c.mpInstance._Helpers.parseNumber(a.Type));e[f]||d.UserIdentities.splice(b,1);});}return d},a}();
1278
+ if(!0===b||!b)return !1;if(!b[a])return !0}else return !1;return !1},a.prototype.transformUserIdentities=function(a){var b,c=this,d=__assign({},a);if(this.blockUserIdentities){var e=this.dataPlanMatchLookups.user_identities;this.mpInstance._Helpers.isObject(e)&&(null===(b=null===d||void 0===d?void 0:d.UserIdentities)||void 0===b?void 0:b.length)&&(d.UserIdentities=d.UserIdentities.filter(function(a){var b=Types.IdentityType.getIdentityName(c.mpInstance._Helpers.parseNumber(a.Type));return e[b]}));}return d},a}();
1296
1279
 
1297
1280
  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
1298
1281
  return [2/*return*/,b]}})})};}
@@ -1350,10 +1333,10 @@ var s=(null===f||void 0===f?void 0:f.sandbox)||!1,t=normalizeRoktLauncherOptions
1350
1333
  // to the Rokt Launcher.
1351
1334
  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,this.watchRouteChanges(),(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.watchRouteChanges=function(){var a,b,c,d=this;return isFunction(null===(a=this.kit)||void 0===a?void 0:a.onRouteChange)?void(// A full navigation or a re-init lands on the trigger route without a route change
1352
1335
  // of its own.
1353
- this.isAutoLogPageViewEnabled()?(null===(c=this.stopRouteChangeWatch)||void 0===c?void 0:c.call(this),this.stopRouteChangeWatch=null):!this.stopRouteChangeWatch&&(this.stopRouteChangeWatch=subscribeToRouteChange("rokt:".concat(this.instanceName),function(){return d.notifyRouteChange()})),this.notifyRouteChange()):(null===(b=this.stopRouteChangeWatch)||void 0===b?void 0:b.call(this),void(this.stopRouteChangeWatch=null))},a.prototype.notifyRouteChange=function(){var a,b,c;try{null===(b=null===(a=this.kit)||void 0===a?void 0:a.onRouteChange)||void 0===b?void 0:b.call(a);}catch(a){null===(c=this.logger)||void 0===c?void 0:c.error("RoktManager: Error in onRouteChange: ".concat(getErrorMessage(a)));}},a.prototype.isAutoLogPageViewEnabled=function(){var a,b,c;return !0===(null===(c=null===(b=null===(a=this.store)||void 0===a?void 0:a.SDKConfig)||void 0===b?void 0:b.flags)||void 0===c?void 0:c[Constants.FeatureFlags.AutoLogPageView])},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return __awaiter(this,void 0,void 0,function(){var r,s,t,u,v,w,x,y,z,A,B,C,D,E,E,F,G,H,I,J,K,L,M,N=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
1354
- 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(r=a.attributes,s=(null===r||void 0===r?void 0:r.sandbox)||null,t=this.mapPlacementAttributes(r,this.placementAttributesMapping),(null===(d=this.logger)||void 0===d?void 0:d.isVerbose())&&(u=obfuscateDevData(r,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(u,null,2)))),this.currentUser=this.identityService.getCurrentUser(),v=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},w=v.email,x=t.email,y=void 0,z=void 0,A=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),A&&(y=v[this.mappedEmailShaIdentityType],z=t.emailsha256||t[this.mappedEmailShaIdentityType]||void 0),B=this.hasIdentityChanged(w,x),C=this.hasIdentityChanged(y,z),D={},B&&(D.email=x,x&&(E="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(E),null===(i=this.errorReporter)||void 0===i?void 0:i.report({message:E,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING}))),C&&(D[this.mappedEmailShaIdentityType]=z,E="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(E),null===(j=this.errorReporter)||void 0===j?void 0:j.report({message:E,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING})),!isEmpty(D))// Fire-and-forget identify — best-effort, does not block selectPlacements
1355
- try{this.identityService.identify({userIdentities:__assign(__assign({},v),D)},function(a){var b=+(null===a||void 0===a?void 0:a.httpCode);b&&(400<=b||0>b)&&N.logger.error("Background identify failed with HTTP "+b),N.processMessageQueue();});}catch(a){this.logger.error("Background identify threw an error: "+getErrorMessage(a));}return F=__assign(__assign({},v),D),this.setUserAttributes(t),G=null===(l=null===(k=this.store)||void 0===k?void 0:k.getTimeOnSite)||void 0===l?void 0:l.call(k),H=null===(n=null===(m=this.store)||void 0===m?void 0:m.getTotalTimeOnSite)||void 0===n?void 0:n.call(m),I=__assign(__assign(__assign(__assign({},t),null===s?{}:{sandbox:s}),G?{active_time_on_site_ms:G}:{}),H?{total_time_on_site_ms:H}:{}),F.email&&!I.email&&(I.email=F.email),A&&(J=F[this.mappedEmailShaIdentityType],J&&!I.emailsha256&&!I[this.mappedEmailShaIdentityType]&&(I.emailsha256=J)),I[PASSBACK_CONVERSION_TRACKING_ID]||(null===(o=this.integrationCapture)||void 0===o?void 0:o.capture(),K=null===(p=this.integrationCapture)||void 0===p?void 0:p.getClickIdsAsIntegrationAttributes(),L=null===(q=null===K||void 0===K?void 0:K[PARTNER_MODULE_IDS.Rokt])||void 0===q?void 0:q[PASSBACK_CONVERSION_TRACKING_ID],L&&(I[PASSBACK_CONVERSION_TRACKING_ID]=L)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,M=__assign(__assign({},a),{attributes:I}),[2/*return*/,this.kit.selectPlacements(M)]}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(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.terminate=function(){var a,b,c;return __awaiter(this,void 0,void 0,function(){var d;return __generator(this,function(e){switch(e.label){case 0:if(!this.isReady())return null===(a=this.logger)||void 0===a?void 0:a.verbose("mParticle.Rokt.terminate called before the Rokt kit was ready. Nothing to terminate."),[2/*return*/];if(!isFunction(this.kit.terminate))return null===(b=this.logger)||void 0===b?void 0:b.error("mParticle.Rokt.terminate is not supported by the attached Rokt Kit version."),[2/*return*/];e.label=1;case 1:return e.trys.push([1,3,,4]),[4/*yield*/,this.kit.terminate()];case 2:return e.sent(),[3/*break*/,4];case 3:return d=e.sent(),null===(c=this.logger)||void 0===c?void 0:c.error("Failed to terminate the Rokt launcher: ".concat(getErrorMessage(d))),[3/*break*/,4];case 4:return [2/*return*/]}})})},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
1356
- 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
1336
+ this.isAutoLogPageViewEnabled()?(null===(c=this.stopRouteChangeWatch)||void 0===c?void 0:c.call(this),this.stopRouteChangeWatch=null):!this.stopRouteChangeWatch&&(this.stopRouteChangeWatch=subscribeToRouteChange("rokt:".concat(this.instanceName),function(){return d.notifyRouteChange()})),this.notifyRouteChange()):(null===(b=this.stopRouteChangeWatch)||void 0===b?void 0:b.call(this),void(this.stopRouteChangeWatch=null))},a.prototype.notifyRouteChange=function(){var a,b,c;try{null===(b=null===(a=this.kit)||void 0===a?void 0:a.onRouteChange)||void 0===b?void 0:b.call(a);}catch(a){null===(c=this.logger)||void 0===c?void 0:c.error("RoktManager: Error in onRouteChange: ".concat(getErrorMessage(a)));}},a.prototype.isAutoLogPageViewEnabled=function(){var a,b,c;return !0===(null===(c=null===(b=null===(a=this.store)||void 0===a?void 0:a.SDKConfig)||void 0===b?void 0:b.flags)||void 0===c?void 0:c[Constants.FeatureFlags.AutoLogPageView])},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return __awaiter(this,void 0,void 0,function(){var r,s,t,u,v,w,x,y,z,A,B,C,D,E,E,F,G,H,I,J,K,L,M,N,O=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
1337
+ 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(r=a.attributes,s=(null===r||void 0===r?void 0:r.sandbox)||null,t=this.mapPlacementAttributes(r,this.placementAttributesMapping),(null===(d=this.logger)||void 0===d?void 0:d.isVerbose())&&(u=obfuscateDevData(r,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(u,null,2)))),this.currentUser=this.identityService.getCurrentUser(),v=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},w=v.email,x=t.email,y=void 0,z=void 0,A=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),A&&(y=v[this.mappedEmailShaIdentityType],z=t.emailsha256||t[this.mappedEmailShaIdentityType]||void 0),B=this.hasIdentityChanged(w,x),C=this.hasIdentityChanged(y,z),D={},B&&(D.email=x,x&&(E="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(E),null===(i=this.errorReporter)||void 0===i?void 0:i.report({message:E,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING}))),C&&(D[this.mappedEmailShaIdentityType]=z,E="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(E),null===(j=this.errorReporter)||void 0===j?void 0:j.report({message:E,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING})),F=this.toUserAttributes(t),isEmpty(D))this.setUserAttributes(this.currentUser,F);else// Fire-and-forget identify — best-effort, does not block selectPlacements
1338
+ try{this.identityService.identify({userIdentities:__assign(__assign({},v),D)},function(a){var b,c=+(null===a||void 0===a?void 0:a.httpCode);c&&(400<=c||0>c)&&O.logger.error("Background identify failed with HTTP "+c),O.setUserAttributes(null===(b=null===a||void 0===a?void 0:a.getUser)||void 0===b?void 0:b.call(a),F,D),O.processMessageQueue();});}catch(a){this.logger.error("Background identify threw an error: "+getErrorMessage(a)),this.setUserAttributes(this.identityService.getCurrentUser(),F,D);}return G=__assign(__assign({},v),D),H=null===(l=null===(k=this.store)||void 0===k?void 0:k.getTimeOnSite)||void 0===l?void 0:l.call(k),I=null===(n=null===(m=this.store)||void 0===m?void 0:m.getTotalTimeOnSite)||void 0===n?void 0:n.call(m),J=__assign(__assign(__assign(__assign({},t),null===s?{}:{sandbox:s}),H?{active_time_on_site_ms:H}:{}),I?{total_time_on_site_ms:I}:{}),G.email&&!J.email&&(J.email=G.email),A&&(K=G[this.mappedEmailShaIdentityType],K&&!J.emailsha256&&!J[this.mappedEmailShaIdentityType]&&(J.emailsha256=K)),J[PASSBACK_CONVERSION_TRACKING_ID]||(null===(o=this.integrationCapture)||void 0===o?void 0:o.capture(),L=null===(p=this.integrationCapture)||void 0===p?void 0:p.getClickIdsAsIntegrationAttributes(),M=null===(q=null===L||void 0===L?void 0:L[PARTNER_MODULE_IDS.Rokt])||void 0===q?void 0:q[PASSBACK_CONVERSION_TRACKING_ID],M&&(J[PASSBACK_CONVERSION_TRACKING_ID]=M)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,N=__assign(__assign({},a),{attributes:J}),[2/*return*/,this.kit.selectPlacements(N)]}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(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.terminate=function(){var a,b,c;return __awaiter(this,void 0,void 0,function(){var d;return __generator(this,function(e){switch(e.label){case 0:if(!this.isReady())return null===(a=this.logger)||void 0===a?void 0:a.verbose("mParticle.Rokt.terminate called before the Rokt kit was ready. Nothing to terminate."),[2/*return*/];if(!isFunction(this.kit.terminate))return null===(b=this.logger)||void 0===b?void 0:b.error("mParticle.Rokt.terminate is not supported by the attached Rokt Kit version."),[2/*return*/];e.label=1;case 1:return e.trys.push([1,3,,4]),[4/*yield*/,this.kit.terminate()];case 2:return e.sent(),[3/*break*/,4];case 3:return d=e.sent(),null===(c=this.logger)||void 0===c?void 0:c.error("Failed to terminate the Rokt launcher: ".concat(getErrorMessage(d))),[3/*break*/,4];case 4:return [2/*return*/]}})})},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
1339
+ return !!(this.kit&&this.kit.launcher)},a.prototype.toUserAttributes=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;}return c},a.prototype.setUserAttributes=function(a,b,c){if(void 0===c&&(c={}),!a)return void this.logger.warning("selectPlacements attributes were not set because there is no user to set them on.");try{if(this.hasContradictingIdentity(a,c))return void this.logger.warning("selectPlacements attributes were not set because identify did not resolve to a user with the passed email or hashed email.");a.setUserAttributes(b);}catch(a){this.logger.error("Error setting user attributes: "+a);}},a.prototype.hasContradictingIdentity=function(a,b){return Object.keys(b).some(function(c){var d,e,f=null===(e=null===(d=a.getUserIdentities())||void 0===d?void 0:d.userIdentities)||void 0===e?void 0:e[c];return !!f&&f!==b[c]})},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
1357
1340
  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
1358
1341
  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
1359
1342
  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