@mparticle/web-rokt-kit 1.33.2 → 1.33.4

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],he=new Set(de);function te(i){return he.has(i.toLowerCase())}function b(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];te(s)||(e[s]=t[s])}return e}function _(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function L(i){return typeof i=="function"}function C(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function D(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const x="__rokt_ls_probe__";function G(){try{return window.localStorage.setItem(x,"1"),window.localStorage.removeItem(x),!0}catch{return!1}}function O(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function ie(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function ne(i){try{window.localStorage.removeItem(i)}catch{}}function re(i,e){const t=O(i);return _(t)?t[e]:void 0}function M(i,e,t){const n=O(i),r=_(n)?{...n}:{};return r[e]=t,ie(i,r)}function ge(i,e){const t=O(i);if(!_(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?ne(i):ie(i,n)}function pe(i,e,t,n){const r=t.slice(),s=()=>r.length<=1?!1:(r.shift(),!0);let o=JSON.stringify(r).length>n;for(;o&&s();)o=JSON.stringify(r).length>n;let c=M(i,e,r);for(;!c&&s();)c=M(i,e,r);return c}const k="mp-rokt-kit",R="pageViews",W="mpPageViews",fe=100*1024;function se(i){const e=O(W);if(e===null)return;if(!(re(k,R)!==void 0)&&Array.isArray(e)&&!M(k,R,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry [reason: migration_retry]",code:"PAGE_VIEW_CAPTURE_FAILED"});return}ne(W)}function j(i){se(i);const e=re(k,R);return Array.isArray(e)?e:[]}function me(i){return pe(k,R,i,fe)}function H(){ge(k,R)}function Ee(i){return i.map((e,t)=>{const n=e.activeTimeOnSite,r=n!==void 0&&Number.isFinite(n),o=i[t+1]?.activeTimeOnSite,c=o!==void 0&&Number.isFinite(o),u=r&&c?o-n:void 0;return{pageUrl:e.pageUrl,sourceMessageId:e.sourceMessageId,timestamp:e.timestamp,...e.pageTitle!==void 0?{pageTitle:e.pageTitle}:{},...e.canonicalUrl!==void 0?{canonicalUrl:e.canonicalUrl}:{},...r?{activeTimeOnSite:n}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function _e(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return D(e)}const d="Rokt",T=181,Se="selectPlacements",ye="apps.roktecommerce.com",Ie=.1,Ae="ThankYouPageJourney",ke="rokt-launcher",Re="rokt-thank-you-element",ve="userIdentifiedInWorkspace",we=3,be=2,Le="page_events",Te="mparticle_session_id",Ne=500,F={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},E={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Oe="apps.rokt-api.com",Pe="/v1/log",Ue="/v1/errors",Ce=10;function a(){return window.mParticle}function V(i,e){const n=[P(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function z(i){return[P(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function P(i){const e=typeof i<"u"?i:Oe;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function oe(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return P(r)+t}function J(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function N(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function B(i){const e=i?N(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(Ae)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Me(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function q(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function $(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!m(n.value)||!m(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function Q(i,e,t){return a().generateHash([i,e,t].join(""))}function Ke(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.33.2";return i&&(n+="_"+i),n}function ae(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function K(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function X(i,e){const t=ae(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ie)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?P(i):"https://apps.rokt.com";K(c+"/v1/wsdk-init/index.html?"+o),K("https://"+ye+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function De(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Fe(){return typeof window<"u"?window.location?.href:void 0}function Ye(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ce{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Ce}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new ce,this._isEnabled=De()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||F.UNKNOWN_ERROR,url:Fe(),deviceInfo:Ye(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const g=new Error("HTTP "+l.status+" from log endpoint");throw g.statusCode=l.status,g}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class Z{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=oe(e?.errorUrl,e?.integrationDomain,Ue)}report(e){if(!e)return;const t=e.severity||E.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ee{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._loggingUrl=oe(e?.loggingUrl,e?.integrationDomain,Pe),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,E.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:F.LOG_DELIVERY_FAILURE,severity:n?E.ERROR:E.WARNING})}})}}function xe(i){const e=D(window.location.href),t=i.EventAttributes?.title||document.title,n=_e(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const f=class f{constructor(){this.name=d,this.id=T,this.moduleId=T,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!m(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!m(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(C(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=D(window.location.href);const n=j(this.loggingService),r=xe(e);if(n.push(r),!me(n)){const s=G()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${s}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}catch(n){const r=G()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&L(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[f.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!_(e))return;const t=a().EventType.Other;a().logEvent(Se,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&L(t.setIntegrationAttribute)&&t.setIntegrationAttribute(T,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(L(t))return t.call(e)||void 0}attachLauncher(e,t,n=[]){const r={accountId:e,...t||{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Me(n,o),this.initRoktLauncher(o)}).catch(o=>{console.error("Error creating Rokt launcher:",o)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,X(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.userAttributes=b(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=N(o.placementEventMapping);this.placementEventMappingLookup=q(u);const l=N(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=$(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:U,legacyRoktExtensions:v,loadThankYouElement:w}=B(o.roktExtensions),p={...a().Rokt?.launcherOptions||{}};this.integrationName=Ke(p.integrationName),p.integrationName=this.integrationName,this.domain=g;const y={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new Z(y,this.integrationName,window.__rokt_li_guid__,o.accountId),A=new ee(y,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=A,this.isTargetingDisabled())try{H()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:E.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(A),n?(this.testHelpers={generateLauncherScript:V,generateThankYouElementScript:z,extractRoktExtensionConfig:B,hashEventMessage:Q,parseSettingsString:N,generateMappedEventLookup:q,generateMappedEventAttributeLookup:$,sendAdBlockMeasurementSignals:X,createAutoRemovedIframe:K,djb2:ae,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:Y,ErrorReportingService:Z,LoggingService:ee,RateLimiter:ce,ErrorCodes:F,WSDKErrorSeverity:E},this.attachLauncher(c,p),"Successfully initialized: "+d):(w&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),J(Re,z(g),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,p,v):(J(ke,V(g,U),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,v):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===we&&this.capturePageView(e),e.EventDataType===be&&(se(this.loggingService),H())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(L(a().Rokt?.setLocalSessionAttribute)&&(C(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!C(this.placementEventMappingLookup))){const t=Q(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return te(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=b(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];m(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,Ne))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...b(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=b(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},U=this.returnUserIdentities(c),v=this.returnLocalSessionAttributes(),w=Ee(j(this.loggingService)),p=this.readMpSessionId(),y={...U,...l,...g,...v,...w.length?{[Le]:JSON.stringify(w)}:{},...this.userIdentifiedInWorkspace?{[ve]:!0}:{},...p?{[Te]:p}:{},mpid:u},I={...e,attributes:y},A=this.launcher.selectPlacements(I),h=()=>this.logSelectPlacementsEvent(y);return Promise.resolve(A).then(le=>le?.context?.sessionId?.then(ue=>this.setRoktSessionId(ue))).catch(()=>{}).finally(h),A}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!m(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};f._allowedOriginHashes=[-553112570,549508659],f.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},f.EMAIL_SHA256_KEY="emailsha256";let S=f;function Ge(){return T}function We(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!_(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}_(i.kits)?i.kits[d]={constructor:S}:(i.kits={},i.kits[d]={constructor:S}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:Ge});exports.register=We;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const de=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],he=new Set(de);function ee(i){return he.has(i.toLowerCase())}function b(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];ee(s)||(e[s]=t[s])}return e}function _(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function L(i){return typeof i=="function"}function C(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function K(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const Y="__rokt_ls_probe__";function x(){try{return window.localStorage.setItem(Y,"1"),window.localStorage.removeItem(Y),!0}catch{return!1}}function N(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function te(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function ie(i){try{window.localStorage.removeItem(i)}catch{}}function ne(i,e){const t=N(i);return _(t)?t[e]:void 0}function re(i,e,t){const n=N(i),r=_(n)?{...n}:{};return r[e]=t,te(i,r)}function pe(i,e){const t=N(i);if(!_(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?ie(i):te(i,n)}const k="mp-rokt-kit",R="pageViews",G="mpPageViews";function se(i){const e=N(G);if(e===null)return;!(ne(k,R)!==void 0)&&Array.isArray(e)&&(i?.log({message:"Rokt Kit: Migrating legacy page-view storage",code:"PAGE_VIEW_LEGACY_MIGRATION"}),re(k,R,e)||i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage [reason: migration_retry]",code:"PAGE_VIEW_CAPTURE_FAILED"})),ie(G)}function W(i){se(i);const e=ne(k,R);return Array.isArray(e)?e:[]}function ge(i){return re(k,R,i.slice(-25))}function j(){pe(k,R)}function fe(i){const e=i.slice(-25);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),l=e[n+1]?.activeTimeOnSite,u=l!==void 0&&Number.isFinite(l),c=s&&u?l-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...c!==void 0&&c>=0?{activeTimeOnPage:c}:{}}})}function me(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return K(e)}const d="Rokt",T=181,Ee="selectPlacements",_e="apps.roktecommerce.com",Ie=.1,Se="ThankYouPageJourney",ye="rokt-launcher",Ae="rokt-thank-you-element",ke="userIdentifiedInWorkspace",Re=3,ve=2,we="page_events",be="mparticle_session_id",Le=500,D={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},E={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Te="apps.rokt-api.com",Pe="/v1/log",Ne="/v1/errors",Oe=10;function a(){return window.mParticle}function H(i,e){const n=[O(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function V(i){return[O(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function O(i){const e=typeof i<"u"?i:Te;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function oe(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return O(r)+t}function z(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function P(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function J(i){const e=i?P(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(Se)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ue(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function q(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function B(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!m(n.value)||!m(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function $(i,e,t){return a().generateHash([i,e,t].join(""))}function Ce(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.33.4";return i&&(n+="_"+i),n}function ae(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function M(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function Q(i,e){const t=ae(window.location.origin);if(I._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ie)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),l=i?O(i):"https://apps.rokt.com";M(l+"/v1/wsdk-init/index.html?"+o),M("https://"+_e+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Me(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Ke(){return typeof window<"u"?window.location?.href:void 0}function De(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ce{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Oe}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new ce,this._isEnabled=Me()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const l={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||D.UNKNOWN_ERROR,url:Ke(),deviceInfo:De(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(l)}).then(c=>{if(!c.ok){const p=new Error("HTTP "+c.status+" from log endpoint");throw p.statusCode=c.status,p}}).catch(c=>{console.error("ReportingTransport: Failed to send log",c),o&&o(c)})}catch(l){console.error("ReportingTransport: Failed to send log",l),o&&o(l)}}}class X{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=oe(e?.errorUrl,e?.integrationDomain,Ne)}report(e){if(!e)return;const t=e.severity||E.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class Z{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._loggingUrl=oe(e?.loggingUrl,e?.integrationDomain,Pe),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,E.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:D.LOG_DELIVERY_FAILURE,severity:n?E.ERROR:E.WARNING})}})}}function Fe(i){const e=K(window.location.href),t=i.EventAttributes?.title||document.title,n=me(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const f=class f{constructor(){this.name=d,this.id=T,this.moduleId=T,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!m(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!m(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(C(s))continue;let o=!0;for(let l=0;l<s.length;l++)if(!this.doesEventMatchRule(e,s[l])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=K(window.location.href);const n=W(this.loggingService),r=Fe(e);if(n.push(r),!ge(n)){const s=x()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${s}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}catch(n){const r=x()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&L(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[f.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!_(e))return;const t=a().EventType.Other;a().logEvent(Ee,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&L(t.setIntegrationAttribute)&&t.setIntegrationAttribute(T,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(L(t))return t.call(e)||void 0}attachLauncher(e,t,n=[]){const r={accountId:e,...t||{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Ue(n,o),this.initRoktLauncher(o)}).catch(o=>{console.error("Error creating Rokt launcher:",o)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,Q(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,l=o.accountId;this.userAttributes=b(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=P(o.placementEventMapping);this.placementEventMappingLookup=q(u);const c=P(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=B(c),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:U,legacyRoktExtensions:v,loadThankYouElement:w}=J(o.roktExtensions),g={...a().Rokt?.launcherOptions||{}};this.integrationName=Ce(g.integrationName),g.integrationName=this.integrationName,this.domain=p;const S={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new X(S,this.integrationName,window.__rokt_li_guid__,o.accountId),A=new Z(S,y,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=y,this.loggingService=A,this.isTargetingDisabled())try{j()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:E.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(A),n?(this.testHelpers={generateLauncherScript:H,generateThankYouElementScript:V,extractRoktExtensionConfig:J,hashEventMessage:$,parseSettingsString:P,generateMappedEventLookup:q,generateMappedEventAttributeLookup:B,sendAdBlockMeasurementSignals:Q,createAutoRemovedIframe:M,djb2:ae,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:X,LoggingService:Z,RateLimiter:ce,ErrorCodes:D,WSDKErrorSeverity:E},this.attachLauncher(l,g),"Successfully initialized: "+d):(w&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),z(Ae,V(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(l,g,v):(z(ye,H(p,U),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(l,g,v):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===Re&&this.capturePageView(e),e.EventDataType===ve&&(se(this.loggingService),j())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(L(a().Rokt?.setLocalSessionAttribute)&&(C(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!C(this.placementEventMappingLookup))){const t=$(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return ee(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=b(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const c=r[u];m(c)&&c.length>0&&(s[u]=c)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const l=o.sort().map(u=>`${u}=${s[u]}`).join("&");return l===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=l,new Promise(u=>{try{n(t,s,c=>{c?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(c){console.error("Rokt Kit: Workspace IDSync search failed",c),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,Le))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...b(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],l=s.filteredUser||null,u=l?l.getMPID():null;let c;s?s.filterUserAttributes?c=s.filterUserAttributes(r,o):c=r:(console.warn("Rokt Kit: No filters available, using user attributes"),c=r),this.userAttributes=b(c);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},U=this.returnUserIdentities(l),v=this.returnLocalSessionAttributes(),w=fe(W(this.loggingService)),g=this.readMpSessionId(),S={...U,...c,...p,...v,...w.length?{[we]:JSON.stringify(w)}:{},...this.userIdentifiedInWorkspace?{[ke]:!0}:{},...g?{[be]:g}:{},mpid:u},y={...e,attributes:S},A=this.launcher.selectPlacements(y),h=()=>this.logSelectPlacementsEvent(S);return Promise.resolve(A).then(le=>le?.context?.sessionId?.then(ue=>this.setRoktSessionId(ue))).catch(()=>{}).finally(h),A}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!m(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};f._allowedOriginHashes=[-553112570,549508659],f.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},f.EMAIL_SHA256_KEY="emailsha256";let I=f;function Ye(){return T}function xe(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!_(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}_(i.kits)?i.kits[d]={constructor:I}:(i.kits={},i.kits[d]={constructor:I}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:I,getId:Ye});exports.register=xe;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -24,14 +24,14 @@ const de = [
24
24
  "shippingzipcode",
25
25
  "totalprice"
26
26
  ], he = new Set(de);
27
- function te(i) {
27
+ function ee(i) {
28
28
  return he.has(i.toLowerCase());
29
29
  }
30
30
  function b(i) {
31
31
  const e = {}, t = i || {}, n = Object.keys(t);
32
32
  for (let r = 0; r < n.length; r++) {
33
33
  const s = n[r];
34
- te(s) || (e[s] = t[s]);
34
+ ee(s) || (e[s] = t[s]);
35
35
  }
36
36
  return e;
37
37
  }
@@ -47,7 +47,7 @@ function L(i) {
47
47
  function C(i) {
48
48
  return i == null ? !0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
49
49
  }
50
- function D(i) {
50
+ function K(i) {
51
51
  try {
52
52
  const e = new URL(i);
53
53
  return e.search = "", e.toString();
@@ -55,15 +55,15 @@ function D(i) {
55
55
  return i;
56
56
  }
57
57
  }
58
- const x = "__rokt_ls_probe__";
59
- function G() {
58
+ const Y = "__rokt_ls_probe__";
59
+ function x() {
60
60
  try {
61
- return window.localStorage.setItem(x, "1"), window.localStorage.removeItem(x), !0;
61
+ return window.localStorage.setItem(Y, "1"), window.localStorage.removeItem(Y), !0;
62
62
  } catch {
63
63
  return !1;
64
64
  }
65
65
  }
66
- function O(i) {
66
+ function P(i) {
67
67
  try {
68
68
  const e = window.localStorage.getItem(i);
69
69
  return e === null ? null : JSON.parse(e);
@@ -71,89 +71,79 @@ function O(i) {
71
71
  return null;
72
72
  }
73
73
  }
74
- function ie(i, e) {
74
+ function te(i, e) {
75
75
  try {
76
76
  return window.localStorage.setItem(i, JSON.stringify(e)), !0;
77
77
  } catch {
78
78
  return !1;
79
79
  }
80
80
  }
81
- function ne(i) {
81
+ function ie(i) {
82
82
  try {
83
83
  window.localStorage.removeItem(i);
84
84
  } catch {
85
85
  }
86
86
  }
87
- function re(i, e) {
88
- const t = O(i);
87
+ function ne(i, e) {
88
+ const t = P(i);
89
89
  return _(t) ? t[e] : void 0;
90
90
  }
91
- function M(i, e, t) {
92
- const n = O(i), r = _(n) ? { ...n } : {};
93
- return r[e] = t, ie(i, r);
91
+ function re(i, e, t) {
92
+ const n = P(i), r = _(n) ? { ...n } : {};
93
+ return r[e] = t, te(i, r);
94
94
  }
95
- function ge(i, e) {
96
- const t = O(i);
95
+ function pe(i, e) {
96
+ const t = P(i);
97
97
  if (!_(t) || !(e in t))
98
98
  return;
99
99
  const n = { ...t };
100
- delete n[e], Object.keys(n).length === 0 ? ne(i) : ie(i, n);
101
- }
102
- function pe(i, e, t, n) {
103
- const r = t.slice(), s = () => r.length <= 1 ? !1 : (r.shift(), !0);
104
- let o = JSON.stringify(r).length > n;
105
- for (; o && s(); )
106
- o = JSON.stringify(r).length > n;
107
- let c = M(i, e, r);
108
- for (; !c && s(); )
109
- c = M(i, e, r);
110
- return c;
111
- }
112
- const k = "mp-rokt-kit", R = "pageViews", W = "mpPageViews", fe = 100 * 1024;
100
+ delete n[e], Object.keys(n).length === 0 ? ie(i) : te(i, n);
101
+ }
102
+ const k = "mp-rokt-kit", R = "pageViews", G = "mpPageViews";
113
103
  function se(i) {
114
- const e = O(W);
104
+ const e = P(G);
115
105
  if (e === null)
116
106
  return;
117
- if (!(re(k, R) !== void 0) && Array.isArray(e) && !M(k, R, e)) {
118
- i?.log({
119
- message: "Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry [reason: migration_retry]",
120
- code: "PAGE_VIEW_CAPTURE_FAILED"
121
- });
122
- return;
123
- }
124
- ne(W);
125
- }
126
- function j(i) {
107
+ !(ne(k, R) !== void 0) && Array.isArray(e) && (i?.log({
108
+ message: "Rokt Kit: Migrating legacy page-view storage",
109
+ code: "PAGE_VIEW_LEGACY_MIGRATION"
110
+ }), re(k, R, e) || i?.log({
111
+ message: "Rokt Kit: Failed to migrate legacy page-view storage [reason: migration_retry]",
112
+ code: "PAGE_VIEW_CAPTURE_FAILED"
113
+ })), ie(G);
114
+ }
115
+ function W(i) {
127
116
  se(i);
128
- const e = re(k, R);
117
+ const e = ne(k, R);
129
118
  return Array.isArray(e) ? e : [];
130
119
  }
131
- function me(i) {
132
- return pe(k, R, i, fe);
120
+ function ge(i) {
121
+ return re(k, R, i.slice(-25));
133
122
  }
134
- function H() {
135
- ge(k, R);
123
+ function j() {
124
+ pe(k, R);
136
125
  }
137
- function Ee(i) {
138
- return i.map((e, t) => {
139
- const n = e.activeTimeOnSite, r = n !== void 0 && Number.isFinite(n), o = i[t + 1]?.activeTimeOnSite, c = o !== void 0 && Number.isFinite(o), u = r && c ? o - n : void 0;
126
+ function fe(i) {
127
+ const e = i.slice(-25);
128
+ return e.map((t, n) => {
129
+ const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), l = e[n + 1]?.activeTimeOnSite, u = l !== void 0 && Number.isFinite(l), c = s && u ? l - r : void 0;
140
130
  return {
141
- pageUrl: e.pageUrl,
142
- sourceMessageId: e.sourceMessageId,
143
- timestamp: e.timestamp,
144
- ...e.pageTitle !== void 0 ? { pageTitle: e.pageTitle } : {},
145
- ...e.canonicalUrl !== void 0 ? { canonicalUrl: e.canonicalUrl } : {},
146
- ...r ? { activeTimeOnSite: n } : {},
147
- ...u !== void 0 && u >= 0 ? { activeTimeOnPage: u } : {}
131
+ pageUrl: t.pageUrl,
132
+ sourceMessageId: t.sourceMessageId,
133
+ timestamp: t.timestamp,
134
+ ...t.pageTitle !== void 0 ? { pageTitle: t.pageTitle } : {},
135
+ ...t.canonicalUrl !== void 0 ? { canonicalUrl: t.canonicalUrl } : {},
136
+ ...s ? { activeTimeOnSite: r } : {},
137
+ ...c !== void 0 && c >= 0 ? { activeTimeOnPage: c } : {}
148
138
  };
149
139
  });
150
140
  }
151
- function _e() {
141
+ function me() {
152
142
  const e = document.querySelector('link[rel="canonical"]')?.href;
153
143
  if (e)
154
- return D(e);
144
+ return K(e);
155
145
  }
156
- const d = "Rokt", T = 181, Ie = "selectPlacements", Se = "apps.roktecommerce.com", ye = 0.1, Ae = "ThankYouPageJourney", ke = "rokt-launcher", Re = "rokt-thank-you-element", ve = "userIdentifiedInWorkspace", we = 3, be = 2, Le = "page_events", Te = "mparticle_session_id", Ne = 500, F = {
146
+ const d = "Rokt", T = 181, Ee = "selectPlacements", _e = "apps.roktecommerce.com", Ie = 0.1, Se = "ThankYouPageJourney", ye = "rokt-launcher", Ae = "rokt-thank-you-element", ke = "userIdentifiedInWorkspace", Re = 3, ve = 2, we = "page_events", be = "mparticle_session_id", Le = 500, D = {
157
147
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
158
148
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
159
149
  IDENTITY_REQUEST: "IDENTITY_REQUEST",
@@ -162,28 +152,28 @@ const d = "Rokt", T = 181, Ie = "selectPlacements", Se = "apps.roktecommerce.com
162
152
  ERROR: "ERROR",
163
153
  INFO: "INFO",
164
154
  WARNING: "WARNING"
165
- }, Oe = "apps.rokt-api.com", Pe = "/v1/log", Ue = "/v1/errors", Ce = 10;
155
+ }, Te = "apps.rokt-api.com", Ne = "/v1/log", Pe = "/v1/errors", Oe = 10;
166
156
  function a() {
167
157
  return window.mParticle;
168
158
  }
169
- function V(i, e) {
170
- const n = [P(i), "/wsdk/integrations/launcher.js"].join("");
159
+ function H(i, e) {
160
+ const n = [O(i), "/wsdk/integrations/launcher.js"].join("");
171
161
  return !e || e.length === 0 ? n : n + "?extensions=" + e.join(",");
172
162
  }
173
- function z(i) {
174
- return [P(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
163
+ function V(i) {
164
+ return [O(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
175
165
  }
176
- function P(i) {
177
- const e = typeof i < "u" ? i : Oe;
166
+ function O(i) {
167
+ const e = typeof i < "u" ? i : Te;
178
168
  return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
179
169
  }
180
170
  function oe(i, e, t) {
181
171
  if (i)
182
172
  return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
183
173
  const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
184
- return P(r) + t;
174
+ return O(r) + t;
185
175
  }
186
- function J(i, e, t) {
176
+ function z(i, e, t) {
187
177
  if (document.getElementById(i)) return;
188
178
  const n = document.head || document.body, r = document.createElement("script");
189
179
  r.id = i, r.type = "text/javascript", r.src = e, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", t?.onLoad && (r.onload = t.onLoad), t?.onError && (r.onerror = t.onError), n.appendChild(r);
@@ -198,12 +188,12 @@ function N(i) {
198
188
  }
199
189
  return [];
200
190
  }
201
- function B(i) {
191
+ function J(i) {
202
192
  const e = i ? N(i) : [], t = [], n = [];
203
193
  let r = !1;
204
194
  for (let s = 0; s < e.length; s++) {
205
195
  const o = e[s].value;
206
- o === "thank-you-journey" ? (r = !0, n.push(Ae)) : t.push(o);
196
+ o === "thank-you-journey" ? (r = !0, n.push(Se)) : t.push(o);
207
197
  }
208
198
  return {
209
199
  roktExtensionsQueryParams: t,
@@ -211,7 +201,7 @@ function B(i) {
211
201
  loadThankYouElement: r
212
202
  };
213
203
  }
214
- async function Me(i, e) {
204
+ async function Ue(i, e) {
215
205
  const t = [];
216
206
  if (e)
217
207
  for (const n of i)
@@ -228,7 +218,7 @@ function q(i) {
228
218
  }
229
219
  return e;
230
220
  }
231
- function $(i) {
221
+ function B(i) {
232
222
  const e = {};
233
223
  if (!Array.isArray(i))
234
224
  return e;
@@ -244,11 +234,11 @@ function $(i) {
244
234
  }
245
235
  return e;
246
236
  }
247
- function Q(i, e, t) {
237
+ function $(i, e, t) {
248
238
  return a().generateHash([i, e, t].join(""));
249
239
  }
250
- function Ke(i) {
251
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.33.2";
240
+ function Ce(i) {
241
+ let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.33.4";
252
242
  return i && (n += "_" + i), n;
253
243
  }
254
244
  function ae(i) {
@@ -257,7 +247,7 @@ function ae(i) {
257
247
  e = (e << 5) + e + i.charCodeAt(t), e = e & e;
258
248
  return e;
259
249
  }
260
- function K(i) {
250
+ function M(i) {
261
251
  const e = document.createElement("iframe");
262
252
  e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = i, e.onload = function() {
263
253
  e.onload = null, e.parentNode && e.parentNode.removeChild(e);
@@ -265,25 +255,25 @@ function K(i) {
265
255
  const t = document.body || document.head;
266
256
  t && t.appendChild(e);
267
257
  }
268
- function X(i, e) {
258
+ function Q(i, e) {
269
259
  const t = ae(window.location.origin);
270
- if (I._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= ye)
260
+ if (I._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ie)
271
261
  return;
272
262
  const r = window.__rokt_li_guid__;
273
263
  if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
274
264
  return;
275
- const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? P(i) : "https://apps.rokt.com";
276
- K(c + "/v1/wsdk-init/index.html?" + o), K(
277
- "https://" + Se + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
265
+ const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), l = i ? O(i) : "https://apps.rokt.com";
266
+ M(l + "/v1/wsdk-init/index.html?" + o), M(
267
+ "https://" + _e + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
278
268
  );
279
269
  }
280
- function De() {
270
+ function Me() {
281
271
  return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
282
272
  }
283
- function Fe() {
273
+ function Ke() {
284
274
  return typeof window < "u" ? window.location?.href : void 0;
285
275
  }
286
- function Ye() {
276
+ function De() {
287
277
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
288
278
  }
289
279
  class ce {
@@ -292,27 +282,27 @@ class ce {
292
282
  }
293
283
  incrementAndCheck(e) {
294
284
  const n = (this._logCount[e] || 0) + 1;
295
- return this._logCount[e] = n, n > Ce;
285
+ return this._logCount[e] = n, n > Oe;
296
286
  }
297
287
  }
298
- class Y {
288
+ class F {
299
289
  constructor(e, t, n, r, s) {
300
290
  this._reporter = "mp-wsdk";
301
291
  const o = e.isLoggingEnabled;
302
- this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ce(), this._isEnabled = De() || o;
292
+ this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ce(), this._isEnabled = Me() || o;
303
293
  }
304
294
  send(e, t, n, r, s, o) {
305
295
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
306
296
  try {
307
- const c = {
297
+ const l = {
308
298
  additionalInformation: {
309
299
  message: n,
310
300
  version: this._integrationName
311
301
  },
312
302
  severity: t,
313
- code: r || F.UNKNOWN_ERROR,
314
- url: Fe(),
315
- deviceInfo: Ye(),
303
+ code: r || D.UNKNOWN_ERROR,
304
+ url: Ke(),
305
+ deviceInfo: De(),
316
306
  stackTrace: s,
317
307
  reporter: this._reporter,
318
308
  integration: this._integrationName
@@ -325,23 +315,23 @@ class Y {
325
315
  this._launcherInstanceGuid && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(e, {
326
316
  method: "POST",
327
317
  headers: u,
328
- body: JSON.stringify(c)
329
- }).then((l) => {
330
- if (!l.ok) {
331
- const g = new Error("HTTP " + l.status + " from log endpoint");
332
- throw g.statusCode = l.status, g;
318
+ body: JSON.stringify(l)
319
+ }).then((c) => {
320
+ if (!c.ok) {
321
+ const p = new Error("HTTP " + c.status + " from log endpoint");
322
+ throw p.statusCode = c.status, p;
333
323
  }
334
- }).catch((l) => {
335
- console.error("ReportingTransport: Failed to send log", l), o && o(l);
324
+ }).catch((c) => {
325
+ console.error("ReportingTransport: Failed to send log", c), o && o(c);
336
326
  });
337
- } catch (c) {
338
- console.error("ReportingTransport: Failed to send log", c), o && o(c);
327
+ } catch (l) {
328
+ console.error("ReportingTransport: Failed to send log", l), o && o(l);
339
329
  }
340
330
  }
341
331
  }
342
- class Z {
332
+ class X {
343
333
  constructor(e, t, n, r, s) {
344
- this._transport = new Y(e, t, n, r, s), this._errorUrl = oe(e?.errorUrl, e?.integrationDomain, Ue);
334
+ this._transport = new F(e, t, n, r, s), this._errorUrl = oe(e?.errorUrl, e?.integrationDomain, Pe);
345
335
  }
346
336
  report(e) {
347
337
  if (!e) return;
@@ -349,9 +339,9 @@ class Z {
349
339
  this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
350
340
  }
351
341
  }
352
- class ee {
342
+ class Z {
353
343
  constructor(e, t, n, r, s, o) {
354
- this._transport = new Y(e, n, r, s, o), this._loggingUrl = oe(e?.loggingUrl, e?.integrationDomain, Pe), this._errorReportingService = t;
344
+ this._transport = new F(e, n, r, s, o), this._loggingUrl = oe(e?.loggingUrl, e?.integrationDomain, Ne), this._errorReportingService = t;
355
345
  }
356
346
  log(e) {
357
347
  e && this._transport.send(
@@ -365,7 +355,7 @@ class ee {
365
355
  const n = typeof t.statusCode == "number";
366
356
  this._errorReportingService.report({
367
357
  message: "LoggingService: Failed to send log: " + t.message,
368
- code: F.LOG_DELIVERY_FAILURE,
358
+ code: D.LOG_DELIVERY_FAILURE,
369
359
  severity: n ? E.ERROR : E.WARNING
370
360
  });
371
361
  }
@@ -373,8 +363,8 @@ class ee {
373
363
  );
374
364
  }
375
365
  }
376
- function xe(i) {
377
- const e = D(window.location.href), t = i.EventAttributes?.title || document.title, n = _e(), r = i.ActiveTimeOnSite;
366
+ function Fe(i) {
367
+ const e = K(window.location.href), t = i.EventAttributes?.title || document.title, n = me(), r = i.ActiveTimeOnSite;
378
368
  return {
379
369
  pageUrl: e,
380
370
  sourceMessageId: i.SourceMessageId,
@@ -420,8 +410,8 @@ const f = class f {
420
410
  if (C(s))
421
411
  continue;
422
412
  let o = !0;
423
- for (let c = 0; c < s.length; c++)
424
- if (!this.doesEventMatchRule(e, s[c])) {
413
+ for (let l = 0; l < s.length; l++)
414
+ if (!this.doesEventMatchRule(e, s[l])) {
425
415
  o = !1;
426
416
  break;
427
417
  }
@@ -431,17 +421,17 @@ const f = class f {
431
421
  capturePageView(e) {
432
422
  let t;
433
423
  try {
434
- t = D(window.location.href);
435
- const n = j(this.loggingService), r = xe(e);
436
- if (n.push(r), !me(n)) {
437
- const s = G() ? "quota" : "ls_unavailable";
424
+ t = K(window.location.href);
425
+ const n = W(this.loggingService), r = Fe(e);
426
+ if (n.push(r), !ge(n)) {
427
+ const s = x() ? "quota" : "ls_unavailable";
438
428
  this.loggingService?.log({
439
429
  message: `Rokt Kit: Failed to persist page view for ${t} [reason: ${s}]`,
440
430
  code: "PAGE_VIEW_CAPTURE_FAILED"
441
431
  });
442
432
  }
443
433
  } catch (n) {
444
- const r = G() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
434
+ const r = x() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
445
435
  this.loggingService?.log({
446
436
  message: `Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,
447
437
  code: "PAGE_VIEW_CAPTURE_FAILED"
@@ -471,7 +461,7 @@ const f = class f {
471
461
  if (!window.mParticle || typeof a().logEvent != "function" || !_(e))
472
462
  return;
473
463
  const t = a().EventType.Other;
474
- a().logEvent(Ie, t, e);
464
+ a().logEvent(Ee, t, e);
475
465
  }
476
466
  setRoktSessionId(e) {
477
467
  if (!(!e || typeof e != "string"))
@@ -495,7 +485,7 @@ const f = class f {
495
485
  };
496
486
  let s;
497
487
  this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
498
- await Me(n, o), this.initRoktLauncher(o);
488
+ await Ue(n, o), this.initRoktLauncher(o);
499
489
  }).catch((o) => {
500
490
  console.error("Error creating Rokt launcher:", o);
501
491
  });
@@ -503,7 +493,7 @@ const f = class f {
503
493
  initRoktLauncher(e) {
504
494
  window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e;
505
495
  const t = a().Rokt?.filters;
506
- t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, X(this.domain, this.integrationName), a().Rokt.attachKit(this);
496
+ t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, Q(this.domain, this.integrationName), a().Rokt.attachKit(this);
507
497
  }
508
498
  fetchOptimizely() {
509
499
  const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
@@ -539,31 +529,31 @@ const f = class f {
539
529
  * Initializes the Rokt forwarder with settings from the mParticle server.
540
530
  */
541
531
  init(e, t, n, r, s) {
542
- const o = e, c = o.accountId;
532
+ const o = e, l = o.accountId;
543
533
  this.userAttributes = b(s), this._onboardingExpProvider = o.onboardingExpProvider;
544
534
  const u = N(o.placementEventMapping);
545
535
  this.placementEventMappingLookup = q(u);
546
- const l = N(
536
+ const c = N(
547
537
  o.placementEventAttributeMapping
548
538
  );
549
- this.placementEventAttributeMappingLookup = $(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
550
- const g = a().Rokt?.domain, { roktExtensionsQueryParams: U, legacyRoktExtensions: v, loadThankYouElement: w } = B(
539
+ this.placementEventAttributeMappingLookup = B(c), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
540
+ const p = a().Rokt?.domain, { roktExtensionsQueryParams: U, legacyRoktExtensions: v, loadThankYouElement: w } = J(
551
541
  o.roktExtensions
552
- ), p = {
542
+ ), g = {
553
543
  ...a().Rokt?.launcherOptions || {}
554
544
  };
555
- this.integrationName = Ke(p.integrationName), p.integrationName = this.integrationName, this.domain = g;
545
+ this.integrationName = Ce(g.integrationName), g.integrationName = this.integrationName, this.domain = p;
556
546
  const S = {
557
547
  loggingUrl: o.loggingUrl,
558
548
  errorUrl: o.errorUrl,
559
- integrationDomain: g,
549
+ integrationDomain: p,
560
550
  isLoggingEnabled: a().config?.isLoggingEnabled === !0
561
- }, y = new Z(
551
+ }, y = new X(
562
552
  S,
563
553
  this.integrationName,
564
554
  window.__rokt_li_guid__,
565
555
  o.accountId
566
- ), A = new ee(
556
+ ), A = new Z(
567
557
  S,
568
558
  y,
569
559
  this.integrationName,
@@ -572,7 +562,7 @@ const f = class f {
572
562
  );
573
563
  if (this.errorReportingService = y, this.loggingService = A, this.isTargetingDisabled())
574
564
  try {
575
- H();
565
+ j();
576
566
  } catch (h) {
577
567
  this.errorReportingService?.report({
578
568
  message: "Rokt Kit: Failed to clear page views when targeting is disabled",
@@ -582,35 +572,35 @@ const f = class f {
582
572
  });
583
573
  }
584
574
  return a()._registerErrorReportingService && a()._registerErrorReportingService(y), a()._registerLoggingService && a()._registerLoggingService(A), n ? (this.testHelpers = {
585
- generateLauncherScript: V,
586
- generateThankYouElementScript: z,
587
- extractRoktExtensionConfig: B,
588
- hashEventMessage: Q,
575
+ generateLauncherScript: H,
576
+ generateThankYouElementScript: V,
577
+ extractRoktExtensionConfig: J,
578
+ hashEventMessage: $,
589
579
  parseSettingsString: N,
590
580
  generateMappedEventLookup: q,
591
- generateMappedEventAttributeLookup: $,
592
- sendAdBlockMeasurementSignals: X,
593
- createAutoRemovedIframe: K,
581
+ generateMappedEventAttributeLookup: B,
582
+ sendAdBlockMeasurementSignals: Q,
583
+ createAutoRemovedIframe: M,
594
584
  djb2: ae,
595
585
  setAllowedOriginHashes: (h) => {
596
586
  f._allowedOriginHashes = h;
597
587
  },
598
- ReportingTransport: Y,
599
- ErrorReportingService: Z,
600
- LoggingService: ee,
588
+ ReportingTransport: F,
589
+ ErrorReportingService: X,
590
+ LoggingService: Z,
601
591
  RateLimiter: ce,
602
- ErrorCodes: F,
592
+ ErrorCodes: D,
603
593
  WSDKErrorSeverity: E
604
- }, this.attachLauncher(c, p), "Successfully initialized: " + d) : (w && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), J(Re, z(g), {
594
+ }, this.attachLauncher(l, g), "Successfully initialized: " + d) : (w && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), z(Ae, V(p), {
605
595
  onLoad: () => {
606
596
  this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
607
597
  },
608
598
  onError: (h) => {
609
599
  console.error("Error loading Rokt Thank You Element script:", h);
610
600
  }
611
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, v) : (J(ke, V(g, U), {
601
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(l, g, v) : (z(ye, H(p, U), {
612
602
  onLoad: () => {
613
- this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, v) : console.error("Rokt object is not available after script load.");
603
+ this.isLauncherReadyToAttach() ? this.attachLauncher(l, g, v) : console.error("Rokt object is not available after script load.");
614
604
  },
615
605
  onError: (h) => {
616
606
  console.error("Error loading Rokt launcher script:", h);
@@ -618,10 +608,10 @@ const f = class f {
618
608
  }), this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
619
609
  }
620
610
  process(e) {
621
- if (this.isTargetingDisabled() || (e.EventDataType === we && this.capturePageView(e), e.EventDataType === be && (se(this.loggingService), H())), !this.isKitReady())
611
+ if (this.isTargetingDisabled() || (e.EventDataType === Re && this.capturePageView(e), e.EventDataType === ve && (se(this.loggingService), j())), !this.isKitReady())
622
612
  return "Kit not ready for forwarder: " + d;
623
613
  if (L(a().Rokt?.setLocalSessionAttribute) && (C(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !C(this.placementEventMappingLookup))) {
624
- const t = Q(e.EventDataType, e.EventCategory, e.EventName ?? "");
614
+ const t = $(e.EventDataType, e.EventCategory, e.EventName ?? "");
625
615
  this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
626
616
  }
627
617
  return "Successfully sent to forwarder: " + d;
@@ -634,7 +624,7 @@ const f = class f {
634
624
  window.Rokt.setExtensionData(e);
635
625
  }
636
626
  setUserAttribute(e, t) {
637
- return te(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
627
+ return ee(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
638
628
  }
639
629
  removeUserAttribute(e) {
640
630
  return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
@@ -656,20 +646,20 @@ const f = class f {
656
646
  const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
657
647
  if (r)
658
648
  for (const u of Object.keys(r)) {
659
- const l = r[u];
660
- m(l) && l.length > 0 && (s[u] = l);
649
+ const c = r[u];
650
+ m(c) && c.length > 0 && (s[u] = c);
661
651
  }
662
652
  const o = Object.keys(s);
663
653
  if (o.length === 0)
664
654
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
665
- const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
666
- return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
655
+ const l = o.sort().map((u) => `${u}=${s[u]}`).join("&");
656
+ return l === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = l, new Promise((u) => {
667
657
  try {
668
- n(t, s, (l) => {
669
- l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
658
+ n(t, s, (c) => {
659
+ c?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
670
660
  });
671
- } catch (l) {
672
- console.error("Rokt Kit: Workspace IDSync search failed", l), this._workspaceLastSearchedIdentitiesKey = void 0, u();
661
+ } catch (c) {
662
+ console.error("Rokt Kit: Workspace IDSync search failed", c), this._workspaceLastSearchedIdentitiesKey = void 0, u();
673
663
  }
674
664
  }));
675
665
  }
@@ -710,23 +700,23 @@ const f = class f {
710
700
  const t = this._workspaceSearchInFlightPromise;
711
701
  return Promise.race([
712
702
  t,
713
- new Promise((n) => setTimeout(n, Ne))
703
+ new Promise((n) => setTimeout(n, Le))
714
704
  ]).then(() => this._dispatchPlacements(e));
715
705
  }
716
706
  return this._dispatchPlacements(e);
717
707
  }
718
708
  _dispatchPlacements(e) {
719
- const t = e && e.attributes || {}, r = { ...b(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
720
- let l;
721
- s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = b(l);
722
- const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, U = this.returnUserIdentities(c), v = this.returnLocalSessionAttributes(), w = Ee(j(this.loggingService)), p = this.readMpSessionId(), S = {
709
+ const t = e && e.attributes || {}, r = { ...b(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], l = s.filteredUser || null, u = l ? l.getMPID() : null;
710
+ let c;
711
+ s ? s.filterUserAttributes ? c = s.filterUserAttributes(r, o) : c = r : (console.warn("Rokt Kit: No filters available, using user attributes"), c = r), this.userAttributes = b(c);
712
+ const p = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, U = this.returnUserIdentities(l), v = this.returnLocalSessionAttributes(), w = fe(W(this.loggingService)), g = this.readMpSessionId(), S = {
723
713
  ...U,
724
- ...l,
725
- ...g,
714
+ ...c,
715
+ ...p,
726
716
  ...v,
727
- ...w.length ? { [Le]: JSON.stringify(w) } : {},
728
- ...this.userIdentifiedInWorkspace ? { [ve]: !0 } : {},
729
- ...p ? { [Te]: p } : {},
717
+ ...w.length ? { [we]: JSON.stringify(w) } : {},
718
+ ...this.userIdentifiedInWorkspace ? { [ke]: !0 } : {},
719
+ ...g ? { [be]: g } : {},
730
720
  mpid: u
731
721
  }, y = { ...e, attributes: S }, A = this.launcher.selectPlacements(y), h = () => this.logSelectPlacementsEvent(S);
732
722
  return Promise.resolve(A).then((le) => le?.context?.sessionId?.then((ue) => this.setRoktSessionId(ue))).catch(() => {
@@ -757,10 +747,10 @@ f._allowedOriginHashes = [-553112570, 549508659], f.PERFORMANCE_MARKS = {
757
747
  RoktScriptAppended: "mp:RoktScriptAppended"
758
748
  }, f.EMAIL_SHA256_KEY = "emailsha256";
759
749
  let I = f;
760
- function Ge() {
750
+ function Ye() {
761
751
  return T;
762
752
  }
763
- function We(i) {
753
+ function xe(i) {
764
754
  if (!i) {
765
755
  window.console.log("You must pass a config object to register the kit " + d);
766
756
  return;
@@ -778,9 +768,9 @@ function We(i) {
778
768
  typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
779
769
  name: d,
780
770
  constructor: I,
781
- getId: Ge
771
+ getId: Ye
782
772
  });
783
773
  export {
784
- We as register
774
+ xe as register
785
775
  };
786
776
  //# sourceMappingURL=Rokt-Kit.esm.js.map
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(U){"use strict";const ue=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],de=new Set(ue);function G(i){return de.has(i.toLowerCase())}function v(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];G(s)||(e[s]=t[s])}return e}function E(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function w(i){return typeof i=="function"}function C(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function M(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const W="__rokt_ls_probe__";function j(){try{return window.localStorage.setItem(W,"1"),window.localStorage.removeItem(W),!0}catch{return!1}}function b(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function H(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function V(i){try{window.localStorage.removeItem(i)}catch{}}function z(i,e){const t=b(i);return E(t)?t[e]:void 0}function K(i,e,t){const n=b(i),r=E(n)?{...n}:{};return r[e]=t,H(i,r)}function he(i,e){const t=b(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?V(i):H(i,n)}function ge(i,e,t,n){const r=t.slice(),s=()=>r.length<=1?!1:(r.shift(),!0);let o=JSON.stringify(r).length>n;for(;o&&s();)o=JSON.stringify(r).length>n;let c=K(i,e,r);for(;!c&&s();)c=K(i,e,r);return c}const y="mp-rokt-kit",I="pageViews",J="mpPageViews",pe=100*1024;function B(i){const e=b(J);if(e===null)return;if(!(z(y,I)!==void 0)&&Array.isArray(e)&&!K(y,I,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry [reason: migration_retry]",code:"PAGE_VIEW_CAPTURE_FAILED"});return}V(J)}function q(i){B(i);const e=z(y,I);return Array.isArray(e)?e:[]}function fe(i){return ge(y,I,i,pe)}function $(){he(y,I)}function me(i){return i.map((e,t)=>{const n=e.activeTimeOnSite,r=n!==void 0&&Number.isFinite(n),o=i[t+1]?.activeTimeOnSite,c=o!==void 0&&Number.isFinite(o),u=r&&c?o-n:void 0;return{pageUrl:e.pageUrl,sourceMessageId:e.sourceMessageId,timestamp:e.timestamp,...e.pageTitle!==void 0?{pageTitle:e.pageTitle}:{},...e.canonicalUrl!==void 0?{canonicalUrl:e.canonicalUrl}:{},...r?{activeTimeOnSite:n}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function Ee(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return M(e)}const d="Rokt",L=181,_e="selectPlacements",Se="apps.roktecommerce.com",ye=.1,Ie="ThankYouPageJourney",ke="rokt-launcher",Ae="rokt-thank-you-element",Re="userIdentifiedInWorkspace",ve=3,we=2,be="page_events",Le="mparticle_session_id",Te=500,D={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},_={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Ne="apps.rokt-api.com",Oe="/v1/log",Pe="/v1/errors",Ue=10;function a(){return window.mParticle}function Q(i,e){const n=[T(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function X(i){return[T(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function T(i){const e=typeof i<"u"?i:Ne;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function Z(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return T(r)+t}function ee(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function N(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function te(i){const e=i?N(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(Ie)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ce(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ie(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function ne(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!m(n.value)||!m(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function re(i,e,t){return a().generateHash([i,e,t].join(""))}function Me(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.33.2";return i&&(n+="_"+i),n}function se(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function F(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function oe(i,e){const t=se(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ye)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?T(i):"https://apps.rokt.com";F(c+"/v1/wsdk-init/index.html?"+o),F("https://"+Se+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Ke(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function De(){return typeof window<"u"?window.location?.href:void 0}function Fe(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ae{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Ue}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new ae,this._isEnabled=Ke()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||D.UNKNOWN_ERROR,url:De(),deviceInfo:Fe(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const g=new Error("HTTP "+l.status+" from log endpoint");throw g.statusCode=l.status,g}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class ce{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=Z(e?.errorUrl,e?.integrationDomain,Pe)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class le{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._loggingUrl=Z(e?.loggingUrl,e?.integrationDomain,Oe),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,_.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:D.LOG_DELIVERY_FAILURE,severity:n?_.ERROR:_.WARNING})}})}}function Ye(i){const e=M(window.location.href),t=i.EventAttributes?.title||document.title,n=Ee(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const p=class p{constructor(){this.name=d,this.id=L,this.moduleId=L,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!m(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!m(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(C(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=M(window.location.href);const n=q(this.loggingService),r=Ye(e);if(n.push(r),!fe(n)){const s=j()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${s}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}catch(n){const r=j()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&w(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[p.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!E(e))return;const t=a().EventType.Other;a().logEvent(_e,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&w(t.setIntegrationAttribute)&&t.setIntegrationAttribute(L,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(w(t))return t.call(e)||void 0}attachLauncher(e,t,n=[]){const r={accountId:e,...t||{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Ce(n,o),this.initRoktLauncher(o)}).catch(o=>{console.error("Error creating Rokt launcher:",o)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,oe(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.userAttributes=v(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=N(o.placementEventMapping);this.placementEventMappingLookup=ie(u);const l=N(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=ne(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:x,legacyRoktExtensions:O,loadThankYouElement:P}=te(o.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=Me(f.integrationName),f.integrationName=this.integrationName,this.domain=g;const k={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},A=new ce(k,this.integrationName,window.__rokt_li_guid__,o.accountId),R=new le(k,A,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=A,this.loggingService=R,this.isTargetingDisabled())try{$()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:_.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(A),a()._registerLoggingService&&a()._registerLoggingService(R),n?(this.testHelpers={generateLauncherScript:Q,generateThankYouElementScript:X,extractRoktExtensionConfig:te,hashEventMessage:re,parseSettingsString:N,generateMappedEventLookup:ie,generateMappedEventAttributeLookup:ne,sendAdBlockMeasurementSignals:oe,createAutoRemovedIframe:F,djb2:se,setAllowedOriginHashes:h=>{p._allowedOriginHashes=h},ReportingTransport:Y,ErrorReportingService:ce,LoggingService:le,RateLimiter:ae,ErrorCodes:D,WSDKErrorSeverity:_},this.attachLauncher(c,f),"Successfully initialized: "+d):(P&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ee(Ae,X(g),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,f,O):(ee(ke,Q(g,x),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,O):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ve&&this.capturePageView(e),e.EventDataType===we&&(B(this.loggingService),$())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(w(a().Rokt?.setLocalSessionAttribute)&&(C(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!C(this.placementEventMappingLookup))){const t=re(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return G(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=v(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];m(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,Te))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...v(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=v(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},x=this.returnUserIdentities(c),O=this.returnLocalSessionAttributes(),P=me(q(this.loggingService)),f=this.readMpSessionId(),k={...x,...l,...g,...O,...P.length?{[be]:JSON.stringify(P)}:{},...this.userIdentifiedInWorkspace?{[Re]:!0}:{},...f?{[Le]:f}:{},mpid:u},A={...e,attributes:k},R=this.launcher.selectPlacements(A),h=()=>this.logSelectPlacementsEvent(k);return Promise.resolve(R).then(We=>We?.context?.sessionId?.then(je=>this.setRoktSessionId(je))).catch(()=>{}).finally(h),R}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!m(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let S=p;function xe(){return L}function Ge(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!E(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}E(i.kits)?i.kits[d]={constructor:S}:(i.kits={},i.kits[d]={constructor:S}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:xe}),U.register=Ge,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"}),U})({});
1
+ var RoktKit=(function(U){"use strict";const ue=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],de=new Set(ue);function x(i){return de.has(i.toLowerCase())}function v(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];x(s)||(e[s]=t[s])}return e}function E(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function w(i){return typeof i=="function"}function C(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function M(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const G="__rokt_ls_probe__";function W(){try{return window.localStorage.setItem(G,"1"),window.localStorage.removeItem(G),!0}catch{return!1}}function b(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function j(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function H(i){try{window.localStorage.removeItem(i)}catch{}}function V(i,e){const t=b(i);return E(t)?t[e]:void 0}function z(i,e,t){const n=b(i),r=E(n)?{...n}:{};return r[e]=t,j(i,r)}function he(i,e){const t=b(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?H(i):j(i,n)}const S="mp-rokt-kit",y="pageViews",J="mpPageViews";function q(i){const e=b(J);if(e===null)return;!(V(S,y)!==void 0)&&Array.isArray(e)&&(i?.log({message:"Rokt Kit: Migrating legacy page-view storage",code:"PAGE_VIEW_LEGACY_MIGRATION"}),z(S,y,e)||i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage [reason: migration_retry]",code:"PAGE_VIEW_CAPTURE_FAILED"})),H(J)}function B(i){q(i);const e=V(S,y);return Array.isArray(e)?e:[]}function ge(i){return z(S,y,i.slice(-25))}function $(){he(S,y)}function pe(i){const e=i.slice(-25);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),l=e[n+1]?.activeTimeOnSite,u=l!==void 0&&Number.isFinite(l),c=s&&u?l-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...c!==void 0&&c>=0?{activeTimeOnPage:c}:{}}})}function fe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return M(e)}const d="Rokt",L=181,me="selectPlacements",Ee="apps.roktecommerce.com",_e=.1,Ie="ThankYouPageJourney",Se="rokt-launcher",ye="rokt-thank-you-element",Ae="userIdentifiedInWorkspace",ke=3,Re=2,ve="page_events",we="mparticle_session_id",be=500,K={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},_={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Le="apps.rokt-api.com",Te="/v1/log",Pe="/v1/errors",Ne=10;function a(){return window.mParticle}function Q(i,e){const n=[T(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function X(i){return[T(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function T(i){const e=typeof i<"u"?i:Le;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function Z(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return T(r)+t}function ee(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function P(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function te(i){const e=i?P(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(Ie)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Oe(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ie(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function ne(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!m(n.value)||!m(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function re(i,e,t){return a().generateHash([i,e,t].join(""))}function Ue(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.33.4";return i&&(n+="_"+i),n}function se(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function D(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function oe(i,e){const t=se(window.location.origin);if(I._allowedOriginHashes.indexOf(t)===-1||Math.random()>=_e)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),l=i?T(i):"https://apps.rokt.com";D(l+"/v1/wsdk-init/index.html?"+o),D("https://"+Ee+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Ce(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Me(){return typeof window<"u"?window.location?.href:void 0}function Ke(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ae{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Ne}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new ae,this._isEnabled=Ce()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const l={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||K.UNKNOWN_ERROR,url:Me(),deviceInfo:Ke(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(l)}).then(c=>{if(!c.ok){const g=new Error("HTTP "+c.status+" from log endpoint");throw g.statusCode=c.status,g}}).catch(c=>{console.error("ReportingTransport: Failed to send log",c),o&&o(c)})}catch(l){console.error("ReportingTransport: Failed to send log",l),o&&o(l)}}}class ce{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=Z(e?.errorUrl,e?.integrationDomain,Pe)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class le{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._loggingUrl=Z(e?.loggingUrl,e?.integrationDomain,Te),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,_.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:K.LOG_DELIVERY_FAILURE,severity:n?_.ERROR:_.WARNING})}})}}function De(i){const e=M(window.location.href),t=i.EventAttributes?.title||document.title,n=fe(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const p=class p{constructor(){this.name=d,this.id=L,this.moduleId=L,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!m(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!m(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(C(s))continue;let o=!0;for(let l=0;l<s.length;l++)if(!this.doesEventMatchRule(e,s[l])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=M(window.location.href);const n=B(this.loggingService),r=De(e);if(n.push(r),!ge(n)){const s=W()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${s}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}catch(n){const r=W()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&w(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[p.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!E(e))return;const t=a().EventType.Other;a().logEvent(me,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&w(t.setIntegrationAttribute)&&t.setIntegrationAttribute(L,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(w(t))return t.call(e)||void 0}attachLauncher(e,t,n=[]){const r={accountId:e,...t||{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Oe(n,o),this.initRoktLauncher(o)}).catch(o=>{console.error("Error creating Rokt launcher:",o)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,oe(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,l=o.accountId;this.userAttributes=v(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=P(o.placementEventMapping);this.placementEventMappingLookup=ie(u);const c=P(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=ne(c),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:Y,legacyRoktExtensions:N,loadThankYouElement:O}=te(o.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=Ue(f.integrationName),f.integrationName=this.integrationName,this.domain=g;const A={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},k=new ce(A,this.integrationName,window.__rokt_li_guid__,o.accountId),R=new le(A,k,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=k,this.loggingService=R,this.isTargetingDisabled())try{$()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:_.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(k),a()._registerLoggingService&&a()._registerLoggingService(R),n?(this.testHelpers={generateLauncherScript:Q,generateThankYouElementScript:X,extractRoktExtensionConfig:te,hashEventMessage:re,parseSettingsString:P,generateMappedEventLookup:ie,generateMappedEventAttributeLookup:ne,sendAdBlockMeasurementSignals:oe,createAutoRemovedIframe:D,djb2:se,setAllowedOriginHashes:h=>{p._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:ce,LoggingService:le,RateLimiter:ae,ErrorCodes:K,WSDKErrorSeverity:_},this.attachLauncher(l,f),"Successfully initialized: "+d):(O&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ee(ye,X(g),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(l,f,N):(ee(Se,Q(g,Y),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(l,f,N):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ke&&this.capturePageView(e),e.EventDataType===Re&&(q(this.loggingService),$())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(w(a().Rokt?.setLocalSessionAttribute)&&(C(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!C(this.placementEventMappingLookup))){const t=re(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return x(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=v(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const c=r[u];m(c)&&c.length>0&&(s[u]=c)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const l=o.sort().map(u=>`${u}=${s[u]}`).join("&");return l===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=l,new Promise(u=>{try{n(t,s,c=>{c?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(c){console.error("Rokt Kit: Workspace IDSync search failed",c),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(n=>setTimeout(n,be))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...v(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],l=s.filteredUser||null,u=l?l.getMPID():null;let c;s?s.filterUserAttributes?c=s.filterUserAttributes(r,o):c=r:(console.warn("Rokt Kit: No filters available, using user attributes"),c=r),this.userAttributes=v(c);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},Y=this.returnUserIdentities(l),N=this.returnLocalSessionAttributes(),O=pe(B(this.loggingService)),f=this.readMpSessionId(),A={...Y,...c,...g,...N,...O.length?{[ve]:JSON.stringify(O)}:{},...this.userIdentifiedInWorkspace?{[Ae]:!0}:{},...f?{[we]:f}:{},mpid:u},k={...e,attributes:A},R=this.launcher.selectPlacements(k),h=()=>this.logSelectPlacementsEvent(A);return Promise.resolve(R).then(xe=>xe?.context?.sessionId?.then(Ge=>this.setRoktSessionId(Ge))).catch(()=>{}).finally(h),R}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!m(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let I=p;function Fe(){return L}function Ye(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!E(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}E(i.kits)?i.kits[d]={constructor:I}:(i.kits={},i.kits[d]={constructor:I}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:I,getId:Fe}),U.register=Ye,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"}),U})({});
2
2
  //# sourceMappingURL=Rokt-Kit.iife.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.33.2",
3
+ "version": "1.33.4",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",