@epigraph/epigraph-std-lib 4.5.3-alpha → 4.5.4-alpha
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/EpigraphLibs/EpigraphAnalytics/analytics-event-interface.d.ts +3 -1
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.cjs +2 -2
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.js +336 -270
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalyticsEventLibrary.d.ts +15 -1
- package/dist/EpigraphLibs/EpigraphAnalytics/plugins/ga4-analytics-plugin.d.ts +41 -5
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@ export interface IAnalyticsEvent {
|
|
|
2
2
|
eventName: string;
|
|
3
3
|
interactiveEvent: boolean;
|
|
4
4
|
customParameters: Record<string, unknown>;
|
|
5
|
-
|
|
5
|
+
getGa4Parameters(solution: string, experienceId: string, sendTo: string): Record<string, unknown>;
|
|
6
|
+
getGTMParameters(solution: string, experienceId: string, sendTo: string): Record<string, unknown>;
|
|
7
|
+
getNexusParameters(): Record<string, unknown>;
|
|
6
8
|
}
|
|
7
9
|
export interface IAnalyticsParameterItem {
|
|
8
10
|
item_id: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var u=(i=>(i.UNAVAILABLE="unavailable",i.AVAILABLE="available",i.RESTRICTED="restricted",i))(u||{});const g=Symbol("data"),d=Symbol("next"),w=class m{constructor(e){this[g]=e,this[d]=null}get data(){return this[g]}set next(e){if(!(e instanceof m)&&e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[d]=e}get next(){return this[d]}};let _=w;const p=Symbol("head");class P{constructor(){this[p]=null}set head(e){this[p]=e}get head(){return this[p]}addToTail(e){let t=this.head;if(t){for(;t.next!==null;)t=t?.next;return t.next=new _(e)}return this.head=new _(e)}removeHead(){const e=this.head;if(e)return this.head=e.next,e.data}}const v=Symbol("queue"),h=Symbol("size");class E{constructor(){this[v]=new P,this[h]=0}get queue(){return this[v]}get size(){return this[h]}enqueue(e){this.queue.addToTail(e),this[h]++}dequeue(){const e=this.queue.removeHead();return this[h]--,e}}class N{constructor({trackingID:e,experienceID:t,solution:n,verboseLogging:s=!1}){this.dataLayerName="dataLayer",this.__status=u.UNAVAILABLE,this.__sentEventCount=0,this.__initializationAttempts=0,this.__lastInitializationAttempt=0,this.__maxInitializationAttempts=10,this.__initializationRetryDelay=2e3,this.__isInitialized=!1,this.__initializationMethod="NONE",this.__nexusFailureReported=!1,this.name=this.pluginName="GA4-PLUGIN",this.trackingID=e,this.experienceID=t,this.solution=n,this.verboseLogging=s,this.__queue=new E,this.initializePlugin()}getStatus(){return this.__status}setStatus(e){this.__status=e}getPendingEventCount(){return this.__queue.size}getSentEventCount(){return this.__sentEventCount}getTotalEventCount(){return this.getPendingEventCount()+this.getSentEventCount()}getUniquePluginIdentifier(){return`${this.name}-${this.trackingID}`}setupPlugin(){this.__isInitialized&&this.dataLayer!==void 0&&this.dequeueAndSendEvents()}async sendEvent(e,t){if(this.__queue.enqueue(e),!t){this.__status=u.RESTRICTED;return}if(!this.__isInitialized){this.logger("Cannot send analytics event: dataLayer not defined or plugin not initialized.");return}try{await this.dequeueAndSendEvents()}catch(n){this.logger(n),await this.reportFailureToNexus("EVENT_SEND_ERROR",n?.toString()||"Unknown error")}}async initializePlugin(){if(this.__isInitialized)return;const e=Date.now();if(this.__initializationAttempts>=this.__maxInitializationAttempts){this.__nexusFailureReported||(await this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS","Maximum initialization attempts reached"),this.__nexusFailureReported=!0);return}if(e-this.__lastInitializationAttempt<this.__initializationRetryDelay)return;this.__lastInitializationAttempt=e,this.__initializationAttempts++;const t=await this.detectAndSetupAnalytics();t.success?(this.__isInitialized=!0,this.__status=u.AVAILABLE,this.__initializationMethod=t.method,this.dataLayerName=t.dataLayerName,this.dataLayer=window[this.dataLayerName],this.logger(`Successfully initialized ${t.method} with dataLayer: ${this.dataLayerName}`),this.__queue.size>0&&await this.dequeueAndSendEvents()):(this.logger(`Initialization attempt ${this.__initializationAttempts} failed: ${t.error}`),this.__initializationAttempts<this.__maxInitializationAttempts&&setTimeout(()=>this.initializePlugin(),this.__initializationRetryDelay))}async detectAndSetupAnalytics(){const e=this.detectGTM();if(e)return this.logger(`GTM detected with container ID: ${e.containerId}`),{success:!0,method:"GTM",dataLayerName:e.dataLayerName};if(window.dataLayer)return this.logger("Existing dataLayer found"),{success:!0,method:"GA4",dataLayerName:"dataLayer"};const t=this.findGA4ScriptInfo(this.trackingID);if(t){const n=t.l||"dataLayer";if(this.logger(`GA4 script found, setting up with dataLayer: ${n}`),this.setupGA4(n))return{success:!0,method:"GA4",dataLayerName:n}}return this.setupGA4("dataLayer")?{success:!0,method:"GA4",dataLayerName:"dataLayer"}:{success:!1,method:"NONE",dataLayerName:"dataLayer",error:"No analytics setup found and unable to create one"}}detectGTM(){const e=document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');for(const t of Array.from(e)){const n=t.getAttribute("src");if(n){const s=n.match(/gtm\.js\?id=([^&]+)/);if(s){const r=n.match(/&l=([^&]+)/),o=r?r[1]:"dataLayer";return{containerId:s[1],dataLayerName:o}}}}return null}setupGA4(e){try{return window[e]||(window[e]=[]),window.epgDataLayerName=e,typeof window.gtag!="function"&&(window.gtag=function(){const t=window.epgDataLayerName;t&&window[t]&&Array.isArray(window[t])&&window[t].push(arguments)},window.gtag("js",new Date),window.gtag("config",this.trackingID,{send_page_view:!1})),!0}catch(t){return this.logger(`Error setting up GA4: ${t}`),!1}}async dequeueAndSendEvents(){if(!this.__isInitialized||!this.dataLayer)return;let e=this.__queue.size;for(let t=0;t<e;t++){const n=this.__queue.dequeue();let s=n.getParameters();if(s.solution=this.solution,s.experience_id=this.experienceID,n.customParameters&&Object.assign(s,n.customParameters),JSON.stringify(s).length>459)try{s={epg_event_tag:await this.sendGA4LongParameters(s)}}catch{}try{this.__initializationMethod==="GTM"?this.sendToGTM(n.eventName,s):this.__initializationMethod==="GA4"&&window.gtag("event",n.eventName,s),this.__sentEventCount++,this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`)}catch(o){this.logger(`Error sending event ${n.eventName}: ${o}`),this.__queue.enqueue(n)}}}logger(e){this.verboseLogging&&console.warn(e)}async sendGA4LongParameters(e){const t="https://api.myepigraph.com/api/analytics/ga4/custom",n={parameters:e};try{const s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return s.ok?(await s.json())?.id??"":""}catch{return""}}sendToGTM(e,t){this.dataLayer&&this.dataLayer.push({event:e,...t})}async reportFailureToNexus(e,t){try{const n={plugin:"GA4",trackingId:this.trackingID,solution:this.solution,experienceId:this.experienceID,failureType:e,errorMessage:t,timestamp:new Date().toISOString(),url:window.location.href,userAgent:navigator.userAgent};this.logger(`Failure reported to Nexus: ${JSON.stringify(n)}`)}catch(n){this.logger(`Error reporting failure to Nexus: ${n}`)}}findGA4ScriptInfo(e){const t=document.querySelectorAll("script[src]");for(const n of t){const s=n.getAttribute("src");if(s&&s.includes(e)){const r=new URL(s,location.href),o=Object.fromEntries(r.searchParams.entries());return{fullSrc:r.href,id:o.id||void 0,l:o.l||void 0}}}return null}}class C{constructor({trackingID:e,experienceID:t,solution:n,sessionId:s,xPath:r,verboseLogging:o=!1,sendToStaging:A=!1}){this.__status=u.UNAVAILABLE,this.__sentEventCount=0,this.sessionId=s,this.xPath=r,this.name=this.pluginName="NEXUS-PLUGIN",this.trackingID=e,this.experienceID=t,this.solution=n,this.verboseLogging=o,this.__queue=new E,this.url=A?"https://nexus.epigraph.dev/api/analytics/event":"https://api.myepigraph.com/api/analytics/event",this.__status=u.AVAILABLE}getStatus(){return this.__status}setStatus(e){this.__status=e}getPendingEventCount(){return this.__queue.size}getSentEventCount(){return this.__sentEventCount}getTotalEventCount(){return this.getPendingEventCount()+this.getSentEventCount()}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){}async sendEvent(e,t){if(this.__queue.enqueue(e),!t){this.__status=u.RESTRICTED;return}await this.dequeueAndSendEvents()}async dequeueAndSendEvents(){for(let e=0;e<this.__queue.size;e++){const t=this.__queue.dequeue();t.customParameters.solution=this.solution;const n={trackingID:this.trackingID,experience_id:this.experienceID,action:t.eventName,parameters:t.getParameters()};try{return(await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","EPG-SESSION-ID":this.sessionId,"EPG-XPATH":this.xPath,Origin:typeof window<"u"?window.location.origin:""},body:JSON.stringify(n)})).status===200,""}catch{return""}this.__sentEventCount++}return""}}class f{constructor(e){this.consentSet=!1,this.consent=!1,this.pluginName="OneTrustConsentPlugin",this.consentIdentifier=e,this.consent=!1,this.addConsentChangedListener()}hasConsent(){if(this.consentSet)return this.consent;if(window.OnetrustActiveGroups!==void 0){let e=window.OnetrustActiveGroups;e!==void 0&&e.split(",").forEach(n=>{n===this.consentIdentifier&&(this.consent=!0,this.consentSet=!0)})}return this.consent}addConsentChangedListener(){window.addEventListener("load",()=>{this.hasConsent(),window.OneTrust!==void 0&&typeof window.OneTrust=="object"&&window.OneTrust.OnConsentChanged(()=>{this.consentSet=!1,this.hasConsent()})})}}var l=(i=>(i.OneTrust="onetrust",i))(l||{});class a{constructor({eventName:e,interactiveEvent:t,customParameters:n}){this.eventName=e,this.interactiveEvent=t,this.customParameters=n}getParameters(){let e={interactive_event:this.interactiveEvent};return e=Object.assign(e,JSON.parse(JSON.stringify(this.customParameters))),e}}class I extends a{constructor(e=[]){super({eventName:"epigraph_ar_requested",interactiveEvent:!0,customParameters:{items:e}})}}class L extends a{constructor(e){super({eventName:"epigraph_module_loading",interactiveEvent:!1,customParameters:{is_pre_config:e}})}}class S extends a{constructor(e,t){super({eventName:"epigraph_module_ready",interactiveEvent:!1,customParameters:{is_pre_config:e,load_time_ms:t}})}}class x extends a{constructor(e,t,n){super({eventName:"epigraph_module_failed",interactiveEvent:!1,customParameters:{is_pre_config:e,load_time_ms:t,error_type:n}})}}class T extends a{constructor(e=[]){super({eventName:"epigraph_module_closed",interactiveEvent:!0,customParameters:{items:e}})}}class q extends a{constructor(e,t={}){super({eventName:"epigraph_support_detected",interactiveEvent:!1,customParameters:{support_type:e,device_capabilities:t}})}}class z extends a{constructor(e,t){super({eventName:"epigraph_button_click",interactiveEvent:!0,customParameters:{button_type:e,button_name:t}})}}class R extends a{constructor(e=[],t,n,s){super({eventName:"epigraph_panel_opened",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:s}})}}class D extends a{constructor(e=[],t,n,s){super({eventName:"epigraph_panel_closed",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:s}})}}class O extends a{constructor(e=[]){super({eventName:"epigraph_add_to_favourites",interactiveEvent:!0,customParameters:{items:e}})}}class b extends a{constructor(e){super({eventName:"epigraph_keyboard_interaction",interactiveEvent:!0,customParameters:{action_performed:e}})}}class G extends a{constructor(e){super({eventName:"epigraph_touch_interaction",interactiveEvent:!0,customParameters:{interaction_type:e}})}}class M extends a{constructor(e=[],t,n,s,r){super({eventName:"epigraph_item_added",interactiveEvent:t,customParameters:{items:e,value:n,currency:s,quantity:r}})}}class $ extends a{constructor(e=[]){super({eventName:"epigraph_item_moved",interactiveEvent:!0,customParameters:{items:e}})}}class k extends a{constructor(e=[],t,n,s){super({eventName:"epigraph_item_removed",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n,quantity:s}})}}class F extends a{constructor(e=[],t){super({eventName:"epigraph_variant_changed",interactiveEvent:!0,customParameters:{items:e,change_type:t}})}}class j extends a{constructor(e=[],t,n){super({eventName:"epigraph_content_shared",interactiveEvent:!0,customParameters:{items:e,content_type:t,share_destination:n}})}}class U extends a{constructor(e=[],t,n){super({eventName:"epigraph_checkout",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n}})}}class B extends a{constructor(e=[],t,n){super({eventName:"epigraph_conversion",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n}})}}class V extends a{constructor(e){super({eventName:"epigraph_changeRate",interactiveEvent:!1,customParameters:{value:e}})}}class J extends a{constructor(e){super({eventName:"epigraph_completionRate",interactiveEvent:!1,customParameters:{value:e}})}}class H extends a{constructor(e){super({eventName:"epigraph_engagementRate",interactiveEvent:!1,customParameters:{value:e}})}}class X extends a{constructor(e,t,n){super({eventName:e,interactiveEvent:t,customParameters:n})}}/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var o=(s=>(s.UNAVAILABLE="unavailable",s.AVAILABLE="available",s.RESTRICTED="restricted",s))(o||{});const g=Symbol("data"),l=Symbol("next"),A=class m{constructor(e){this[g]=e,this[l]=null}get data(){return this[g]}set next(e){if(!(e instanceof m)&&e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[l]=e}get next(){return this[l]}};let v=A;const d=Symbol("head");class N{constructor(){this[d]=null}set head(e){this[d]=e}get head(){return this[d]}addToTail(e){let t=this.head;if(t){for(;t.next!==null;)t=t?.next;return t.next=new v(e)}return this.head=new v(e)}removeHead(){const e=this.head;if(e)return this.head=e.next,e.data}}const _=Symbol("queue"),h=Symbol("size");class E{constructor(){this[_]=new N,this[h]=0}get queue(){return this[_]}get size(){return this[h]}enqueue(e){this.queue.addToTail(e),this[h]++}dequeue(){const e=this.queue.removeHead();return this[h]--,e}}class C{constructor({trackingID:e,experienceID:t,solution:n,verboseLogging:i=!1}){this.__status=o.UNAVAILABLE,this.__sentEventCount=0,this.__initializationAttempts=0,this.__lastInitializationAttempt=performance.now(),this.__maxInitializationAttempts=10,this.__initializationRetryDelay=2e3,this.__isInitialized=!1,this.__initializationMethod="NONE",this.__nexusFailureReported=!1,this.name=this.pluginName="GA4-PLUGIN",this.trackingID=e,this.experienceID=t,this.solution=n,this.verboseLogging=i,this.__queue=new E,this.initializePlugin()}getStatus(){return this.__status}setStatus(e){this.__status=e}getPendingEventCount(){return this.__queue.size}getSentEventCount(){return this.__sentEventCount}getTotalEventCount(){return this.getPendingEventCount()+this.getSentEventCount()}getUniquePluginIdentifier(){return`${this.name}-${this.trackingID}`}setupPlugin(){this.__isInitialized&&this.dataLayer!==void 0&&this.dequeueAndSendEvents()}async sendEvent(e,t){if(this.__queue.enqueue(e),!t){this.__status=o.RESTRICTED;return}if(!this.__isInitialized){this.logger("Cannot send analytics event: dataLayer not defined or plugin not initialized.");return}try{await this.dequeueAndSendEvents()}catch(n){this.logger(n),await this.reportFailureToNexus("EVENT_SEND_ERROR",n?.toString()||"Unknown error")}}initializePlugin(){if(this.__isInitialized)return;if(this.__initializationAttempts>=this.__maxInitializationAttempts){this.__nexusFailureReported||(this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS","Maximum initialization attempts reached"),this.__nexusFailureReported=!0);return}const e=performance.now();if(this.__initializationAttempts>0&&e-this.__lastInitializationAttempt<this.__initializationRetryDelay)return;this.__lastInitializationAttempt=e,this.__initializationAttempts++;const t=this.detectAndSetupAnalytics();t.success?(this.__isInitialized=!0,this.__status=o.AVAILABLE,this.__initializationMethod=t.method,this.dataLayerName=t.dataLayerName,this.dataLayer=window[this.dataLayerName],this.logger(`Successfully initialized ${t.method} with dataLayer: ${this.dataLayerName}`),this.__queue.size>0&&this.dequeueAndSendEvents()):(this.logger(`Initialization attempt ${this.__initializationAttempts} failed: ${t.error}`),this.__initializationAttempts<this.__maxInitializationAttempts&&setTimeout(()=>{this.initializePlugin()},this.__initializationRetryDelay))}detectAndSetupAnalytics(){const e=this.detectGTM();if(e)return this.logger(`GTM detected with container ID: ${e.containerId}`),{success:!0,method:"GTM",dataLayerName:e.dataLayerName};const t=this.findGA4Info(this.trackingID);if(t){const n=t.l||"dataLayer";return this.logger(`GA4 script found, setting up with dataLayer: ${n}`),{success:!0,method:"GA4",dataLayerName:n}}return{success:!1,method:"NONE",dataLayerName:"dataLayer",error:"No analytics setup found and unable to create one"}}detectGTM(){const e=document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');for(const t of Array.from(e)){const n=t.getAttribute("src");if(n){const i=n.match(/gtm\.js\?id=([^&]+)/);if(i&&i.length>0){const r=n.match(/&l=([^&]+)/),u=r?r[1]:"dataLayer";return{containerId:i[1],dataLayerName:u}}}}return null}async dequeueAndSendEvents(){if(!this.__isInitialized||!this.dataLayer)return;let e=this.__queue.size;for(let t=0;t<e;t++){const n=this.__queue.dequeue();try{this.__initializationMethod==="GTM"?(this.sendGTMEvent(n),this.__sentEventCount++,this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`)):this.__initializationMethod==="GA4"?(this.sendGA4Event(n),this.__sentEventCount++,this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`)):this.__queue.enqueue(n)}catch(i){this.logger(`Error sending event ${n.eventName}: ${i}`),this.__queue.enqueue(n)}}}async sendGTMEvent(e){let t=e.getGTMParameters(this.solution,this.experienceID,this.trackingID);this.isValidPayload(t)||(t=await this.convertGTMParametersToEpgEventTag(e.eventName,t)),this.dataLayer&&this.dataLayer.push(t)}async sendGA4Event(e){let t=e.getGa4Parameters(this.solution,this.experienceID,this.trackingID);this.isValidPayload(t)||(t=await this.convertGA4ParametersToEpgEventTag(t)),window.gtag("event",e.eventName,t)}isValidPayload(e){if(Object.keys(e).length>=25)return!1;for(const[i,r]of Object.entries(e))if(i!=="items"&&(i.length>40||String(r).length>100))return!1;return!0}async convertGTMParametersToEpgEventTag(e,t){try{let n=await this.sendGA4LongParameters(t);return{event:e,epg_event_tag:n,send_to:this.trackingID}}catch{return t}}async convertGA4ParametersToEpgEventTag(e){try{return{epg_event_tag:await this.sendGA4LongParameters(e),send_to:this.trackingID}}catch{return e}}logger(e){this.verboseLogging&&console.warn(e)}async sendGA4LongParameters(e){const t="https://api.myepigraph.com/api/analytics/ga4/custom",n={parameters:e};try{const i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return i.ok?(await i.json())?.id??"":""}catch{return""}}async reportFailureToNexus(e,t){try{const n={plugin:"GA4",trackingId:this.trackingID,solution:this.solution,experienceId:this.experienceID,failureType:e,errorMessage:t,timestamp:new Date().toISOString(),url:window.location.href,userAgent:navigator.userAgent};this.logger(`Failure reported to Nexus: ${JSON.stringify(n)}`)}catch(n){this.logger(`Error reporting failure to Nexus: ${n}`)}}findGA4Info(e){if(window.google_tag_manager&&window.google_tag_manager[e]){const n=window.google_tag_manager[e];if(n&&n.dataLayerName)return{fullSrc:"",id:e,l:n.dataLayerName}}const t=document.querySelectorAll("script[src]");for(const n of t){const i=n.getAttribute("src");if(i&&i.includes(e)){const r=new URL(i,location.href),u=Object.fromEntries(r.searchParams.entries());return{fullSrc:r.href,id:u.id||void 0,l:u.l||void 0}}}return null}}class I{constructor({trackingID:e,experienceID:t,solution:n,sessionId:i,xPath:r,verboseLogging:u=!1,sendToStaging:P=!1}){this.__status=o.UNAVAILABLE,this.__sentEventCount=0,this.sessionId=i,this.xPath=r,this.name=this.pluginName="NEXUS-PLUGIN",this.trackingID=e,this.experienceID=t,this.solution=n,this.verboseLogging=u,this.__queue=new E,this.url=P?"https://nexus.epigraph.dev/api/analytics/event":"https://api.myepigraph.com/api/analytics/event",this.__status=o.AVAILABLE}getStatus(){return this.__status}setStatus(e){this.__status=e}getPendingEventCount(){return this.__queue.size}getSentEventCount(){return this.__sentEventCount}getTotalEventCount(){return this.getPendingEventCount()+this.getSentEventCount()}getUniquePluginIdentifier(){return this.name+"-"+this.trackingID}setupPlugin(){}async sendEvent(e,t){if(this.__queue.enqueue(e),!t){this.__status=o.RESTRICTED;return}await this.dequeueAndSendEvents()}async dequeueAndSendEvents(){for(let e=0;e<this.__queue.size;e++){const t=this.__queue.dequeue();t.customParameters.solution=this.solution;const n={trackingID:this.trackingID,experience_id:this.experienceID,action:t.eventName,parameters:t.getNexusParameters()};try{return(await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","EPG-SESSION-ID":this.sessionId,"EPG-XPATH":this.xPath,Origin:typeof window<"u"?window.location.origin:""},body:JSON.stringify(n)})).status===200,""}catch{return""}this.__sentEventCount++}return""}}class f{constructor(e){this.consentSet=!1,this.consent=!1,this.pluginName="OneTrustConsentPlugin",this.consentIdentifier=e,this.consent=!1,this.addConsentChangedListener()}hasConsent(){if(this.consentSet)return this.consent;if(window.OnetrustActiveGroups!==void 0){let e=window.OnetrustActiveGroups;e!==void 0&&e.split(",").forEach(n=>{n===this.consentIdentifier&&(this.consent=!0,this.consentSet=!0)})}return this.consent}addConsentChangedListener(){window.addEventListener("load",()=>{this.hasConsent(),window.OneTrust!==void 0&&typeof window.OneTrust=="object"&&window.OneTrust.OnConsentChanged(()=>{this.consentSet=!1,this.hasConsent()})})}}var p=(s=>(s.OneTrust="onetrust",s))(p||{});class a{constructor({eventName:e,interactiveEvent:t,customParameters:n}){this.eventName=e,this.interactiveEvent=t,this.customParameters=n}getGa4Parameters(e,t,n){let i={solution:e,experience_id:t,interactive_event:this.interactiveEvent,sendTo:n};return i=Object.assign(i,JSON.parse(JSON.stringify(this.customParameters))),i}getGTMParameters(e,t,n){let i={solution:e,experience_id:t,event:this.eventName,interactive_event:this.interactiveEvent,items:[],sendTo:n};return i=Object.assign(i,JSON.parse(JSON.stringify(this.customParameters))),i}getNexusParameters(){let e={interactive_event:this.interactiveEvent};return e=Object.assign(e,JSON.parse(JSON.stringify(this.customParameters))),e}}class S extends a{constructor(e=[]){super({eventName:"epigraph_ar_requested",interactiveEvent:!0,customParameters:{items:e}})}}class w extends a{constructor(e){super({eventName:"epigraph_module_loading",interactiveEvent:!1,customParameters:{is_pre_config:e}})}}class T extends a{constructor(e,t){super({eventName:"epigraph_module_ready",interactiveEvent:!1,customParameters:{is_pre_config:e,load_time_ms:t}})}}class x extends a{constructor(e,t,n){super({eventName:"epigraph_module_failed",interactiveEvent:!1,customParameters:{is_pre_config:e,load_time_ms:t,error_type:n}})}}class L extends a{constructor(e=[]){super({eventName:"epigraph_module_closed",interactiveEvent:!0,customParameters:{items:e}})}}class q extends a{constructor(e,t={}){super({eventName:"epigraph_support_detected",interactiveEvent:!1,customParameters:{support_type:e,device_capabilities:t}})}}class z extends a{constructor(e,t){super({eventName:"epigraph_button_click",interactiveEvent:!0,customParameters:{button_type:e,button_name:t}})}}class O extends a{constructor(e=[],t,n,i){super({eventName:"epigraph_panel_opened",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:i}})}}class G extends a{constructor(e=[],t,n,i){super({eventName:"epigraph_panel_closed",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:i}})}}class M extends a{constructor(e=[]){super({eventName:"epigraph_add_to_favourites",interactiveEvent:!0,customParameters:{items:e}})}}class b extends a{constructor(e){super({eventName:"epigraph_keyboard_interaction",interactiveEvent:!0,customParameters:{action_performed:e}})}}class R extends a{constructor(e){super({eventName:"epigraph_touch_interaction",interactiveEvent:!0,customParameters:{interaction_type:e}})}}class D extends a{constructor(e=[],t,n,i,r){super({eventName:"epigraph_item_added",interactiveEvent:t,customParameters:{items:e,value:n,currency:i,quantity:r}})}}class k extends a{constructor(e=[]){super({eventName:"epigraph_item_moved",interactiveEvent:!0,customParameters:{items:e}})}}class $ extends a{constructor(e=[],t,n,i){super({eventName:"epigraph_item_removed",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n,quantity:i}})}}class j extends a{constructor(e=[],t){super({eventName:"epigraph_variant_changed",interactiveEvent:!0,customParameters:{items:e,change_type:t}})}}class F extends a{constructor(e=[],t,n){super({eventName:"epigraph_content_shared",interactiveEvent:!0,customParameters:{items:e,content_type:t,share_destination:n}})}}class V extends a{constructor(e=[],t,n){super({eventName:"epigraph_checkout",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n}})}}class U extends a{constructor(e=[],t,n){super({eventName:"epigraph_conversion",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n}})}}class B extends a{constructor(e){super({eventName:"epigraph_changeRate",interactiveEvent:!1,customParameters:{value:e}})}}class J extends a{constructor(e){super({eventName:"epigraph_completionRate",interactiveEvent:!1,customParameters:{value:e}})}}class K extends a{constructor(e){super({eventName:"epigraph_engagementRate",interactiveEvent:!1,customParameters:{value:e}})}}class H extends a{constructor(e,t,n){super({eventName:e,interactiveEvent:t,customParameters:n})}}/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
|
|
4
4
|
*
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/var y;const c=Symbol("analyticsPluginsMap");y=c;class
|
|
16
|
+
*/var y;const c=Symbol("analyticsPluginsMap");y=c;class X{constructor(e,t){this[y]=new Map,this.__consentPlugin=null,e&&t&&(this.__consentPlugin=this.buildConsentPlugin(e,t)),window.addEventListener("epigraphAnalyticsConsentChange",this.__onConsentChangeFromEvent)}__onConsentChangeFromEvent(e){let t=e;this.__overrideConsent=t.detail.hasConsent;for(const n of this[c].values())this.__hasConsent()||n.setStatus(o.RESTRICTED)}addEventPlugin(e){this[c].has(e.getUniquePluginIdentifier())||(this[c].set(e.getUniquePluginIdentifier(),e),e.setupPlugin())}__hasConsent(){let e=!0;return this.__overrideConsent!==void 0?(e=this.__overrideConsent,e):(this.__consentPlugin&&(e=this.__consentPlugin.hasConsent()),e)}sendEvent(e){this[c].forEach(t=>{t.sendEvent(e,this.__hasConsent())})}buildConsentPlugin(e,t){return e.toLowerCase()===p.OneTrust.toLowerCase()?new f(t):null}}exports.ConsentPluginNames=p;exports.EpigraphAddToFavouritesEvent=M;exports.EpigraphAnalytics=X;exports.EpigraphArRequestedEvent=S;exports.EpigraphButtonClickEvent=z;exports.EpigraphChangeRateEvent=B;exports.EpigraphCheckoutEvent=V;exports.EpigraphCompletionRateEvent=J;exports.EpigraphContentSharedEvent=F;exports.EpigraphConversionEvent=U;exports.EpigraphCustomEvent=H;exports.EpigraphEngagementRateEvent=K;exports.EpigraphItemAddedEvent=D;exports.EpigraphItemMovedEvent=k;exports.EpigraphItemRemovedEvent=$;exports.EpigraphKeyboardInteractionEvent=b;exports.EpigraphModuleClosedEvent=L;exports.EpigraphModuleFailedEvent=x;exports.EpigraphModuleLoadingEvent=w;exports.EpigraphModuleReadyEvent=T;exports.EpigraphPanelClosedEvent=G;exports.EpigraphPanelOpenedEvent=O;exports.EpigraphSupportDetectedEvent=q;exports.EpigraphTouchInteractionEvent=R;exports.EpigraphVariantChangedEvent=j;exports.GA4AnalyticsPlugin=C;exports.NexusAnalyticsPlugin=I;exports.OneTrustConsentPlugin=f;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
var
|
|
2
|
-
const p = Symbol("data"),
|
|
3
|
-
constructor(
|
|
4
|
-
this[p] =
|
|
1
|
+
var o = /* @__PURE__ */ ((s) => (s.UNAVAILABLE = "unavailable", s.AVAILABLE = "available", s.RESTRICTED = "restricted", s))(o || {});
|
|
2
|
+
const p = Symbol("data"), l = Symbol("next"), N = class v {
|
|
3
|
+
constructor(e) {
|
|
4
|
+
this[p] = e, this[l] = null;
|
|
5
5
|
}
|
|
6
6
|
get data() {
|
|
7
7
|
return this[p];
|
|
8
8
|
}
|
|
9
|
-
set next(
|
|
10
|
-
if (!(
|
|
9
|
+
set next(e) {
|
|
10
|
+
if (!(e instanceof v) && e !== null)
|
|
11
11
|
throw new Error(
|
|
12
12
|
"This node is not an instance of the custom class 'Node'."
|
|
13
13
|
);
|
|
14
|
-
this[
|
|
14
|
+
this[l] = e;
|
|
15
15
|
}
|
|
16
16
|
get next() {
|
|
17
|
-
return this[
|
|
17
|
+
return this[l];
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
let g =
|
|
21
|
-
const
|
|
22
|
-
class
|
|
20
|
+
let g = N;
|
|
21
|
+
const d = Symbol("head");
|
|
22
|
+
class P {
|
|
23
23
|
constructor() {
|
|
24
|
-
this[
|
|
24
|
+
this[d] = null;
|
|
25
25
|
}
|
|
26
|
-
set head(
|
|
27
|
-
this[
|
|
26
|
+
set head(e) {
|
|
27
|
+
this[d] = e;
|
|
28
28
|
}
|
|
29
29
|
get head() {
|
|
30
|
-
return this[
|
|
30
|
+
return this[d];
|
|
31
31
|
}
|
|
32
|
-
addToTail(
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
for (;
|
|
36
|
-
|
|
37
|
-
return
|
|
32
|
+
addToTail(e) {
|
|
33
|
+
let t = this.head;
|
|
34
|
+
if (t) {
|
|
35
|
+
for (; t.next !== null; )
|
|
36
|
+
t = t?.next;
|
|
37
|
+
return t.next = new g(e);
|
|
38
38
|
}
|
|
39
|
-
return this.head = new g(
|
|
39
|
+
return this.head = new g(e);
|
|
40
40
|
}
|
|
41
41
|
removeHead() {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return this.head =
|
|
42
|
+
const e = this.head;
|
|
43
|
+
if (e)
|
|
44
|
+
return this.head = e.next, e.data;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
const _ = Symbol("queue"), h = Symbol("size");
|
|
48
|
-
class
|
|
48
|
+
class m {
|
|
49
49
|
constructor() {
|
|
50
|
-
this[_] = new
|
|
50
|
+
this[_] = new P(), this[h] = 0;
|
|
51
51
|
}
|
|
52
52
|
get queue() {
|
|
53
53
|
return this[_];
|
|
@@ -55,28 +55,28 @@ class v {
|
|
|
55
55
|
get size() {
|
|
56
56
|
return this[h];
|
|
57
57
|
}
|
|
58
|
-
enqueue(
|
|
59
|
-
this.queue.addToTail(
|
|
58
|
+
enqueue(e) {
|
|
59
|
+
this.queue.addToTail(e), this[h]++;
|
|
60
60
|
}
|
|
61
61
|
dequeue() {
|
|
62
|
-
const
|
|
63
|
-
return this[h]--,
|
|
62
|
+
const e = this.queue.removeHead();
|
|
63
|
+
return this[h]--, e;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
class
|
|
66
|
+
class I {
|
|
67
67
|
constructor({
|
|
68
|
-
trackingID:
|
|
69
|
-
experienceID:
|
|
68
|
+
trackingID: e,
|
|
69
|
+
experienceID: t,
|
|
70
70
|
solution: n,
|
|
71
|
-
verboseLogging:
|
|
71
|
+
verboseLogging: i = !1
|
|
72
72
|
}) {
|
|
73
|
-
this.
|
|
73
|
+
this.__status = o.UNAVAILABLE, this.__sentEventCount = 0, this.__initializationAttempts = 0, this.__lastInitializationAttempt = performance.now(), this.__maxInitializationAttempts = 10, this.__initializationRetryDelay = 2e3, this.__isInitialized = !1, this.__initializationMethod = "NONE", this.__nexusFailureReported = !1, this.name = this.pluginName = "GA4-PLUGIN", this.trackingID = e, this.experienceID = t, this.solution = n, this.verboseLogging = i, this.__queue = new m(), this.initializePlugin();
|
|
74
74
|
}
|
|
75
75
|
getStatus() {
|
|
76
76
|
return this.__status;
|
|
77
77
|
}
|
|
78
|
-
setStatus(
|
|
79
|
-
this.__status =
|
|
78
|
+
setStatus(e) {
|
|
79
|
+
this.__status = e;
|
|
80
80
|
}
|
|
81
81
|
getPendingEventCount() {
|
|
82
82
|
return this.__queue.size;
|
|
@@ -99,12 +99,12 @@ class P {
|
|
|
99
99
|
/**
|
|
100
100
|
* This function will send an Event to Google Analytics 4.
|
|
101
101
|
*
|
|
102
|
-
* @param
|
|
102
|
+
* @param analyticsEvent
|
|
103
103
|
* @param consent boolean Whether consent is granted
|
|
104
104
|
*/
|
|
105
|
-
async sendEvent(
|
|
106
|
-
if (this.__queue.enqueue(
|
|
107
|
-
this.__status =
|
|
105
|
+
async sendEvent(e, t) {
|
|
106
|
+
if (this.__queue.enqueue(e), !t) {
|
|
107
|
+
this.__status = o.RESTRICTED;
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
if (!this.__isInitialized) {
|
|
@@ -117,49 +117,40 @@ class P {
|
|
|
117
117
|
this.logger(n), await this.reportFailureToNexus("EVENT_SEND_ERROR", n?.toString() || "Unknown error");
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
initializePlugin() {
|
|
121
121
|
if (this.__isInitialized)
|
|
122
122
|
return;
|
|
123
|
-
const t = Date.now();
|
|
124
123
|
if (this.__initializationAttempts >= this.__maxInitializationAttempts) {
|
|
125
|
-
this.__nexusFailureReported || (
|
|
124
|
+
this.__nexusFailureReported || (this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS", "Maximum initialization attempts reached"), this.__nexusFailureReported = !0);
|
|
126
125
|
return;
|
|
127
126
|
}
|
|
128
|
-
|
|
127
|
+
const e = performance.now();
|
|
128
|
+
if (this.__initializationAttempts > 0 && e - this.__lastInitializationAttempt < this.__initializationRetryDelay)
|
|
129
129
|
return;
|
|
130
|
-
this.__lastInitializationAttempt =
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
this.__lastInitializationAttempt = e, this.__initializationAttempts++;
|
|
131
|
+
const t = this.detectAndSetupAnalytics();
|
|
132
|
+
t.success ? (this.__isInitialized = !0, this.__status = o.AVAILABLE, this.__initializationMethod = t.method, this.dataLayerName = t.dataLayerName, this.dataLayer = window[this.dataLayerName], this.logger(`Successfully initialized ${t.method} with dataLayer: ${this.dataLayerName}`), this.__queue.size > 0 && this.dequeueAndSendEvents()) : (this.logger(`Initialization attempt ${this.__initializationAttempts} failed: ${t.error}`), this.__initializationAttempts < this.__maxInitializationAttempts && setTimeout(() => {
|
|
133
|
+
this.initializePlugin();
|
|
134
|
+
}, this.__initializationRetryDelay));
|
|
135
|
+
}
|
|
136
|
+
detectAndSetupAnalytics() {
|
|
137
|
+
const e = this.detectGTM();
|
|
138
|
+
if (e)
|
|
139
|
+
return this.logger(`GTM detected with container ID: ${e.containerId}`), {
|
|
138
140
|
success: !0,
|
|
139
141
|
method: "GTM",
|
|
140
|
-
dataLayerName:
|
|
142
|
+
dataLayerName: e.dataLayerName
|
|
141
143
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
const t = this.findGA4Info(this.trackingID);
|
|
145
|
+
if (t) {
|
|
146
|
+
const n = t.l || "dataLayer";
|
|
147
|
+
return this.logger(`GA4 script found, setting up with dataLayer: ${n}`), {
|
|
144
148
|
success: !0,
|
|
145
149
|
method: "GA4",
|
|
146
|
-
dataLayerName:
|
|
150
|
+
dataLayerName: n
|
|
147
151
|
};
|
|
148
|
-
const e = this.findGA4ScriptInfo(this.trackingID);
|
|
149
|
-
if (e) {
|
|
150
|
-
const n = e.l || "dataLayer";
|
|
151
|
-
if (this.logger(`GA4 script found, setting up with dataLayer: ${n}`), this.setupGA4(n))
|
|
152
|
-
return {
|
|
153
|
-
success: !0,
|
|
154
|
-
method: "GA4",
|
|
155
|
-
dataLayerName: n
|
|
156
|
-
};
|
|
157
152
|
}
|
|
158
|
-
return
|
|
159
|
-
success: !0,
|
|
160
|
-
method: "GA4",
|
|
161
|
-
dataLayerName: "dataLayer"
|
|
162
|
-
} : {
|
|
153
|
+
return {
|
|
163
154
|
success: !1,
|
|
164
155
|
method: "NONE",
|
|
165
156
|
dataLayerName: "dataLayer",
|
|
@@ -167,32 +158,22 @@ class P {
|
|
|
167
158
|
};
|
|
168
159
|
}
|
|
169
160
|
detectGTM() {
|
|
170
|
-
const
|
|
171
|
-
for (const
|
|
172
|
-
const n =
|
|
161
|
+
const e = document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');
|
|
162
|
+
for (const t of Array.from(e)) {
|
|
163
|
+
const n = t.getAttribute("src");
|
|
173
164
|
if (n) {
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
const r = n.match(/&l=([^&]+)/),
|
|
165
|
+
const i = n.match(/gtm\.js\?id=([^&]+)/);
|
|
166
|
+
if (i && i.length > 0) {
|
|
167
|
+
const r = n.match(/&l=([^&]+)/), u = r ? r[1] : "dataLayer";
|
|
177
168
|
return {
|
|
178
|
-
containerId:
|
|
179
|
-
dataLayerName:
|
|
169
|
+
containerId: i[1],
|
|
170
|
+
dataLayerName: u
|
|
180
171
|
};
|
|
181
172
|
}
|
|
182
173
|
}
|
|
183
174
|
}
|
|
184
175
|
return null;
|
|
185
176
|
}
|
|
186
|
-
setupGA4(t) {
|
|
187
|
-
try {
|
|
188
|
-
return window[t] || (window[t] = []), window.epgDataLayerName = t, typeof window.gtag != "function" && (window.gtag = function() {
|
|
189
|
-
const e = window.epgDataLayerName;
|
|
190
|
-
e && window[e] && Array.isArray(window[e]) && window[e].push(arguments);
|
|
191
|
-
}, window.gtag("js", /* @__PURE__ */ new Date()), window.gtag("config", this.trackingID, { send_page_view: !1 })), !0;
|
|
192
|
-
} catch (e) {
|
|
193
|
-
return this.logger(`Error setting up GA4: ${e}`), !1;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
177
|
/**
|
|
197
178
|
* Send all events that are in the queue
|
|
198
179
|
* @private
|
|
@@ -200,35 +181,97 @@ class P {
|
|
|
200
181
|
async dequeueAndSendEvents() {
|
|
201
182
|
if (!this.__isInitialized || !this.dataLayer)
|
|
202
183
|
return;
|
|
203
|
-
let
|
|
204
|
-
for (let
|
|
184
|
+
let e = this.__queue.size;
|
|
185
|
+
for (let t = 0; t < e; t++) {
|
|
205
186
|
const n = this.__queue.dequeue();
|
|
206
|
-
let s = n.getParameters();
|
|
207
|
-
if (s.solution = this.solution, s.experience_id = this.experienceID, n.customParameters && Object.assign(s, n.customParameters), JSON.stringify(s).length > 459)
|
|
208
|
-
try {
|
|
209
|
-
s = {
|
|
210
|
-
epg_event_tag: await this.sendGA4LongParameters(s)
|
|
211
|
-
};
|
|
212
|
-
} catch {
|
|
213
|
-
}
|
|
214
187
|
try {
|
|
215
|
-
this.__initializationMethod === "GTM" ? this.
|
|
216
|
-
} catch (
|
|
217
|
-
this.logger(`Error sending event ${n.eventName}: ${
|
|
188
|
+
this.__initializationMethod === "GTM" ? (this.sendGTMEvent(n), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`)) : this.__initializationMethod === "GA4" ? (this.sendGA4Event(n), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`)) : this.__queue.enqueue(n);
|
|
189
|
+
} catch (i) {
|
|
190
|
+
this.logger(`Error sending event ${n.eventName}: ${i}`), this.__queue.enqueue(n);
|
|
218
191
|
}
|
|
219
192
|
}
|
|
220
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Send events to GTM based GA4
|
|
196
|
+
* @param event
|
|
197
|
+
* @private
|
|
198
|
+
*/
|
|
199
|
+
async sendGTMEvent(e) {
|
|
200
|
+
let t = e.getGTMParameters(this.solution, this.experienceID, this.trackingID);
|
|
201
|
+
this.isValidPayload(t) || (t = await this.convertGTMParametersToEpgEventTag(e.eventName, t)), this.dataLayer && this.dataLayer.push(t);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Send events to GA4 via Google Analytics 4.
|
|
205
|
+
* @param event
|
|
206
|
+
* @private
|
|
207
|
+
*/
|
|
208
|
+
async sendGA4Event(e) {
|
|
209
|
+
let t = e.getGa4Parameters(this.solution, this.experienceID, this.trackingID);
|
|
210
|
+
this.isValidPayload(t) || (t = await this.convertGA4ParametersToEpgEventTag(t)), window.gtag("event", e.eventName, t);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Validates a payload by checking its parameter count and the constraints of parameter names and values.
|
|
214
|
+
* See docs here for requirements: https://support.google.com/analytics/answer/9267744?hl=en
|
|
215
|
+
*
|
|
216
|
+
* @param {Record<string, unknown>} parameterPayload - An object containing the parameters to validate.
|
|
217
|
+
* The keys represent parameter names and the values represent parameter values.
|
|
218
|
+
* @return {boolean} Returns true if the payload meets the validation criteria; false otherwise.
|
|
219
|
+
*/
|
|
220
|
+
isValidPayload(e) {
|
|
221
|
+
if (Object.keys(e).length >= 25)
|
|
222
|
+
return !1;
|
|
223
|
+
for (const [i, r] of Object.entries(e))
|
|
224
|
+
if (i !== "items" && (i.length > 40 || String(r).length > 100))
|
|
225
|
+
return !1;
|
|
226
|
+
return !0;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Converts the given GTM parameters to an EPG event tag, sending specific parameter payloads
|
|
230
|
+
* for processing and returning the formatted result. Falls back to the original payload in case of errors.
|
|
231
|
+
*
|
|
232
|
+
* @param {string} eventName - The event name associated with the EPG event tag being processed.
|
|
233
|
+
* @param {Record<string, unknown>} parameterPayload - A key-value pair object containing the parameters to be converted.
|
|
234
|
+
* @return {Promise<Record<string, unknown>>} A promise that resolves to an object containing the event name and the generated EPG event tag, or the original payload upon failure.
|
|
235
|
+
*/
|
|
236
|
+
async convertGTMParametersToEpgEventTag(e, t) {
|
|
237
|
+
try {
|
|
238
|
+
let n = await this.sendGA4LongParameters(t);
|
|
239
|
+
return {
|
|
240
|
+
event: e,
|
|
241
|
+
epg_event_tag: n,
|
|
242
|
+
send_to: this.trackingID
|
|
243
|
+
};
|
|
244
|
+
} catch {
|
|
245
|
+
return t;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Converts GA4 parameters into an EPG event tag.
|
|
250
|
+
*
|
|
251
|
+
* @param {Record<string, unknown>} parameterPayload - The GA4 parameters to be converted.
|
|
252
|
+
* @return {Promise<Record<string, any>>} A promise resolving to an object containing the EPG event tag or the original payload if the conversion fails.
|
|
253
|
+
*/
|
|
254
|
+
async convertGA4ParametersToEpgEventTag(e) {
|
|
255
|
+
try {
|
|
256
|
+
return {
|
|
257
|
+
epg_event_tag: await this.sendGA4LongParameters(e),
|
|
258
|
+
send_to: this.trackingID
|
|
259
|
+
};
|
|
260
|
+
} catch {
|
|
261
|
+
return e;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
221
264
|
/**
|
|
222
265
|
* Checks if verboseLogging is enabled, then logs the error
|
|
223
266
|
* @param err
|
|
224
267
|
*/
|
|
225
|
-
logger(
|
|
226
|
-
this.verboseLogging && console.warn(
|
|
268
|
+
logger(e) {
|
|
269
|
+
this.verboseLogging && console.warn(e);
|
|
227
270
|
}
|
|
228
|
-
async sendGA4LongParameters(
|
|
229
|
-
const
|
|
271
|
+
async sendGA4LongParameters(e) {
|
|
272
|
+
const t = "https://api.myepigraph.com/api/analytics/ga4/custom", n = { parameters: e };
|
|
230
273
|
try {
|
|
231
|
-
const
|
|
274
|
+
const i = await fetch(t, {
|
|
232
275
|
method: "POST",
|
|
233
276
|
// Assuming it's a POST request, adjust if necessary
|
|
234
277
|
headers: {
|
|
@@ -237,26 +280,20 @@ class P {
|
|
|
237
280
|
},
|
|
238
281
|
body: JSON.stringify(n)
|
|
239
282
|
});
|
|
240
|
-
return
|
|
283
|
+
return i.ok ? (await i.json())?.id ?? "" : "";
|
|
241
284
|
} catch {
|
|
242
285
|
return "";
|
|
243
286
|
}
|
|
244
287
|
}
|
|
245
|
-
|
|
246
|
-
this.dataLayer && this.dataLayer.push({
|
|
247
|
-
event: t,
|
|
248
|
-
...e
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
async reportFailureToNexus(t, e) {
|
|
288
|
+
async reportFailureToNexus(e, t) {
|
|
252
289
|
try {
|
|
253
290
|
const n = {
|
|
254
291
|
plugin: "GA4",
|
|
255
292
|
trackingId: this.trackingID,
|
|
256
293
|
solution: this.solution,
|
|
257
294
|
experienceId: this.experienceID,
|
|
258
|
-
failureType:
|
|
259
|
-
errorMessage:
|
|
295
|
+
failureType: e,
|
|
296
|
+
errorMessage: t,
|
|
260
297
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
261
298
|
url: window.location.href,
|
|
262
299
|
userAgent: navigator.userAgent
|
|
@@ -266,39 +303,48 @@ class P {
|
|
|
266
303
|
this.logger(`Error reporting failure to Nexus: ${n}`);
|
|
267
304
|
}
|
|
268
305
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
306
|
+
findGA4Info(e) {
|
|
307
|
+
if (window.google_tag_manager && window.google_tag_manager[e]) {
|
|
308
|
+
const n = window.google_tag_manager[e];
|
|
309
|
+
if (n && n.dataLayerName)
|
|
310
|
+
return {
|
|
311
|
+
fullSrc: "",
|
|
312
|
+
id: e,
|
|
313
|
+
l: n.dataLayerName
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const t = document.querySelectorAll("script[src]");
|
|
317
|
+
for (const n of t) {
|
|
318
|
+
const i = n.getAttribute("src");
|
|
319
|
+
if (i && i.includes(e)) {
|
|
320
|
+
const r = new URL(i, location.href), u = Object.fromEntries(r.searchParams.entries());
|
|
275
321
|
return {
|
|
276
322
|
fullSrc: r.href,
|
|
277
|
-
id:
|
|
278
|
-
l:
|
|
323
|
+
id: u.id || void 0,
|
|
324
|
+
l: u.l || void 0
|
|
279
325
|
};
|
|
280
326
|
}
|
|
281
327
|
}
|
|
282
328
|
return null;
|
|
283
329
|
}
|
|
284
330
|
}
|
|
285
|
-
class
|
|
331
|
+
class C {
|
|
286
332
|
constructor({
|
|
287
|
-
trackingID:
|
|
288
|
-
experienceID:
|
|
333
|
+
trackingID: e,
|
|
334
|
+
experienceID: t,
|
|
289
335
|
solution: n,
|
|
290
|
-
sessionId:
|
|
336
|
+
sessionId: i,
|
|
291
337
|
xPath: r,
|
|
292
|
-
verboseLogging:
|
|
338
|
+
verboseLogging: u = !1,
|
|
293
339
|
sendToStaging: y = !1
|
|
294
340
|
}) {
|
|
295
|
-
this.__status =
|
|
341
|
+
this.__status = o.UNAVAILABLE, this.__sentEventCount = 0, this.sessionId = i, this.xPath = r, this.name = this.pluginName = "NEXUS-PLUGIN", this.trackingID = e, this.experienceID = t, this.solution = n, this.verboseLogging = u, this.__queue = new m(), this.url = y ? "https://nexus.epigraph.dev/api/analytics/event" : "https://api.myepigraph.com/api/analytics/event", this.__status = o.AVAILABLE;
|
|
296
342
|
}
|
|
297
343
|
getStatus() {
|
|
298
344
|
return this.__status;
|
|
299
345
|
}
|
|
300
|
-
setStatus(
|
|
301
|
-
this.__status =
|
|
346
|
+
setStatus(e) {
|
|
347
|
+
this.__status = e;
|
|
302
348
|
}
|
|
303
349
|
getPendingEventCount() {
|
|
304
350
|
return this.__queue.size;
|
|
@@ -314,22 +360,22 @@ class I {
|
|
|
314
360
|
}
|
|
315
361
|
setupPlugin() {
|
|
316
362
|
}
|
|
317
|
-
async sendEvent(
|
|
318
|
-
if (this.__queue.enqueue(
|
|
319
|
-
this.__status =
|
|
363
|
+
async sendEvent(e, t) {
|
|
364
|
+
if (this.__queue.enqueue(e), !t) {
|
|
365
|
+
this.__status = o.RESTRICTED;
|
|
320
366
|
return;
|
|
321
367
|
}
|
|
322
368
|
await this.dequeueAndSendEvents();
|
|
323
369
|
}
|
|
324
370
|
async dequeueAndSendEvents() {
|
|
325
|
-
for (let
|
|
326
|
-
const
|
|
327
|
-
|
|
371
|
+
for (let e = 0; e < this.__queue.size; e++) {
|
|
372
|
+
const t = this.__queue.dequeue();
|
|
373
|
+
t.customParameters.solution = this.solution;
|
|
328
374
|
const n = {
|
|
329
375
|
trackingID: this.trackingID,
|
|
330
376
|
experience_id: this.experienceID,
|
|
331
|
-
action:
|
|
332
|
-
parameters:
|
|
377
|
+
action: t.eventName,
|
|
378
|
+
parameters: t.getNexusParameters()
|
|
333
379
|
};
|
|
334
380
|
try {
|
|
335
381
|
return (await fetch(this.url, {
|
|
@@ -352,9 +398,9 @@ class I {
|
|
|
352
398
|
return "";
|
|
353
399
|
}
|
|
354
400
|
}
|
|
355
|
-
class
|
|
356
|
-
constructor(
|
|
357
|
-
this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier =
|
|
401
|
+
class A {
|
|
402
|
+
constructor(e) {
|
|
403
|
+
this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = e, this.consent = !1, this.addConsentChangedListener();
|
|
358
404
|
}
|
|
359
405
|
/**
|
|
360
406
|
* Checks to see if the user has consented. If this is false, it will block all analytics
|
|
@@ -363,8 +409,8 @@ class N {
|
|
|
363
409
|
if (this.consentSet)
|
|
364
410
|
return this.consent;
|
|
365
411
|
if (window.OnetrustActiveGroups !== void 0) {
|
|
366
|
-
let
|
|
367
|
-
|
|
412
|
+
let e = window.OnetrustActiveGroups;
|
|
413
|
+
e !== void 0 && e.split(",").forEach((n) => {
|
|
368
414
|
n === this.consentIdentifier && (this.consent = !0, this.consentSet = !0);
|
|
369
415
|
});
|
|
370
416
|
}
|
|
@@ -378,291 +424,311 @@ class N {
|
|
|
378
424
|
});
|
|
379
425
|
}
|
|
380
426
|
}
|
|
381
|
-
var E = /* @__PURE__ */ ((
|
|
427
|
+
var E = /* @__PURE__ */ ((s) => (s.OneTrust = "onetrust", s))(E || {});
|
|
382
428
|
class a {
|
|
383
429
|
constructor({
|
|
384
|
-
eventName:
|
|
385
|
-
interactiveEvent:
|
|
430
|
+
eventName: e,
|
|
431
|
+
interactiveEvent: t,
|
|
386
432
|
customParameters: n
|
|
387
433
|
}) {
|
|
388
|
-
this.eventName =
|
|
434
|
+
this.eventName = e, this.interactiveEvent = t, this.customParameters = n;
|
|
435
|
+
}
|
|
436
|
+
getGa4Parameters(e, t, n) {
|
|
437
|
+
let i = {
|
|
438
|
+
solution: e,
|
|
439
|
+
experience_id: t,
|
|
440
|
+
interactive_event: this.interactiveEvent,
|
|
441
|
+
sendTo: n
|
|
442
|
+
};
|
|
443
|
+
return i = Object.assign(i, JSON.parse(JSON.stringify(this.customParameters))), i;
|
|
444
|
+
}
|
|
445
|
+
getGTMParameters(e, t, n) {
|
|
446
|
+
let i = {
|
|
447
|
+
solution: e,
|
|
448
|
+
experience_id: t,
|
|
449
|
+
event: this.eventName,
|
|
450
|
+
interactive_event: this.interactiveEvent,
|
|
451
|
+
items: [],
|
|
452
|
+
sendTo: n
|
|
453
|
+
};
|
|
454
|
+
return i = Object.assign(i, JSON.parse(JSON.stringify(this.customParameters))), i;
|
|
389
455
|
}
|
|
390
|
-
|
|
391
|
-
let
|
|
456
|
+
getNexusParameters() {
|
|
457
|
+
let e = {
|
|
392
458
|
interactive_event: this.interactiveEvent
|
|
393
459
|
};
|
|
394
|
-
return
|
|
460
|
+
return e = Object.assign(e, JSON.parse(JSON.stringify(this.customParameters))), e;
|
|
395
461
|
}
|
|
396
462
|
}
|
|
397
|
-
class
|
|
398
|
-
constructor(
|
|
463
|
+
class w extends a {
|
|
464
|
+
constructor(e = []) {
|
|
399
465
|
super({
|
|
400
466
|
eventName: "epigraph_ar_requested",
|
|
401
467
|
interactiveEvent: !0,
|
|
402
468
|
customParameters: {
|
|
403
|
-
items:
|
|
469
|
+
items: e
|
|
404
470
|
}
|
|
405
471
|
});
|
|
406
472
|
}
|
|
407
473
|
}
|
|
408
|
-
class
|
|
409
|
-
constructor(
|
|
474
|
+
class x extends a {
|
|
475
|
+
constructor(e) {
|
|
410
476
|
super({
|
|
411
477
|
eventName: "epigraph_module_loading",
|
|
412
478
|
interactiveEvent: !1,
|
|
413
479
|
customParameters: {
|
|
414
|
-
is_pre_config:
|
|
480
|
+
is_pre_config: e
|
|
415
481
|
}
|
|
416
482
|
});
|
|
417
483
|
}
|
|
418
484
|
}
|
|
419
485
|
class S extends a {
|
|
420
|
-
constructor(
|
|
486
|
+
constructor(e, t) {
|
|
421
487
|
super({
|
|
422
488
|
eventName: "epigraph_module_ready",
|
|
423
489
|
interactiveEvent: !1,
|
|
424
490
|
customParameters: {
|
|
425
|
-
is_pre_config:
|
|
426
|
-
load_time_ms:
|
|
491
|
+
is_pre_config: e,
|
|
492
|
+
load_time_ms: t
|
|
427
493
|
}
|
|
428
494
|
});
|
|
429
495
|
}
|
|
430
496
|
}
|
|
431
|
-
class
|
|
432
|
-
constructor(
|
|
497
|
+
class T extends a {
|
|
498
|
+
constructor(e, t, n) {
|
|
433
499
|
super({
|
|
434
500
|
eventName: "epigraph_module_failed",
|
|
435
501
|
interactiveEvent: !1,
|
|
436
502
|
customParameters: {
|
|
437
|
-
is_pre_config:
|
|
438
|
-
load_time_ms:
|
|
503
|
+
is_pre_config: e,
|
|
504
|
+
load_time_ms: t,
|
|
439
505
|
error_type: n
|
|
440
506
|
}
|
|
441
507
|
});
|
|
442
508
|
}
|
|
443
509
|
}
|
|
444
|
-
class
|
|
445
|
-
constructor(
|
|
510
|
+
class L extends a {
|
|
511
|
+
constructor(e = []) {
|
|
446
512
|
super({
|
|
447
513
|
eventName: "epigraph_module_closed",
|
|
448
514
|
interactiveEvent: !0,
|
|
449
515
|
customParameters: {
|
|
450
|
-
items:
|
|
516
|
+
items: e
|
|
451
517
|
}
|
|
452
518
|
});
|
|
453
519
|
}
|
|
454
520
|
}
|
|
455
521
|
class z extends a {
|
|
456
|
-
constructor(
|
|
522
|
+
constructor(e, t = {}) {
|
|
457
523
|
super({
|
|
458
524
|
eventName: "epigraph_support_detected",
|
|
459
525
|
interactiveEvent: !1,
|
|
460
526
|
customParameters: {
|
|
461
|
-
support_type:
|
|
462
|
-
device_capabilities:
|
|
527
|
+
support_type: e,
|
|
528
|
+
device_capabilities: t
|
|
463
529
|
}
|
|
464
530
|
});
|
|
465
531
|
}
|
|
466
532
|
}
|
|
467
533
|
class q extends a {
|
|
468
|
-
constructor(
|
|
534
|
+
constructor(e, t) {
|
|
469
535
|
super({
|
|
470
536
|
eventName: "epigraph_button_click",
|
|
471
537
|
interactiveEvent: !0,
|
|
472
538
|
customParameters: {
|
|
473
|
-
button_type:
|
|
474
|
-
button_name:
|
|
539
|
+
button_type: e,
|
|
540
|
+
button_name: t
|
|
475
541
|
}
|
|
476
542
|
});
|
|
477
543
|
}
|
|
478
544
|
}
|
|
479
|
-
class
|
|
480
|
-
constructor(
|
|
545
|
+
class O extends a {
|
|
546
|
+
constructor(e = [], t, n, i) {
|
|
481
547
|
super({
|
|
482
548
|
eventName: "epigraph_panel_opened",
|
|
483
|
-
interactiveEvent:
|
|
549
|
+
interactiveEvent: t,
|
|
484
550
|
customParameters: {
|
|
485
|
-
items:
|
|
551
|
+
items: e,
|
|
486
552
|
panel_type: n,
|
|
487
|
-
trigger_source:
|
|
553
|
+
trigger_source: i
|
|
488
554
|
}
|
|
489
555
|
});
|
|
490
556
|
}
|
|
491
557
|
}
|
|
492
558
|
class G extends a {
|
|
493
|
-
constructor(
|
|
559
|
+
constructor(e = [], t, n, i) {
|
|
494
560
|
super({
|
|
495
561
|
eventName: "epigraph_panel_closed",
|
|
496
|
-
interactiveEvent:
|
|
562
|
+
interactiveEvent: t,
|
|
497
563
|
customParameters: {
|
|
498
|
-
items:
|
|
564
|
+
items: e,
|
|
499
565
|
panel_type: n,
|
|
500
|
-
trigger_source:
|
|
566
|
+
trigger_source: i
|
|
501
567
|
}
|
|
502
568
|
});
|
|
503
569
|
}
|
|
504
570
|
}
|
|
505
|
-
class
|
|
506
|
-
constructor(
|
|
571
|
+
class b extends a {
|
|
572
|
+
constructor(e = []) {
|
|
507
573
|
super({
|
|
508
574
|
eventName: "epigraph_add_to_favourites",
|
|
509
575
|
interactiveEvent: !0,
|
|
510
576
|
customParameters: {
|
|
511
|
-
items:
|
|
577
|
+
items: e
|
|
512
578
|
}
|
|
513
579
|
});
|
|
514
580
|
}
|
|
515
581
|
}
|
|
516
|
-
class
|
|
517
|
-
constructor(
|
|
582
|
+
class D extends a {
|
|
583
|
+
constructor(e) {
|
|
518
584
|
super({
|
|
519
585
|
eventName: "epigraph_keyboard_interaction",
|
|
520
586
|
interactiveEvent: !0,
|
|
521
587
|
customParameters: {
|
|
522
|
-
action_performed:
|
|
588
|
+
action_performed: e
|
|
523
589
|
}
|
|
524
590
|
});
|
|
525
591
|
}
|
|
526
592
|
}
|
|
527
|
-
class
|
|
528
|
-
constructor(
|
|
593
|
+
class M extends a {
|
|
594
|
+
constructor(e) {
|
|
529
595
|
super({
|
|
530
596
|
eventName: "epigraph_touch_interaction",
|
|
531
597
|
interactiveEvent: !0,
|
|
532
598
|
customParameters: {
|
|
533
|
-
interaction_type:
|
|
599
|
+
interaction_type: e
|
|
534
600
|
}
|
|
535
601
|
});
|
|
536
602
|
}
|
|
537
603
|
}
|
|
538
|
-
class
|
|
539
|
-
constructor(
|
|
604
|
+
class R extends a {
|
|
605
|
+
constructor(e = [], t, n, i, r) {
|
|
540
606
|
super({
|
|
541
607
|
eventName: "epigraph_item_added",
|
|
542
|
-
interactiveEvent:
|
|
608
|
+
interactiveEvent: t,
|
|
543
609
|
customParameters: {
|
|
544
|
-
items:
|
|
610
|
+
items: e,
|
|
545
611
|
value: n,
|
|
546
|
-
currency:
|
|
612
|
+
currency: i,
|
|
547
613
|
quantity: r
|
|
548
614
|
}
|
|
549
615
|
});
|
|
550
616
|
}
|
|
551
617
|
}
|
|
552
618
|
class $ extends a {
|
|
553
|
-
constructor(
|
|
619
|
+
constructor(e = []) {
|
|
554
620
|
super({
|
|
555
621
|
eventName: "epigraph_item_moved",
|
|
556
622
|
interactiveEvent: !0,
|
|
557
623
|
customParameters: {
|
|
558
|
-
items:
|
|
624
|
+
items: e
|
|
559
625
|
}
|
|
560
626
|
});
|
|
561
627
|
}
|
|
562
628
|
}
|
|
563
629
|
class k extends a {
|
|
564
|
-
constructor(
|
|
630
|
+
constructor(e = [], t, n, i) {
|
|
565
631
|
super({
|
|
566
632
|
eventName: "epigraph_item_removed",
|
|
567
633
|
interactiveEvent: !0,
|
|
568
634
|
customParameters: {
|
|
569
|
-
items:
|
|
570
|
-
value:
|
|
635
|
+
items: e,
|
|
636
|
+
value: t,
|
|
571
637
|
currency: n,
|
|
572
|
-
quantity:
|
|
638
|
+
quantity: i
|
|
573
639
|
}
|
|
574
640
|
});
|
|
575
641
|
}
|
|
576
642
|
}
|
|
577
|
-
class
|
|
578
|
-
constructor(
|
|
643
|
+
class j extends a {
|
|
644
|
+
constructor(e = [], t) {
|
|
579
645
|
super({
|
|
580
646
|
eventName: "epigraph_variant_changed",
|
|
581
647
|
interactiveEvent: !0,
|
|
582
648
|
customParameters: {
|
|
583
|
-
items:
|
|
584
|
-
change_type:
|
|
649
|
+
items: e,
|
|
650
|
+
change_type: t
|
|
585
651
|
}
|
|
586
652
|
});
|
|
587
653
|
}
|
|
588
654
|
}
|
|
589
|
-
class
|
|
590
|
-
constructor(
|
|
655
|
+
class U extends a {
|
|
656
|
+
constructor(e = [], t, n) {
|
|
591
657
|
super({
|
|
592
658
|
eventName: "epigraph_content_shared",
|
|
593
659
|
interactiveEvent: !0,
|
|
594
660
|
customParameters: {
|
|
595
|
-
items:
|
|
596
|
-
content_type:
|
|
661
|
+
items: e,
|
|
662
|
+
content_type: t,
|
|
597
663
|
share_destination: n
|
|
598
664
|
}
|
|
599
665
|
});
|
|
600
666
|
}
|
|
601
667
|
}
|
|
602
|
-
class
|
|
603
|
-
constructor(
|
|
668
|
+
class V extends a {
|
|
669
|
+
constructor(e = [], t, n) {
|
|
604
670
|
super({
|
|
605
671
|
eventName: "epigraph_checkout",
|
|
606
672
|
interactiveEvent: !0,
|
|
607
673
|
customParameters: {
|
|
608
|
-
items:
|
|
609
|
-
value:
|
|
674
|
+
items: e,
|
|
675
|
+
value: t,
|
|
610
676
|
currency: n
|
|
611
677
|
}
|
|
612
678
|
});
|
|
613
679
|
}
|
|
614
680
|
}
|
|
615
|
-
class
|
|
616
|
-
constructor(
|
|
681
|
+
class F extends a {
|
|
682
|
+
constructor(e = [], t, n) {
|
|
617
683
|
super({
|
|
618
684
|
eventName: "epigraph_conversion",
|
|
619
685
|
interactiveEvent: !0,
|
|
620
686
|
customParameters: {
|
|
621
|
-
items:
|
|
622
|
-
value:
|
|
687
|
+
items: e,
|
|
688
|
+
value: t,
|
|
623
689
|
currency: n
|
|
624
690
|
}
|
|
625
691
|
});
|
|
626
692
|
}
|
|
627
693
|
}
|
|
628
|
-
class
|
|
629
|
-
constructor(
|
|
694
|
+
class B extends a {
|
|
695
|
+
constructor(e) {
|
|
630
696
|
super({
|
|
631
697
|
eventName: "epigraph_changeRate",
|
|
632
698
|
interactiveEvent: !1,
|
|
633
699
|
customParameters: {
|
|
634
|
-
value:
|
|
700
|
+
value: e
|
|
635
701
|
}
|
|
636
702
|
});
|
|
637
703
|
}
|
|
638
704
|
}
|
|
639
705
|
class J extends a {
|
|
640
|
-
constructor(
|
|
706
|
+
constructor(e) {
|
|
641
707
|
super({
|
|
642
708
|
eventName: "epigraph_completionRate",
|
|
643
709
|
interactiveEvent: !1,
|
|
644
710
|
customParameters: {
|
|
645
|
-
value:
|
|
711
|
+
value: e
|
|
646
712
|
}
|
|
647
713
|
});
|
|
648
714
|
}
|
|
649
715
|
}
|
|
650
716
|
class H extends a {
|
|
651
|
-
constructor(
|
|
717
|
+
constructor(e) {
|
|
652
718
|
super({
|
|
653
719
|
eventName: "epigraph_engagementRate",
|
|
654
720
|
interactiveEvent: !1,
|
|
655
721
|
customParameters: {
|
|
656
|
-
value:
|
|
722
|
+
value: e
|
|
657
723
|
}
|
|
658
724
|
});
|
|
659
725
|
}
|
|
660
726
|
}
|
|
661
|
-
class
|
|
662
|
-
constructor(
|
|
727
|
+
class K extends a {
|
|
728
|
+
constructor(e, t, n) {
|
|
663
729
|
super({
|
|
664
|
-
eventName:
|
|
665
|
-
interactiveEvent:
|
|
730
|
+
eventName: e,
|
|
731
|
+
interactiveEvent: t,
|
|
666
732
|
customParameters: n
|
|
667
733
|
});
|
|
668
734
|
}
|
|
@@ -686,15 +752,15 @@ class X extends a {
|
|
|
686
752
|
var f;
|
|
687
753
|
const c = Symbol("analyticsPluginsMap");
|
|
688
754
|
f = c;
|
|
689
|
-
class
|
|
690
|
-
constructor(
|
|
691
|
-
this[f] = /* @__PURE__ */ new Map(), this.__consentPlugin = null,
|
|
755
|
+
class X {
|
|
756
|
+
constructor(e, t) {
|
|
757
|
+
this[f] = /* @__PURE__ */ new Map(), this.__consentPlugin = null, e && t && (this.__consentPlugin = this.buildConsentPlugin(e, t)), window.addEventListener("epigraphAnalyticsConsentChange", this.__onConsentChangeFromEvent);
|
|
692
758
|
}
|
|
693
|
-
__onConsentChangeFromEvent(
|
|
694
|
-
let
|
|
695
|
-
this.__overrideConsent =
|
|
759
|
+
__onConsentChangeFromEvent(e) {
|
|
760
|
+
let t = e;
|
|
761
|
+
this.__overrideConsent = t.detail.hasConsent;
|
|
696
762
|
for (const n of this[c].values())
|
|
697
|
-
this.__hasConsent() || n.setStatus(
|
|
763
|
+
this.__hasConsent() || n.setStatus(o.RESTRICTED);
|
|
698
764
|
}
|
|
699
765
|
/**
|
|
700
766
|
* Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
|
|
@@ -703,11 +769,11 @@ class K {
|
|
|
703
769
|
*
|
|
704
770
|
* @param plugin
|
|
705
771
|
*/
|
|
706
|
-
addEventPlugin(
|
|
707
|
-
this[c].has(
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
),
|
|
772
|
+
addEventPlugin(e) {
|
|
773
|
+
this[c].has(e.getUniquePluginIdentifier()) || (this[c].set(
|
|
774
|
+
e.getUniquePluginIdentifier(),
|
|
775
|
+
e
|
|
776
|
+
), e.setupPlugin());
|
|
711
777
|
}
|
|
712
778
|
/**
|
|
713
779
|
* Resolves session consent by prioritizing this._overrideConsent and if not found,
|
|
@@ -716,17 +782,17 @@ class K {
|
|
|
716
782
|
* @returns {boolean} Whether the session has consent to track analytics or not.
|
|
717
783
|
*/
|
|
718
784
|
__hasConsent() {
|
|
719
|
-
let
|
|
720
|
-
return this.__overrideConsent !== void 0 ? (
|
|
785
|
+
let e = !0;
|
|
786
|
+
return this.__overrideConsent !== void 0 ? (e = this.__overrideConsent, e) : (this.__consentPlugin && (e = this.__consentPlugin.hasConsent()), e);
|
|
721
787
|
}
|
|
722
788
|
/**
|
|
723
789
|
* Send an Event to all plugins
|
|
724
790
|
*
|
|
725
791
|
* @param eventData
|
|
726
792
|
*/
|
|
727
|
-
sendEvent(
|
|
728
|
-
this[c].forEach((
|
|
729
|
-
|
|
793
|
+
sendEvent(e) {
|
|
794
|
+
this[c].forEach((t) => {
|
|
795
|
+
t.sendEvent(e, this.__hasConsent());
|
|
730
796
|
});
|
|
731
797
|
}
|
|
732
798
|
/**
|
|
@@ -735,37 +801,37 @@ class K {
|
|
|
735
801
|
* @param consentIdentifier
|
|
736
802
|
* @private
|
|
737
803
|
*/
|
|
738
|
-
buildConsentPlugin(
|
|
739
|
-
return
|
|
804
|
+
buildConsentPlugin(e, t) {
|
|
805
|
+
return e.toLowerCase() === E.OneTrust.toLowerCase() ? new A(t) : null;
|
|
740
806
|
}
|
|
741
807
|
}
|
|
742
808
|
export {
|
|
743
809
|
E as ConsentPluginNames,
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
810
|
+
b as EpigraphAddToFavouritesEvent,
|
|
811
|
+
X as EpigraphAnalytics,
|
|
812
|
+
w as EpigraphArRequestedEvent,
|
|
747
813
|
q as EpigraphButtonClickEvent,
|
|
748
|
-
|
|
749
|
-
|
|
814
|
+
B as EpigraphChangeRateEvent,
|
|
815
|
+
V as EpigraphCheckoutEvent,
|
|
750
816
|
J as EpigraphCompletionRateEvent,
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
817
|
+
U as EpigraphContentSharedEvent,
|
|
818
|
+
F as EpigraphConversionEvent,
|
|
819
|
+
K as EpigraphCustomEvent,
|
|
754
820
|
H as EpigraphEngagementRateEvent,
|
|
755
|
-
|
|
821
|
+
R as EpigraphItemAddedEvent,
|
|
756
822
|
$ as EpigraphItemMovedEvent,
|
|
757
823
|
k as EpigraphItemRemovedEvent,
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
824
|
+
D as EpigraphKeyboardInteractionEvent,
|
|
825
|
+
L as EpigraphModuleClosedEvent,
|
|
826
|
+
T as EpigraphModuleFailedEvent,
|
|
827
|
+
x as EpigraphModuleLoadingEvent,
|
|
762
828
|
S as EpigraphModuleReadyEvent,
|
|
763
829
|
G as EpigraphPanelClosedEvent,
|
|
764
|
-
|
|
830
|
+
O as EpigraphPanelOpenedEvent,
|
|
765
831
|
z as EpigraphSupportDetectedEvent,
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
832
|
+
M as EpigraphTouchInteractionEvent,
|
|
833
|
+
j as EpigraphVariantChangedEvent,
|
|
834
|
+
I as GA4AnalyticsPlugin,
|
|
835
|
+
C as NexusAnalyticsPlugin,
|
|
836
|
+
A as OneTrustConsentPlugin
|
|
771
837
|
};
|
|
@@ -8,7 +8,21 @@ declare class BaseAnalyticsEvent implements IAnalyticsEvent {
|
|
|
8
8
|
interactiveEvent: boolean;
|
|
9
9
|
customParameters: Record<string, unknown>;
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
getGa4Parameters(solution: string, experienceId: string, sendTo: string): {
|
|
12
|
+
solution: string;
|
|
13
|
+
experience_id: string;
|
|
14
|
+
interactive_event: boolean;
|
|
15
|
+
sendTo: string;
|
|
16
|
+
};
|
|
17
|
+
getGTMParameters(solution: string, experienceId: string, sendTo: string): {
|
|
18
|
+
solution: string;
|
|
19
|
+
experience_id: string;
|
|
20
|
+
event: string;
|
|
21
|
+
interactive_event: boolean;
|
|
22
|
+
items: never[];
|
|
23
|
+
sendTo: string;
|
|
24
|
+
};
|
|
25
|
+
getNexusParameters(): {
|
|
12
26
|
interactive_event: boolean;
|
|
13
27
|
};
|
|
14
28
|
}
|
|
@@ -6,6 +6,7 @@ declare global {
|
|
|
6
6
|
gtag?: (...args: any[]) => void;
|
|
7
7
|
dataLayer?: Array<Record<string, any>>;
|
|
8
8
|
epgDataLayerName?: string;
|
|
9
|
+
google_tag_manager: Record<string, any>;
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
export declare class GA4AnalyticsPlugin implements IAnalyticsPlugin {
|
|
@@ -16,7 +17,7 @@ export declare class GA4AnalyticsPlugin implements IAnalyticsPlugin {
|
|
|
16
17
|
experienceID: string;
|
|
17
18
|
verboseLogging: boolean;
|
|
18
19
|
dataLayer: Array<Record<string, any>> | undefined;
|
|
19
|
-
dataLayerName: string;
|
|
20
|
+
dataLayerName: string | undefined;
|
|
20
21
|
private __queue;
|
|
21
22
|
private __status;
|
|
22
23
|
private __sentEventCount;
|
|
@@ -46,26 +47,61 @@ export declare class GA4AnalyticsPlugin implements IAnalyticsPlugin {
|
|
|
46
47
|
/**
|
|
47
48
|
* This function will send an Event to Google Analytics 4.
|
|
48
49
|
*
|
|
49
|
-
* @param
|
|
50
|
+
* @param analyticsEvent
|
|
50
51
|
* @param consent boolean Whether consent is granted
|
|
51
52
|
*/
|
|
52
53
|
sendEvent(analyticsEvent: IAnalyticsEvent, consent: boolean): Promise<void>;
|
|
53
54
|
private initializePlugin;
|
|
54
55
|
private detectAndSetupAnalytics;
|
|
55
56
|
private detectGTM;
|
|
56
|
-
private setupGA4;
|
|
57
57
|
/**
|
|
58
58
|
* Send all events that are in the queue
|
|
59
59
|
* @private
|
|
60
60
|
*/
|
|
61
61
|
private dequeueAndSendEvents;
|
|
62
|
+
/**
|
|
63
|
+
* Send events to GTM based GA4
|
|
64
|
+
* @param event
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
private sendGTMEvent;
|
|
68
|
+
/**
|
|
69
|
+
* Send events to GA4 via Google Analytics 4.
|
|
70
|
+
* @param event
|
|
71
|
+
* @private
|
|
72
|
+
*/
|
|
73
|
+
private sendGA4Event;
|
|
74
|
+
/**
|
|
75
|
+
* Validates a payload by checking its parameter count and the constraints of parameter names and values.
|
|
76
|
+
* See docs here for requirements: https://support.google.com/analytics/answer/9267744?hl=en
|
|
77
|
+
*
|
|
78
|
+
* @param {Record<string, unknown>} parameterPayload - An object containing the parameters to validate.
|
|
79
|
+
* The keys represent parameter names and the values represent parameter values.
|
|
80
|
+
* @return {boolean} Returns true if the payload meets the validation criteria; false otherwise.
|
|
81
|
+
*/
|
|
82
|
+
private isValidPayload;
|
|
83
|
+
/**
|
|
84
|
+
* Converts the given GTM parameters to an EPG event tag, sending specific parameter payloads
|
|
85
|
+
* for processing and returning the formatted result. Falls back to the original payload in case of errors.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} eventName - The event name associated with the EPG event tag being processed.
|
|
88
|
+
* @param {Record<string, unknown>} parameterPayload - A key-value pair object containing the parameters to be converted.
|
|
89
|
+
* @return {Promise<Record<string, unknown>>} A promise that resolves to an object containing the event name and the generated EPG event tag, or the original payload upon failure.
|
|
90
|
+
*/
|
|
91
|
+
private convertGTMParametersToEpgEventTag;
|
|
92
|
+
/**
|
|
93
|
+
* Converts GA4 parameters into an EPG event tag.
|
|
94
|
+
*
|
|
95
|
+
* @param {Record<string, unknown>} parameterPayload - The GA4 parameters to be converted.
|
|
96
|
+
* @return {Promise<Record<string, any>>} A promise resolving to an object containing the EPG event tag or the original payload if the conversion fails.
|
|
97
|
+
*/
|
|
98
|
+
private convertGA4ParametersToEpgEventTag;
|
|
62
99
|
/**
|
|
63
100
|
* Checks if verboseLogging is enabled, then logs the error
|
|
64
101
|
* @param err
|
|
65
102
|
*/
|
|
66
103
|
private logger;
|
|
67
104
|
private sendGA4LongParameters;
|
|
68
|
-
private sendToGTM;
|
|
69
105
|
private reportFailureToNexus;
|
|
70
|
-
private
|
|
106
|
+
private findGA4Info;
|
|
71
107
|
}
|