@epigraph/epigraph-std-lib 4.5.2-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 +4 -2
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.cjs +2 -2
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.js +209 -164
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalyticsEventLibrary.d.ts +21 -16
- package/dist/EpigraphLibs/EpigraphAnalytics/plugins/ga4-analytics-plugin.d.ts +41 -5
- package/package.json +1 -1
|
@@ -2,12 +2,14 @@ export interface IAnalyticsEvent {
|
|
|
2
2
|
eventName: string;
|
|
3
3
|
interactiveEvent: boolean;
|
|
4
4
|
customParameters: Record<string, unknown>;
|
|
5
|
-
getGa4Parameters(solution: string, experienceId: string): Record<string, unknown>;
|
|
6
|
-
getGTMParameters(): Record<string, unknown>;
|
|
5
|
+
getGa4Parameters(solution: string, experienceId: string, sendTo: string): Record<string, unknown>;
|
|
6
|
+
getGTMParameters(solution: string, experienceId: string, sendTo: string): Record<string, unknown>;
|
|
7
7
|
getNexusParameters(): Record<string, unknown>;
|
|
8
8
|
}
|
|
9
9
|
export interface IAnalyticsParameterItem {
|
|
10
10
|
item_id: string;
|
|
11
11
|
item_name: string;
|
|
12
|
+
price: number;
|
|
13
|
+
quantity: number;
|
|
12
14
|
}
|
|
13
15
|
export type IAnalyticsParameterItems = Array<IAnalyticsParameterItem>;
|
|
@@ -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 v=w;const p=Symbol("head");class N{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 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 P{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(),s=n.getGa4Parameters(this.solution,this.experienceID);if(n.customParameters&&Object.assign(s,n.customParameters),JSON.stringify(s).length>459)try{let o=await this.sendGA4LongParameters(s);s.epg_event_tag=o}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.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 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}getGa4Parameters(e,t){let n={solution:e,experience_id:t,interactive_event:this.interactiveEvent,items:[],epg_event_tag:""};return n=Object.assign(n,JSON.parse(JSON.stringify(this.customParameters))),n}getGTMParameters(){return{}}getNexusParameters(){let e={interactive_event:this.interactiveEvent,items:[]};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 S extends a{constructor(e=[],t){super({eventName:"epigraph_module_loading",interactiveEvent:!1,customParameters:{items:e,is_pre_config:t}})}}class L extends a{constructor(e=[],t,n){super({eventName:"epigraph_module_ready",interactiveEvent:!1,customParameters:{items:e,is_pre_config:t,load_time_ms:n}})}}class x extends a{constructor(e=[],t,n,s){super({eventName:"epigraph_module_failed",interactiveEvent:!1,customParameters:{items:e,is_pre_config:t,load_time_ms:n,error_type:s}})}}class T extends a{constructor(e=[]){super({eventName:"epigraph_module_closed",interactiveEvent:!0,customParameters:{items:e}})}}class q extends a{constructor(e=[],t,n={}){super({eventName:"epigraph_support_detected",interactiveEvent:!1,customParameters:{items:e,support_type:t,device_capabilities:n}})}}class z extends a{constructor(e=[],t,n){super({eventName:"epigraph_button_click",interactiveEvent:!0,customParameters:{items:e,button_type:t,button_name:n}})}}class O extends a{constructor(e=[],t,n,s){super({eventName:"epigraph_panel_opened",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:s}})}}class G extends a{constructor(e=[],t,n,s){super({eventName:"epigraph_panel_closed",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:s}})}}class R extends a{constructor(e=[]){super({eventName:"epigraph_add_to_favourites",interactiveEvent:!0,customParameters:{items:e}})}}class b extends a{constructor(e=[],t){super({eventName:"epigraph_keyboard_interaction",interactiveEvent:!0,customParameters:{items:e,action_performed:t}})}}class D extends a{constructor(e=[],t){super({eventName:"epigraph_touch_interaction",interactiveEvent:!0,customParameters:{items:e,interaction_type:t}})}}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){super({eventName:"epigraph_item_removed",interactiveEvent:!0,customParameters:{items:e,currency:t,quantity:n}})}}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 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=[],t){super({eventName:"epigraph_changeRate",interactiveEvent:!1,customParameters:{items:e,value:t}})}}class J extends a{constructor(e=[],t){super({eventName:"epigraph_completionRate",interactiveEvent:!1,customParameters:{items:e,value:t}})}}class H extends a{constructor(e=[],t){super({eventName:"epigraph_engagementRate",interactiveEvent:!1,customParameters:{items:e,value:t}})}}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,33 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
const p = Symbol("data"),
|
|
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
3
|
constructor(e) {
|
|
4
|
-
this[p] = e, this[
|
|
4
|
+
this[p] = e, this[l] = null;
|
|
5
5
|
}
|
|
6
6
|
get data() {
|
|
7
7
|
return this[p];
|
|
8
8
|
}
|
|
9
9
|
set next(e) {
|
|
10
|
-
if (!(e instanceof
|
|
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
26
|
set head(e) {
|
|
27
|
-
this[
|
|
27
|
+
this[d] = e;
|
|
28
28
|
}
|
|
29
29
|
get head() {
|
|
30
|
-
return this[
|
|
30
|
+
return this[d];
|
|
31
31
|
}
|
|
32
32
|
addToTail(e) {
|
|
33
33
|
let t = this.head;
|
|
@@ -45,9 +45,9 @@ class A {
|
|
|
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[_];
|
|
@@ -63,14 +63,14 @@ class v {
|
|
|
63
63
|
return this[h]--, e;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
class
|
|
66
|
+
class I {
|
|
67
67
|
constructor({
|
|
68
68
|
trackingID: e,
|
|
69
69
|
experienceID: t,
|
|
70
70
|
solution: n,
|
|
71
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;
|
|
@@ -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
105
|
async sendEvent(e, t) {
|
|
106
106
|
if (this.__queue.enqueue(e), !t) {
|
|
107
|
-
this.__status =
|
|
107
|
+
this.__status = o.RESTRICTED;
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
if (!this.__isInitialized) {
|
|
@@ -117,21 +117,23 @@ 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 e = 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
130
|
this.__lastInitializationAttempt = e, this.__initializationAttempts++;
|
|
131
|
-
const t =
|
|
132
|
-
t.success ? (this.__isInitialized = !0, this.__status =
|
|
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));
|
|
133
135
|
}
|
|
134
|
-
|
|
136
|
+
detectAndSetupAnalytics() {
|
|
135
137
|
const e = this.detectGTM();
|
|
136
138
|
if (e)
|
|
137
139
|
return this.logger(`GTM detected with container ID: ${e.containerId}`), {
|
|
@@ -139,27 +141,16 @@ class P {
|
|
|
139
141
|
method: "GTM",
|
|
140
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 t = this.findGA4ScriptInfo(this.trackingID);
|
|
149
|
-
if (t) {
|
|
150
|
-
const n = t.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",
|
|
@@ -172,27 +163,17 @@ class P {
|
|
|
172
163
|
const n = t.getAttribute("src");
|
|
173
164
|
if (n) {
|
|
174
165
|
const i = n.match(/gtm\.js\?id=([^&]+)/);
|
|
175
|
-
if (i) {
|
|
176
|
-
const r = n.match(/&l=([^&]+)/),
|
|
166
|
+
if (i && i.length > 0) {
|
|
167
|
+
const r = n.match(/&l=([^&]+)/), u = r ? r[1] : "dataLayer";
|
|
177
168
|
return {
|
|
178
169
|
containerId: i[1],
|
|
179
|
-
dataLayerName:
|
|
170
|
+
dataLayerName: u
|
|
180
171
|
};
|
|
181
172
|
}
|
|
182
173
|
}
|
|
183
174
|
}
|
|
184
175
|
return null;
|
|
185
176
|
}
|
|
186
|
-
setupGA4(e) {
|
|
187
|
-
try {
|
|
188
|
-
return window[e] || (window[e] = []), window.epgDataLayerName = e, typeof window.gtag != "function" && (window.gtag = function() {
|
|
189
|
-
const t = window.epgDataLayerName;
|
|
190
|
-
t && window[t] && Array.isArray(window[t]) && window[t].push(arguments);
|
|
191
|
-
}, window.gtag("js", /* @__PURE__ */ new Date()), window.gtag("config", this.trackingID, { send_page_view: !1 })), !0;
|
|
192
|
-
} catch (t) {
|
|
193
|
-
return this.logger(`Error setting up GA4: ${t}`), !1;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
177
|
/**
|
|
197
178
|
* Send all events that are in the queue
|
|
198
179
|
* @private
|
|
@@ -202,20 +183,84 @@ class P {
|
|
|
202
183
|
return;
|
|
203
184
|
let e = this.__queue.size;
|
|
204
185
|
for (let t = 0; t < e; t++) {
|
|
205
|
-
const n = this.__queue.dequeue()
|
|
206
|
-
if (n.customParameters && Object.assign(i, n.customParameters), JSON.stringify(i).length > 459)
|
|
207
|
-
try {
|
|
208
|
-
let o = await this.sendGA4LongParameters(i);
|
|
209
|
-
i.epg_event_tag = o;
|
|
210
|
-
} catch {
|
|
211
|
-
}
|
|
186
|
+
const n = this.__queue.dequeue();
|
|
212
187
|
try {
|
|
213
|
-
this.__initializationMethod === "GTM" ? this.
|
|
214
|
-
} catch (
|
|
215
|
-
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);
|
|
216
191
|
}
|
|
217
192
|
}
|
|
218
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
|
+
}
|
|
219
264
|
/**
|
|
220
265
|
* Checks if verboseLogging is enabled, then logs the error
|
|
221
266
|
* @param err
|
|
@@ -240,12 +285,6 @@ class P {
|
|
|
240
285
|
return "";
|
|
241
286
|
}
|
|
242
287
|
}
|
|
243
|
-
sendToGTM(e, t) {
|
|
244
|
-
this.dataLayer && this.dataLayer.push({
|
|
245
|
-
event: e,
|
|
246
|
-
...t
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
288
|
async reportFailureToNexus(e, t) {
|
|
250
289
|
try {
|
|
251
290
|
const n = {
|
|
@@ -264,33 +303,42 @@ class P {
|
|
|
264
303
|
this.logger(`Error reporting failure to Nexus: ${n}`);
|
|
265
304
|
}
|
|
266
305
|
}
|
|
267
|
-
|
|
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
|
+
}
|
|
268
316
|
const t = document.querySelectorAll("script[src]");
|
|
269
317
|
for (const n of t) {
|
|
270
318
|
const i = n.getAttribute("src");
|
|
271
319
|
if (i && i.includes(e)) {
|
|
272
|
-
const r = new URL(i, location.href),
|
|
320
|
+
const r = new URL(i, location.href), u = Object.fromEntries(r.searchParams.entries());
|
|
273
321
|
return {
|
|
274
322
|
fullSrc: r.href,
|
|
275
|
-
id:
|
|
276
|
-
l:
|
|
323
|
+
id: u.id || void 0,
|
|
324
|
+
l: u.l || void 0
|
|
277
325
|
};
|
|
278
326
|
}
|
|
279
327
|
}
|
|
280
328
|
return null;
|
|
281
329
|
}
|
|
282
330
|
}
|
|
283
|
-
class
|
|
331
|
+
class C {
|
|
284
332
|
constructor({
|
|
285
333
|
trackingID: e,
|
|
286
334
|
experienceID: t,
|
|
287
335
|
solution: n,
|
|
288
336
|
sessionId: i,
|
|
289
337
|
xPath: r,
|
|
290
|
-
verboseLogging:
|
|
338
|
+
verboseLogging: u = !1,
|
|
291
339
|
sendToStaging: y = !1
|
|
292
340
|
}) {
|
|
293
|
-
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;
|
|
294
342
|
}
|
|
295
343
|
getStatus() {
|
|
296
344
|
return this.__status;
|
|
@@ -314,7 +362,7 @@ class I {
|
|
|
314
362
|
}
|
|
315
363
|
async sendEvent(e, t) {
|
|
316
364
|
if (this.__queue.enqueue(e), !t) {
|
|
317
|
-
this.__status =
|
|
365
|
+
this.__status = o.RESTRICTED;
|
|
318
366
|
return;
|
|
319
367
|
}
|
|
320
368
|
await this.dequeueAndSendEvents();
|
|
@@ -350,7 +398,7 @@ class I {
|
|
|
350
398
|
return "";
|
|
351
399
|
}
|
|
352
400
|
}
|
|
353
|
-
class
|
|
401
|
+
class A {
|
|
354
402
|
constructor(e) {
|
|
355
403
|
this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = e, this.consent = !1, this.addConsentChangedListener();
|
|
356
404
|
}
|
|
@@ -385,28 +433,34 @@ class a {
|
|
|
385
433
|
}) {
|
|
386
434
|
this.eventName = e, this.interactiveEvent = t, this.customParameters = n;
|
|
387
435
|
}
|
|
388
|
-
getGa4Parameters(e, t) {
|
|
389
|
-
let
|
|
436
|
+
getGa4Parameters(e, t, n) {
|
|
437
|
+
let i = {
|
|
390
438
|
solution: e,
|
|
391
439
|
experience_id: t,
|
|
392
440
|
interactive_event: this.interactiveEvent,
|
|
393
|
-
|
|
394
|
-
epg_event_tag: ""
|
|
441
|
+
sendTo: n
|
|
395
442
|
};
|
|
396
|
-
return
|
|
443
|
+
return i = Object.assign(i, JSON.parse(JSON.stringify(this.customParameters))), i;
|
|
397
444
|
}
|
|
398
|
-
getGTMParameters() {
|
|
399
|
-
|
|
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;
|
|
400
455
|
}
|
|
401
456
|
getNexusParameters() {
|
|
402
457
|
let e = {
|
|
403
|
-
interactive_event: this.interactiveEvent
|
|
404
|
-
items: []
|
|
458
|
+
interactive_event: this.interactiveEvent
|
|
405
459
|
};
|
|
406
460
|
return e = Object.assign(e, JSON.parse(JSON.stringify(this.customParameters))), e;
|
|
407
461
|
}
|
|
408
462
|
}
|
|
409
|
-
class
|
|
463
|
+
class w extends a {
|
|
410
464
|
constructor(e = []) {
|
|
411
465
|
super({
|
|
412
466
|
eventName: "epigraph_ar_requested",
|
|
@@ -417,46 +471,43 @@ class C extends a {
|
|
|
417
471
|
});
|
|
418
472
|
}
|
|
419
473
|
}
|
|
420
|
-
class
|
|
421
|
-
constructor(e
|
|
474
|
+
class x extends a {
|
|
475
|
+
constructor(e) {
|
|
422
476
|
super({
|
|
423
477
|
eventName: "epigraph_module_loading",
|
|
424
478
|
interactiveEvent: !1,
|
|
425
479
|
customParameters: {
|
|
426
|
-
|
|
427
|
-
is_pre_config: t
|
|
480
|
+
is_pre_config: e
|
|
428
481
|
}
|
|
429
482
|
});
|
|
430
483
|
}
|
|
431
484
|
}
|
|
432
485
|
class S extends a {
|
|
433
|
-
constructor(e
|
|
486
|
+
constructor(e, t) {
|
|
434
487
|
super({
|
|
435
488
|
eventName: "epigraph_module_ready",
|
|
436
489
|
interactiveEvent: !1,
|
|
437
490
|
customParameters: {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
load_time_ms: n
|
|
491
|
+
is_pre_config: e,
|
|
492
|
+
load_time_ms: t
|
|
441
493
|
}
|
|
442
494
|
});
|
|
443
495
|
}
|
|
444
496
|
}
|
|
445
|
-
class
|
|
446
|
-
constructor(e
|
|
497
|
+
class T extends a {
|
|
498
|
+
constructor(e, t, n) {
|
|
447
499
|
super({
|
|
448
500
|
eventName: "epigraph_module_failed",
|
|
449
501
|
interactiveEvent: !1,
|
|
450
502
|
customParameters: {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
error_type: i
|
|
503
|
+
is_pre_config: e,
|
|
504
|
+
load_time_ms: t,
|
|
505
|
+
error_type: n
|
|
455
506
|
}
|
|
456
507
|
});
|
|
457
508
|
}
|
|
458
509
|
}
|
|
459
|
-
class
|
|
510
|
+
class L extends a {
|
|
460
511
|
constructor(e = []) {
|
|
461
512
|
super({
|
|
462
513
|
eventName: "epigraph_module_closed",
|
|
@@ -468,32 +519,30 @@ class T extends a {
|
|
|
468
519
|
}
|
|
469
520
|
}
|
|
470
521
|
class z extends a {
|
|
471
|
-
constructor(e
|
|
522
|
+
constructor(e, t = {}) {
|
|
472
523
|
super({
|
|
473
524
|
eventName: "epigraph_support_detected",
|
|
474
525
|
interactiveEvent: !1,
|
|
475
526
|
customParameters: {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
device_capabilities: n
|
|
527
|
+
support_type: e,
|
|
528
|
+
device_capabilities: t
|
|
479
529
|
}
|
|
480
530
|
});
|
|
481
531
|
}
|
|
482
532
|
}
|
|
483
533
|
class q extends a {
|
|
484
|
-
constructor(e
|
|
534
|
+
constructor(e, t) {
|
|
485
535
|
super({
|
|
486
536
|
eventName: "epigraph_button_click",
|
|
487
537
|
interactiveEvent: !0,
|
|
488
538
|
customParameters: {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
button_name: n
|
|
539
|
+
button_type: e,
|
|
540
|
+
button_name: t
|
|
492
541
|
}
|
|
493
542
|
});
|
|
494
543
|
}
|
|
495
544
|
}
|
|
496
|
-
class
|
|
545
|
+
class O extends a {
|
|
497
546
|
constructor(e = [], t, n, i) {
|
|
498
547
|
super({
|
|
499
548
|
eventName: "epigraph_panel_opened",
|
|
@@ -506,7 +555,7 @@ class G extends a {
|
|
|
506
555
|
});
|
|
507
556
|
}
|
|
508
557
|
}
|
|
509
|
-
class
|
|
558
|
+
class G extends a {
|
|
510
559
|
constructor(e = [], t, n, i) {
|
|
511
560
|
super({
|
|
512
561
|
eventName: "epigraph_panel_closed",
|
|
@@ -519,7 +568,7 @@ class O extends a {
|
|
|
519
568
|
});
|
|
520
569
|
}
|
|
521
570
|
}
|
|
522
|
-
class
|
|
571
|
+
class b extends a {
|
|
523
572
|
constructor(e = []) {
|
|
524
573
|
super({
|
|
525
574
|
eventName: "epigraph_add_to_favourites",
|
|
@@ -530,31 +579,29 @@ class D extends a {
|
|
|
530
579
|
});
|
|
531
580
|
}
|
|
532
581
|
}
|
|
533
|
-
class
|
|
534
|
-
constructor(e
|
|
582
|
+
class D extends a {
|
|
583
|
+
constructor(e) {
|
|
535
584
|
super({
|
|
536
585
|
eventName: "epigraph_keyboard_interaction",
|
|
537
586
|
interactiveEvent: !0,
|
|
538
587
|
customParameters: {
|
|
539
|
-
|
|
540
|
-
action_performed: t
|
|
588
|
+
action_performed: e
|
|
541
589
|
}
|
|
542
590
|
});
|
|
543
591
|
}
|
|
544
592
|
}
|
|
545
|
-
class
|
|
546
|
-
constructor(e
|
|
593
|
+
class M extends a {
|
|
594
|
+
constructor(e) {
|
|
547
595
|
super({
|
|
548
596
|
eventName: "epigraph_touch_interaction",
|
|
549
597
|
interactiveEvent: !0,
|
|
550
598
|
customParameters: {
|
|
551
|
-
|
|
552
|
-
interaction_type: t
|
|
599
|
+
interaction_type: e
|
|
553
600
|
}
|
|
554
601
|
});
|
|
555
602
|
}
|
|
556
603
|
}
|
|
557
|
-
class
|
|
604
|
+
class R extends a {
|
|
558
605
|
constructor(e = [], t, n, i, r) {
|
|
559
606
|
super({
|
|
560
607
|
eventName: "epigraph_item_added",
|
|
@@ -580,14 +627,15 @@ class $ extends a {
|
|
|
580
627
|
}
|
|
581
628
|
}
|
|
582
629
|
class k extends a {
|
|
583
|
-
constructor(e = [], t, n) {
|
|
630
|
+
constructor(e = [], t, n, i) {
|
|
584
631
|
super({
|
|
585
632
|
eventName: "epigraph_item_removed",
|
|
586
633
|
interactiveEvent: !0,
|
|
587
634
|
customParameters: {
|
|
588
635
|
items: e,
|
|
589
|
-
|
|
590
|
-
|
|
636
|
+
value: t,
|
|
637
|
+
currency: n,
|
|
638
|
+
quantity: i
|
|
591
639
|
}
|
|
592
640
|
});
|
|
593
641
|
}
|
|
@@ -617,7 +665,7 @@ class U extends a {
|
|
|
617
665
|
});
|
|
618
666
|
}
|
|
619
667
|
}
|
|
620
|
-
class
|
|
668
|
+
class V extends a {
|
|
621
669
|
constructor(e = [], t, n) {
|
|
622
670
|
super({
|
|
623
671
|
eventName: "epigraph_checkout",
|
|
@@ -630,7 +678,7 @@ class F extends a {
|
|
|
630
678
|
});
|
|
631
679
|
}
|
|
632
680
|
}
|
|
633
|
-
class
|
|
681
|
+
class F extends a {
|
|
634
682
|
constructor(e = [], t, n) {
|
|
635
683
|
super({
|
|
636
684
|
eventName: "epigraph_conversion",
|
|
@@ -643,43 +691,40 @@ class B extends a {
|
|
|
643
691
|
});
|
|
644
692
|
}
|
|
645
693
|
}
|
|
646
|
-
class
|
|
647
|
-
constructor(e
|
|
694
|
+
class B extends a {
|
|
695
|
+
constructor(e) {
|
|
648
696
|
super({
|
|
649
697
|
eventName: "epigraph_changeRate",
|
|
650
698
|
interactiveEvent: !1,
|
|
651
699
|
customParameters: {
|
|
652
|
-
|
|
653
|
-
value: t
|
|
700
|
+
value: e
|
|
654
701
|
}
|
|
655
702
|
});
|
|
656
703
|
}
|
|
657
704
|
}
|
|
658
|
-
class
|
|
659
|
-
constructor(e
|
|
705
|
+
class J extends a {
|
|
706
|
+
constructor(e) {
|
|
660
707
|
super({
|
|
661
708
|
eventName: "epigraph_completionRate",
|
|
662
709
|
interactiveEvent: !1,
|
|
663
710
|
customParameters: {
|
|
664
|
-
|
|
665
|
-
value: t
|
|
711
|
+
value: e
|
|
666
712
|
}
|
|
667
713
|
});
|
|
668
714
|
}
|
|
669
715
|
}
|
|
670
716
|
class H extends a {
|
|
671
|
-
constructor(e
|
|
717
|
+
constructor(e) {
|
|
672
718
|
super({
|
|
673
719
|
eventName: "epigraph_engagementRate",
|
|
674
720
|
interactiveEvent: !1,
|
|
675
721
|
customParameters: {
|
|
676
|
-
|
|
677
|
-
value: t
|
|
722
|
+
value: e
|
|
678
723
|
}
|
|
679
724
|
});
|
|
680
725
|
}
|
|
681
726
|
}
|
|
682
|
-
class
|
|
727
|
+
class K extends a {
|
|
683
728
|
constructor(e, t, n) {
|
|
684
729
|
super({
|
|
685
730
|
eventName: e,
|
|
@@ -707,7 +752,7 @@ class X extends a {
|
|
|
707
752
|
var f;
|
|
708
753
|
const c = Symbol("analyticsPluginsMap");
|
|
709
754
|
f = c;
|
|
710
|
-
class
|
|
755
|
+
class X {
|
|
711
756
|
constructor(e, t) {
|
|
712
757
|
this[f] = /* @__PURE__ */ new Map(), this.__consentPlugin = null, e && t && (this.__consentPlugin = this.buildConsentPlugin(e, t)), window.addEventListener("epigraphAnalyticsConsentChange", this.__onConsentChangeFromEvent);
|
|
713
758
|
}
|
|
@@ -715,7 +760,7 @@ class K {
|
|
|
715
760
|
let t = e;
|
|
716
761
|
this.__overrideConsent = t.detail.hasConsent;
|
|
717
762
|
for (const n of this[c].values())
|
|
718
|
-
this.__hasConsent() || n.setStatus(
|
|
763
|
+
this.__hasConsent() || n.setStatus(o.RESTRICTED);
|
|
719
764
|
}
|
|
720
765
|
/**
|
|
721
766
|
* Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
|
|
@@ -757,36 +802,36 @@ class K {
|
|
|
757
802
|
* @private
|
|
758
803
|
*/
|
|
759
804
|
buildConsentPlugin(e, t) {
|
|
760
|
-
return e.toLowerCase() === E.OneTrust.toLowerCase() ? new
|
|
805
|
+
return e.toLowerCase() === E.OneTrust.toLowerCase() ? new A(t) : null;
|
|
761
806
|
}
|
|
762
807
|
}
|
|
763
808
|
export {
|
|
764
809
|
E as ConsentPluginNames,
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
810
|
+
b as EpigraphAddToFavouritesEvent,
|
|
811
|
+
X as EpigraphAnalytics,
|
|
812
|
+
w as EpigraphArRequestedEvent,
|
|
768
813
|
q as EpigraphButtonClickEvent,
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
814
|
+
B as EpigraphChangeRateEvent,
|
|
815
|
+
V as EpigraphCheckoutEvent,
|
|
816
|
+
J as EpigraphCompletionRateEvent,
|
|
772
817
|
U as EpigraphContentSharedEvent,
|
|
773
|
-
|
|
774
|
-
|
|
818
|
+
F as EpigraphConversionEvent,
|
|
819
|
+
K as EpigraphCustomEvent,
|
|
775
820
|
H as EpigraphEngagementRateEvent,
|
|
776
|
-
|
|
821
|
+
R as EpigraphItemAddedEvent,
|
|
777
822
|
$ as EpigraphItemMovedEvent,
|
|
778
823
|
k as EpigraphItemRemovedEvent,
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
824
|
+
D as EpigraphKeyboardInteractionEvent,
|
|
825
|
+
L as EpigraphModuleClosedEvent,
|
|
826
|
+
T as EpigraphModuleFailedEvent,
|
|
827
|
+
x as EpigraphModuleLoadingEvent,
|
|
783
828
|
S as EpigraphModuleReadyEvent,
|
|
784
|
-
|
|
785
|
-
|
|
829
|
+
G as EpigraphPanelClosedEvent,
|
|
830
|
+
O as EpigraphPanelOpenedEvent,
|
|
786
831
|
z as EpigraphSupportDetectedEvent,
|
|
787
|
-
|
|
832
|
+
M as EpigraphTouchInteractionEvent,
|
|
788
833
|
j as EpigraphVariantChangedEvent,
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
834
|
+
I as GA4AnalyticsPlugin,
|
|
835
|
+
C as NexusAnalyticsPlugin,
|
|
836
|
+
A as OneTrustConsentPlugin
|
|
792
837
|
};
|
|
@@ -8,39 +8,44 @@ declare class BaseAnalyticsEvent implements IAnalyticsEvent {
|
|
|
8
8
|
interactiveEvent: boolean;
|
|
9
9
|
customParameters: Record<string, unknown>;
|
|
10
10
|
});
|
|
11
|
-
getGa4Parameters(solution: string, experienceId: string): {
|
|
11
|
+
getGa4Parameters(solution: string, experienceId: string, sendTo: string): {
|
|
12
12
|
solution: string;
|
|
13
13
|
experience_id: string;
|
|
14
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;
|
|
15
22
|
items: never[];
|
|
16
|
-
|
|
23
|
+
sendTo: string;
|
|
17
24
|
};
|
|
18
|
-
getGTMParameters(): {};
|
|
19
25
|
getNexusParameters(): {
|
|
20
26
|
interactive_event: boolean;
|
|
21
|
-
items: never[];
|
|
22
27
|
};
|
|
23
28
|
}
|
|
24
29
|
export declare class EpigraphArRequestedEvent extends BaseAnalyticsEvent {
|
|
25
30
|
constructor(items?: IAnalyticsParameterItems);
|
|
26
31
|
}
|
|
27
32
|
export declare class EpigraphModuleLoadingEvent extends BaseAnalyticsEvent {
|
|
28
|
-
constructor(
|
|
33
|
+
constructor(isPreConfig: boolean);
|
|
29
34
|
}
|
|
30
35
|
export declare class EpigraphModuleReadyEvent extends BaseAnalyticsEvent {
|
|
31
|
-
constructor(
|
|
36
|
+
constructor(isPreConfig: boolean, loadTimeMs: number);
|
|
32
37
|
}
|
|
33
38
|
export declare class EpigraphModuleFailedEvent extends BaseAnalyticsEvent {
|
|
34
|
-
constructor(
|
|
39
|
+
constructor(isPreConfig: boolean, loadTimeMs: number, errorType: string);
|
|
35
40
|
}
|
|
36
41
|
export declare class EpigraphModuleClosedEvent extends BaseAnalyticsEvent {
|
|
37
42
|
constructor(items?: IAnalyticsParameterItems);
|
|
38
43
|
}
|
|
39
44
|
export declare class EpigraphSupportDetectedEvent extends BaseAnalyticsEvent {
|
|
40
|
-
constructor(
|
|
45
|
+
constructor(supportType: string, deviceCapabilities?: Record<string, unknown>);
|
|
41
46
|
}
|
|
42
47
|
export declare class EpigraphButtonClickEvent extends BaseAnalyticsEvent {
|
|
43
|
-
constructor(
|
|
48
|
+
constructor(buttonType: string, buttonName: string);
|
|
44
49
|
}
|
|
45
50
|
export declare class EpigraphPanelOpenedEvent extends BaseAnalyticsEvent {
|
|
46
51
|
constructor(items: IAnalyticsParameterItems | undefined, isInteractive: boolean, panelType: string, triggerSource: string);
|
|
@@ -52,10 +57,10 @@ export declare class EpigraphAddToFavouritesEvent extends BaseAnalyticsEvent {
|
|
|
52
57
|
constructor(items?: IAnalyticsParameterItems);
|
|
53
58
|
}
|
|
54
59
|
export declare class EpigraphKeyboardInteractionEvent extends BaseAnalyticsEvent {
|
|
55
|
-
constructor(
|
|
60
|
+
constructor(actionPerformed: string);
|
|
56
61
|
}
|
|
57
62
|
export declare class EpigraphTouchInteractionEvent extends BaseAnalyticsEvent {
|
|
58
|
-
constructor(
|
|
63
|
+
constructor(interactionType: string);
|
|
59
64
|
}
|
|
60
65
|
export declare class EpigraphItemAddedEvent extends BaseAnalyticsEvent {
|
|
61
66
|
constructor(items: IAnalyticsParameterItems | undefined, isInteractive: boolean, value: number, currency: string, quantity: number);
|
|
@@ -64,7 +69,7 @@ export declare class EpigraphItemMovedEvent extends BaseAnalyticsEvent {
|
|
|
64
69
|
constructor(items?: IAnalyticsParameterItems);
|
|
65
70
|
}
|
|
66
71
|
export declare class EpigraphItemRemovedEvent extends BaseAnalyticsEvent {
|
|
67
|
-
constructor(items: IAnalyticsParameterItems | undefined, currency: string, quantity: number);
|
|
72
|
+
constructor(items: IAnalyticsParameterItems | undefined, value: number, currency: string, quantity: number);
|
|
68
73
|
}
|
|
69
74
|
export declare class EpigraphVariantChangedEvent extends BaseAnalyticsEvent {
|
|
70
75
|
constructor(items: IAnalyticsParameterItems | undefined, changeType: string);
|
|
@@ -73,19 +78,19 @@ export declare class EpigraphContentSharedEvent extends BaseAnalyticsEvent {
|
|
|
73
78
|
constructor(items: IAnalyticsParameterItems | undefined, contentType: string, shareDestination: string);
|
|
74
79
|
}
|
|
75
80
|
export declare class EpigraphCheckoutEvent extends BaseAnalyticsEvent {
|
|
76
|
-
constructor(items:
|
|
81
|
+
constructor(items: IAnalyticsParameterItems | undefined, value: number, currency: string);
|
|
77
82
|
}
|
|
78
83
|
export declare class EpigraphConversionEvent extends BaseAnalyticsEvent {
|
|
79
84
|
constructor(items: IAnalyticsParameterItems | undefined, value: number, currency: string);
|
|
80
85
|
}
|
|
81
86
|
export declare class EpigraphChangeRateEvent extends BaseAnalyticsEvent {
|
|
82
|
-
constructor(
|
|
87
|
+
constructor(value: number);
|
|
83
88
|
}
|
|
84
89
|
export declare class EpigraphCompletionRateEvent extends BaseAnalyticsEvent {
|
|
85
|
-
constructor(
|
|
90
|
+
constructor(value: number);
|
|
86
91
|
}
|
|
87
92
|
export declare class EpigraphEngagementRateEvent extends BaseAnalyticsEvent {
|
|
88
|
-
constructor(
|
|
93
|
+
constructor(value: number);
|
|
89
94
|
}
|
|
90
95
|
export declare class EpigraphCustomEvent extends BaseAnalyticsEvent {
|
|
91
96
|
constructor(eventName: string, interactiveEvent: boolean, customParameters: Record<string, unknown>);
|
|
@@ -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
|
}
|