@mparticle/web-rokt-kit 1.30.2 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Rokt-Kit.common.js +1 -1
- package/dist/Rokt-Kit.d.ts +34 -0
- package/dist/Rokt-Kit.esm.js +329 -273
- package/dist/Rokt-Kit.iife.js +1 -1
- package/package.json +1 -1
package/dist/Rokt-Kit.common.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=["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"],Z=new Set($);function J(n){return Z.has(n.toLowerCase())}function R(n){const e={},t=n||{},i=Object.keys(t);for(let r=0;r<i.length;r++){const s=i[r];J(s)||(e[s]=t[s])}return e}const d="Rokt",w=181,ee="selectPlacements",te="apps.roktecommerce.com",ie=.1,ne="ThankYouPageJourney",re="rokt-launcher",se="rokt-thank-you-element",oe="userIdentifiedInWorkspace",ae=3,ce=2,P="mpPageViews",le=25,ue="page_events",de=500,N={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},m={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},he="apps.rokt-api.com",pe="/v1/log",ge="/v1/errors",fe=10;function a(){return window.mParticle}function K(){try{const n=window.localStorage.getItem(P);if(n===null)return[];const e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}function me(n){window.localStorage.setItem(P,JSON.stringify(n))}function M(){window.localStorage.removeItem(P)}function D(n,e){const i=[C(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function F(n){return[C(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function C(n){return["https://",typeof n<"u"?n:he].join("")}function q(n,e,t){return n?n.startsWith("http://")||n.startsWith("https://")?n:"https://"+n:C(e)+t}function x(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,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),i.appendChild(r)}function L(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function v(n){if(!n)return[];try{return JSON.parse(n.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Y(n){const e=n?v(n):[],t=[],i=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,i.push(ne)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function Ee(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function G(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function j(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!E(i.value)||!E(i.map))continue;const r=i.value,s=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function W(n,e,t){return a().generateHash([n,e,t].join(""))}function T(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function E(n){return typeof n=="string"}function _e(n){try{const e=new URL(n);return e.search="",e.toString()}catch{return n}}function ye(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.30.2";return n&&(i+="_"+n),i}function B(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function O(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function H(n,e){const t=B(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ie)return;const r=window.__rokt_li_guid__;if(!r)return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s);O("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),O("https://"+te+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Ie(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Se(){return typeof window<"u"?window.location?.href:void 0}function ke(){return typeof window<"u"?window.navigator?.userAgent:void 0}class Q{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>fe}}class U{constructor(e,t,i,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=s||new Q,this._isEnabled=Ie()||o}send(e,t,i,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||N.UNKNOWN_ERROR,url:Se(),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(c)}).then(l=>{if(!l.ok){const h=new Error("HTTP "+l.status+" from log endpoint");throw h.statusCode=l.status,h}}).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 V{constructor(e,t,i,r,s){this._transport=new U(e,t,i,r,s),this._errorUrl=q(e?.errorUrl,e?.integrationDomain,ge)}report(e){if(!e)return;const t=e.severity||m.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class z{constructor(e,t,i,r,s,o){this._transport=new U(e,i,r,s,o),this._loggingUrl=q(e?.loggingUrl,e?.integrationDomain,pe),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,m.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const i=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:N.LOG_DELIVERY_FAILURE,severity:i?m.ERROR:m.WARNING})}})}}const f=class f{constructor(){this.name=d,this.id=w,this.moduleId=w,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 i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!E(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!E(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let s=0;s<i.length;s++)if(!this.doesEventAttributeConditionMatch(i[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],s=this.placementEventAttributeMappingLookup[r];if(T(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=_e(window.location.href);const i=K(),r={pageUrl:t,sourceMessageId:e.SourceMessageId,timestamp:e.Timestamp};for(Number.isFinite(e.ActiveTimeOnSite)&&(r.activeTimeOnSite=e.ActiveTimeOnSite),i.push(r);i.length>le;)i.shift();me(i)}catch(i){this.errorReportingService?.report({message:`Rokt Kit: Failed to capture page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED",severity:m.INFO,stackTrace:i instanceof Error?i.stack:void 0})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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()}buildPageEvents(e){return e.map((t,i)=>{const r={pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp},s=t.activeTimeOnSite,o=s!==void 0&&Number.isFinite(s);o&&(r.activeTimeOnSite=s);const u=e[i+1]?.activeTimeOnSite,l=u!==void 0&&Number.isFinite(u);if(o&&l){const h=u-s;h>=0&&(r.activeTimeOnPage=h)}return r})}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[f.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!L(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&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(w,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await Ee(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}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,H(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,i,r,s){const o=e,c=o.accountId;this.userAttributes=R(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=v(o.placementEventMapping);this.placementEventMappingLookup=G(u);const l=v(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=j(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=E(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const h=a().Rokt?.domain,{roktExtensionsQueryParams:b,legacyRoktExtensions:I,loadThankYouElement:S}=Y(o.roktExtensions),g={...a().Rokt?.launcherOptions||{}};this.integrationName=ye(g.integrationName),g.integrationName=this.integrationName,this.domain=h;const k={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:h,isLoggingEnabled:a().config?.isLoggingEnabled===!0},_=new V(k,this.integrationName,window.__rokt_li_guid__,o.accountId),A=new z(k,_,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=_,this.loggingService=A,this.isTargetingDisabled())try{M()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:m.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(_),a()._registerLoggingService&&a()._registerLoggingService(A),i?(this.testHelpers={generateLauncherScript:D,generateThankYouElementScript:F,extractRoktExtensionConfig:Y,hashEventMessage:W,parseSettingsString:v,generateMappedEventLookup:G,generateMappedEventAttributeLookup:j,sendAdBlockMeasurementSignals:H,createAutoRemovedIframe:O,djb2:B,setAllowedOriginHashes:p=>{f._allowedOriginHashes=p},ReportingTransport:U,ErrorReportingService:V,LoggingService:z,RateLimiter:Q,ErrorCodes:N,WSDKErrorSeverity:m},this.attachLauncher(c,g),"Successfully initialized: "+d):(S&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),x(se,F(h),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,g,I):(x(re,D(h,b),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,g,I):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(!this.isTargetingDisabled()&&(e.EventDataType===ae&&this.capturePageView(e),e.EventDataType===ce))try{M()}catch(t){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views on session end",code:"PAGE_VIEW_CAPTURE_FAILED",severity:m.INFO,stackTrace:t instanceof Error?t.stack:void 0})}if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(T(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!T(this.placementEventMappingLookup))){const t=W(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 J(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=R(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 i=a().Identity?.search;if(typeof i!="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];E(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{i(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(i=>setTimeout(i,de))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...R(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=R(l);const h=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},b=this.returnUserIdentities(c),I=this.returnLocalSessionAttributes(),S=this.buildPageEvents(K()),g={...b,...l,...h,...I,...S.length?{[ue]:JSON.stringify(S)}:{},...this.userIdentifiedInWorkspace?{[oe]:!0}:{},mpid:u},k={...e,attributes:g},_=this.launcher.selectPlacements(k),A=()=>this.logSelectPlacementsEvent(g);return Promise.resolve(_).then(p=>p?.context?.sessionId?.then(X=>this.setRoktSessionId(X))).catch(()=>{}).finally(A),_}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!E(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 y=f;function Ae(){return w}function Re(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!L(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}L(n.kits)?n.kits[d]={constructor:y}:(n.kits={},n.kits[d]={constructor:y}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:Ae});exports.register=Re;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=["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"],ce=new Set(ae);function X(i){return ce.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];X(s)||(e[s]=t[s])}return e}function y(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function U(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}}function N(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function Z(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function ee(i){try{window.localStorage.removeItem(i)}catch{}}function te(i,e){const t=N(i);return y(t)?t[e]:void 0}function C(i,e,t){const n=N(i),r=y(n)?{...n}:{};return r[e]=t,Z(i,r)}function le(i,e){const t=N(i);if(!y(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?ee(i):Z(i,n)}function ue(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=C(i,e,r);for(;!c&&s();)c=C(i,e,r);return c}const I="mp-rokt-kit",k="pageViews",Y="mpPageViews",de=100*1024;function ie(i){const e=N(Y);if(e===null)return;if(!(te(I,k)!==void 0)&&Array.isArray(e)&&!C(I,k,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",code:"PAGE_VIEW_CAPTURE_FAILED"});return}ee(Y)}function x(i){ie(i);const e=te(I,k);return Array.isArray(e)?e:[]}function he(i){return ue(I,k,i,de)}function G(){le(I,k)}function ge(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 pe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return K(e)}const d="Rokt",L=181,fe="selectPlacements",me="apps.roktecommerce.com",Ee=.1,_e="ThankYouPageJourney",ye="rokt-launcher",Se="rokt-thank-you-element",Ie="userIdentifiedInWorkspace",ke=3,Ae=2,Re="page_events",ve=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"},we="apps.rokt-api.com",be="/v1/log",Le="/v1/errors",Te=10;function a(){return window.mParticle}function W(i,e){const n=[O(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function j(i){return[O(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function O(i){const e=typeof i<"u"?i:we;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ne(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 H(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 T(i){if(!i)return[];try{return JSON.parse(i.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function V(i){const e=i?T(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(_e)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ne(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function z(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 J(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 B(i,e,t){return a().generateHash([i,e,t].join(""))}function Oe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.32.0";return i&&(n+="_"+i),n}function re(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=re(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ee)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?O(i):"https://apps.rokt.com";M(c+"/v1/wsdk-init/index.html?"+o),M("https://"+me+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Pe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Ue(){return typeof window<"u"?window.location?.href:void 0}function Ce(){return typeof window<"u"?window.navigator?.userAgent:void 0}class se{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Te}}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 se,this._isEnabled=Pe()||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:Ue(),deviceInfo:Ce(),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 ${constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=ne(e?.errorUrl,e?.integrationDomain,Le)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class Q{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._loggingUrl=ne(e?.loggingUrl,e?.integrationDomain,be),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 Me(i){const e=K(window.location.href),t=i.EventAttributes?.title||document.title,n=pe(),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=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(U(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=K(window.location.href);const n=x(this.loggingService),r=Me(e);n.push(r),he(n)||this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}catch(n){this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${n instanceof Error?n.message:String(n)}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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"||!y(e))return;const t=a().EventType.Other;a().logEvent(fe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(L,{roktSessionId:e})}catch{}}attachLauncher(e,t,n=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await Ne(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}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,c=o.accountId;this.userAttributes=b(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=T(o.placementEventMapping);this.placementEventMappingLookup=z(u);const l=T(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=J(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:P,legacyRoktExtensions:A,loadThankYouElement:R}=V(o.roktExtensions),p={...a().Rokt?.launcherOptions||{}};this.integrationName=Oe(p.integrationName),p.integrationName=this.integrationName,this.domain=g;const v={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},E=new $(v,this.integrationName,window.__rokt_li_guid__,o.accountId),w=new Q(v,E,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=E,this.loggingService=w,this.isTargetingDisabled())try{G()}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(E),a()._registerLoggingService&&a()._registerLoggingService(w),n?(this.testHelpers={generateLauncherScript:W,generateThankYouElementScript:j,extractRoktExtensionConfig:V,hashEventMessage:B,parseSettingsString:T,generateMappedEventLookup:z,generateMappedEventAttributeLookup:J,sendAdBlockMeasurementSignals:q,createAutoRemovedIframe:M,djb2:re,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:$,LoggingService:Q,RateLimiter:se,ErrorCodes:D,WSDKErrorSeverity:_},this.attachLauncher(c,p),"Successfully initialized: "+d):(R&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),H(Se,j(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,A):(H(ye,W(g,P),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,A):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===ke&&this.capturePageView(e),e.EventDataType===Ae&&(ie(this.loggingService),G())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(this.placementEventMappingLookup))){const t=B(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=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,ve))]).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():{},P=this.returnUserIdentities(c),A=this.returnLocalSessionAttributes(),R=ge(x(this.loggingService)),p={...P,...l,...g,...A,...R.length?{[Re]:JSON.stringify(R)}:{},...this.userIdentifiedInWorkspace?{[Ie]:!0}:{},mpid:u},v={...e,attributes:p},E=this.launcher.selectPlacements(v),w=()=>this.logSelectPlacementsEvent(p);return Promise.resolve(E).then(h=>h?.context?.sessionId?.then(oe=>this.setRoktSessionId(oe))).catch(()=>{}).finally(w),E}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 Ke(){return L}function De(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!y(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}y(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:Ke});exports.register=De;
|
|
2
2
|
//# sourceMappingURL=Rokt-Kit.common.js.map
|
package/dist/Rokt-Kit.d.ts
CHANGED
|
@@ -1,7 +1,41 @@
|
|
|
1
|
+
declare interface ErrorReport {
|
|
2
|
+
message: string;
|
|
3
|
+
code?: string;
|
|
4
|
+
severity?: string;
|
|
5
|
+
stackTrace?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare interface LogEntry {
|
|
9
|
+
message: string;
|
|
10
|
+
code?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare class LoggingService {
|
|
14
|
+
private _transport;
|
|
15
|
+
private _loggingUrl;
|
|
16
|
+
private _errorReportingService;
|
|
17
|
+
constructor(config: ReportingConfig, errorReportingService: {
|
|
18
|
+
report: (e: ErrorReport) => void;
|
|
19
|
+
}, integrationName: string | null | undefined, launcherInstanceGuid?: string, accountId?: string | null, rateLimiter?: RateLimiter);
|
|
20
|
+
log(entry: LogEntry | null | undefined): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare class RateLimiter {
|
|
24
|
+
private _logCount;
|
|
25
|
+
incrementAndCheck(severity: string): boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
1
28
|
export declare function register(config: {
|
|
2
29
|
kits?: Record<string, unknown>;
|
|
3
30
|
}): void;
|
|
4
31
|
|
|
32
|
+
declare interface ReportingConfig {
|
|
33
|
+
loggingUrl?: string;
|
|
34
|
+
errorUrl?: string;
|
|
35
|
+
integrationDomain?: string;
|
|
36
|
+
isLoggingEnabled: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
5
39
|
export { }
|
|
6
40
|
|
|
7
41
|
|
package/dist/Rokt-Kit.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ae = [
|
|
2
2
|
"active_time_on_site_ms",
|
|
3
3
|
"billingaddress1",
|
|
4
4
|
"billingaddress2",
|
|
@@ -23,208 +23,285 @@ const $ = [
|
|
|
23
23
|
"shippingstate",
|
|
24
24
|
"shippingzipcode",
|
|
25
25
|
"totalprice"
|
|
26
|
-
],
|
|
27
|
-
function
|
|
28
|
-
return
|
|
26
|
+
], ce = new Set(ae);
|
|
27
|
+
function X(i) {
|
|
28
|
+
return ce.has(i.toLowerCase());
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const e = {}, t =
|
|
32
|
-
for (let r = 0; r <
|
|
33
|
-
const s =
|
|
34
|
-
|
|
30
|
+
function b(i) {
|
|
31
|
+
const e = {}, t = i || {}, n = Object.keys(t);
|
|
32
|
+
for (let r = 0; r < n.length; r++) {
|
|
33
|
+
const s = n[r];
|
|
34
|
+
X(s) || (e[s] = t[s]);
|
|
35
35
|
}
|
|
36
36
|
return e;
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
function y(i) {
|
|
39
|
+
return typeof i == "object" && i !== null && !Array.isArray(i);
|
|
40
|
+
}
|
|
41
|
+
function m(i) {
|
|
42
|
+
return typeof i == "string";
|
|
43
|
+
}
|
|
44
|
+
function U(i) {
|
|
45
|
+
return i == null ? !0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
|
|
46
|
+
}
|
|
47
|
+
function K(i) {
|
|
48
|
+
try {
|
|
49
|
+
const e = new URL(i);
|
|
50
|
+
return e.search = "", e.toString();
|
|
51
|
+
} catch {
|
|
52
|
+
return i;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function N(i) {
|
|
56
|
+
try {
|
|
57
|
+
const e = window.localStorage.getItem(i);
|
|
58
|
+
return e === null ? null : JSON.parse(e);
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function Z(i, e) {
|
|
64
|
+
try {
|
|
65
|
+
return window.localStorage.setItem(i, JSON.stringify(e)), !0;
|
|
66
|
+
} catch {
|
|
67
|
+
return !1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function ee(i) {
|
|
71
|
+
try {
|
|
72
|
+
window.localStorage.removeItem(i);
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function te(i, e) {
|
|
77
|
+
const t = N(i);
|
|
78
|
+
return y(t) ? t[e] : void 0;
|
|
79
|
+
}
|
|
80
|
+
function C(i, e, t) {
|
|
81
|
+
const n = N(i), r = y(n) ? { ...n } : {};
|
|
82
|
+
return r[e] = t, Z(i, r);
|
|
83
|
+
}
|
|
84
|
+
function le(i, e) {
|
|
85
|
+
const t = N(i);
|
|
86
|
+
if (!y(t) || !(e in t))
|
|
87
|
+
return;
|
|
88
|
+
const n = { ...t };
|
|
89
|
+
delete n[e], Object.keys(n).length === 0 ? ee(i) : Z(i, n);
|
|
90
|
+
}
|
|
91
|
+
function ue(i, e, t, n) {
|
|
92
|
+
const r = t.slice(), s = () => r.length <= 1 ? !1 : (r.shift(), !0);
|
|
93
|
+
let o = JSON.stringify(r).length > n;
|
|
94
|
+
for (; o && s(); )
|
|
95
|
+
o = JSON.stringify(r).length > n;
|
|
96
|
+
let c = C(i, e, r);
|
|
97
|
+
for (; !c && s(); )
|
|
98
|
+
c = C(i, e, r);
|
|
99
|
+
return c;
|
|
100
|
+
}
|
|
101
|
+
const S = "mp-rokt-kit", k = "pageViews", x = "mpPageViews", de = 100 * 1024;
|
|
102
|
+
function ie(i) {
|
|
103
|
+
const e = N(x);
|
|
104
|
+
if (e === null)
|
|
105
|
+
return;
|
|
106
|
+
if (!(te(S, k) !== void 0) && Array.isArray(e) && !C(S, k, e)) {
|
|
107
|
+
i?.log({
|
|
108
|
+
message: "Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",
|
|
109
|
+
code: "PAGE_VIEW_CAPTURE_FAILED"
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
ee(x);
|
|
114
|
+
}
|
|
115
|
+
function Y(i) {
|
|
116
|
+
ie(i);
|
|
117
|
+
const e = te(S, k);
|
|
118
|
+
return Array.isArray(e) ? e : [];
|
|
119
|
+
}
|
|
120
|
+
function he(i) {
|
|
121
|
+
return ue(S, k, i, de);
|
|
122
|
+
}
|
|
123
|
+
function G() {
|
|
124
|
+
le(S, k);
|
|
125
|
+
}
|
|
126
|
+
function ge(i) {
|
|
127
|
+
return i.map((e, t) => {
|
|
128
|
+
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;
|
|
129
|
+
return {
|
|
130
|
+
pageUrl: e.pageUrl,
|
|
131
|
+
sourceMessageId: e.sourceMessageId,
|
|
132
|
+
timestamp: e.timestamp,
|
|
133
|
+
...e.pageTitle !== void 0 ? { pageTitle: e.pageTitle } : {},
|
|
134
|
+
...e.canonicalUrl !== void 0 ? { canonicalUrl: e.canonicalUrl } : {},
|
|
135
|
+
...r ? { activeTimeOnSite: n } : {},
|
|
136
|
+
...u !== void 0 && u >= 0 ? { activeTimeOnPage: u } : {}
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function pe() {
|
|
141
|
+
const e = document.querySelector('link[rel="canonical"]')?.href;
|
|
142
|
+
if (e)
|
|
143
|
+
return K(e);
|
|
144
|
+
}
|
|
145
|
+
const d = "Rokt", L = 181, fe = "selectPlacements", me = "apps.roktecommerce.com", Ee = 0.1, _e = "ThankYouPageJourney", ye = "rokt-launcher", Ie = "rokt-thank-you-element", Se = "userIdentifiedInWorkspace", ke = 3, Ae = 2, Re = "page_events", ve = 500, D = {
|
|
39
146
|
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
40
147
|
UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
|
|
41
148
|
IDENTITY_REQUEST: "IDENTITY_REQUEST",
|
|
42
149
|
LOG_DELIVERY_FAILURE: "LOG_DELIVERY_FAILURE"
|
|
43
|
-
},
|
|
150
|
+
}, _ = {
|
|
44
151
|
ERROR: "ERROR",
|
|
45
152
|
INFO: "INFO",
|
|
46
153
|
WARNING: "WARNING"
|
|
47
|
-
},
|
|
154
|
+
}, we = "apps.rokt-api.com", be = "/v1/log", Le = "/v1/errors", Te = 10;
|
|
48
155
|
function a() {
|
|
49
156
|
return window.mParticle;
|
|
50
157
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (n === null)
|
|
55
|
-
return [];
|
|
56
|
-
const e = JSON.parse(n);
|
|
57
|
-
return Array.isArray(e) ? e : [];
|
|
58
|
-
} catch {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function me(n) {
|
|
63
|
-
window.localStorage.setItem(N, JSON.stringify(n));
|
|
64
|
-
}
|
|
65
|
-
function M() {
|
|
66
|
-
window.localStorage.removeItem(N);
|
|
67
|
-
}
|
|
68
|
-
function D(n, e) {
|
|
69
|
-
const i = [C(n), "/wsdk/integrations/launcher.js"].join("");
|
|
70
|
-
return !e || e.length === 0 ? i : i + "?extensions=" + e.join(",");
|
|
158
|
+
function W(i, e) {
|
|
159
|
+
const n = [O(i), "/wsdk/integrations/launcher.js"].join("");
|
|
160
|
+
return !e || e.length === 0 ? n : n + "?extensions=" + e.join(",");
|
|
71
161
|
}
|
|
72
|
-
function
|
|
73
|
-
return [
|
|
162
|
+
function j(i) {
|
|
163
|
+
return [O(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
|
|
74
164
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
165
|
+
function O(i) {
|
|
166
|
+
const e = typeof i < "u" ? i : we;
|
|
167
|
+
return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
|
|
77
168
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
169
|
+
function ne(i, e, t) {
|
|
170
|
+
if (i)
|
|
171
|
+
return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
|
|
172
|
+
const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
|
|
173
|
+
return O(r) + t;
|
|
80
174
|
}
|
|
81
|
-
function
|
|
82
|
-
if (document.getElementById(
|
|
83
|
-
const
|
|
84
|
-
r.id =
|
|
175
|
+
function H(i, e, t) {
|
|
176
|
+
if (document.getElementById(i)) return;
|
|
177
|
+
const n = document.head || document.body, r = document.createElement("script");
|
|
178
|
+
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);
|
|
85
179
|
}
|
|
86
|
-
function T(
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
function v(n) {
|
|
90
|
-
if (!n)
|
|
180
|
+
function T(i) {
|
|
181
|
+
if (!i)
|
|
91
182
|
return [];
|
|
92
183
|
try {
|
|
93
|
-
return JSON.parse(
|
|
184
|
+
return JSON.parse(i.replace(/"/g, '"'));
|
|
94
185
|
} catch {
|
|
95
186
|
console.error("Settings string contains invalid JSON");
|
|
96
187
|
}
|
|
97
188
|
return [];
|
|
98
189
|
}
|
|
99
|
-
function
|
|
100
|
-
const e =
|
|
190
|
+
function V(i) {
|
|
191
|
+
const e = i ? T(i) : [], t = [], n = [];
|
|
101
192
|
let r = !1;
|
|
102
193
|
for (let s = 0; s < e.length; s++) {
|
|
103
194
|
const o = e[s].value;
|
|
104
|
-
o === "thank-you-journey" ? (r = !0,
|
|
195
|
+
o === "thank-you-journey" ? (r = !0, n.push(_e)) : t.push(o);
|
|
105
196
|
}
|
|
106
197
|
return {
|
|
107
198
|
roktExtensionsQueryParams: t,
|
|
108
|
-
legacyRoktExtensions:
|
|
199
|
+
legacyRoktExtensions: n,
|
|
109
200
|
loadThankYouElement: r
|
|
110
201
|
};
|
|
111
202
|
}
|
|
112
|
-
async function
|
|
203
|
+
async function Ne(i, e) {
|
|
113
204
|
const t = [];
|
|
114
205
|
if (e)
|
|
115
|
-
for (const
|
|
116
|
-
t.push(e.use(
|
|
206
|
+
for (const n of i)
|
|
207
|
+
t.push(e.use(n));
|
|
117
208
|
return Promise.all(t);
|
|
118
209
|
}
|
|
119
|
-
function
|
|
120
|
-
if (!
|
|
210
|
+
function z(i) {
|
|
211
|
+
if (!i)
|
|
121
212
|
return {};
|
|
122
213
|
const e = {};
|
|
123
|
-
for (let t = 0; t <
|
|
124
|
-
const
|
|
125
|
-
e[
|
|
214
|
+
for (let t = 0; t < i.length; t++) {
|
|
215
|
+
const n = i[t];
|
|
216
|
+
e[n.jsmap] = n.value;
|
|
126
217
|
}
|
|
127
218
|
return e;
|
|
128
219
|
}
|
|
129
|
-
function
|
|
220
|
+
function J(i) {
|
|
130
221
|
const e = {};
|
|
131
|
-
if (!Array.isArray(
|
|
222
|
+
if (!Array.isArray(i))
|
|
132
223
|
return e;
|
|
133
|
-
for (let t = 0; t <
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
224
|
+
for (let t = 0; t < i.length; t++) {
|
|
225
|
+
const n = i[t];
|
|
226
|
+
if (!n || !m(n.value) || !m(n.map))
|
|
136
227
|
continue;
|
|
137
|
-
const r =
|
|
228
|
+
const r = n.value, s = n.map;
|
|
138
229
|
e[r] || (e[r] = []), e[r].push({
|
|
139
230
|
eventAttributeKey: s,
|
|
140
|
-
conditions: Array.isArray(
|
|
231
|
+
conditions: Array.isArray(n.conditions) ? n.conditions : []
|
|
141
232
|
});
|
|
142
233
|
}
|
|
143
234
|
return e;
|
|
144
235
|
}
|
|
145
|
-
function
|
|
146
|
-
return a().generateHash([
|
|
147
|
-
}
|
|
148
|
-
function L(n) {
|
|
149
|
-
return n == null ? !0 : typeof n == "object" ? Object.keys(n).length === 0 : Array.isArray(n) ? n.length === 0 : !1;
|
|
150
|
-
}
|
|
151
|
-
function E(n) {
|
|
152
|
-
return typeof n == "string";
|
|
153
|
-
}
|
|
154
|
-
function _e(n) {
|
|
155
|
-
try {
|
|
156
|
-
const e = new URL(n);
|
|
157
|
-
return e.search = "", e.toString();
|
|
158
|
-
} catch {
|
|
159
|
-
return n;
|
|
160
|
-
}
|
|
236
|
+
function B(i, e, t) {
|
|
237
|
+
return a().generateHash([i, e, t].join(""));
|
|
161
238
|
}
|
|
162
|
-
function
|
|
163
|
-
let
|
|
164
|
-
return
|
|
239
|
+
function Oe(i) {
|
|
240
|
+
let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.32.0";
|
|
241
|
+
return i && (n += "_" + i), n;
|
|
165
242
|
}
|
|
166
|
-
function
|
|
243
|
+
function re(i) {
|
|
167
244
|
let e = 5381;
|
|
168
|
-
for (let t = 0; t <
|
|
169
|
-
e = (e << 5) + e +
|
|
245
|
+
for (let t = 0; t < i.length; t++)
|
|
246
|
+
e = (e << 5) + e + i.charCodeAt(t), e = e & e;
|
|
170
247
|
return e;
|
|
171
248
|
}
|
|
172
|
-
function
|
|
249
|
+
function M(i) {
|
|
173
250
|
const e = document.createElement("iframe");
|
|
174
|
-
e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src =
|
|
251
|
+
e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = i, e.onload = function() {
|
|
175
252
|
e.onload = null, e.parentNode && e.parentNode.removeChild(e);
|
|
176
253
|
};
|
|
177
254
|
const t = document.body || document.head;
|
|
178
255
|
t && t.appendChild(e);
|
|
179
256
|
}
|
|
180
|
-
function
|
|
181
|
-
const t =
|
|
182
|
-
if (
|
|
257
|
+
function q(i, e) {
|
|
258
|
+
const t = re(window.location.origin);
|
|
259
|
+
if (I._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ee)
|
|
183
260
|
return;
|
|
184
261
|
const r = window.__rokt_li_guid__;
|
|
185
|
-
if (!r)
|
|
262
|
+
if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
|
|
186
263
|
return;
|
|
187
|
-
const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s);
|
|
188
|
-
|
|
189
|
-
"https://" +
|
|
264
|
+
const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? O(i) : "https://apps.rokt.com";
|
|
265
|
+
M(c + "/v1/wsdk-init/index.html?" + o), M(
|
|
266
|
+
"https://" + me + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
|
|
190
267
|
);
|
|
191
268
|
}
|
|
192
|
-
function
|
|
269
|
+
function Pe() {
|
|
193
270
|
return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
|
|
194
271
|
}
|
|
195
|
-
function
|
|
272
|
+
function Ue() {
|
|
196
273
|
return typeof window < "u" ? window.location?.href : void 0;
|
|
197
274
|
}
|
|
198
|
-
function
|
|
275
|
+
function Ce() {
|
|
199
276
|
return typeof window < "u" ? window.navigator?.userAgent : void 0;
|
|
200
277
|
}
|
|
201
|
-
class
|
|
278
|
+
class se {
|
|
202
279
|
constructor() {
|
|
203
280
|
this._logCount = {};
|
|
204
281
|
}
|
|
205
282
|
incrementAndCheck(e) {
|
|
206
|
-
const
|
|
207
|
-
return this._logCount[e] =
|
|
283
|
+
const n = (this._logCount[e] || 0) + 1;
|
|
284
|
+
return this._logCount[e] = n, n > Te;
|
|
208
285
|
}
|
|
209
286
|
}
|
|
210
|
-
class
|
|
211
|
-
constructor(e, t,
|
|
287
|
+
class F {
|
|
288
|
+
constructor(e, t, n, r, s) {
|
|
212
289
|
this._reporter = "mp-wsdk";
|
|
213
290
|
const o = e.isLoggingEnabled;
|
|
214
|
-
this._integrationName = t || "", this._launcherInstanceGuid =
|
|
291
|
+
this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new se(), this._isEnabled = Pe() || o;
|
|
215
292
|
}
|
|
216
|
-
send(e, t,
|
|
293
|
+
send(e, t, n, r, s, o) {
|
|
217
294
|
if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
|
|
218
295
|
try {
|
|
219
296
|
const c = {
|
|
220
297
|
additionalInformation: {
|
|
221
|
-
message:
|
|
298
|
+
message: n,
|
|
222
299
|
version: this._integrationName
|
|
223
300
|
},
|
|
224
301
|
severity: t,
|
|
225
|
-
code: r ||
|
|
226
|
-
url:
|
|
227
|
-
deviceInfo:
|
|
302
|
+
code: r || D.UNKNOWN_ERROR,
|
|
303
|
+
url: Ue(),
|
|
304
|
+
deviceInfo: Ce(),
|
|
228
305
|
stackTrace: s,
|
|
229
306
|
reporter: this._reporter,
|
|
230
307
|
integration: this._integrationName
|
|
@@ -240,8 +317,8 @@ class U {
|
|
|
240
317
|
body: JSON.stringify(c)
|
|
241
318
|
}).then((l) => {
|
|
242
319
|
if (!l.ok) {
|
|
243
|
-
const
|
|
244
|
-
throw
|
|
320
|
+
const g = new Error("HTTP " + l.status + " from log endpoint");
|
|
321
|
+
throw g.statusCode = l.status, g;
|
|
245
322
|
}
|
|
246
323
|
}).catch((l) => {
|
|
247
324
|
console.error("ReportingTransport: Failed to send log", l), o && o(l);
|
|
@@ -251,74 +328,85 @@ class U {
|
|
|
251
328
|
}
|
|
252
329
|
}
|
|
253
330
|
}
|
|
254
|
-
class
|
|
255
|
-
constructor(e, t,
|
|
256
|
-
this._transport = new
|
|
331
|
+
class $ {
|
|
332
|
+
constructor(e, t, n, r, s) {
|
|
333
|
+
this._transport = new F(e, t, n, r, s), this._errorUrl = ne(e?.errorUrl, e?.integrationDomain, Le);
|
|
257
334
|
}
|
|
258
335
|
report(e) {
|
|
259
336
|
if (!e) return;
|
|
260
|
-
const t = e.severity ||
|
|
337
|
+
const t = e.severity || _.ERROR;
|
|
261
338
|
this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
|
|
262
339
|
}
|
|
263
340
|
}
|
|
264
|
-
class
|
|
265
|
-
constructor(e, t,
|
|
266
|
-
this._transport = new
|
|
341
|
+
class Q {
|
|
342
|
+
constructor(e, t, n, r, s, o) {
|
|
343
|
+
this._transport = new F(e, n, r, s, o), this._loggingUrl = ne(e?.loggingUrl, e?.integrationDomain, be), this._errorReportingService = t;
|
|
267
344
|
}
|
|
268
345
|
log(e) {
|
|
269
346
|
e && this._transport.send(
|
|
270
347
|
this._loggingUrl,
|
|
271
|
-
|
|
348
|
+
_.INFO,
|
|
272
349
|
e.message,
|
|
273
350
|
e.code,
|
|
274
351
|
void 0,
|
|
275
352
|
(t) => {
|
|
276
353
|
if (this._errorReportingService) {
|
|
277
|
-
const
|
|
354
|
+
const n = typeof t.statusCode == "number";
|
|
278
355
|
this._errorReportingService.report({
|
|
279
356
|
message: "LoggingService: Failed to send log: " + t.message,
|
|
280
|
-
code:
|
|
281
|
-
severity:
|
|
357
|
+
code: D.LOG_DELIVERY_FAILURE,
|
|
358
|
+
severity: n ? _.ERROR : _.WARNING
|
|
282
359
|
});
|
|
283
360
|
}
|
|
284
361
|
}
|
|
285
362
|
);
|
|
286
363
|
}
|
|
287
364
|
}
|
|
365
|
+
function Me(i) {
|
|
366
|
+
const e = K(window.location.href), t = i.EventAttributes?.title || document.title, n = pe(), r = i.ActiveTimeOnSite;
|
|
367
|
+
return {
|
|
368
|
+
pageUrl: e,
|
|
369
|
+
sourceMessageId: i.SourceMessageId,
|
|
370
|
+
timestamp: i.Timestamp,
|
|
371
|
+
...t ? { pageTitle: t } : {},
|
|
372
|
+
...n !== void 0 ? { canonicalUrl: n } : {},
|
|
373
|
+
...Number.isFinite(r) ? { activeTimeOnSite: r } : {}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
288
376
|
const f = class f {
|
|
289
377
|
constructor() {
|
|
290
|
-
this.name = d, this.id =
|
|
378
|
+
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;
|
|
291
379
|
}
|
|
292
380
|
// ---- Private helpers ----
|
|
293
381
|
getEventAttributeValue(e, t) {
|
|
294
|
-
const
|
|
295
|
-
return !
|
|
382
|
+
const n = e && e.EventAttributes;
|
|
383
|
+
return !n || typeof n[t] > "u" ? null : n[t];
|
|
296
384
|
}
|
|
297
385
|
doesEventAttributeConditionMatch(e, t) {
|
|
298
|
-
if (!e || !
|
|
386
|
+
if (!e || !m(e.operator))
|
|
299
387
|
return !1;
|
|
300
|
-
const
|
|
301
|
-
return
|
|
388
|
+
const n = e.operator.toLowerCase(), r = e.attributeValue;
|
|
389
|
+
return n === "exists" ? t !== null : t == null ? !1 : n === "equals" ? String(t) === String(r) : n === "contains" ? String(t).indexOf(String(r)) !== -1 : !1;
|
|
302
390
|
}
|
|
303
391
|
doesEventMatchRule(e, t) {
|
|
304
|
-
if (!t || !
|
|
392
|
+
if (!t || !m(t.eventAttributeKey))
|
|
305
393
|
return !1;
|
|
306
|
-
const
|
|
307
|
-
if (!Array.isArray(
|
|
394
|
+
const n = t.conditions;
|
|
395
|
+
if (!Array.isArray(n))
|
|
308
396
|
return !1;
|
|
309
397
|
const r = this.getEventAttributeValue(e, t.eventAttributeKey);
|
|
310
|
-
if (
|
|
398
|
+
if (n.length === 0)
|
|
311
399
|
return r !== null;
|
|
312
|
-
for (let s = 0; s <
|
|
313
|
-
if (!this.doesEventAttributeConditionMatch(
|
|
400
|
+
for (let s = 0; s < n.length; s++)
|
|
401
|
+
if (!this.doesEventAttributeConditionMatch(n[s], r))
|
|
314
402
|
return !1;
|
|
315
403
|
return !0;
|
|
316
404
|
}
|
|
317
405
|
applyPlacementEventAttributeMapping(e) {
|
|
318
406
|
const t = Object.keys(this.placementEventAttributeMappingLookup);
|
|
319
|
-
for (let
|
|
320
|
-
const r = t[
|
|
321
|
-
if (
|
|
407
|
+
for (let n = 0; n < t.length; n++) {
|
|
408
|
+
const r = t[n], s = this.placementEventAttributeMappingLookup[r];
|
|
409
|
+
if (U(s))
|
|
322
410
|
continue;
|
|
323
411
|
let o = !0;
|
|
324
412
|
for (let c = 0; c < s.length; c++)
|
|
@@ -332,21 +420,16 @@ const f = class f {
|
|
|
332
420
|
capturePageView(e) {
|
|
333
421
|
let t;
|
|
334
422
|
try {
|
|
335
|
-
t =
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
this.errorReportingService?.report({
|
|
346
|
-
message: `Rokt Kit: Failed to capture page view for ${t}`,
|
|
347
|
-
code: "PAGE_VIEW_CAPTURE_FAILED",
|
|
348
|
-
severity: m.INFO,
|
|
349
|
-
stackTrace: i instanceof Error ? i.stack : void 0
|
|
423
|
+
t = K(window.location.href);
|
|
424
|
+
const n = Y(this.loggingService), r = Me(e);
|
|
425
|
+
n.push(r), he(n) || this.loggingService?.log({
|
|
426
|
+
message: `Rokt Kit: Failed to persist page view for ${t}`,
|
|
427
|
+
code: "PAGE_VIEW_CAPTURE_FAILED"
|
|
428
|
+
});
|
|
429
|
+
} catch (n) {
|
|
430
|
+
this.loggingService?.log({
|
|
431
|
+
message: `Rokt Kit: Failed to capture page view for ${t}: ${n instanceof Error ? n.message : String(n)}`,
|
|
432
|
+
code: "PAGE_VIEW_CAPTURE_FAILED"
|
|
350
433
|
});
|
|
351
434
|
}
|
|
352
435
|
}
|
|
@@ -365,43 +448,27 @@ const f = class f {
|
|
|
365
448
|
returnLocalSessionAttributes() {
|
|
366
449
|
return !a().Rokt || typeof a().Rokt.getLocalSessionAttributes != "function" ? {} : a().Rokt.getLocalSessionAttributes();
|
|
367
450
|
}
|
|
368
|
-
buildPageEvents(e) {
|
|
369
|
-
return e.map((t, i) => {
|
|
370
|
-
const r = {
|
|
371
|
-
pageUrl: t.pageUrl,
|
|
372
|
-
sourceMessageId: t.sourceMessageId,
|
|
373
|
-
timestamp: t.timestamp
|
|
374
|
-
}, s = t.activeTimeOnSite, o = s !== void 0 && Number.isFinite(s);
|
|
375
|
-
o && (r.activeTimeOnSite = s);
|
|
376
|
-
const u = e[i + 1]?.activeTimeOnSite, l = u !== void 0 && Number.isFinite(u);
|
|
377
|
-
if (o && l) {
|
|
378
|
-
const h = u - s;
|
|
379
|
-
h >= 0 && (r.activeTimeOnPage = h);
|
|
380
|
-
}
|
|
381
|
-
return r;
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
451
|
replaceOtherIdentityWithEmailsha256(e) {
|
|
385
|
-
const t = { ...e || {} },
|
|
386
|
-
return
|
|
452
|
+
const t = { ...e || {} }, n = this._mappedEmailSha256Key;
|
|
453
|
+
return n && e[n] && (t[f.EMAIL_SHA256_KEY] = e[n]), n && delete t[n], t;
|
|
387
454
|
}
|
|
388
455
|
logSelectPlacementsEvent(e) {
|
|
389
|
-
if (!window.mParticle || typeof a().logEvent != "function" || !
|
|
456
|
+
if (!window.mParticle || typeof a().logEvent != "function" || !y(e))
|
|
390
457
|
return;
|
|
391
458
|
const t = a().EventType.Other;
|
|
392
|
-
a().logEvent(
|
|
459
|
+
a().logEvent(fe, t, e);
|
|
393
460
|
}
|
|
394
461
|
setRoktSessionId(e) {
|
|
395
462
|
if (!(!e || typeof e != "string"))
|
|
396
463
|
try {
|
|
397
464
|
const t = a().getInstance();
|
|
398
|
-
t && typeof t.setIntegrationAttribute == "function" && t.setIntegrationAttribute(
|
|
465
|
+
t && typeof t.setIntegrationAttribute == "function" && t.setIntegrationAttribute(L, {
|
|
399
466
|
roktSessionId: e
|
|
400
467
|
});
|
|
401
468
|
} catch {
|
|
402
469
|
}
|
|
403
470
|
}
|
|
404
|
-
attachLauncher(e, t,
|
|
471
|
+
attachLauncher(e, t, n = []) {
|
|
405
472
|
const r = a() && a().sessionManager && typeof a().sessionManager.getSession == "function" ? a().sessionManager.getSession() : void 0, s = {
|
|
406
473
|
accountId: e,
|
|
407
474
|
...t || {},
|
|
@@ -409,7 +476,7 @@ const f = class f {
|
|
|
409
476
|
};
|
|
410
477
|
let o;
|
|
411
478
|
this.isPartnerInLocalLauncherTestGroup() ? o = Promise.resolve(window.Rokt.createLocalLauncher(s)) : o = window.Rokt.createLauncher(s), o.then(async (c) => {
|
|
412
|
-
await
|
|
479
|
+
await Ne(n, c), this.initRoktLauncher(c);
|
|
413
480
|
}).catch((c) => {
|
|
414
481
|
console.error("Error creating Rokt launcher:", c);
|
|
415
482
|
});
|
|
@@ -417,7 +484,7 @@ const f = class f {
|
|
|
417
484
|
initRoktLauncher(e) {
|
|
418
485
|
window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e;
|
|
419
486
|
const t = a().Rokt?.filters;
|
|
420
|
-
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,
|
|
487
|
+
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);
|
|
421
488
|
}
|
|
422
489
|
fetchOptimizely() {
|
|
423
490
|
const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
|
|
@@ -452,101 +519,90 @@ const f = class f {
|
|
|
452
519
|
/**
|
|
453
520
|
* Initializes the Rokt forwarder with settings from the mParticle server.
|
|
454
521
|
*/
|
|
455
|
-
init(e, t,
|
|
522
|
+
init(e, t, n, r, s) {
|
|
456
523
|
const o = e, c = o.accountId;
|
|
457
|
-
this.userAttributes =
|
|
458
|
-
const u =
|
|
459
|
-
this.placementEventMappingLookup =
|
|
460
|
-
const l =
|
|
524
|
+
this.userAttributes = b(s), this._onboardingExpProvider = o.onboardingExpProvider;
|
|
525
|
+
const u = T(o.placementEventMapping);
|
|
526
|
+
this.placementEventMappingLookup = z(u);
|
|
527
|
+
const l = T(
|
|
461
528
|
o.placementEventAttributeMapping
|
|
462
529
|
);
|
|
463
|
-
this.placementEventAttributeMappingLookup =
|
|
464
|
-
const
|
|
530
|
+
this.placementEventAttributeMappingLookup = J(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
|
|
531
|
+
const g = a().Rokt?.domain, { roktExtensionsQueryParams: P, legacyRoktExtensions: A, loadThankYouElement: R } = V(
|
|
465
532
|
o.roktExtensions
|
|
466
|
-
),
|
|
533
|
+
), p = {
|
|
467
534
|
...a().Rokt?.launcherOptions || {}
|
|
468
535
|
};
|
|
469
|
-
this.integrationName =
|
|
470
|
-
const
|
|
536
|
+
this.integrationName = Oe(p.integrationName), p.integrationName = this.integrationName, this.domain = g;
|
|
537
|
+
const v = {
|
|
471
538
|
loggingUrl: o.loggingUrl,
|
|
472
539
|
errorUrl: o.errorUrl,
|
|
473
|
-
integrationDomain:
|
|
540
|
+
integrationDomain: g,
|
|
474
541
|
isLoggingEnabled: a().config?.isLoggingEnabled === !0
|
|
475
|
-
},
|
|
476
|
-
|
|
542
|
+
}, E = new $(
|
|
543
|
+
v,
|
|
477
544
|
this.integrationName,
|
|
478
545
|
window.__rokt_li_guid__,
|
|
479
546
|
o.accountId
|
|
480
|
-
),
|
|
481
|
-
|
|
482
|
-
|
|
547
|
+
), w = new Q(
|
|
548
|
+
v,
|
|
549
|
+
E,
|
|
483
550
|
this.integrationName,
|
|
484
551
|
window.__rokt_li_guid__,
|
|
485
552
|
o.accountId
|
|
486
553
|
);
|
|
487
|
-
if (this.errorReportingService =
|
|
554
|
+
if (this.errorReportingService = E, this.loggingService = w, this.isTargetingDisabled())
|
|
488
555
|
try {
|
|
489
|
-
|
|
490
|
-
} catch (
|
|
556
|
+
G();
|
|
557
|
+
} catch (h) {
|
|
491
558
|
this.errorReportingService?.report({
|
|
492
559
|
message: "Rokt Kit: Failed to clear page views when targeting is disabled",
|
|
493
560
|
code: "PAGE_VIEW_CAPTURE_FAILED",
|
|
494
|
-
severity:
|
|
495
|
-
stackTrace:
|
|
561
|
+
severity: _.INFO,
|
|
562
|
+
stackTrace: h instanceof Error ? h.stack : void 0
|
|
496
563
|
});
|
|
497
564
|
}
|
|
498
|
-
return a()._registerErrorReportingService && a()._registerErrorReportingService(
|
|
499
|
-
generateLauncherScript:
|
|
500
|
-
generateThankYouElementScript:
|
|
501
|
-
extractRoktExtensionConfig:
|
|
502
|
-
hashEventMessage:
|
|
503
|
-
parseSettingsString:
|
|
504
|
-
generateMappedEventLookup:
|
|
505
|
-
generateMappedEventAttributeLookup:
|
|
506
|
-
sendAdBlockMeasurementSignals:
|
|
507
|
-
createAutoRemovedIframe:
|
|
508
|
-
djb2:
|
|
509
|
-
setAllowedOriginHashes: (
|
|
510
|
-
f._allowedOriginHashes =
|
|
565
|
+
return a()._registerErrorReportingService && a()._registerErrorReportingService(E), a()._registerLoggingService && a()._registerLoggingService(w), n ? (this.testHelpers = {
|
|
566
|
+
generateLauncherScript: W,
|
|
567
|
+
generateThankYouElementScript: j,
|
|
568
|
+
extractRoktExtensionConfig: V,
|
|
569
|
+
hashEventMessage: B,
|
|
570
|
+
parseSettingsString: T,
|
|
571
|
+
generateMappedEventLookup: z,
|
|
572
|
+
generateMappedEventAttributeLookup: J,
|
|
573
|
+
sendAdBlockMeasurementSignals: q,
|
|
574
|
+
createAutoRemovedIframe: M,
|
|
575
|
+
djb2: re,
|
|
576
|
+
setAllowedOriginHashes: (h) => {
|
|
577
|
+
f._allowedOriginHashes = h;
|
|
511
578
|
},
|
|
512
|
-
ReportingTransport:
|
|
513
|
-
ErrorReportingService:
|
|
514
|
-
LoggingService:
|
|
515
|
-
RateLimiter:
|
|
516
|
-
ErrorCodes:
|
|
517
|
-
WSDKErrorSeverity:
|
|
518
|
-
}, this.attachLauncher(c,
|
|
579
|
+
ReportingTransport: F,
|
|
580
|
+
ErrorReportingService: $,
|
|
581
|
+
LoggingService: Q,
|
|
582
|
+
RateLimiter: se,
|
|
583
|
+
ErrorCodes: D,
|
|
584
|
+
WSDKErrorSeverity: _
|
|
585
|
+
}, this.attachLauncher(c, p), "Successfully initialized: " + d) : (R && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), H(Ie, j(g), {
|
|
519
586
|
onLoad: () => {
|
|
520
587
|
this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
|
|
521
588
|
},
|
|
522
|
-
onError: (
|
|
523
|
-
console.error("Error loading Rokt Thank You Element script:",
|
|
589
|
+
onError: (h) => {
|
|
590
|
+
console.error("Error loading Rokt Thank You Element script:", h);
|
|
524
591
|
}
|
|
525
|
-
})), this.isLauncherReadyToAttach() ? this.attachLauncher(c,
|
|
592
|
+
})), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, A) : (H(ye, W(g, P), {
|
|
526
593
|
onLoad: () => {
|
|
527
|
-
this.isLauncherReadyToAttach() ? this.attachLauncher(c,
|
|
594
|
+
this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, A) : console.error("Rokt object is not available after script load.");
|
|
528
595
|
},
|
|
529
|
-
onError: (
|
|
530
|
-
console.error("Error loading Rokt launcher script:",
|
|
596
|
+
onError: (h) => {
|
|
597
|
+
console.error("Error loading Rokt launcher script:", h);
|
|
531
598
|
}
|
|
532
599
|
}), this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
|
|
533
600
|
}
|
|
534
601
|
process(e) {
|
|
535
|
-
if (
|
|
536
|
-
try {
|
|
537
|
-
M();
|
|
538
|
-
} catch (t) {
|
|
539
|
-
this.errorReportingService?.report({
|
|
540
|
-
message: "Rokt Kit: Failed to clear page views on session end",
|
|
541
|
-
code: "PAGE_VIEW_CAPTURE_FAILED",
|
|
542
|
-
severity: m.INFO,
|
|
543
|
-
stackTrace: t instanceof Error ? t.stack : void 0
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
if (!this.isKitReady())
|
|
602
|
+
if (this.isTargetingDisabled() || (e.EventDataType === ke && this.capturePageView(e), e.EventDataType === Ae && (ie(this.loggingService), G())), !this.isKitReady())
|
|
547
603
|
return "Kit not ready for forwarder: " + d;
|
|
548
|
-
if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (
|
|
549
|
-
const t =
|
|
604
|
+
if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (U(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !U(this.placementEventMappingLookup))) {
|
|
605
|
+
const t = B(e.EventDataType, e.EventCategory, e.EventName ?? "");
|
|
550
606
|
this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
|
|
551
607
|
}
|
|
552
608
|
return "Successfully sent to forwarder: " + d;
|
|
@@ -559,13 +615,13 @@ const f = class f {
|
|
|
559
615
|
window.Rokt.setExtensionData(e);
|
|
560
616
|
}
|
|
561
617
|
setUserAttribute(e, t) {
|
|
562
|
-
return
|
|
618
|
+
return X(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
|
|
563
619
|
}
|
|
564
620
|
removeUserAttribute(e) {
|
|
565
621
|
return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
|
|
566
622
|
}
|
|
567
623
|
handleIdentityComplete(e, t) {
|
|
568
|
-
return this.userAttributes =
|
|
624
|
+
return this.userAttributes = b(e.getAllUserAttributes()), "Successfully called " + t + " for forwarder: " + d;
|
|
569
625
|
}
|
|
570
626
|
onUserIdentified(e) {
|
|
571
627
|
const t = e;
|
|
@@ -575,14 +631,14 @@ const f = class f {
|
|
|
575
631
|
const t = this._workspaceIdSyncApiKey;
|
|
576
632
|
if (!t)
|
|
577
633
|
return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
|
|
578
|
-
const
|
|
579
|
-
if (typeof
|
|
634
|
+
const n = a().Identity?.search;
|
|
635
|
+
if (typeof n != "function")
|
|
580
636
|
return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
|
|
581
637
|
const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
|
|
582
638
|
if (r)
|
|
583
639
|
for (const u of Object.keys(r)) {
|
|
584
640
|
const l = r[u];
|
|
585
|
-
|
|
641
|
+
m(l) && l.length > 0 && (s[u] = l);
|
|
586
642
|
}
|
|
587
643
|
const o = Object.keys(s);
|
|
588
644
|
if (o.length === 0)
|
|
@@ -590,7 +646,7 @@ const f = class f {
|
|
|
590
646
|
const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
|
|
591
647
|
return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
|
|
592
648
|
try {
|
|
593
|
-
|
|
649
|
+
n(t, s, (l) => {
|
|
594
650
|
l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
|
|
595
651
|
});
|
|
596
652
|
} catch (l) {
|
|
@@ -635,26 +691,26 @@ const f = class f {
|
|
|
635
691
|
const t = this._workspaceSearchInFlightPromise;
|
|
636
692
|
return Promise.race([
|
|
637
693
|
t,
|
|
638
|
-
new Promise((
|
|
694
|
+
new Promise((n) => setTimeout(n, ve))
|
|
639
695
|
]).then(() => this._dispatchPlacements(e));
|
|
640
696
|
}
|
|
641
697
|
return this._dispatchPlacements(e);
|
|
642
698
|
}
|
|
643
699
|
_dispatchPlacements(e) {
|
|
644
|
-
const t = e && e.attributes || {}, r = { ...
|
|
700
|
+
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;
|
|
645
701
|
let l;
|
|
646
|
-
s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes =
|
|
647
|
-
const
|
|
648
|
-
...
|
|
702
|
+
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);
|
|
703
|
+
const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, P = this.returnUserIdentities(c), A = this.returnLocalSessionAttributes(), R = ge(Y(this.loggingService)), p = {
|
|
704
|
+
...P,
|
|
649
705
|
...l,
|
|
650
|
-
...
|
|
651
|
-
...
|
|
652
|
-
...
|
|
653
|
-
...this.userIdentifiedInWorkspace ? { [
|
|
706
|
+
...g,
|
|
707
|
+
...A,
|
|
708
|
+
...R.length ? { [Re]: JSON.stringify(R) } : {},
|
|
709
|
+
...this.userIdentifiedInWorkspace ? { [Se]: !0 } : {},
|
|
654
710
|
mpid: u
|
|
655
|
-
},
|
|
656
|
-
return Promise.resolve(
|
|
657
|
-
}).finally(
|
|
711
|
+
}, v = { ...e, attributes: p }, E = this.launcher.selectPlacements(v), w = () => this.logSelectPlacementsEvent(p);
|
|
712
|
+
return Promise.resolve(E).then((h) => h?.context?.sessionId?.then((oe) => this.setRoktSessionId(oe))).catch(() => {
|
|
713
|
+
}).finally(w), E;
|
|
658
714
|
}
|
|
659
715
|
/**
|
|
660
716
|
* Passes attributes to the Rokt Web SDK for client-side hashing.
|
|
@@ -668,7 +724,7 @@ const f = class f {
|
|
|
668
724
|
* @deprecated This functionality has been internalized and will be removed in a future release.
|
|
669
725
|
*/
|
|
670
726
|
use(e) {
|
|
671
|
-
return this.isKitReady() ? !e || !
|
|
727
|
+
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")));
|
|
672
728
|
}
|
|
673
729
|
/**
|
|
674
730
|
* Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
|
|
@@ -680,31 +736,31 @@ const f = class f {
|
|
|
680
736
|
f._allowedOriginHashes = [-553112570, 549508659], f.PERFORMANCE_MARKS = {
|
|
681
737
|
RoktScriptAppended: "mp:RoktScriptAppended"
|
|
682
738
|
}, f.EMAIL_SHA256_KEY = "emailsha256";
|
|
683
|
-
let
|
|
684
|
-
function
|
|
685
|
-
return
|
|
739
|
+
let I = f;
|
|
740
|
+
function Ke() {
|
|
741
|
+
return L;
|
|
686
742
|
}
|
|
687
|
-
function
|
|
688
|
-
if (!
|
|
743
|
+
function De(i) {
|
|
744
|
+
if (!i) {
|
|
689
745
|
window.console.log("You must pass a config object to register the kit " + d);
|
|
690
746
|
return;
|
|
691
747
|
}
|
|
692
|
-
if (!
|
|
693
|
-
window.console.log("'config' must be an object. You passed in a " + typeof
|
|
748
|
+
if (!y(i)) {
|
|
749
|
+
window.console.log("'config' must be an object. You passed in a " + typeof i);
|
|
694
750
|
return;
|
|
695
751
|
}
|
|
696
|
-
|
|
697
|
-
constructor:
|
|
698
|
-
} : (
|
|
699
|
-
constructor:
|
|
752
|
+
y(i.kits) ? i.kits[d] = {
|
|
753
|
+
constructor: I
|
|
754
|
+
} : (i.kits = {}, i.kits[d] = {
|
|
755
|
+
constructor: I
|
|
700
756
|
}), window.console.log("Successfully registered " + d + " to your mParticle configuration");
|
|
701
757
|
}
|
|
702
758
|
typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
|
|
703
759
|
name: d,
|
|
704
|
-
constructor:
|
|
705
|
-
getId:
|
|
760
|
+
constructor: I,
|
|
761
|
+
getId: Ke
|
|
706
762
|
});
|
|
707
763
|
export {
|
|
708
|
-
|
|
764
|
+
De as register
|
|
709
765
|
};
|
|
710
766
|
//# sourceMappingURL=Rokt-Kit.esm.js.map
|
package/dist/Rokt-Kit.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var RoktKit=(function(b){"use strict";const $=["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"],Z=new Set($);function M(n){return Z.has(n.toLowerCase())}function I(n){const e={},t=n||{},i=Object.keys(t);for(let r=0;r<i.length;r++){const s=i[r];M(s)||(e[s]=t[s])}return e}const d="Rokt",S=181,ee="selectPlacements",te="apps.roktecommerce.com",ie=.1,ne="ThankYouPageJourney",re="rokt-launcher",se="rokt-thank-you-element",oe="userIdentifiedInWorkspace",ae=3,ce=2,T="mpPageViews",le=25,ue="page_events",de=500,L={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},g={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},he="apps.rokt-api.com",pe="/v1/log",ge="/v1/errors",fe=10;function a(){return window.mParticle}function D(){try{const n=window.localStorage.getItem(T);if(n===null)return[];const e=JSON.parse(n);return Array.isArray(e)?e:[]}catch{return[]}}function me(n){window.localStorage.setItem(T,JSON.stringify(n))}function F(){window.localStorage.removeItem(T)}function Y(n,e){const i=[O(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function x(n){return[O(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function O(n){return["https://",typeof n<"u"?n:he].join("")}function G(n,e,t){return n?n.startsWith("http://")||n.startsWith("https://")?n:"https://"+n:O(e)+t}function j(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,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),i.appendChild(r)}function P(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function k(n){if(!n)return[];try{return JSON.parse(n.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function W(n){const e=n?k(n):[],t=[],i=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,i.push(ne)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function Ee(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function H(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function V(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!E(i.value)||!E(i.map))continue;const r=i.value,s=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function z(n,e,t){return a().generateHash([n,e,t].join(""))}function N(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function E(n){return typeof n=="string"}function _e(n){try{const e=new URL(n);return e.search="",e.toString()}catch{return n}}function ye(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.30.2";return n&&(i+="_"+n),i}function J(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function C(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function q(n,e){const t=J(window.location.origin);if(_._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ie)return;const r=window.__rokt_li_guid__;if(!r)return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s);C("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),C("https://"+te+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Ie(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Se(){return typeof window<"u"?window.location?.href:void 0}function ke(){return typeof window<"u"?window.navigator?.userAgent:void 0}class B{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>fe}}class U{constructor(e,t,i,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=s||new B,this._isEnabled=Ie()||o}send(e,t,i,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||L.UNKNOWN_ERROR,url:Se(),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(c)}).then(l=>{if(!l.ok){const h=new Error("HTTP "+l.status+" from log endpoint");throw h.statusCode=l.status,h}}).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 Q{constructor(e,t,i,r,s){this._transport=new U(e,t,i,r,s),this._errorUrl=G(e?.errorUrl,e?.integrationDomain,ge)}report(e){if(!e)return;const t=e.severity||g.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class X{constructor(e,t,i,r,s,o){this._transport=new U(e,i,r,s,o),this._loggingUrl=G(e?.loggingUrl,e?.integrationDomain,pe),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,g.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const i=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:L.LOG_DELIVERY_FAILURE,severity:i?g.ERROR:g.WARNING})}})}}const f=class f{constructor(){this.name=d,this.id=S,this.moduleId=S,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 i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!E(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!E(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let s=0;s<i.length;s++)if(!this.doesEventAttributeConditionMatch(i[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],s=this.placementEventAttributeMappingLookup[r];if(N(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=_e(window.location.href);const i=D(),r={pageUrl:t,sourceMessageId:e.SourceMessageId,timestamp:e.Timestamp};for(Number.isFinite(e.ActiveTimeOnSite)&&(r.activeTimeOnSite=e.ActiveTimeOnSite),i.push(r);i.length>le;)i.shift();me(i)}catch(i){this.errorReportingService?.report({message:`Rokt Kit: Failed to capture page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED",severity:g.INFO,stackTrace:i instanceof Error?i.stack:void 0})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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()}buildPageEvents(e){return e.map((t,i)=>{const r={pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp},s=t.activeTimeOnSite,o=s!==void 0&&Number.isFinite(s);o&&(r.activeTimeOnSite=s);const u=e[i+1]?.activeTimeOnSite,l=u!==void 0&&Number.isFinite(u);if(o&&l){const h=u-s;h>=0&&(r.activeTimeOnPage=h)}return r})}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[f.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!P(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&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(S,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await Ee(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}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,i,r,s){const o=e,c=o.accountId;this.userAttributes=I(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=k(o.placementEventMapping);this.placementEventMappingLookup=H(u);const l=k(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=V(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=E(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const h=a().Rokt?.domain,{roktExtensionsQueryParams:K,legacyRoktExtensions:A,loadThankYouElement:R}=W(o.roktExtensions),m={...a().Rokt?.launcherOptions||{}};this.integrationName=ye(m.integrationName),m.integrationName=this.integrationName,this.domain=h;const w={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:h,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new Q(w,this.integrationName,window.__rokt_li_guid__,o.accountId),v=new X(w,y,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=y,this.loggingService=v,this.isTargetingDisabled())try{F()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:g.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(v),i?(this.testHelpers={generateLauncherScript:Y,generateThankYouElementScript:x,extractRoktExtensionConfig:W,hashEventMessage:z,parseSettingsString:k,generateMappedEventLookup:H,generateMappedEventAttributeLookup:V,sendAdBlockMeasurementSignals:q,createAutoRemovedIframe:C,djb2:J,setAllowedOriginHashes:p=>{f._allowedOriginHashes=p},ReportingTransport:U,ErrorReportingService:Q,LoggingService:X,RateLimiter:B,ErrorCodes:L,WSDKErrorSeverity:g},this.attachLauncher(c,m),"Successfully initialized: "+d):(R&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),j(se,x(h),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,m,A):(j(re,Y(h,K),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,m,A):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(!this.isTargetingDisabled()&&(e.EventDataType===ae&&this.capturePageView(e),e.EventDataType===ce))try{F()}catch(t){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views on session end",code:"PAGE_VIEW_CAPTURE_FAILED",severity:g.INFO,stackTrace:t instanceof Error?t.stack:void 0})}if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(N(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!N(this.placementEventMappingLookup))){const t=z(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 M(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=I(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 i=a().Identity?.search;if(typeof i!="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];E(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{i(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(i=>setTimeout(i,de))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...I(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=I(l);const h=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},K=this.returnUserIdentities(c),A=this.returnLocalSessionAttributes(),R=this.buildPageEvents(D()),m={...K,...l,...h,...A,...R.length?{[ue]:JSON.stringify(R)}:{},...this.userIdentifiedInWorkspace?{[oe]:!0}:{},mpid:u},w={...e,attributes:m},y=this.launcher.selectPlacements(w),v=()=>this.logSelectPlacementsEvent(m);return Promise.resolve(y).then(p=>p?.context?.sessionId?.then(we=>this.setRoktSessionId(we))).catch(()=>{}).finally(v),y}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!E(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 _=f;function Ae(){return S}function Re(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!P(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}P(n.kits)?n.kits[d]={constructor:_}:(n.kits={},n.kits[d]={constructor:_}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:_,getId:Ae}),b.register=Re,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),b})({});
|
|
1
|
+
var RoktKit=(function(P){"use strict";const ae=["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"],ce=new Set(ae);function G(i){return ce.has(i.toLowerCase())}function A(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 U(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function C(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function R(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function x(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function W(i){try{window.localStorage.removeItem(i)}catch{}}function j(i,e){const t=R(i);return E(t)?t[e]:void 0}function M(i,e,t){const n=R(i),r=E(n)?{...n}:{};return r[e]=t,x(i,r)}function le(i,e){const t=R(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?W(i):x(i,n)}function ue(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 I="mp-rokt-kit",k="pageViews",H="mpPageViews",de=100*1024;function V(i){const e=R(H);if(e===null)return;if(!(j(I,k)!==void 0)&&Array.isArray(e)&&!M(I,k,e)){i?.log({message:"Rokt Kit: Failed to migrate legacy page-view storage; retaining legacy key for retry",code:"PAGE_VIEW_CAPTURE_FAILED"});return}W(H)}function z(i){V(i);const e=j(I,k);return Array.isArray(e)?e:[]}function he(i){return ue(I,k,i,de)}function J(){le(I,k)}function ge(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 pe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return C(e)}const d="Rokt",v=181,fe="selectPlacements",me="apps.roktecommerce.com",Ee=.1,_e="ThankYouPageJourney",ye="rokt-launcher",Se="rokt-thank-you-element",Ie="userIdentifiedInWorkspace",ke=3,Ae=2,Re="page_events",ve=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"},we="apps.rokt-api.com",be="/v1/log",Le="/v1/errors",Te=10;function a(){return window.mParticle}function B(i,e){const n=[w(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function q(i){return[w(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function w(i){const e=typeof i<"u"?i:we;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function $(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 w(r)+t}function Q(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 b(i){if(!i)return[];try{return JSON.parse(i.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function X(i){const e=i?b(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(_e)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Ne(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function Z(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 ee(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 te(i,e,t){return a().generateHash([i,e,t].join(""))}function Oe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.32.0";return i&&(n+="_"+i),n}function ie(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 ne(i,e){const t=ie(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ee)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?w(i):"https://apps.rokt.com";D(c+"/v1/wsdk-init/index.html?"+o),D("https://"+me+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Pe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Ue(){return typeof window<"u"?window.location?.href:void 0}function Ce(){return typeof window<"u"?window.navigator?.userAgent:void 0}class re{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Te}}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 re,this._isEnabled=Pe()||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||K.UNKNOWN_ERROR,url:Ue(),deviceInfo:Ce(),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 se{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=$(e?.errorUrl,e?.integrationDomain,Le)}report(e){if(!e)return;const t=e.severity||_.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class oe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._loggingUrl=$(e?.loggingUrl,e?.integrationDomain,be),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 Me(i){const e=C(window.location.href),t=i.EventAttributes?.title||document.title,n=pe(),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=v,this.moduleId=v,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(U(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=C(window.location.href);const n=z(this.loggingService),r=Me(e);n.push(r),he(n)||this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}catch(n){this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${n instanceof Error?n.message:String(n)}`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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(fe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(v,{roktSessionId:e})}catch{}}attachLauncher(e,t,n=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await Ne(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}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,ne(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=A(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=b(o.placementEventMapping);this.placementEventMappingLookup=Z(u);const l=b(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=ee(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:Y,legacyRoktExtensions:L,loadThankYouElement:T}=X(o.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=Oe(f.integrationName),f.integrationName=this.integrationName,this.domain=g;const N={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},S=new se(N,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new oe(N,S,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=S,this.loggingService=O,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:_.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(S),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:B,generateThankYouElementScript:q,extractRoktExtensionConfig:X,hashEventMessage:te,parseSettingsString:b,generateMappedEventLookup:Z,generateMappedEventAttributeLookup:ee,sendAdBlockMeasurementSignals:ne,createAutoRemovedIframe:D,djb2:ie,setAllowedOriginHashes:h=>{p._allowedOriginHashes=h},ReportingTransport:F,ErrorReportingService:se,LoggingService:oe,RateLimiter:re,ErrorCodes:K,WSDKErrorSeverity:_},this.attachLauncher(c,f),"Successfully initialized: "+d):(T&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),Q(Se,q(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,L):(Q(ye,B(g,Y),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,L):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===Ae&&(V(this.loggingService),J())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(this.placementEventMappingLookup))){const t=te(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=A(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,ve))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...A(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=A(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},Y=this.returnUserIdentities(c),L=this.returnLocalSessionAttributes(),T=ge(z(this.loggingService)),f={...Y,...l,...g,...L,...T.length?{[Re]:JSON.stringify(T)}:{},...this.userIdentifiedInWorkspace?{[Ie]:!0}:{},mpid:u},N={...e,attributes:f},S=this.launcher.selectPlacements(N),O=()=>this.logSelectPlacementsEvent(f);return Promise.resolve(S).then(h=>h?.context?.sessionId?.then(Fe=>this.setRoktSessionId(Fe))).catch(()=>{}).finally(O),S}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 y=p;function Ke(){return v}function De(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:y}:(i.kits={},i.kits[d]={constructor:y}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:Ke}),P.register=De,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"}),P})({});
|
|
2
2
|
//# sourceMappingURL=Rokt-Kit.iife.js.map
|