@mparticle/web-sdk 3.20.0 → 3.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +91 -38
- package/dist/mparticle.esm.js +91 -38
- package/dist/mparticle.js +425 -79
- package/dist/types/src/batchUploader.d.ts +2 -0
- package/dist/types/src/buttonTracking/buttonDescription.d.ts +7 -2
- package/dist/types/src/buttonTracking/buttonTracker.d.ts +6 -0
- package/dist/types/src/buttonTracking/checkoutIntent.d.ts +7 -1
- package/dist/types/src/buttonTracking/controls.d.ts +3 -0
- package/dist/types/src/roktManager.d.ts +4 -1
- package/package.json +1 -1
- package/src/batchUploader.ts +33 -1
- package/src/buttonTracking/buttonClickEvent.ts +6 -0
- package/src/buttonTracking/buttonDescription.ts +92 -8
- package/src/buttonTracking/buttonTracker.ts +92 -8
- package/src/buttonTracking/checkoutIntent.ts +199 -66
- package/src/buttonTracking/controls.ts +150 -32
- package/src/pageViewTracker.ts +7 -1
- package/src/roktManager.ts +16 -1
package/dist/mparticle.common.js
CHANGED
|
@@ -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.
|
|
18
|
+
var version = "3.22.0";
|
|
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
|
|
@@ -556,7 +556,7 @@ function appendUserInfo(a,b){if(b){if(!a)return b.MPID=null,b.ConsentState=null,
|
|
|
556
556
|
* Creates an instance of a BatchUploader
|
|
557
557
|
* @param {IMParticleWebSDKInstance} mpInstance - the mParticle SDK instance
|
|
558
558
|
* @param {number} uploadInterval - the desired upload interval in milliseconds
|
|
559
|
-
*/function a(b,c){var d,e,f;this.offlineStorageEnabled=!1,this.lastASTEventTime=0,this.AST_DEBOUNCE_MS=1e3,this.uploadIntervalTimerId=null,this.exitHandler=null,this.visibilityChangeHandler=null,this.destroyed=!1,this.mpInstance=b,this.uploadIntervalMillis=c,this.batchingEnabled=c>=a.MINIMUM_INTERVAL_MILLIS,this.uploadIntervalMillis<a.MINIMUM_INTERVAL_MILLIS&&(this.uploadIntervalMillis=a.MINIMUM_INTERVAL_MILLIS),this.eventsQueuedForProcessing=[],this.batchesQueuedForProcessing=[],this.offlineStorageEnabled=this.isOfflineStorageAvailable();// When noFunctional is true, prevent events/batches storage
|
|
559
|
+
*/function a(b,c){var d,e,f;this.offlineStorageEnabled=!1,this.lastASTEventTime=0,this.AST_DEBOUNCE_MS=1e3,this.uploadIntervalTimerId=null,this.exitHandler=null,this.visibilityChangeHandler=null,this.destroyed=!1,this.batchOrder=new Map,this.nextBatchOrder=0,this.mpInstance=b,this.uploadIntervalMillis=c,this.batchingEnabled=c>=a.MINIMUM_INTERVAL_MILLIS,this.uploadIntervalMillis<a.MINIMUM_INTERVAL_MILLIS&&(this.uploadIntervalMillis=a.MINIMUM_INTERVAL_MILLIS),this.eventsQueuedForProcessing=[],this.batchesQueuedForProcessing=[],this.offlineStorageEnabled=this.isOfflineStorageAvailable();// When noFunctional is true, prevent events/batches storage
|
|
560
560
|
var g=null===(e=b._CookieConsentManager)||void 0===e?void 0:e.getNoFunctional();this.offlineStorageEnabled&&!g&&(this.eventVault=new SessionStorageVault("".concat(b._Store.storageName,"-events")),this.batchVault=new LocalStorageVault("".concat(b._Store.storageName,"-batches")),(d=this.eventsQueuedForProcessing).push.apply(d,null!==(f=this.eventVault.retrieve())&&void 0!==f?f:[]));var h=this.mpInstance._Store,i=h.SDKConfig,j=h.devToken,k=this.mpInstance._Helpers.createServiceUrl(i.v3SecureServiceUrl,j);this.uploadUrl="".concat(k,"/events"),this.uploader=window.fetch?new FetchUploader(this.uploadUrl):new XHRUploader(this.uploadUrl),this.triggerUploadInterval(!0,!1),this.addEventListeners();}/**
|
|
561
561
|
* Cleans up timers and event listeners to prevent leaks when the SDK
|
|
562
562
|
* is re-initialized (e.g. between tests or on repeated init calls).
|
|
@@ -570,11 +570,14 @@ var c=a.mpInstance._Helpers.getFeatureFlag,d=Constants.FeatureFlags.AstBackgroun
|
|
|
570
570
|
var e=b.createBackgroundASTEvent();b.queueEvent(e);}// Then trigger the upload with beacon
|
|
571
571
|
b.prepareAndUpload(!1,b.isBeaconAvailable());};this.exitHandler=c,this.visibilityChangeHandler=function(){"hidden"===document.visibilityState&&c();},document.addEventListener("visibilitychange",this.visibilityChangeHandler),window.addEventListener("beforeunload",c),window.addEventListener("pagehide",c);},a.prototype.isBeaconAvailable=function(){return !!navigator.sendBeacon},a.prototype.triggerUploadInterval=function(a,b){var c=this;void 0===a&&(a=!1),void 0===b&&(b=!1),this.uploadIntervalTimerId=setTimeout(function(){c.prepareAndUpload(a,b);},this.uploadIntervalMillis);},a.prototype.queueEvent=function(a){if(!isEmpty(a)){if(this.eventsQueuedForProcessing.push(a),this.offlineStorageEnabled&&this.eventVault&&this.eventVault.store(this.eventsQueuedForProcessing),this.mpInstance.Logger.isVerbose()){var b=obfuscateDevData(a,this.mpInstance._Store.SDKConfig.isDevelopmentMode);this.mpInstance.Logger.verbose("Queuing event: ".concat(JSON.stringify(b))),this.mpInstance.Logger.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));}this.shouldTriggerImmediateUpload(a.EventDataType)&&this.prepareAndUpload(!1,!1);}},a.prototype.shouldTriggerImmediateUpload=function(a){var b=[MessageType$1.Commerce,MessageType$1.UserIdentityChange];return !this.batchingEnabled||b.includes(a)},(a.createNewBatches=function(a,b,c){if(!b||!a||!a.length)return null;//bucket by MPID, and then by session, ordered by timestamp
|
|
572
572
|
for(var d,e=[],f=new Map,g=0,h=a;g<h.length;g++){//on initial startup, there may be events logged without an mpid.
|
|
573
|
-
if(d=h[g],!d.MPID){var i=b.getMPID();d.MPID=i;}var j=f.get(d.MPID);j||(j=[]),j.push(d),f.set(d.MPID,j);}for(var k=0,l=Array.from(f.entries());k<l.length;k++){for(var m=l[k],i=m[0],n=m[1],o=new Map,p=0,q=n;p<q.length;p++){var d=q[p],j=o.get(d.SessionId);j||(j=[]),j.push(d),o.set(d.SessionId,j);}for(var r=0,s=Array.from(o.entries());r<s.length;r++){var t=s[r],u=convertEvents(i,t[1],c),v=c._Store.SDKConfig.onCreateBatch;v&&(u=v(u),u?u.modified=!0:c.Logger.warning("Skiping batch upload because no batch was returned from onCreateBatch callback")),u&&e.push(u);}}return e},a.prototype.prepareAndUpload=function(b,c){var d;return void 0===b&&(b=!1),void 0===c&&(c=!1),__awaiter(this,void 0,void 0,function(){var e,f,g,h,i,j,k,l;return __generator(this,function(
|
|
574
|
-
|
|
573
|
+
if(d=h[g],!d.MPID){var i=b.getMPID();d.MPID=i;}var j=f.get(d.MPID);j||(j=[]),j.push(d),f.set(d.MPID,j);}for(var k=0,l=Array.from(f.entries());k<l.length;k++){for(var m=l[k],i=m[0],n=m[1],o=new Map,p=0,q=n;p<q.length;p++){var d=q[p],j=o.get(d.SessionId);j||(j=[]),j.push(d),o.set(d.SessionId,j);}for(var r=0,s=Array.from(o.entries());r<s.length;r++){var t=s[r],u=convertEvents(i,t[1],c),v=c._Store.SDKConfig.onCreateBatch;v&&(u=v(u),u?u.modified=!0:c.Logger.warning("Skiping batch upload because no batch was returned from onCreateBatch callback")),u&&e.push(u);}}return e},a.prototype.prepareAndUpload=function(b,c){var d;return void 0===b&&(b=!1),void 0===c&&(c=!1),__awaiter(this,void 0,void 0,function(){var e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:return e=this.mpInstance.Identity.getCurrentUser(),f=this.eventsQueuedForProcessing,this.eventsQueuedForProcessing=[],this.offlineStorageEnabled&&this.eventVault&&this.eventVault.store([]),g=[],isEmpty(f)||(g=a.createNewBatches(f,e,this.mpInstance)),this.offlineStorageEnabled&&this.batchVault&&((k=this.batchesQueuedForProcessing).unshift.apply(k,null!==(d=this.batchVault.retrieve())&&void 0!==d?d:[]),this.batchVault.purge()),isEmpty(g)||(l=this.batchesQueuedForProcessing).push.apply(l,g),h=this.batchesQueuedForProcessing,this.batchesQueuedForProcessing=[],h.forEach(function(a){n.batchOrder.has(a.source_request_id)||n.batchOrder.set(a.source_request_id,n.nextBatchOrder++);}),[4/*yield*/,this.uploadBatches(h,c)];case 1:return i=o.sent(),j=(i||[]).map(function(a){return a.source_request_id}),h.forEach(function(a){-1===j.indexOf(a.source_request_id)&&n.batchOrder["delete"](a.source_request_id);}),isEmpty(i)||(m=this.batchesQueuedForProcessing).unshift.apply(m,i),!c&&this.offlineStorageEnabled&&this.batchVault&&this.storeBatchesQueuedForProcessing(),b&&!this.destroyed&&this.triggerUploadInterval(b,!1),[2/*return*/]}})})},a.prototype.storeBatchesQueuedForProcessing=function(){var a,b=this,c=function(a){var c;return null!==(c=b.batchOrder.get(a.source_request_id))&&void 0!==c?c:-1},d=__spreadArray(__spreadArray([],this.batchesQueuedForProcessing,!0),null!==(a=this.batchVault.retrieve())&&void 0!==a?a:[],!0).sort(function(d,a){var b,e;return c(d)-c(a)||(null!==(b=d.timestamp_unixtime_ms)&&void 0!==b?b:0)-(null!==(e=a.timestamp_unixtime_ms)&&void 0!==e?e:0)});// Another upload may have stored its failed batches while this one was
|
|
574
|
+
// in flight. Merge them in creation order, whichever upload finished
|
|
575
|
+
// first, so they are not overwritten and quota trimming drops the oldest.
|
|
576
|
+
// Nothing to persist: reset offline storage to an empty state.
|
|
577
|
+
if(isEmpty(d))return this.batchVault.store([]),void(this.batchesQueuedForProcessing=[]);// Drop oldest batches until storage accepts the payload. Only quota
|
|
575
578
|
// failures are recoverable by trimming; if storage is unavailable,
|
|
576
579
|
// dropping batches won't help, so retain them in memory.
|
|
577
|
-
for(var
|
|
580
|
+
for(var e,f=0;f<d.length;f++){if(e=this.batchVault.store(d.slice(f)),e===StorageResult.Success)return this.logDroppedOfflineBatches(f),void(this.batchesQueuedForProcessing=[]);if(e===StorageResult.Unavailable)return void this.mpInstance.Logger.warning("Offline batch storage is unavailable. Retaining batches in memory.")}// Every attempt stayed over quota, even down to the newest batch.
|
|
578
581
|
// Retain them in memory rather than dropping everything.
|
|
579
582
|
this.mpInstance.Logger.warning("Offline batch storage is over quota. Retaining batches in memory.");},a.prototype.logDroppedOfflineBatches=function(a){0<a&&this.mpInstance.Logger.warning("Offline batch storage is over quota. Dropped "+"".concat(a," oldest batch(es)."));},a.prototype.uploadBatches=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,j,k;return __generator(this,function(i){switch(i.label){case 0:if(d=b.filter(function(a){return !isEmpty(a.events)}),isEmpty(d))return [2/*return*/,null];this.mpInstance.Logger.isVerbose()&&(e=obfuscateDevData(d,this.mpInstance._Store.SDKConfig.isDevelopmentMode),this.mpInstance.Logger.verbose("Uploading batches: ".concat(JSON.stringify(e))),this.mpInstance.Logger.verbose("Batch count: ".concat(d.length))),f=0,i.label=1;case 1:return f<d.length?(g={method:"POST",headers:{Accept:a.CONTENT_TYPE,"Content-Type":"text/plain;charset=UTF-8"},body:JSON.stringify(d[f])},!(c&&this.isBeaconAvailable()))?[3/*break*/,2]:(h=new Blob([g.body],{type:"text/plain;charset=UTF-8"}),navigator.sendBeacon(this.uploadUrl,h),[3/*break*/,5]):[3/*break*/,6];case 2:return i.trys.push([2,4,,5]),[4/*yield*/,this.uploader.upload(g)];case 3:if(j=i.sent(),200<=j.status&&300>j.status)this.mpInstance.Logger.verbose("Upload success for request ID: ".concat(d[f].source_request_id));else {if(500<=j.status||429===j.status)// Server error, add back current batches and try again later
|
|
580
583
|
return this.mpInstance.Logger.error("HTTP error status ".concat(j.status," received")),[2/*return*/,d.slice(f,d.length)];if(401<=j.status)//if we're getting a 401, assume we'll keep getting a 401 and clear the uploads.
|
|
@@ -898,10 +901,11 @@ var ALLOWED_QUERY_PARAMS=[// Campaign attribution
|
|
|
898
901
|
"gclid","gbraid","wbraid","fbclid","msclkid","ttclid","twclid","li_fat_id","dclid",// OAuth / OIDC \u2014 see the SECURITY note above
|
|
899
902
|
"client_id","redirect_uri","response_type","scope","state","code","nonce",// Pagination
|
|
900
903
|
"page","limit","offset","cursor","per_page",// Site search term, as the common platforms spell it. Matching is
|
|
901
|
-
// case-insensitive
|
|
902
|
-
|
|
904
|
+
// case-insensitive. `s` is WordPress and WooCommerce search; other
|
|
905
|
+
// single-letter names are too generic. `oq` is a storefront search term.
|
|
906
|
+
"q","s","oq","search","query","keyword","keywords","term","text","searchTerm","searchText","search_query","search_text","Ntt",// Product and variant identifiers. `cid` is not a category: it is a
|
|
903
907
|
// customer id on many sites.
|
|
904
|
-
"pid","productId","sku","skuId","variant",// Category
|
|
908
|
+
"pid","productId","sku","skuId","variant","color","colour","size",// Category
|
|
905
909
|
"category",// Referral
|
|
906
910
|
"ref","referrer"];// ---------------------------------------------------------------------------
|
|
907
911
|
// Pure helpers. No `this`, no globals, no side effects \u2014 callable and assertable
|
|
@@ -1333,7 +1337,7 @@ var s=(null===f||void 0===f?void 0:f.sandbox)||!1,t=normalizeRoktLauncherOptions
|
|
|
1333
1337
|
// to the Rokt Launcher.
|
|
1334
1338
|
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(),this.flushCheckoutIntents(),(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
|
|
1335
1339
|
// of its own.
|
|
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.isCheckoutIntentSuppressed=function(){var a,b,c=null===(b=null===(a=this.store)||void 0===a?void 0:a.SDKConfig)||void 0===b?void 0:b.flags;if(!c||!0!==c[Constants.FeatureFlags.AutoButtonTracking]||!this.store.isEnabled)return !0;var d=this.launcherOptions||{};if(d.noFunctional||d.noTargeting||d.doNotShareOrSell)return !0;var e="undefined"==typeof navigator?void 0:navigator;return !!e&&!0===e.globalPrivacyControl},a.prototype.notifyCheckoutIntent=function(a,b){var c;if(void 0===b&&(b=window.location.pathname),!this.isCheckoutIntentSuppressed()){var d=this.kit;if(!d)return void(this.pendingCheckoutIntents=this.pendingCheckoutIntents.filter(function(b){return b.signal.kind!==a.kind}).concat({signal:a,pathname:b}).slice(-CHECKOUT_INTENT_BUFFER_LIMIT));try{isFunction(d.onCheckoutIntent)&&d.onCheckoutIntent(a);}catch(a){null===(c=this.logger)||void 0===c?void 0:c.error("RoktManager: Error in onCheckoutIntent: ".concat(getErrorMessage(a)));}}},a.prototype.discardCheckoutIntents=function(){this.pendingCheckoutIntents=[];},a.prototype.flushCheckoutIntents=function(){var a=this,b=this.pendingCheckoutIntents;this.pendingCheckoutIntents=[];var c=Date.now(),d=window.location.pathname;b.filter(function(a){var b=a.signal,e=a.pathname;return c-b.t<CHECKOUT_INTENT_MAX_AGE_MS&&e===d}).sort(function(c,a){return c.signal.t-a.signal.t}).forEach(function(b){var c=b.signal;return a.notifyCheckoutIntent(c)});},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
|
|
1340
|
+
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.isCheckoutIntentSuppressed=function(){var a,b,c=null===(b=null===(a=this.store)||void 0===a?void 0:a.SDKConfig)||void 0===b?void 0:b.flags;if(!c||!0!==c[Constants.FeatureFlags.AutoButtonTracking]||!this.store.isEnabled)return !0;var d=this.launcherOptions||{};if(d.noFunctional||d.noTargeting||d.doNotShareOrSell)return !0;var e="undefined"==typeof navigator?void 0:navigator;return !!e&&!0===e.globalPrivacyControl},a.prototype.isCheckoutIntentLive=function(){return !this.isCheckoutIntentSuppressed()&&"undefined"!=typeof Event&&isFunction(Event.prototype.composedPath)},a.prototype.notifyCheckoutIntent=function(a,b){var c;if(void 0===b&&(b=window.location.pathname),!this.isCheckoutIntentSuppressed()){var d=this.kit;if(!d)return void(this.pendingCheckoutIntents=this.pendingCheckoutIntents.filter(function(b){return b.signal.kind!==a.kind}).concat({signal:a,pathname:b}).slice(-CHECKOUT_INTENT_BUFFER_LIMIT));try{isFunction(d.onCheckoutIntent)&&d.onCheckoutIntent(a);}catch(a){null===(c=this.logger)||void 0===c?void 0:c.error("RoktManager: Error in onCheckoutIntent: ".concat(getErrorMessage(a)));}}},a.prototype.discardCheckoutIntents=function(){this.pendingCheckoutIntents=[];},a.prototype.flushCheckoutIntents=function(){var a=this,b=this.pendingCheckoutIntents;this.pendingCheckoutIntents=[];var c=Date.now(),d=window.location.pathname;b.filter(function(a){var b=a.signal,e=a.pathname;return c-b.t<CHECKOUT_INTENT_MAX_AGE_MS&&e===d}).sort(function(c,a){return c.signal.t-a.signal.t}).forEach(function(b){var c=b.signal;return a.notifyCheckoutIntent(c)});},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
1341
|
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 \u2014 best-effort, does not block selectPlacements
|
|
1338
1342
|
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
1343
|
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
|
|
@@ -1364,17 +1368,33 @@ var BUTTON_CLICK_EVENT_NAME="Auto Button Click";// One custom event per click, l
|
|
|
1364
1368
|
// page fields that auto page views carry. No intent: classifying clicks is left
|
|
1365
1369
|
// to whoever reads the data.
|
|
1366
1370
|
var buildButtonClickEvent=function(a,b){// Optional fields are left out when the button has no safe value for them.
|
|
1367
|
-
for(var c,d,e=(c={label_source:a.labelSource,element:a.element,type:a.type,path:b,hostname:window.location.hostname},c[AUTO_BUTTON_ATTRIBUTE]=!0,c),f={label:a.label,aria_label:a.ariaLabel,icon:a.icon,element_id:a.elementId,element_name:a.elementName,test_id:a.testId,controls:a.controls,form:a.form},g=0,h=Object.keys(f);g<h.length;g++)d=h[g],f[d]&&(e[d]=f[d]);return {messageType:MessageType$1.PageEvent,name:BUTTON_CLICK_EVENT_NAME,data:e,eventType:EventType.Other}};
|
|
1371
|
+
for(var c,d,e=(c={label_source:a.labelSource,element:a.element,type:a.type,path:b,hostname:window.location.hostname},c[AUTO_BUTTON_ATTRIBUTE]=!0,c),f={label:a.label,aria_label:a.ariaLabel,icon:a.icon,element_id:a.elementId,element_name:a.elementName,test_id:a.testId,controls:a.controls,form:a.form,link_type:a.linkType,link_domain:a.linkDomain,file_extension:a.fileExtension},g=0,h=Object.keys(f);g<h.length;g++)d=h[g],f[d]&&(e[d]=f[d]);return void 0!==a.checked&&(e.checked=a.checked),{messageType:MessageType$1.PageEvent,name:BUTTON_CLICK_EVENT_NAME,data:e,eventType:EventType.Other}};
|
|
1368
1372
|
|
|
1369
1373
|
// descriptions. Rokt's own elements, disabled controls and anything under
|
|
1370
1374
|
// data-mp-no-track are never returned.
|
|
1371
1375
|
var CONTROL_SELECTOR="button, input[type=\"submit\"], input[type=\"button\"], input[type=\"image\"], [role=\"button\"]";// closest() over the composed tree: slots, parents, then shadow hosts.
|
|
1372
|
-
function hasComposedAncestor(a,b){for(var c=a;c;){if(c.matches(b))return !0;var d=isFunction(c.getRootNode)?c.getRootNode():null;c=c.assignedSlot||c.parentElement||d&&d.host||null;}return !1}
|
|
1373
|
-
function
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1376
|
+
function hasComposedAncestor(a,b){for(var c=a;c;){if(c.matches(b))return !0;var d=isFunction(c.getRootNode)?c.getRootNode():null;c=c.assignedSlot||c.parentElement||d&&d.host||null;}return !1}var ROKT_SELECTOR="[data-core-type], #rokt-controller-frame";// A Rokt frame or script is served from a /wsdk/ path.
|
|
1377
|
+
function hasRoktSrc(a){var b=a.getAttribute("src");if(!b)return !1;try{return -1!==new URL(b,"https://example.test").pathname.indexOf("/wsdk/")}catch(a){// An unparseable src is not a Rokt element.
|
|
1378
|
+
return !1}}// Rokt's own placements and frames never count as partner checkout controls.
|
|
1379
|
+
function isRoktElement(a){return hasComposedAncestor(a,ROKT_SELECTOR)||hasRoktSrc(a)}// Wallet and quick-pay buttons as their vendors render them: official custom
|
|
1380
|
+
// elements and documented classes, ids and attributes.
|
|
1381
|
+
var CARD_FORM_BUTTON="paypal-basic-card-button",VENDOR_BUTTON="apple-pay-button, .apple-pay-button, .gpay-button, .gpay-card-info-container, #gpay-button-online-api-id, paypal-button, venmo-button, paypal-pay-later-button, paypal-credit-button, shop-pay-button, shop-pay-wallet-button, shopify-accelerated-checkout, shopify-accelerated-checkout-cart, shopify-apple-pay-button, shopify-google-pay-button, shopify-paypal-button, shopify-amazon-pay-button, .amazonpay-button-focusable, #AmazonPayButton, [data-amazon-pay-button], [data-afterpay-entry-point], "+CARD_FORM_BUTTON,NOT_A_PAYMENT=["set-up","add-money","reload","top-up"].map(function(a){return "apple-pay-button[type=\""+a+"\"]"}).join(", ");// PayPal's card button opens a card form, so it is a step rather than a wallet.
|
|
1382
|
+
// Apple's set-up and top-up buttons manage a wallet rather than pay with it.
|
|
1383
|
+
// What a vendor's own button markup says about a control. Only the control or
|
|
1384
|
+
// the shadow host that owns it counts, so a merchant wrapper reusing a vendor
|
|
1385
|
+
// class never turns its children into wallet buttons.
|
|
1386
|
+
function vendorButtonKind(a){var b=a.matches(VENDOR_BUTTON)?a:null;if(!b){var c=isFunction(a.getRootNode)?a.getRootNode():null;b=c&&c.host&&c.host.matches(VENDOR_BUTTON)?c.host:null;}return b?b.matches(NOT_A_PAYMENT)?"none":b.matches(CARD_FORM_BUTTON)?"checkout_step":"wallet":void 0}function isWalletElement(a){return "wallet"===vendorButtonKind(a)}// Pickers and toggles choose a payment method or open a panel; they never pay.
|
|
1387
|
+
var PICKER="input[type=\"radio\"], input[type=\"checkbox\"], label, [role=\"radio\"], [role=\"tab\"], [role=\"option\"], [role=\"checkbox\"], [role=\"switch\"], [role=\"menuitemradio\"], [role=\"menuitemcheckbox\"], [aria-checked], [aria-selected]",PICKER_GROUP="[role=\"radiogroup\"], [role=\"tablist\"], [role=\"listbox\"]",MESSAGING="klarna-placement, afterpay-placement, square-placement, .affirm-as-low-as, .affirm-site-modal, .affirm-product-modal, [data-pp-message]";// Pay-later and financing messages link to details rather than pay.
|
|
1388
|
+
// A control that is still logged as a click but never counts as checkout intent.
|
|
1389
|
+
function isQuietIntentControl(a,b){return !!a.matches(PICKER)||!!hasComposedAncestor(a,PICKER_GROUP)||!!(!b&&(a.hasAttribute("aria-expanded")||a.hasAttribute("aria-pressed")))||hasComposedAncestor(a,MESSAGING)}// A checkbox or radio is a control of its own only when no button or link
|
|
1390
|
+
// around it takes the click, so a tappable row keeps its own name.
|
|
1391
|
+
var OPTION_INPUT="input[type=\"checkbox\"], input[type=\"radio\"]";// Walks at most 12 entries of an event's composed path for the nearest control.
|
|
1392
|
+
// One composed walk from the target rules out Rokt elements and anything under
|
|
1393
|
+
// data-mp-no-track; disabled controls are skipped.
|
|
1394
|
+
function findControl(a){for(var b,c,d=a.slice(0,12),e=0,f=d;e<f.length;e++)if(c=f[e],c instanceof Element){b=c;break}if(b&&!hasComposedAncestor(b,"[data-core-type], #rokt-controller-frame, [data-mp-no-track]")){for(var g,h,c,i=0;i<(void 0).length;i++)if(c=(void 0)[i],!!(c instanceof Element)){if(hasRoktSrc(c))return;!g&&c.matches("button, input[type=\"submit\"], input[type=\"button\"], input[type=\"image\"], [role=\"button\"], a[href], "+VENDOR_BUTTON)?g=c:!g&&!h&&c.matches(OPTION_INPUT)&&(h=c);}return g=g||h,!g||g.matches(":disabled, [aria-disabled=\"true\"]")?void 0:g}}// fields, editable regions, and anything under data-mp-no-track.
|
|
1395
|
+
function isUnsafeTextSource(a){return a.matches("input, select, textarea, option, optgroup, datalist, [contenteditable]:not([contenteditable=\"false\"])")||!!a.querySelector("input, select, textarea, [data-mp-no-track], [contenteditable]:not([contenteditable=\"false\"])")||hasComposedAncestor(a,"select, datalist, textarea, [data-mp-no-track], [contenteditable]:not([contenteditable=\"false\"])")}// A label around a checkbox or radio holds no typed text, so only the other
|
|
1396
|
+
// fields rule its text out.
|
|
1397
|
+
function isUnsafeLabelSource(a){return !!a.querySelector("input:not([type=\"checkbox\"]):not([type=\"radio\"]), select, textarea, [data-mp-no-track], [contenteditable]:not([contenteditable=\"false\"])")||hasComposedAncestor(a,"select, datalist, textarea, [data-mp-no-track], [contenteditable]:not([contenteditable=\"false\"])")}
|
|
1378
1398
|
|
|
1379
1399
|
// Masks a button label before it is logged. Button text can carry personal data,
|
|
1380
1400
|
// so this is the privacy boundary for every label and aria-label.
|
|
@@ -1384,13 +1404,15 @@ function createDigitPatterns(){try{return {run:/\p{Nd}{6,}/u,number:/\p{Nd}+(?:[
|
|
|
1384
1404
|
// masked. Dropped when it looks like an email, phone or card number.
|
|
1385
1405
|
function maskLabel(a){if(a&&!(128<a.length)&&digitPatterns){var b=a.replace(/\s+/g," ").trim().toLowerCase();if(b&&-1===b.indexOf("@")&&!digitPatterns.run.test(b.replace(/[\s()\-\u2010-\u2015]/g,""))){var c=b.replace(digitPatterns.number,"#").slice(0,64).trim();return c||void 0}}}
|
|
1386
1406
|
|
|
1387
|
-
function elementKind(a){if(isWalletElement(a))return "wallet";var b=a.tagName.toLowerCase();return "button"===b||"input"===b?b:"role"}function textOf(a){return a&&!isUnsafeTextSource(a)&&a.textContent?a.textContent.trim():""}function nonBlank(a){return a&&a.trim()?a:void 0}// The button's name as a screen reader would read it, simplified: the first of
|
|
1388
|
-
// aria-labelledby, aria-label, own text (or an inner image's alt), title,
|
|
1389
|
-
// inputs their value
|
|
1390
|
-
//
|
|
1407
|
+
var DOWNLOAD_EXTENSIONS=/\.(pdf|zip|csv|txt|ics|docx?|xlsx?|pptx?|dmg|exe|apk|mp3|mp4)$/i;function elementKind(a){if(isWalletElement(a))return "wallet";var b=a.tagName.toLowerCase();return "button"===b||"input"===b?b:a.matches("a[href]:not([role=\"button\"])")?"link":"role"}function textOf(a){return a&&!isUnsafeTextSource(a)&&a.textContent?a.textContent.trim():""}function nonBlank(a){return a&&a.trim()?a:void 0}// The button's name as a screen reader would read it, simplified: the first of
|
|
1408
|
+
// aria-labelledby, aria-label, own text (or an inner image's alt), title, for
|
|
1409
|
+
// inputs their value, and for checkboxes and radios their label's text. The text
|
|
1410
|
+
// sources are skipped for controls that hold form fields or more than four
|
|
1411
|
+
// children, so a typed value is never read.
|
|
1391
1412
|
function accessibleName(a){var b=a.getAttribute("aria-labelledby");if(b){var c=isFunction(a.getRootNode)?a.getRootNode():document,d=b.split(/\s+/).map(function(a){return textOf(c.getElementById?c.getElementById(a):null)}).filter(function(a){return !!a}).join(" ");if(d)return {raw:d,source:"labelledby"}}var e=nonBlank(a.getAttribute("aria-label"));if(e)return {raw:e,source:"aria"};var f=4>=a.children.length&&!isUnsafeTextSource(a);if(a instanceof HTMLInputElement){// The browser's normalised type: an unknown value reads as 'text'.
|
|
1392
1413
|
var g=a.type;if("image"===g){var h=nonBlank(a.getAttribute("alt"));if(h)return {raw:h,source:"alt"}}else if("submit"===g||"button"===g||"reset"===g){var i=nonBlank(a.value);if(i)return {raw:i,source:"value"};if("button"!==g)// What the browser shows on an input without a value.
|
|
1393
|
-
return {raw:g,source:"value"}}
|
|
1414
|
+
return {raw:g,source:"value"}}else if("checkbox"===g||"radio"===g){// The label the browser ties to the box, never the box's value.
|
|
1415
|
+
var j=a.labels?a.labels[0]:void 0,d=j&&!isUnsafeLabelSource(j)&&j.textContent?j.textContent.trim():"";if(d)return {raw:d,source:"label"}}}else if(f){var d=textOf(a);if(d)return {raw:d,source:"text"};var k=a.querySelector("img[alt]"),h=k?nonBlank(k.getAttribute("alt")):void 0;if(h)return {raw:h,source:"alt"}}var l=nonBlank(a.getAttribute("title"));return l?{raw:l,source:"title"}:{source:"none"}}var ICON_CLASS=/^(?:fa|fas|far|fal|icon|bi|glyphicon|ti|mdi|ri|la|lucide|ion|feather|ph)-([a-z][a-z-]{1,31})$/,ICON_MODIFIER=/^(?:solid|regular|light|thin|duotone|brands|sharp|fw|lg|xs|sm|xl|spin|pulse|border|inverse|stack|flip(?:-[a-z]+)?|rotate(?:-[a-z]+)?|pull-[a-z]+)$/;// Size, style and animation classes that share the icon prefixes.
|
|
1394
1416
|
function iconToken(a){if(a){var b=a.toLowerCase().replace(/^icon-/,"");return /^[a-z][a-z-]{1,31}$/.test(b)?b:void 0}}// An icon name from an SVG sprite reference or an icon-font class, for buttons
|
|
1395
1417
|
// whose only content is an icon. Letters and hyphens only.
|
|
1396
1418
|
function iconHint(a){var b=function(a){return !hasComposedAncestor(a,"[data-mp-no-track]")},c=Array.from(a.querySelectorAll("use")).filter(b)[0];if(c){var d=c.getAttribute("href")||c.getAttribute("xlink:href")||"",e=d.indexOf("#"),f=iconToken(-1===e?null:d.slice(e+1));if(f)return f}for(var g=[a].concat(Array.from(a.querySelectorAll("i, span, svg"))).filter(b).slice(0,5),h=0,i=g;h<i.length;h++)for(var j=i[h],k=(j.getAttribute("class")||"").split(/\s+/),l=0,m=k;l<m.length;l++){var n=m[l],o=ICON_CLASS.exec(n.toLowerCase());if(o&&!ICON_MODIFIER.test(o[1]))return o[1]}}// Words of letters, each optionally ending in up to three digits, joined by
|
|
@@ -1406,36 +1428,67 @@ function controlsIdentifier(a){var b=a.getAttribute("aria-controls");return stab
|
|
|
1406
1428
|
// field named "id" shadows form.id.
|
|
1407
1429
|
function formIdentifier(a){var b=a instanceof HTMLButtonElement||a instanceof HTMLInputElement?a.form:null;return b?stableIdentifier(b.getAttribute("id")):void 0}// The browser's normalised type: a button defaults to 'submit' and an unknown
|
|
1408
1430
|
// input type reads as 'text'. Wallet and role buttons are just 'button'.
|
|
1409
|
-
function controlType(a,b){return "button"===b||"input"===b?a.type:"button"}//
|
|
1410
|
-
//
|
|
1411
|
-
|
|
1431
|
+
function controlType(a,b){return "button"===b||"input"===b?a.type:"button"}// Reads the link's own resolved URL parts, never its full href: only the hostname of
|
|
1432
|
+
// a link that leaves the site and the extension of a file it downloads travel. Navigation
|
|
1433
|
+
// within the site is left to page views, and mailto:, tel: and other schemes are skipped.
|
|
1434
|
+
function describeLink(a){var b=(a.getAttribute("href")||"").trim();if(!b||"#"===b.charAt(0))return {type:"same_page"};if(a instanceof HTMLAnchorElement){var c=a.protocol.toLowerCase();if("javascript:"===c)return {type:"same_page"};if("http:"===c||"https:"===c){var d=a.hostname===window.location.hostname?void 0:a.hostname.toLowerCase(),e=DOWNLOAD_EXTENSIONS.exec(a.pathname);return a.hasAttribute("download")||e?{type:"download",domain:d,fileExtension:e?e[1].toLowerCase():void 0}:d?{type:"outbound",domain:d}:a.pathname===window.location.pathname&&a.search===window.location.search?{type:"same_page"}:void 0}}}// Describes a clicked control for auto button tracking. A link counts only when page
|
|
1435
|
+
// views can't see the click, and carries its link type.
|
|
1436
|
+
function describeButtonClick(a){var b;if(!(a.matches("a[href]:not([role=\"button\"])")&&(b=describeLink(a),!b))){var c=elementKind(a),d=accessibleName(a),e=maskLabel(d.raw);return {label:e,labelSource:e?d.source:"none",// Kept on its own as well: it often says more than the visible text,
|
|
1412
1437
|
// such as which item a remove button removes.
|
|
1413
|
-
ariaLabel:maskLabel(a.getAttribute("aria-label")),icon:iconHint(a),elementId:stableIdentifier(a.getAttribute("id")),elementName:stableIdentifier(a.getAttribute("name")),testId:firstIdentifier(a,TEST_ID_ATTRIBUTES),controls:controlsIdentifier(a),form:formIdentifier(a),element:
|
|
1414
|
-
|
|
1415
|
-
|
|
1438
|
+
ariaLabel:maskLabel(a.getAttribute("aria-label")),icon:iconHint(a),elementId:stableIdentifier(a.getAttribute("id")),elementName:stableIdentifier(a.getAttribute("name")),testId:firstIdentifier(a,TEST_ID_ATTRIBUTES),controls:controlsIdentifier(a),form:formIdentifier(a),element:c,type:controlType(a,c),linkType:b?b.type:void 0,linkDomain:b?b.domain:void 0,fileExtension:b?b.fileExtension:void 0,// The box as the click left it: the browser toggles it before the click
|
|
1439
|
+
// reaches listeners, and puts it back if the click is cancelled.
|
|
1440
|
+
checked:a instanceof HTMLInputElement&&("checkbox"===a.type||"radio"===a.type)?a.checked:void 0}}}
|
|
1441
|
+
|
|
1442
|
+
var checkoutPath=/(?:^|\/)(?:checkouts?|payment|order|kasse|paiement|commander?|pago)(?:\/|$)/i,englishExclusions=/\b(?:coupon|promo(?: code)?|newsletter|sign in|sign up|log in|login|add to (?:cart|bag|basket)|gift card balance|(?:add|apply|redeem|check|enter|use) (?:a |an |your )?gift card|pay later|interest free|as low as|learn more|prequalify|apply (?:now|for)|payment plan|available|accepted|we accept|set up|add money|reload|top up|add to (?:apple|google) wallet|connect|link your|unlink|remove|delete|edit|change|manage|use a different|switch)\b|^pay in$|\bpay in (?:installments|instalments)\b/,otherExclusions=new RegExp("gutschein|anmelden|warenkorb|bon cadeau|connexion|panier|cup\xF3n|iniciar sesi\xF3n|carrito|carrello|codice sconto|accedi|buono regalo|winkelwagen|kortingscode|inloggen|cadeaubon|achteraf betalen|\u30AB\u30FC\u30C8|\u30AF\u30FC\u30DD\u30F3|\u30ED\u30B0\u30A4\u30F3|\u4F1A\u54E1\u767B\u9332|\u30AE\u30D5\u30C8|\u5F8C\u6255\u3044|\u30E1\u30EB\u30DE\u30AC"),englishCommits="(?:(?:agree|accept|review) and )?(?:place|submit|complete|confirm|finali[sz]e)(?!(?: [^ ]+){0,2} (?:another|new|next)(?: |$))(?! (?:[^ ]+ )?gift card)(?: [^ ]+){0,2} (?:order|purchase|booking|reservation|payment|checkout|transaction)(?: now| securely| and pay| (?:with|using) [^ ]+(?: [^ ]+)?)?(?: (?:total|subtotal|items?|tickets?))?|pay(?: securely)?(?: now)?|(?:confirm|agree|accept|submit|order|book) and pay|pay and place (?:my |your )?order|order with obligation to pay",otherCommits="(?:jetzt )?(?:zahlungs|kosten)pflichtig (?:bestellen|buchen)|(?:jetzt )?bezahlen|kauf abschlie\xDFen|bestellung abschlie\xDFen|commander et payer|payer(?: maintenant)?|(?:confirmer|finaliser) (?:ma |la )?commande|valider et payer|confirmer et payer|commande avec obligation de paiement|finaliser l'achat|(?:realizar|confirmar|completar) (?:el |mi |la )?(?:pedido|compra|reserva)|finalizar (?:el |mi )?pedido|pagar(?: ahora)?|pedido con obligaci\xF3n de pago|(?:effettua|conferma|concludi|completa) (?:l'|il )?(?:ordine|acquisto)|ordine con obbligo di pagamento|paga(?: ora| adesso)?|ordina e paga|(?:nu )?betalen|bestellen en betalen|bestelling plaatsen|plaats bestelling|bestelling afronden|bestelling met betalingsverplichting|(?:\u3053\u306E\u5185\u5BB9\u3067|\u4E0A\u8A18\u306E?\u5185\u5BB9\u3067)?\u3054?(?:\u6CE8\u6587|\u8CFC\u5165|\u4E88\u7D04|\u6C7A\u6E08|\u304A?\u652F\u6255\u3044?)\u3092?(?:\u78BA\u5B9A|\u5B8C\u4E86)(?:\u3059\u308B)?|(?:\u3053\u306E\u5185\u5BB9\u3067|\u4E0A\u8A18\u306E?\u5185\u5BB9\u3067)\u3054?(?:\u6CE8\u6587|\u8CFC\u5165|\u4E88\u7D04)\u3059\u308B|\u3054?\u6CE8\u6587\u3059\u308B|\u6C7A\u6E08\u3059\u308B|(?:\u4ECA\u3059\u3050|\u3092)?\u652F\u6255\u3046",commits=new RegExp("^(?:"+englishCommits+"|"+otherCommits+")$"),linkCommits=new RegExp("^(?:(?:place|submit|complete)(?!(?: [^ ]+){0,2} (?:another|new|next)(?: |$))(?: [^ ]+){0,2} (?:order|purchase)|"+otherCommits+")$"),routeGatedCommits=/^(?:buy now|purchase|jetzt kaufen|kaufen|commander|(?:passer|valider) (?:la |ma )?commande|finalizar (?:la |mi )?compra|comprar ahora|acquista ora|nu kopen|\u4ECA\u3059\u3050\u8CFC\u5165|\u8CFC\u5165\u3059\u308B|\u3053\u306E\u5185\u5BB9\u3067\u7533\u3057\u8FBC\u3080)$/,steps=new RegExp("^(?:"+"(?:let's |lets |go to |proceed to |secure )?(?:check ?out|checkout)(?: now| securely| as guest)?|(?:continue|proceed) to (?:payment|review|billing|shipping|delivery|order review)|review (?:my |your )?order|guest checkout|(?:pay|continue|check ?out) (?:with|by) (?:card|credit card|debit card|credit or debit card)|zur kasse|zur kasse gehen|auschecken|weiter zur zahlung|passer \xE0 la caisse|continuer vers le paiement|proc\xE9der au paiement|ir a caja|continuar al pago|tramitar pedido|procedi al checkout|procedi all'acquisto|procedi al pagamento|vai alla cassa|afrekenen|verder naar betalen|doorgaan naar betalen|\u30EC\u30B8\u306B\u9032\u3080|\u3054?(?:\u8CFC\u5165|\u6CE8\u6587)\u624B\u7D9A\u304D(?:\u3078|\u306B)(?:\u9032\u3080)?|\u304A?\u652F\u6255\u3044(?:\u3078|\u306B)\u9032\u3080|(?:\u3054\u6CE8\u6587\u5185\u5BB9\u306E)?\u78BA\u8A8D\u753B\u9762\u3078(?:\u9032\u3080)?"+")$"),WALLET_NAMES="apple pay|google pay|paypal|venmo|amazon pay|shop pay|klarna|afterpay|clearpay|cash app(?: pay)?|affirm|sezzle|samsung pay",WALLET_VERBS="pay|buy|purchase|order|book|donate|subscribe|check ?out|checkout|express checkout|continue|proceed|complete purchase|place (?:my |your )?order",walletPhrases=new RegExp("^(?:(?:"+WALLET_VERBS+")(?: now| securely)? (?:with|using|via|through|by) (?:"+WALLET_NAMES+")(?: express(?: checkout)?| checkout)?|(?:continue|proceed|go) (?:to|with) (?:"+WALLET_NAMES+"))$"),walletBrands=new RegExp("^(?:"+WALLET_NAMES+")(?: (?:checkout|check out|express(?: checkout)?|express pay|buy now|pay now|pay|now)| (?:logo|icon|mark|button)(?: (?:logo|icon|mark|button))*)?$"),walletFrameHosts=new Set(["pay.google.com","applepay.cdn-apple.com","payments.amazon.com","pay.shopify.com"]),paypalFrameHosts=new Set(["www.paypal.com","www.sandbox.paypal.com"]),PAYPAL_BUTTON_FRAME=/^\/smart\/(?:buttons|menu)(?:\/|$)/,STRIPE_WALLET_FRAME=/\/elements-inner-(?:payment-request|express-checkout)-/,CARD_FRAME_DOMAINS=["adyen.com","braintreegateway.com","cybersource.com","squarecdn.com","checkout.com"],TYPOGRAPHIC_APOSTROPHES=/[\u2019\u2018]/g,CURRENCY_AND_NUMBER_CHARS=/[0-9\uFF10-\uFF19$\u20AC\u00A3\u00A5\uFFE5\u20B9\u5186.,\uFF0C]/g,BRACKETED=/\([^()]*\)|\[[^[\]]*\]|\uFF08[^\uFF08\uFF09]*\uFF09|\uFF3B[^\uFF3B\uFF3D]*\uFF3D|\u3010[^\u3010\u3011]*\u3011/g,EDGE="[\\s!-/:-@\\[-`{-~\\u00A1-\\u00BF\\u00D7\\u00F7\\u2000-\\u206F\\u20A0-\\u20CF\\u2190-\\u2BFF\\u3000-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u30FB\\uD800-\\uDFFF\\uFE00-\\uFE0F\\uFF01-\\uFF0F\\uFF1A-\\uFF20\\uFF3B-\\uFF40\\uFF5B-\\uFF65]+",EDGE_SYMBOLS=new RegExp("^"+EDGE+"|"+EDGE+"$","g");// English look-alikes are whole words; the other languages stay substring
|
|
1443
|
+
// matches, since several of them do not separate words with spaces.
|
|
1444
|
+
// A plain link is navigation, so in English only an order or purchase it
|
|
1445
|
+
// places, submits or completes counts as the confirm click.
|
|
1446
|
+
// "Pay with Klarna", "Buy with GPay", "Continue to PayPal".
|
|
1447
|
+
// A wallet's own name on a button: "PayPal", "Klarna checkout", "Apple Pay logo".
|
|
1448
|
+
// Exact HTTPS hosts of hosted wallet button frames.
|
|
1449
|
+
// PayPal serves its buttons and its card fields and pay-later messages from
|
|
1450
|
+
// the same hosts; only the button frames are wallet taps.
|
|
1451
|
+
// Stripe's quick-pay button frames; its other frames are card and form fields.
|
|
1452
|
+
// Hosted card-entry and fingerprint frames: focus there is typing card details.
|
|
1416
1453
|
// Keep these classes ASCII-only in source bytes to avoid mojibake parse failures
|
|
1417
1454
|
// when a host page forces non-UTF-8 decoding before JavaScript parse.
|
|
1418
|
-
|
|
1419
|
-
//
|
|
1420
|
-
|
|
1421
|
-
function
|
|
1422
|
-
|
|
1423
|
-
function
|
|
1455
|
+
// Spaces, punctuation, separators, arrows and symbols, CJK and full-width forms
|
|
1456
|
+
// included, plus emoji halves and variation selectors.
|
|
1457
|
+
function getIntentRouteClass(a){return checkoutPath.test(a)?"checkout_path":"other"}var SEPARATORS=/[-_|\u00B7\u2022]/g,CURRENCY_CODES=/(?:^| )(?:usd|aud|cad|nzd|gbp|eur|chf|sgd|hkd|jpy|inr|mxn)(?= |$)|\b(?:a|au|ca|c|us|nz|hk|s)\$/g,WALLET_ALIASES=[[/\bapplepay\b/g,"apple pay"],[/\bg ?pay\b/g,"google pay"],[/\bamazonpay\b/g,"amazon pay"],[/\bshoppay\b/g,"shop pay"],[/\bcashapp\b/g,"cash app"]],MAX_LABEL_WORDS=8;// Labels longer than this are sentences: they neither match nor veto intent.
|
|
1458
|
+
function normalize(a){if(a&&!(128<a.length)){var b=a.toLowerCase().replace(TYPOGRAPHIC_APOSTROPHES,"'").replace(/[&+]/g," and ").replace(SEPARATORS," ").replace(CURRENCY_CODES," ").replace(CURRENCY_AND_NUMBER_CHARS,"").replace(/\s+/g," ").trim();return WALLET_ALIASES.forEach(function(a){var c=a[0],d=a[1];b=b.replace(c,d);}),b.split(" ").length>MAX_LABEL_WORDS?void 0:b}}// The label without bracketed asides or the separators and symbols left at its
|
|
1459
|
+
// edges, so "place order -" and "place order ( items)" both read "place order".
|
|
1460
|
+
function coreLabel(a){var b=a.replace(BRACKETED," ").replace(/\s+/g," ").replace(EDGE_SYMBOLS,"");return b||a.replace(EDGE_SYMBOLS,"")}// Labels come from aria-label then visible text. Only submit and button inputs
|
|
1461
|
+
// have their value read, so a typed field value is never touched. A control
|
|
1462
|
+
// holding form fields or more than four children gives only its aria-label.
|
|
1463
|
+
function labelSources(a){if(a instanceof HTMLInputElement){var b=a.type,c=null;return "submit"===b||"button"===b?c=a.value:"image"===b&&(c=a.getAttribute("alt")),[a.getAttribute("aria-label"),c]}return 4<a.children.length||isUnsafeTextSource(a)?[a.getAttribute("aria-label")]:[a.getAttribute("aria-label"),a.textContent]}function labels(a){return labelSources(a).map(normalize).filter(function(a){return !!a})}// "Buy now" and "Purchase" count only on a checkout route, and never on a plain
|
|
1464
|
+
// link, which is navigation.
|
|
1465
|
+
function isCommitLabel(a,b,c){return b?linkCommits.test(a):commits.test(a)||routeGatedCommits.test(a)&&"checkout_path"===getIntentRouteClass(c)}// Classifies a clicked or submitting control found by findControl, in order:
|
|
1466
|
+
// pickers, toggles and pay-later messages never count; a vendor's own wallet
|
|
1467
|
+
// button counts before any label rule; a confirm label on any source counts
|
|
1468
|
+
// before the look-alike exclusions veto; then wallet phrases and steps.
|
|
1469
|
+
function classifyIntent(a,b){var c=vendorButtonKind(a);if(!(isQuietIntentControl(a,"wallet"===c)||"none"===c)){if(c)return {kind:c,source:"vendor"};var d=labels(a),e=d.map(coreLabel),f=a.matches("a[href]:not([role=\"button\"])");if(e.some(function(a){return isCommitLabel(a,f,b)}))return {kind:"commit",source:"label"};if(!d.concat(e).some(function(a){return englishExclusions.test(a)||otherExclusions.test(a)}))for(var g,h=!f&&a.matches(CONTROL_SELECTOR),i=0;i<(void 0).length;i++){if(g=(void 0)[i],h&&walletPhrases.test(g))return {kind:"wallet",source:"label"};if(h&&walletBrands.test(g))return {kind:"wallet",source:"brand"};if(steps.test(g))return {kind:"checkout_step",source:"label"}}}}function isOnDomain(a,b){return a===b||a.length>b.length&&a.slice(a.length-b.length-1)==="."+b}// Focus moving into a visible hosted wallet button counts as a wallet click;
|
|
1470
|
+
// focus into hosted card fields or messages is only a frame.
|
|
1471
|
+
function classifyIntentFrame(a,b){if("visible"===b.document.visibilityState&&a instanceof HTMLIFrameElement&&!(isRoktElement(a)||hasComposedAncestor(a,"[data-mp-no-track]")))try{var c=new URL(a.src),d="https:"===c.protocol?c.hostname:"";if(paypalFrameHosts.has(d))return PAYPAL_BUTTON_FRAME.test(c.pathname)?"wallet":"frame";if(walletFrameHosts.has(d))return "wallet";if("js.stripe.com"===d)return STRIPE_WALLET_FRAME.test(c.pathname)?"wallet":"frame";if(CARD_FRAME_DOMAINS.some(function(a){return isOnDomain(d,a)}))return "frame"}catch(a){// An unparseable frame src is not a wallet frame.
|
|
1424
1472
|
}}
|
|
1425
1473
|
|
|
1426
1474
|
// listeners. Inspect `window.__mpBtn__` in a console to see if one is live.
|
|
1427
|
-
var WIN_BTN_KEY="__mpBtn__";var THROTTLE_MS=2e3,SUBMIT_AFTER_COMMIT_CLICK_MS=1e3,PATH_LIMIT=12,PAGE_EVENT_LIMIT=100,btnWindow=function(){return "undefined"==typeof window?null:window};// A ceiling, not a dedupe: a held Enter key or browser automation fires a
|
|
1475
|
+
var WIN_BTN_KEY="__mpBtn__";var THROTTLE_MS=2e3,SUBMIT_AFTER_COMMIT_CLICK_MS=1e3,PATH_LIMIT=12,PAGE_EVENT_LIMIT=100,UPLOAD_DEBOUNCE_MS=100,btnWindow=function(){return "undefined"==typeof window?null:window};// A ceiling, not a dedupe: a held Enter key or browser automation fires a
|
|
1428
1476
|
// trusted click per repeat, and each one is forwarded to every kit.
|
|
1477
|
+
// A click uploads at once. Taps that follow it this quickly are held and share
|
|
1478
|
+
// one upload once they stop.
|
|
1429
1479
|
var getActiveButtonTracker=function(){var a=btnWindow(),b=a?a[WIN_BTN_KEY]:void 0;return b?b.tracker:void 0};// Stops whichever tracker is active, including one from an earlier bundle load.
|
|
1430
1480
|
var resetButtonTracking=function(){var a=btnWindow();if(a){var b=getActiveButtonTracker();b&&b.teardown(),a[WIN_BTN_KEY]={};}};// Runs once the browser has painted the page's response to the interaction, so
|
|
1431
1481
|
// describing and logging a click never delays that paint.
|
|
1432
|
-
var afterNextPaint=function(a){isFunction(window.requestAnimationFrame)&&"hidden"!==document.visibilityState?requestAnimationFrame(function(){setTimeout(a,0);}):setTimeout(a,0);},CAPTURE_PASSIVE={capture:!0,passive:!0},PASSIVE={passive:!0},ButtonTracker=/** @class */function(){function a(a){var b=this;this.active=!1,this.hasRoktKit=!1,this.generation=0,this.lastCommitClick=-Infinity,this.lastSent={},this.pagePath=null,this.pageEvents=0,this.pending=[],this.drain=function(){var a=b.pending;b.pending=[],a.forEach(function(a){return a()});},this.onHide=function(a){("beforeunload"===a.type||"pagehide"===a.type||"hidden"===document.visibilityState)
|
|
1482
|
+
var afterNextPaint=function(a){isFunction(window.requestAnimationFrame)&&"hidden"!==document.visibilityState?requestAnimationFrame(function(){setTimeout(a,0);}):setTimeout(a,0);},CAPTURE_PASSIVE={capture:!0,passive:!0},PASSIVE={passive:!0},ButtonTracker=/** @class */function(){function a(a){var b=this;this.active=!1,this.hasRoktKit=!1,this.generation=0,this.lastCommitClick=-Infinity,this.lastSent={},this.pagePath=null,this.pageEvents=0,this.pending=[],this.uploadTimerId=null,this.uploadHeld=!1,this.leaving=!1,this.drain=function(){var a=b.pending;b.pending=[],a.forEach(function(a){return a()});},this.onHide=function(a){if("beforeunload"===a.type||"pagehide"===a.type||"hidden"===document.visibilityState){b.leaving=!0;try{b.drain();}finally{b.leaving=!1;}// The SDK's exit upload sends the queue, held taps included.
|
|
1483
|
+
b.cancelUpload();}},this.onPageShow=function(a){a.persisted&&b.reset();},this.onEvent=function(a){try{b.observe(a);}catch(a){b.log("[error] event handler threw: "+a);}},this.mpInstance=a;}return Object.defineProperty(a.prototype,"isActive",{get:function get(){return this.active},enumerable:!1,configurable:!0}),a.prototype.init=function(a){var b=btnWindow();if(b){var c=getActiveButtonTracker();return c&&c.teardown(),this.active&&this.teardown(),this.hasRoktKit=a.hasRoktKit,!this.eventsEnabled()&&this.isKitSuppressed()?void this.log("opted out, not starting"):void(b.document.addEventListener("click",this.onEvent,CAPTURE_PASSIVE),b.document.addEventListener("submit",this.onEvent,CAPTURE_PASSIVE),b.addEventListener("blur",this.onEvent,PASSIVE),b.addEventListener("pageshow",this.onPageShow,PASSIVE),b.addEventListener("beforeunload",this.onHide,CAPTURE_PASSIVE),b.addEventListener("pagehide",this.onHide,CAPTURE_PASSIVE),b.document.addEventListener("visibilitychange",this.onHide,CAPTURE_PASSIVE),this.active=!0,!b[WIN_BTN_KEY]&&(b[WIN_BTN_KEY]={}),b[WIN_BTN_KEY].tracker=this,this.log("listening"))}},a.prototype.teardown=function(){var a=btnWindow();if(a){a.document.removeEventListener("click",this.onEvent,!0),a.document.removeEventListener("submit",this.onEvent,!0),a.removeEventListener("blur",this.onEvent),a.removeEventListener("pageshow",this.onPageShow),a.removeEventListener("beforeunload",this.onHide,!0),a.removeEventListener("pagehide",this.onHide,!0),a.document.removeEventListener("visibilitychange",this.onHide,!0);var b=a[WIN_BTN_KEY];b&&b.tracker===this&&(b.tracker=void 0);}this.active=!1,this.clearPending();},a.prototype.clearPending=function(){this.reset();var a=this.mpInstance._RoktManager;a&&a.discardCheckoutIntents();},a.prototype.reset=function(){this.generation++,this.pending=[],this.lastCommitClick=-Infinity,this.lastSent={},this.pagePath=null,this.pageEvents=0,this.cancelUpload();},a.prototype.enqueue=function(a){this.pending.push(a),1===this.pending.length&&afterNextPaint(this.drain);},a.prototype.observe=function(a){var b=this;if(this.active&&a.isTrusted){// The button is read now, while the click is still being dispatched:
|
|
1433
1484
|
// this capture listener runs before the page's own handlers, so a
|
|
1434
1485
|
// button that disables or relabels itself is seen as it was clicked.
|
|
1435
1486
|
// Logging and the kit hand-off wait for the next paint.
|
|
1436
|
-
var c=a.type,d="click"===c&&this.eventsEnabled(),e=!this.isKitSuppressed();if(d||e){var f,g,h=Date.now(),
|
|
1437
|
-
var
|
|
1438
|
-
|
|
1487
|
+
var c=a.type,d="click"===c&&this.eventsEnabled(),e=!this.isKitSuppressed();if(d||e){var f,g,h,i,j=Date.now(),k=window.location.pathname,l=!1;if("click"===c){// The composed path is only populated during dispatch.
|
|
1488
|
+
var m=findControl(isFunction(a.composedPath)?a.composedPath().slice(0,PATH_LIMIT):[]);if(m){f=d?describeButtonClick(m):void 0,f&&void 0!==f.checked&&(g=m);// Checkout intent is only worked out when the kit can use it.
|
|
1489
|
+
var n=e?classifyIntent(m,k):void 0;h=n?n.kind:void 0,i=n?n.source:void 0;}}else if("submit"===c){var o=a.submitter,m=o?findControl([o]):void 0;// A form submitted without a submitter only counts right after a
|
|
1490
|
+
// commit click, which is known once that click is delivered.
|
|
1491
|
+
if(!o)h="commit",i="submit";else if(m){var n=classifyIntent(m,k);h=n?n.kind:void 0,i=n?n.source:void 0;}l=!o;}var p=this.generation;this.enqueue(function(){if(p===b.generation)try{"blur"===c?(h=classifyIntentFrame(document.activeElement,window),i="frame"):l&&j-b.lastCommitClick>SUBMIT_AFTER_COMMIT_CLICK_MS&&(h=void 0),f&&d&&(g&&a.defaultPrevented&&(f.checked="checkbox"===g.type?!f.checked:g.checked),b.logClick(f,k)),h&&b.emit(h,i,c,j,k);}catch(a){b.log("[error] delivery threw: "+a);}});}}},a.prototype.logClick=function(a,b){if(this.eventsEnabled()&&(b!==this.pagePath&&(this.pagePath=b,this.pageEvents=0),!(this.pageEvents>=PAGE_EVENT_LIMIT))){this.pageEvents++,this.mpInstance._SessionManager.resetSessionTimer();var c=this.queuedForUpload();this.mpInstance._Events.logEvent(buildButtonClickEvent(a,b)),!this.leaving&&void 0===a.checked&&this.queuedForUpload()>c&&this.uploadNow();}},a.prototype.queuedForUpload=function(){var a=this.mpInstance._APIClient.uploader;return a?a.eventsQueuedForProcessing.length:0},a.prototype.uploadNow=function(){var a=this;null===this.uploadTimerId?this.mpInstance.upload():(clearTimeout(this.uploadTimerId),this.uploadHeld=!0),this.uploadTimerId=setTimeout(function(){a.uploadTimerId=null,a.uploadHeld&&(a.uploadHeld=!1,a.mpInstance.upload());},UPLOAD_DEBOUNCE_MS);},a.prototype.cancelUpload=function(){null!==this.uploadTimerId&&(clearTimeout(this.uploadTimerId),this.uploadTimerId=null),this.uploadHeld=!1;},a.prototype.emit=function(a,b,c,d,e){if(!this.isKitSuppressed()){"commit"===a&&"click"===c&&(this.lastCommitClick=d);var f=this.lastSent[a];f&&f.pathname===e&&d-f.t<THROTTLE_MS||(this.lastSent[a]={t:d,pathname:e},this.mpInstance._RoktManager.notifyCheckoutIntent(Object.freeze({kind:a,t:d,source:b,pathname:e}),e));}},a.prototype.eventsEnabled=function(){var a=this.mpInstance._Store;return !!a&&a.isEnabled},a.prototype.isKitSuppressed=function(){var a=this.mpInstance._RoktManager;return !this.hasRoktKit||!a||a.isCheckoutIntentSuppressed()},a.prototype.log=function(a){this.mpInstance.Logger.verbose("mParticle button tracking: "+a);},a}();// Logs every button click as an mParticle event, and hands checkout intent to the
|
|
1439
1492
|
|
|
1440
1493
|
var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,CaptureIntegrationSpecificIdsV2Modes=Constants.CaptureIntegrationSpecificIdsV2Modes,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,CaptureIntegrationSpecificIdsV2=FeatureFlags.CaptureIntegrationSpecificIdsV2,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
|
|
1441
1494
|
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
|