@epigraph/epigraph-std-lib 4.5.0-alpha → 4.5.2-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/README.md +68 -68
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.cjs +2 -2
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.js +220 -122
- package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalyticsEventLibrary.d.ts +3 -0
- package/dist/EpigraphLibs/EpigraphAnalytics/plugins/ga4-analytics-plugin.d.ts +19 -5
- package/dist/epigraph-std-lib.cjs +1 -1
- package/dist/epigraph-std-lib.js +43 -42
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
# INTRODUCTION
|
|
2
|
-
|
|
3
|
-
Epigraph Standard Library or epigraph-std-lib is a collection of standards that we follow across our solutions. The idea is to have a single source of truth across solutions while ensuring that the dependencies are always up to date with the industry standards.
|
|
4
|
-
|
|
5
|
-
### EPIGRAPH
|
|
6
|
-
A global object that must only be initialized once per session and provides some common functionalities across solutions in that session.
|
|
7
|
-
|
|
8
|
-
### EPIGRAPH LIBRARY EXPORTS
|
|
9
|
-
|
|
10
|
-
| Name | Description |
|
|
11
|
-
|---|---|
|
|
12
|
-
| EpigraphBaseSolutionHtmlElement | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
13
|
-
| EpigraphBaseSolutionLitElement | A base class intended to enforce some common functionalities across our solutions, built by extending the LitElement |
|
|
14
|
-
| EpigraphLogger | A logger class that provides a convenient way for logging info, warning or errors in any given session |
|
|
15
|
-
| EpigraphQrCoreGenerator | A Utility class that allows the generation of a QR code from a give string input |
|
|
16
|
-
| EpigraphUnitsConverter | |
|
|
17
|
-
| EpigraphUrlProcessor | |
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# HOW TO:
|
|
21
|
-
|
|
22
|
-
### Add a new EpigraphLibrary:
|
|
23
|
-
1. Create a new directory under lib/EpigraphLibs/`<MyEpigraphLibrary>`
|
|
24
|
-
2. Create the module file/s. Ensure that the names of these files are in camelCase.
|
|
25
|
-
3. Write a test for this Library under tests/<MyEpigraphLibrary.test.ts>
|
|
26
|
-
4. Add the module that you wish to export as an entry in vite.config.ts > defineConfig > build > entry, similar to other entries in there. This will bundle the new module on build.
|
|
27
|
-
5. Go to package.json:
|
|
28
|
-
- Add the new module entry under exports similar to other entries in that field.
|
|
29
|
-
- Add the new module entry under typesVersions similar to other entries in that field.
|
|
30
|
-
|
|
31
|
-
### Use the library
|
|
32
|
-
This library exports the module into submodules to allow for better tree shaking when bundling the final product. Here is how you can import the submodules individually.
|
|
33
|
-
|
|
34
|
-
```javascript
|
|
35
|
-
// Epigraph Object
|
|
36
|
-
import { Epigraph } from "@epigraph/epigraph-std-lib/dist/Epigraph/epigraph";
|
|
37
|
-
|
|
38
|
-
// Epigraph libs
|
|
39
|
-
import { EpigraphAnalytics } from "@epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics";
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Exported Submodules:
|
|
44
|
-
| Name | Description |
|
|
45
|
-
|---|---|
|
|
46
|
-
| @epigraph/epigraph-std-lib/dist/Epigraph/epigraph | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
47
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics | An Analytics modules that exports handy ways to log analytics across our solutions |
|
|
48
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphLogger | A Logger modules that exports handy ways to log across our solutions |
|
|
49
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphNexusApi | A Nexus API modules that exports handy ways to interact with the Nexus API across our solutions |
|
|
50
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphQrCodeGenerator | A QR Code generator modules that exports handy ways to generate QR Codes across our solutions |
|
|
51
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphResultFactory | A Result Factory modules that exports handy ways to generate Result objects across our solutions |
|
|
52
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUnitsConverter | A Utility class that allows conversion between different standard unit, including but not limited to Distance, Color, etc. |
|
|
53
|
-
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUrlProcessor | A Utility class that provides various methods to generate, process, manipulate URLs |
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Write a test:
|
|
57
|
-
We use [vitest](https://vitest.dev/guide/) to write tests in this repository using [happy-dom](https://www.npmjs.com/package/happy-dom) to support some but not all browser functionalities. In order to write a new test:
|
|
58
|
-
|
|
59
|
-
1. Create a new file for a specific test under tests/ as `<MyEpigraphLibrary>`.test.ts
|
|
60
|
-
2. Write a test following the instructions and samples [here](https://vitest.dev/guide/#writing-tests)
|
|
61
|
-
3. Make sure to import the library from "../dist/epigraph-std-lib" to avoid any issues that might come up after bundling.
|
|
62
|
-
4. Open a terminal and execute "npm run test". This will build all the libraries under dist/ and then run tests using those.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
# REFERENCES
|
|
66
|
-
A huge thanks to everyone who inspired the setup for this repository:
|
|
67
|
-
1. [Andreas Riedmuller's Article](https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma)
|
|
68
|
-
2. [Vitest Docs](https://vitest.dev/guide/)
|
|
1
|
+
# INTRODUCTION
|
|
2
|
+
|
|
3
|
+
Epigraph Standard Library or epigraph-std-lib is a collection of standards that we follow across our solutions. The idea is to have a single source of truth across solutions while ensuring that the dependencies are always up to date with the industry standards.
|
|
4
|
+
|
|
5
|
+
### EPIGRAPH
|
|
6
|
+
A global object that must only be initialized once per session and provides some common functionalities across solutions in that session.
|
|
7
|
+
|
|
8
|
+
### EPIGRAPH LIBRARY EXPORTS
|
|
9
|
+
|
|
10
|
+
| Name | Description |
|
|
11
|
+
|---|---|
|
|
12
|
+
| EpigraphBaseSolutionHtmlElement | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
13
|
+
| EpigraphBaseSolutionLitElement | A base class intended to enforce some common functionalities across our solutions, built by extending the LitElement |
|
|
14
|
+
| EpigraphLogger | A logger class that provides a convenient way for logging info, warning or errors in any given session |
|
|
15
|
+
| EpigraphQrCoreGenerator | A Utility class that allows the generation of a QR code from a give string input |
|
|
16
|
+
| EpigraphUnitsConverter | |
|
|
17
|
+
| EpigraphUrlProcessor | |
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# HOW TO:
|
|
21
|
+
|
|
22
|
+
### Add a new EpigraphLibrary:
|
|
23
|
+
1. Create a new directory under lib/EpigraphLibs/`<MyEpigraphLibrary>`
|
|
24
|
+
2. Create the module file/s. Ensure that the names of these files are in camelCase.
|
|
25
|
+
3. Write a test for this Library under tests/<MyEpigraphLibrary.test.ts>
|
|
26
|
+
4. Add the module that you wish to export as an entry in vite.config.ts > defineConfig > build > entry, similar to other entries in there. This will bundle the new module on build.
|
|
27
|
+
5. Go to package.json:
|
|
28
|
+
- Add the new module entry under exports similar to other entries in that field.
|
|
29
|
+
- Add the new module entry under typesVersions similar to other entries in that field.
|
|
30
|
+
|
|
31
|
+
### Use the library
|
|
32
|
+
This library exports the module into submodules to allow for better tree shaking when bundling the final product. Here is how you can import the submodules individually.
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
// Epigraph Object
|
|
36
|
+
import { Epigraph } from "@epigraph/epigraph-std-lib/dist/Epigraph/epigraph";
|
|
37
|
+
|
|
38
|
+
// Epigraph libs
|
|
39
|
+
import { EpigraphAnalytics } from "@epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics";
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Exported Submodules:
|
|
44
|
+
| Name | Description |
|
|
45
|
+
|---|---|
|
|
46
|
+
| @epigraph/epigraph-std-lib/dist/Epigraph/epigraph | A base class intended to enforce some common functionalities across our solutions, built by extending the HTMLElement |
|
|
47
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphAnalytics | An Analytics modules that exports handy ways to log analytics across our solutions |
|
|
48
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphLogger | A Logger modules that exports handy ways to log across our solutions |
|
|
49
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphNexusApi | A Nexus API modules that exports handy ways to interact with the Nexus API across our solutions |
|
|
50
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphQrCodeGenerator | A QR Code generator modules that exports handy ways to generate QR Codes across our solutions |
|
|
51
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphResultFactory | A Result Factory modules that exports handy ways to generate Result objects across our solutions |
|
|
52
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUnitsConverter | A Utility class that allows conversion between different standard unit, including but not limited to Distance, Color, etc. |
|
|
53
|
+
| @epigraph/epigraph-std-lib/dist/EpigraphLibs/epigraphUrlProcessor | A Utility class that provides various methods to generate, process, manipulate URLs |
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Write a test:
|
|
57
|
+
We use [vitest](https://vitest.dev/guide/) to write tests in this repository using [happy-dom](https://www.npmjs.com/package/happy-dom) to support some but not all browser functionalities. In order to write a new test:
|
|
58
|
+
|
|
59
|
+
1. Create a new file for a specific test under tests/ as `<MyEpigraphLibrary>`.test.ts
|
|
60
|
+
2. Write a test following the instructions and samples [here](https://vitest.dev/guide/#writing-tests)
|
|
61
|
+
3. Make sure to import the library from "../dist/epigraph-std-lib" to avoid any issues that might come up after bundling.
|
|
62
|
+
4. Open a terminal and execute "npm run test". This will build all the libraries under dist/ and then run tests using those.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# REFERENCES
|
|
66
|
+
A huge thanks to everyone who inspired the setup for this repository:
|
|
67
|
+
1. [Andreas Riedmuller's Article](https://dev.to/receter/how-to-create-a-react-component-library-using-vites-library-mode-4lma)
|
|
68
|
+
2. [Vitest Docs](https://vitest.dev/guide/)
|
|
@@ -1,4 +1,4 @@
|
|
|
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 l=Symbol("data"),p=Symbol("next"),C=class m{constructor(e){this[l]=e,this[p]=null}get data(){return this[l]}set next(e){if(!(e instanceof m)&&e!==null)throw new Error("This node is not an instance of the custom class 'Node'.");this[p]=e}get next(){return this[p]}};let v=C;const d=Symbol("head");class w{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 E=Symbol("queue"),h=Symbol("size");class _{constructor(){this[E]=new w,this[h]=0}get queue(){return this[E]}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:r=!1}){this.__status=o.UNAVAILABLE,this.__sentEventCount=0,this.name=this.pluginName="GA4-PLUGIN",this.trackingID=e,this.experienceID=t,this.solution=n,this.verboseLogging=r,this.__queue=new _,this.dataLayer=window.dataLayer,this.dataLayerName="dataLayer",this.setupDataLayer(),this.initGtag(this.dataLayerName,this.trackingID)}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.dataLayer!==void 0&&this.dequeueAndSendEvents()}async sendEvent(e,t){if(this.__queue.enqueue(e),!t){this.__status=o.RESTRICTED;return}if(this.dataLayer!==void 0)try{await this.dequeueAndSendEvents()}catch(n){this.logger(n)}else this.logger("Cannot send Google Analytics 4 event: dataLayer is not defined.")}setupDataLayer(){if(this.dataLayer){this.__status=o.AVAILABLE;return}const t=this.findGA4ScriptInfo(this.trackingID)?.l;t&&(this.dataLayerName=t,this.dataLayer=window[t])}initGtag(e="dataLayer",t){window.epgDataLayerName=e,typeof window.gtag!="function"&&(window.gtag=function(){window[window.epgDataLayerName].push(arguments)},window.gtag("js",new Date),window.gtag("config",t,{send_page_view:!1}))}async dequeueAndSendEvents(){let e=this.__queue.size;for(let t=0;t<e;t++){const n=this.__queue.dequeue(),r=n.getGa4Parameters(this.solution,this.experienceID);if(n.customParameters&&Object.assign(r,n.customParameters),JSON.stringify(r).length>459)try{let u=await this.sendGA4LongParameters(r);r.epg_event_tag=u}catch{}gtag("event",n.eventName,r),this.__sentEventCount++,this.logger(`Google Analytics 4 event successfully sent: ${n.eventName}`)}}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 r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});if(r.ok){const i=await r.json();return i&&i.id?i.id:""}else return""}catch{return""}}findGA4ScriptInfo(e){const t=document.querySelectorAll("script[src]");for(const n of t){const r=n.getAttribute("src");if(r&&r.includes(e)){const i=new URL(r,location.href),u=Object.fromEntries(i.searchParams.entries());return{fullSrc:i.href,id:u.id||void 0,l:u.l||void 0}}}return null}}class S{constructor({trackingID:e,experienceID:t,solution:n,sessionId:r,xPath:i,verboseLogging:u=!1,sendToStaging:P=!1}){this.__status=o.UNAVAILABLE,this.__sentEventCount=0,this.sessionId=r,this.xPath=i,this.name=this.pluginName="NEXUS-PLUGIN",this.trackingID=e,this.experienceID=t,this.solution=n,this.verboseLogging=u,this.__queue=new _,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 g=(s=>(s.OneTrust="onetrust",s))(g||{});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 A extends a{constructor(e=[]){super({eventName:"epigraph_ar_requested",interactiveEvent:!0,customParameters:{items:e}})}}class L extends a{constructor(e=[],t){super({eventName:"epigraph_module_loading",interactiveEvent:!1,customParameters:{items:e,is_pre_config:t}})}}class I 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,r){super({eventName:"epigraph_module_failed",interactiveEvent:!1,customParameters:{items:e,is_pre_config:t,load_time_ms:n,error_type:r}})}}class q extends a{constructor(e=[]){super({eventName:"epigraph_module_closed",interactiveEvent:!0,customParameters:{items:e}})}}class T extends a{constructor(e=[],t,n={}){super({eventName:"epigraph_support_detected",interactiveEvent:!1,customParameters:{items:e,support_type:t,device_capabilities:n}})}}class b 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,r){super({eventName:"epigraph_panel_opened",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:r}})}}class R extends a{constructor(e=[],t,n,r){super({eventName:"epigraph_panel_closed",interactiveEvent:t,customParameters:{items:e,panel_type:n,trigger_source:r}})}}class D extends a{constructor(e=[]){super({eventName:"epigraph_add_to_favourites",interactiveEvent:!0,customParameters:{items:e}})}}class G extends a{constructor(e=[],t){super({eventName:"epigraph_keyboard_interaction",interactiveEvent:!0,customParameters:{items:e,action_performed:t}})}}class k 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,r,i){super({eventName:"epigraph_item_added",interactiveEvent:t,customParameters:{items:e,value:n,currency:r,quantity:i}})}}class j extends a{constructor(e=[]){super({eventName:"epigraph_item_moved",interactiveEvent:!0,customParameters:{items:e}})}}class B extends a{constructor(e=[],t,n){super({eventName:"epigraph_item_removed",interactiveEvent:!0,customParameters:{items:e,currency:t,quantity:n}})}}class U extends a{constructor(e=[],t){super({eventName:"epigraph_variant_changed",interactiveEvent:!0,customParameters:{items:e,change_type:t}})}}class $ extends a{constructor(e=[],t,n){super({eventName:"epigraph_content_shared",interactiveEvent:!0,customParameters:{items:e,content_type:t,share_destination:n}})}}class z extends a{constructor(e=[],t,n){super({eventName:"epigraph_checkout",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n}})}}class V extends a{constructor(e=[],t,n){super({eventName:"epigraph_conversion",interactiveEvent:!0,customParameters:{items:e,value:t,currency:n}})}}class J extends a{constructor(e=[],t){super({eventName:"epigraph_changeRate",interactiveEvent:!1,customParameters:{items:e,value:t}})}}class F 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}})}}/**
|
|
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})}}/**
|
|
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 K{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(
|
|
16
|
+
*/var y;const c=Symbol("analyticsPluginsMap");y=c;class K{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(u.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()===l.OneTrust.toLowerCase()?new f(t):null}}exports.ConsentPluginNames=l;exports.EpigraphAddToFavouritesEvent=R;exports.EpigraphAnalytics=K;exports.EpigraphArRequestedEvent=I;exports.EpigraphButtonClickEvent=z;exports.EpigraphChangeRateEvent=V;exports.EpigraphCheckoutEvent=U;exports.EpigraphCompletionRateEvent=J;exports.EpigraphContentSharedEvent=F;exports.EpigraphConversionEvent=B;exports.EpigraphCustomEvent=X;exports.EpigraphEngagementRateEvent=H;exports.EpigraphItemAddedEvent=M;exports.EpigraphItemMovedEvent=$;exports.EpigraphItemRemovedEvent=k;exports.EpigraphKeyboardInteractionEvent=b;exports.EpigraphModuleClosedEvent=T;exports.EpigraphModuleFailedEvent=x;exports.EpigraphModuleLoadingEvent=S;exports.EpigraphModuleReadyEvent=L;exports.EpigraphPanelClosedEvent=G;exports.EpigraphPanelOpenedEvent=O;exports.EpigraphSupportDetectedEvent=q;exports.EpigraphTouchInteractionEvent=D;exports.EpigraphVariantChangedEvent=j;exports.GA4AnalyticsPlugin=P;exports.NexusAnalyticsPlugin=C;exports.OneTrustConsentPlugin=f;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
1
|
+
var u = /* @__PURE__ */ ((s) => (s.UNAVAILABLE = "unavailable", s.AVAILABLE = "available", s.RESTRICTED = "restricted", s))(u || {});
|
|
2
|
+
const p = Symbol("data"), d = Symbol("next"), w = class m {
|
|
3
3
|
constructor(e) {
|
|
4
|
-
this[
|
|
4
|
+
this[p] = e, this[d] = null;
|
|
5
5
|
}
|
|
6
6
|
get data() {
|
|
7
|
-
return this[
|
|
7
|
+
return this[p];
|
|
8
8
|
}
|
|
9
9
|
set next(e) {
|
|
10
10
|
if (!(e instanceof m) && e !== null)
|
|
@@ -17,17 +17,17 @@ const l = Symbol("data"), d = Symbol("next"), P = class m {
|
|
|
17
17
|
return this[d];
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
let g =
|
|
21
|
-
const
|
|
22
|
-
class
|
|
20
|
+
let g = w;
|
|
21
|
+
const l = Symbol("head");
|
|
22
|
+
class A {
|
|
23
23
|
constructor() {
|
|
24
|
-
this[
|
|
24
|
+
this[l] = null;
|
|
25
25
|
}
|
|
26
26
|
set head(e) {
|
|
27
|
-
this[
|
|
27
|
+
this[l] = e;
|
|
28
28
|
}
|
|
29
29
|
get head() {
|
|
30
|
-
return this[
|
|
30
|
+
return this[l];
|
|
31
31
|
}
|
|
32
32
|
addToTail(e) {
|
|
33
33
|
let t = this.head;
|
|
@@ -44,13 +44,13 @@ class C {
|
|
|
44
44
|
return this.head = e.next, e.data;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
class
|
|
47
|
+
const _ = Symbol("queue"), h = Symbol("size");
|
|
48
|
+
class v {
|
|
49
49
|
constructor() {
|
|
50
|
-
this[
|
|
50
|
+
this[_] = new A(), this[h] = 0;
|
|
51
51
|
}
|
|
52
52
|
get queue() {
|
|
53
|
-
return this[
|
|
53
|
+
return this[_];
|
|
54
54
|
}
|
|
55
55
|
get size() {
|
|
56
56
|
return this[h];
|
|
@@ -63,14 +63,14 @@ class _ {
|
|
|
63
63
|
return this[h]--, e;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
class
|
|
66
|
+
class P {
|
|
67
67
|
constructor({
|
|
68
68
|
trackingID: e,
|
|
69
69
|
experienceID: t,
|
|
70
70
|
solution: n,
|
|
71
|
-
verboseLogging:
|
|
71
|
+
verboseLogging: i = !1
|
|
72
72
|
}) {
|
|
73
|
-
this.__status =
|
|
73
|
+
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 = i, this.__queue = new v(), this.initializePlugin();
|
|
74
74
|
}
|
|
75
75
|
getStatus() {
|
|
76
76
|
return this.__status;
|
|
@@ -94,56 +94,126 @@ class N {
|
|
|
94
94
|
return `${this.name}-${this.trackingID}`;
|
|
95
95
|
}
|
|
96
96
|
setupPlugin() {
|
|
97
|
-
this.dataLayer !== void 0 && this.dequeueAndSendEvents();
|
|
97
|
+
this.__isInitialized && this.dataLayer !== void 0 && this.dequeueAndSendEvents();
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* This function will send an Event to Google Analytics 4.
|
|
101
101
|
*
|
|
102
102
|
* @param eventData IAnalyticsEvent The event to be tracked
|
|
103
|
-
* @param
|
|
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 = u.RESTRICTED;
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
if (this.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.logger(
|
|
110
|
+
if (!this.__isInitialized) {
|
|
111
|
+
this.logger("Cannot send analytics event: dataLayer not defined or plugin not initialized.");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
await this.dequeueAndSendEvents();
|
|
116
|
+
} catch (n) {
|
|
117
|
+
this.logger(n), await this.reportFailureToNexus("EVENT_SEND_ERROR", n?.toString() || "Unknown error");
|
|
118
|
+
}
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
-
if (this.
|
|
121
|
-
|
|
120
|
+
async initializePlugin() {
|
|
121
|
+
if (this.__isInitialized)
|
|
122
|
+
return;
|
|
123
|
+
const e = Date.now();
|
|
124
|
+
if (this.__initializationAttempts >= this.__maxInitializationAttempts) {
|
|
125
|
+
this.__nexusFailureReported || (await this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS", "Maximum initialization attempts reached"), this.__nexusFailureReported = !0);
|
|
122
126
|
return;
|
|
123
127
|
}
|
|
124
|
-
|
|
125
|
-
|
|
128
|
+
if (e - this.__lastInitializationAttempt < this.__initializationRetryDelay)
|
|
129
|
+
return;
|
|
130
|
+
this.__lastInitializationAttempt = e, this.__initializationAttempts++;
|
|
131
|
+
const t = await this.detectAndSetupAnalytics();
|
|
132
|
+
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));
|
|
126
133
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
async detectAndSetupAnalytics() {
|
|
135
|
+
const e = this.detectGTM();
|
|
136
|
+
if (e)
|
|
137
|
+
return this.logger(`GTM detected with container ID: ${e.containerId}`), {
|
|
138
|
+
success: !0,
|
|
139
|
+
method: "GTM",
|
|
140
|
+
dataLayerName: e.dataLayerName
|
|
141
|
+
};
|
|
142
|
+
if (window.dataLayer)
|
|
143
|
+
return this.logger("Existing dataLayer found"), {
|
|
144
|
+
success: !0,
|
|
145
|
+
method: "GA4",
|
|
146
|
+
dataLayerName: "dataLayer"
|
|
147
|
+
};
|
|
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
|
+
}
|
|
158
|
+
return this.setupGA4("dataLayer") ? {
|
|
159
|
+
success: !0,
|
|
160
|
+
method: "GA4",
|
|
161
|
+
dataLayerName: "dataLayer"
|
|
162
|
+
} : {
|
|
163
|
+
success: !1,
|
|
164
|
+
method: "NONE",
|
|
165
|
+
dataLayerName: "dataLayer",
|
|
166
|
+
error: "No analytics setup found and unable to create one"
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
detectGTM() {
|
|
170
|
+
const e = document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');
|
|
171
|
+
for (const t of Array.from(e)) {
|
|
172
|
+
const n = t.getAttribute("src");
|
|
173
|
+
if (n) {
|
|
174
|
+
const i = n.match(/gtm\.js\?id=([^&]+)/);
|
|
175
|
+
if (i) {
|
|
176
|
+
const r = n.match(/&l=([^&]+)/), o = r ? r[1] : "dataLayer";
|
|
177
|
+
return {
|
|
178
|
+
containerId: i[1],
|
|
179
|
+
dataLayerName: o
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
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
|
+
}
|
|
131
195
|
}
|
|
132
196
|
/**
|
|
133
197
|
* Send all events that are in the queue
|
|
134
198
|
* @private
|
|
135
199
|
*/
|
|
136
200
|
async dequeueAndSendEvents() {
|
|
201
|
+
if (!this.__isInitialized || !this.dataLayer)
|
|
202
|
+
return;
|
|
137
203
|
let e = this.__queue.size;
|
|
138
204
|
for (let t = 0; t < e; t++) {
|
|
139
|
-
const n = this.__queue.dequeue(),
|
|
140
|
-
if (n.customParameters && Object.assign(
|
|
205
|
+
const n = this.__queue.dequeue(), i = n.getGa4Parameters(this.solution, this.experienceID);
|
|
206
|
+
if (n.customParameters && Object.assign(i, n.customParameters), JSON.stringify(i).length > 459)
|
|
141
207
|
try {
|
|
142
|
-
let
|
|
143
|
-
|
|
208
|
+
let o = await this.sendGA4LongParameters(i);
|
|
209
|
+
i.epg_event_tag = o;
|
|
144
210
|
} catch {
|
|
145
211
|
}
|
|
146
|
-
|
|
212
|
+
try {
|
|
213
|
+
this.__initializationMethod === "GTM" ? this.sendToGTM(n.eventName, i) : this.__initializationMethod === "GA4" && window.gtag("event", n.eventName, i), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${n.eventName}`);
|
|
214
|
+
} catch (o) {
|
|
215
|
+
this.logger(`Error sending event ${n.eventName}: ${o}`), this.__queue.enqueue(n);
|
|
216
|
+
}
|
|
147
217
|
}
|
|
148
218
|
}
|
|
149
219
|
/**
|
|
@@ -154,11 +224,9 @@ class N {
|
|
|
154
224
|
this.verboseLogging && console.warn(e);
|
|
155
225
|
}
|
|
156
226
|
async sendGA4LongParameters(e) {
|
|
157
|
-
const t = "https://api.myepigraph.com/api/analytics/ga4/custom", n = {
|
|
158
|
-
parameters: e
|
|
159
|
-
};
|
|
227
|
+
const t = "https://api.myepigraph.com/api/analytics/ga4/custom", n = { parameters: e };
|
|
160
228
|
try {
|
|
161
|
-
const
|
|
229
|
+
const i = await fetch(t, {
|
|
162
230
|
method: "POST",
|
|
163
231
|
// Assuming it's a POST request, adjust if necessary
|
|
164
232
|
headers: {
|
|
@@ -167,42 +235,62 @@ class N {
|
|
|
167
235
|
},
|
|
168
236
|
body: JSON.stringify(n)
|
|
169
237
|
});
|
|
170
|
-
|
|
171
|
-
const i = await r.json();
|
|
172
|
-
return i && i.id ? i.id : "";
|
|
173
|
-
} else
|
|
174
|
-
return "";
|
|
238
|
+
return i.ok ? (await i.json())?.id ?? "" : "";
|
|
175
239
|
} catch {
|
|
176
240
|
return "";
|
|
177
241
|
}
|
|
178
242
|
}
|
|
243
|
+
sendToGTM(e, t) {
|
|
244
|
+
this.dataLayer && this.dataLayer.push({
|
|
245
|
+
event: e,
|
|
246
|
+
...t
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
async reportFailureToNexus(e, t) {
|
|
250
|
+
try {
|
|
251
|
+
const n = {
|
|
252
|
+
plugin: "GA4",
|
|
253
|
+
trackingId: this.trackingID,
|
|
254
|
+
solution: this.solution,
|
|
255
|
+
experienceId: this.experienceID,
|
|
256
|
+
failureType: e,
|
|
257
|
+
errorMessage: t,
|
|
258
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
259
|
+
url: window.location.href,
|
|
260
|
+
userAgent: navigator.userAgent
|
|
261
|
+
};
|
|
262
|
+
this.logger(`Failure reported to Nexus: ${JSON.stringify(n)}`);
|
|
263
|
+
} catch (n) {
|
|
264
|
+
this.logger(`Error reporting failure to Nexus: ${n}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
179
267
|
findGA4ScriptInfo(e) {
|
|
180
268
|
const t = document.querySelectorAll("script[src]");
|
|
181
269
|
for (const n of t) {
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
270
|
+
const i = n.getAttribute("src");
|
|
271
|
+
if (i && i.includes(e)) {
|
|
272
|
+
const r = new URL(i, location.href), o = Object.fromEntries(r.searchParams.entries());
|
|
185
273
|
return {
|
|
186
|
-
fullSrc:
|
|
187
|
-
id:
|
|
188
|
-
l:
|
|
274
|
+
fullSrc: r.href,
|
|
275
|
+
id: o.id || void 0,
|
|
276
|
+
l: o.l || void 0
|
|
189
277
|
};
|
|
190
278
|
}
|
|
191
279
|
}
|
|
192
280
|
return null;
|
|
193
281
|
}
|
|
194
282
|
}
|
|
195
|
-
class
|
|
283
|
+
class I {
|
|
196
284
|
constructor({
|
|
197
285
|
trackingID: e,
|
|
198
286
|
experienceID: t,
|
|
199
287
|
solution: n,
|
|
200
|
-
sessionId:
|
|
201
|
-
xPath:
|
|
202
|
-
verboseLogging:
|
|
288
|
+
sessionId: i,
|
|
289
|
+
xPath: r,
|
|
290
|
+
verboseLogging: o = !1,
|
|
203
291
|
sendToStaging: y = !1
|
|
204
292
|
}) {
|
|
205
|
-
this.__status =
|
|
293
|
+
this.__status = u.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 = o, this.__queue = new v(), this.url = y ? "https://nexus.epigraph.dev/api/analytics/event" : "https://api.myepigraph.com/api/analytics/event", this.__status = u.AVAILABLE;
|
|
206
294
|
}
|
|
207
295
|
getStatus() {
|
|
208
296
|
return this.__status;
|
|
@@ -226,7 +314,7 @@ class S {
|
|
|
226
314
|
}
|
|
227
315
|
async sendEvent(e, t) {
|
|
228
316
|
if (this.__queue.enqueue(e), !t) {
|
|
229
|
-
this.__status =
|
|
317
|
+
this.__status = u.RESTRICTED;
|
|
230
318
|
return;
|
|
231
319
|
}
|
|
232
320
|
await this.dequeueAndSendEvents();
|
|
@@ -262,7 +350,7 @@ class S {
|
|
|
262
350
|
return "";
|
|
263
351
|
}
|
|
264
352
|
}
|
|
265
|
-
class
|
|
353
|
+
class N {
|
|
266
354
|
constructor(e) {
|
|
267
355
|
this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = e, this.consent = !1, this.addConsentChangedListener();
|
|
268
356
|
}
|
|
@@ -318,7 +406,7 @@ class a {
|
|
|
318
406
|
return e = Object.assign(e, JSON.parse(JSON.stringify(this.customParameters))), e;
|
|
319
407
|
}
|
|
320
408
|
}
|
|
321
|
-
class
|
|
409
|
+
class C extends a {
|
|
322
410
|
constructor(e = []) {
|
|
323
411
|
super({
|
|
324
412
|
eventName: "epigraph_ar_requested",
|
|
@@ -329,7 +417,7 @@ class L extends a {
|
|
|
329
417
|
});
|
|
330
418
|
}
|
|
331
419
|
}
|
|
332
|
-
class
|
|
420
|
+
class L extends a {
|
|
333
421
|
constructor(e = [], t) {
|
|
334
422
|
super({
|
|
335
423
|
eventName: "epigraph_module_loading",
|
|
@@ -341,7 +429,7 @@ class A extends a {
|
|
|
341
429
|
});
|
|
342
430
|
}
|
|
343
431
|
}
|
|
344
|
-
class
|
|
432
|
+
class S extends a {
|
|
345
433
|
constructor(e = [], t, n) {
|
|
346
434
|
super({
|
|
347
435
|
eventName: "epigraph_module_ready",
|
|
@@ -354,8 +442,8 @@ class x extends a {
|
|
|
354
442
|
});
|
|
355
443
|
}
|
|
356
444
|
}
|
|
357
|
-
class
|
|
358
|
-
constructor(e = [], t, n,
|
|
445
|
+
class x extends a {
|
|
446
|
+
constructor(e = [], t, n, i) {
|
|
359
447
|
super({
|
|
360
448
|
eventName: "epigraph_module_failed",
|
|
361
449
|
interactiveEvent: !1,
|
|
@@ -363,12 +451,12 @@ class I extends a {
|
|
|
363
451
|
items: e,
|
|
364
452
|
is_pre_config: t,
|
|
365
453
|
load_time_ms: n,
|
|
366
|
-
error_type:
|
|
454
|
+
error_type: i
|
|
367
455
|
}
|
|
368
456
|
});
|
|
369
457
|
}
|
|
370
458
|
}
|
|
371
|
-
class
|
|
459
|
+
class T extends a {
|
|
372
460
|
constructor(e = []) {
|
|
373
461
|
super({
|
|
374
462
|
eventName: "epigraph_module_closed",
|
|
@@ -379,7 +467,7 @@ class q extends a {
|
|
|
379
467
|
});
|
|
380
468
|
}
|
|
381
469
|
}
|
|
382
|
-
class
|
|
470
|
+
class z extends a {
|
|
383
471
|
constructor(e = [], t, n = {}) {
|
|
384
472
|
super({
|
|
385
473
|
eventName: "epigraph_support_detected",
|
|
@@ -392,7 +480,7 @@ class T extends a {
|
|
|
392
480
|
});
|
|
393
481
|
}
|
|
394
482
|
}
|
|
395
|
-
class
|
|
483
|
+
class q extends a {
|
|
396
484
|
constructor(e = [], t, n) {
|
|
397
485
|
super({
|
|
398
486
|
eventName: "epigraph_button_click",
|
|
@@ -405,33 +493,33 @@ class b extends a {
|
|
|
405
493
|
});
|
|
406
494
|
}
|
|
407
495
|
}
|
|
408
|
-
class
|
|
409
|
-
constructor(e = [], t, n,
|
|
496
|
+
class G extends a {
|
|
497
|
+
constructor(e = [], t, n, i) {
|
|
410
498
|
super({
|
|
411
499
|
eventName: "epigraph_panel_opened",
|
|
412
500
|
interactiveEvent: t,
|
|
413
501
|
customParameters: {
|
|
414
502
|
items: e,
|
|
415
503
|
panel_type: n,
|
|
416
|
-
trigger_source:
|
|
504
|
+
trigger_source: i
|
|
417
505
|
}
|
|
418
506
|
});
|
|
419
507
|
}
|
|
420
508
|
}
|
|
421
|
-
class
|
|
422
|
-
constructor(e = [], t, n,
|
|
509
|
+
class O extends a {
|
|
510
|
+
constructor(e = [], t, n, i) {
|
|
423
511
|
super({
|
|
424
512
|
eventName: "epigraph_panel_closed",
|
|
425
513
|
interactiveEvent: t,
|
|
426
514
|
customParameters: {
|
|
427
515
|
items: e,
|
|
428
516
|
panel_type: n,
|
|
429
|
-
trigger_source:
|
|
517
|
+
trigger_source: i
|
|
430
518
|
}
|
|
431
519
|
});
|
|
432
520
|
}
|
|
433
521
|
}
|
|
434
|
-
class
|
|
522
|
+
class D extends a {
|
|
435
523
|
constructor(e = []) {
|
|
436
524
|
super({
|
|
437
525
|
eventName: "epigraph_add_to_favourites",
|
|
@@ -442,7 +530,7 @@ class R extends a {
|
|
|
442
530
|
});
|
|
443
531
|
}
|
|
444
532
|
}
|
|
445
|
-
class
|
|
533
|
+
class b extends a {
|
|
446
534
|
constructor(e = [], t) {
|
|
447
535
|
super({
|
|
448
536
|
eventName: "epigraph_keyboard_interaction",
|
|
@@ -454,7 +542,7 @@ class G extends a {
|
|
|
454
542
|
});
|
|
455
543
|
}
|
|
456
544
|
}
|
|
457
|
-
class
|
|
545
|
+
class R extends a {
|
|
458
546
|
constructor(e = [], t) {
|
|
459
547
|
super({
|
|
460
548
|
eventName: "epigraph_touch_interaction",
|
|
@@ -466,21 +554,21 @@ class k extends a {
|
|
|
466
554
|
});
|
|
467
555
|
}
|
|
468
556
|
}
|
|
469
|
-
class
|
|
470
|
-
constructor(e = [], t, n,
|
|
557
|
+
class M extends a {
|
|
558
|
+
constructor(e = [], t, n, i, r) {
|
|
471
559
|
super({
|
|
472
560
|
eventName: "epigraph_item_added",
|
|
473
561
|
interactiveEvent: t,
|
|
474
562
|
customParameters: {
|
|
475
563
|
items: e,
|
|
476
564
|
value: n,
|
|
477
|
-
currency:
|
|
478
|
-
quantity:
|
|
565
|
+
currency: i,
|
|
566
|
+
quantity: r
|
|
479
567
|
}
|
|
480
568
|
});
|
|
481
569
|
}
|
|
482
570
|
}
|
|
483
|
-
class
|
|
571
|
+
class $ extends a {
|
|
484
572
|
constructor(e = []) {
|
|
485
573
|
super({
|
|
486
574
|
eventName: "epigraph_item_moved",
|
|
@@ -491,7 +579,7 @@ class U extends a {
|
|
|
491
579
|
});
|
|
492
580
|
}
|
|
493
581
|
}
|
|
494
|
-
class
|
|
582
|
+
class k extends a {
|
|
495
583
|
constructor(e = [], t, n) {
|
|
496
584
|
super({
|
|
497
585
|
eventName: "epigraph_item_removed",
|
|
@@ -504,7 +592,7 @@ class B extends a {
|
|
|
504
592
|
});
|
|
505
593
|
}
|
|
506
594
|
}
|
|
507
|
-
class
|
|
595
|
+
class j extends a {
|
|
508
596
|
constructor(e = [], t) {
|
|
509
597
|
super({
|
|
510
598
|
eventName: "epigraph_variant_changed",
|
|
@@ -516,7 +604,7 @@ class M extends a {
|
|
|
516
604
|
});
|
|
517
605
|
}
|
|
518
606
|
}
|
|
519
|
-
class
|
|
607
|
+
class U extends a {
|
|
520
608
|
constructor(e = [], t, n) {
|
|
521
609
|
super({
|
|
522
610
|
eventName: "epigraph_content_shared",
|
|
@@ -529,7 +617,7 @@ class $ extends a {
|
|
|
529
617
|
});
|
|
530
618
|
}
|
|
531
619
|
}
|
|
532
|
-
class
|
|
620
|
+
class F extends a {
|
|
533
621
|
constructor(e = [], t, n) {
|
|
534
622
|
super({
|
|
535
623
|
eventName: "epigraph_checkout",
|
|
@@ -542,7 +630,7 @@ class z extends a {
|
|
|
542
630
|
});
|
|
543
631
|
}
|
|
544
632
|
}
|
|
545
|
-
class
|
|
633
|
+
class B extends a {
|
|
546
634
|
constructor(e = [], t, n) {
|
|
547
635
|
super({
|
|
548
636
|
eventName: "epigraph_conversion",
|
|
@@ -555,7 +643,7 @@ class J extends a {
|
|
|
555
643
|
});
|
|
556
644
|
}
|
|
557
645
|
}
|
|
558
|
-
class
|
|
646
|
+
class J extends a {
|
|
559
647
|
constructor(e = [], t) {
|
|
560
648
|
super({
|
|
561
649
|
eventName: "epigraph_changeRate",
|
|
@@ -567,7 +655,7 @@ class V extends a {
|
|
|
567
655
|
});
|
|
568
656
|
}
|
|
569
657
|
}
|
|
570
|
-
class
|
|
658
|
+
class V extends a {
|
|
571
659
|
constructor(e = [], t) {
|
|
572
660
|
super({
|
|
573
661
|
eventName: "epigraph_completionRate",
|
|
@@ -591,6 +679,15 @@ class H extends a {
|
|
|
591
679
|
});
|
|
592
680
|
}
|
|
593
681
|
}
|
|
682
|
+
class X extends a {
|
|
683
|
+
constructor(e, t, n) {
|
|
684
|
+
super({
|
|
685
|
+
eventName: e,
|
|
686
|
+
interactiveEvent: t,
|
|
687
|
+
customParameters: n
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
}
|
|
594
691
|
/**
|
|
595
692
|
* @license
|
|
596
693
|
* Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
|
|
@@ -610,7 +707,7 @@ class H extends a {
|
|
|
610
707
|
var f;
|
|
611
708
|
const c = Symbol("analyticsPluginsMap");
|
|
612
709
|
f = c;
|
|
613
|
-
class
|
|
710
|
+
class K {
|
|
614
711
|
constructor(e, t) {
|
|
615
712
|
this[f] = /* @__PURE__ */ new Map(), this.__consentPlugin = null, e && t && (this.__consentPlugin = this.buildConsentPlugin(e, t)), window.addEventListener("epigraphAnalyticsConsentChange", this.__onConsentChangeFromEvent);
|
|
616
713
|
}
|
|
@@ -618,7 +715,7 @@ class X {
|
|
|
618
715
|
let t = e;
|
|
619
716
|
this.__overrideConsent = t.detail.hasConsent;
|
|
620
717
|
for (const n of this[c].values())
|
|
621
|
-
this.__hasConsent() || n.setStatus(
|
|
718
|
+
this.__hasConsent() || n.setStatus(u.RESTRICTED);
|
|
622
719
|
}
|
|
623
720
|
/**
|
|
624
721
|
* Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
|
|
@@ -660,35 +757,36 @@ class X {
|
|
|
660
757
|
* @private
|
|
661
758
|
*/
|
|
662
759
|
buildConsentPlugin(e, t) {
|
|
663
|
-
return e.toLowerCase() === E.OneTrust.toLowerCase() ? new
|
|
760
|
+
return e.toLowerCase() === E.OneTrust.toLowerCase() ? new N(t) : null;
|
|
664
761
|
}
|
|
665
762
|
}
|
|
666
763
|
export {
|
|
667
764
|
E as ConsentPluginNames,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
765
|
+
D as EpigraphAddToFavouritesEvent,
|
|
766
|
+
K as EpigraphAnalytics,
|
|
767
|
+
C as EpigraphArRequestedEvent,
|
|
768
|
+
q as EpigraphButtonClickEvent,
|
|
769
|
+
J as EpigraphChangeRateEvent,
|
|
770
|
+
F as EpigraphCheckoutEvent,
|
|
771
|
+
V as EpigraphCompletionRateEvent,
|
|
772
|
+
U as EpigraphContentSharedEvent,
|
|
773
|
+
B as EpigraphConversionEvent,
|
|
774
|
+
X as EpigraphCustomEvent,
|
|
677
775
|
H as EpigraphEngagementRateEvent,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
776
|
+
M as EpigraphItemAddedEvent,
|
|
777
|
+
$ as EpigraphItemMovedEvent,
|
|
778
|
+
k as EpigraphItemRemovedEvent,
|
|
779
|
+
b as EpigraphKeyboardInteractionEvent,
|
|
780
|
+
T as EpigraphModuleClosedEvent,
|
|
781
|
+
x as EpigraphModuleFailedEvent,
|
|
782
|
+
L as EpigraphModuleLoadingEvent,
|
|
783
|
+
S as EpigraphModuleReadyEvent,
|
|
784
|
+
O as EpigraphPanelClosedEvent,
|
|
785
|
+
G as EpigraphPanelOpenedEvent,
|
|
786
|
+
z as EpigraphSupportDetectedEvent,
|
|
787
|
+
R as EpigraphTouchInteractionEvent,
|
|
788
|
+
j as EpigraphVariantChangedEvent,
|
|
789
|
+
P as GA4AnalyticsPlugin,
|
|
790
|
+
I as NexusAnalyticsPlugin,
|
|
791
|
+
N as OneTrustConsentPlugin
|
|
694
792
|
};
|
|
@@ -87,4 +87,7 @@ export declare class EpigraphCompletionRateEvent extends BaseAnalyticsEvent {
|
|
|
87
87
|
export declare class EpigraphEngagementRateEvent extends BaseAnalyticsEvent {
|
|
88
88
|
constructor(items: IAnalyticsParameterItems | undefined, value: number);
|
|
89
89
|
}
|
|
90
|
+
export declare class EpigraphCustomEvent extends BaseAnalyticsEvent {
|
|
91
|
+
constructor(eventName: string, interactiveEvent: boolean, customParameters: Record<string, unknown>);
|
|
92
|
+
}
|
|
90
93
|
export {};
|
|
@@ -3,6 +3,9 @@ import { IAnalyticsEvent } from '../analytics-event-interface';
|
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
5
5
|
[key: string]: any;
|
|
6
|
+
gtag?: (...args: any[]) => void;
|
|
7
|
+
dataLayer?: Array<Record<string, any>>;
|
|
8
|
+
epgDataLayerName?: string;
|
|
6
9
|
}
|
|
7
10
|
}
|
|
8
11
|
export declare class GA4AnalyticsPlugin implements IAnalyticsPlugin {
|
|
@@ -12,11 +15,18 @@ export declare class GA4AnalyticsPlugin implements IAnalyticsPlugin {
|
|
|
12
15
|
solution: string;
|
|
13
16
|
experienceID: string;
|
|
14
17
|
verboseLogging: boolean;
|
|
15
|
-
dataLayer: Array<Record<string, any
|
|
16
|
-
dataLayerName: string
|
|
18
|
+
dataLayer: Array<Record<string, any>> | undefined;
|
|
19
|
+
dataLayerName: string;
|
|
17
20
|
private __queue;
|
|
18
21
|
private __status;
|
|
19
22
|
private __sentEventCount;
|
|
23
|
+
private __initializationAttempts;
|
|
24
|
+
private __lastInitializationAttempt;
|
|
25
|
+
private __maxInitializationAttempts;
|
|
26
|
+
private __initializationRetryDelay;
|
|
27
|
+
private __isInitialized;
|
|
28
|
+
private __initializationMethod;
|
|
29
|
+
private __nexusFailureReported;
|
|
20
30
|
constructor({ trackingID, experienceID, solution, verboseLogging }: {
|
|
21
31
|
trackingID: string;
|
|
22
32
|
experienceID: string;
|
|
@@ -37,11 +47,13 @@ export declare class GA4AnalyticsPlugin implements IAnalyticsPlugin {
|
|
|
37
47
|
* This function will send an Event to Google Analytics 4.
|
|
38
48
|
*
|
|
39
49
|
* @param eventData IAnalyticsEvent The event to be tracked
|
|
40
|
-
* @param
|
|
50
|
+
* @param consent boolean Whether consent is granted
|
|
41
51
|
*/
|
|
42
52
|
sendEvent(analyticsEvent: IAnalyticsEvent, consent: boolean): Promise<void>;
|
|
43
|
-
private
|
|
44
|
-
private
|
|
53
|
+
private initializePlugin;
|
|
54
|
+
private detectAndSetupAnalytics;
|
|
55
|
+
private detectGTM;
|
|
56
|
+
private setupGA4;
|
|
45
57
|
/**
|
|
46
58
|
* Send all events that are in the queue
|
|
47
59
|
* @private
|
|
@@ -53,5 +65,7 @@ export declare class GA4AnalyticsPlugin implements IAnalyticsPlugin {
|
|
|
53
65
|
*/
|
|
54
66
|
private logger;
|
|
55
67
|
private sendGA4LongParameters;
|
|
68
|
+
private sendToGTM;
|
|
69
|
+
private reportFailureToNexus;
|
|
56
70
|
private findGA4ScriptInfo;
|
|
57
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./Epigraph/epigraph.cjs"),E=require("./Epigraph/epigraphBaseSolutions.cjs"),e=require("./EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.cjs"),r=require("./EpigraphLibs/EpigraphLogger/epigraphLogger.cjs"),p=require("./EpigraphLibs/EpigraphNexusApi/epigraphNexusApi.cjs"),g=require("./EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./Epigraph/epigraph.cjs"),E=require("./Epigraph/epigraphBaseSolutions.cjs"),e=require("./EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.cjs"),r=require("./EpigraphLibs/EpigraphLogger/epigraphLogger.cjs"),p=require("./EpigraphLibs/EpigraphNexusApi/epigraphNexusApi.cjs"),g=require("./EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.cjs"),t=require("./EpigraphLibs/EpigraphResultFactory/epigraphResultFactory.cjs"),i=require("./EpigraphLibs/EpigraphUnitsConverter/epigraphUnitsConverter.cjs"),a=require("./EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.cjs");exports.ENVIRONMENT_TYPE=n.ENVIRONMENT_TYPE;exports.Epigraph=n.Epigraph;exports.EpigraphBaseSolutionHtmlElement=E.EpigraphBaseSolutionHtmlElement;exports.EpigraphBaseSolutionLitElement=E.EpigraphBaseSolutionLitElement;exports.ConsentPluginNames=e.ConsentPluginNames;exports.EpigraphAddToFavouritesEvent=e.EpigraphAddToFavouritesEvent;exports.EpigraphAnalytics=e.EpigraphAnalytics;exports.EpigraphArRequestedEvent=e.EpigraphArRequestedEvent;exports.EpigraphButtonClickEvent=e.EpigraphButtonClickEvent;exports.EpigraphChangeRateEvent=e.EpigraphChangeRateEvent;exports.EpigraphCheckoutEvent=e.EpigraphCheckoutEvent;exports.EpigraphCompletionRateEvent=e.EpigraphCompletionRateEvent;exports.EpigraphContentSharedEvent=e.EpigraphContentSharedEvent;exports.EpigraphConversionEvent=e.EpigraphConversionEvent;exports.EpigraphCustomEvent=e.EpigraphCustomEvent;exports.EpigraphEngagementRateEvent=e.EpigraphEngagementRateEvent;exports.EpigraphItemAddedEvent=e.EpigraphItemAddedEvent;exports.EpigraphItemMovedEvent=e.EpigraphItemMovedEvent;exports.EpigraphItemRemovedEvent=e.EpigraphItemRemovedEvent;exports.EpigraphKeyboardInteractionEvent=e.EpigraphKeyboardInteractionEvent;exports.EpigraphModuleClosedEvent=e.EpigraphModuleClosedEvent;exports.EpigraphModuleFailedEvent=e.EpigraphModuleFailedEvent;exports.EpigraphModuleLoadingEvent=e.EpigraphModuleLoadingEvent;exports.EpigraphModuleReadyEvent=e.EpigraphModuleReadyEvent;exports.EpigraphPanelClosedEvent=e.EpigraphPanelClosedEvent;exports.EpigraphPanelOpenedEvent=e.EpigraphPanelOpenedEvent;exports.EpigraphSupportDetectedEvent=e.EpigraphSupportDetectedEvent;exports.EpigraphTouchInteractionEvent=e.EpigraphTouchInteractionEvent;exports.EpigraphVariantChangedEvent=e.EpigraphVariantChangedEvent;exports.GA4AnalyticsPlugin=e.GA4AnalyticsPlugin;exports.NexusAnalyticsPlugin=e.NexusAnalyticsPlugin;exports.OneTrustConsentPlugin=e.OneTrustConsentPlugin;exports.EpigraphLogger=r.EpigraphLogger;exports.LogTypes=r.LogTypes;exports.LoggerModeNames=r.LoggerModeNames;exports.EpigraphNexusAPI=p.EpigraphNexusAPI;exports.HTTPMethod=p.HTTPMethod;exports.NexusAPIResourceIdentifier=p.NexusAPIResourceIdentifier;exports.NexusAPIRoutes=p.NexusAPIRoutes;exports.NexusAPIVersions=p.NexusAPIVersions;exports.NexusEndpoints=p.NexusEndpoints;exports.EpigraphQrCodeGenerator=g.EpigraphQrCodeGenerator;exports.Result=t.Result;exports.failureResult=t.failureResult;exports.successResult=t.successResult;exports.Distance=i.Distance;exports.DistanceUnits=i.DistanceUnits;exports.UnitTypes=i.UnitTypes;exports.EpigraphUrlProcessor=a.EpigraphUrlProcessor;exports.QUERY_PARAMETER_ACTION_NAMES=a.QUERY_PARAMETER_ACTION_NAMES;exports.QUERY_PARAMETER_NAMES=a.QUERY_PARAMETER_NAMES;
|
package/dist/epigraph-std-lib.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ENVIRONMENT_TYPE as p, Epigraph as r } from "./Epigraph/epigraph.js";
|
|
2
2
|
import { EpigraphBaseSolutionHtmlElement as n, EpigraphBaseSolutionLitElement as o } from "./Epigraph/epigraphBaseSolutions.js";
|
|
3
|
-
import { ConsentPluginNames as i, EpigraphAddToFavouritesEvent as g, EpigraphAnalytics as s, EpigraphArRequestedEvent as h, EpigraphButtonClickEvent as u, EpigraphChangeRateEvent as l, EpigraphCheckoutEvent as d, EpigraphCompletionRateEvent as v, EpigraphContentSharedEvent as m, EpigraphConversionEvent as A,
|
|
4
|
-
import { EpigraphLogger as
|
|
5
|
-
import { EpigraphNexusAPI as
|
|
6
|
-
import { EpigraphQrCodeGenerator as
|
|
7
|
-
import { Result as
|
|
8
|
-
import { Distance as
|
|
9
|
-
import { EpigraphUrlProcessor as
|
|
3
|
+
import { ConsentPluginNames as i, EpigraphAddToFavouritesEvent as g, EpigraphAnalytics as s, EpigraphArRequestedEvent as h, EpigraphButtonClickEvent as u, EpigraphChangeRateEvent as l, EpigraphCheckoutEvent as d, EpigraphCompletionRateEvent as v, EpigraphContentSharedEvent as m, EpigraphConversionEvent as A, EpigraphCustomEvent as R, EpigraphEngagementRateEvent as c, EpigraphItemAddedEvent as x, EpigraphItemMovedEvent as P, EpigraphItemRemovedEvent as C, EpigraphKeyboardInteractionEvent as N, EpigraphModuleClosedEvent as I, EpigraphModuleFailedEvent as M, EpigraphModuleLoadingEvent as T, EpigraphModuleReadyEvent as f, EpigraphPanelClosedEvent as y, EpigraphPanelOpenedEvent as S, EpigraphSupportDetectedEvent as _, EpigraphTouchInteractionEvent as L, EpigraphVariantChangedEvent as U, GA4AnalyticsPlugin as O, NexusAnalyticsPlugin as B, OneTrustConsentPlugin as D } from "./EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.js";
|
|
4
|
+
import { EpigraphLogger as V, LogTypes as Y, LoggerModeNames as k } from "./EpigraphLibs/EpigraphLogger/epigraphLogger.js";
|
|
5
|
+
import { EpigraphNexusAPI as G, HTTPMethod as H, NexusAPIResourceIdentifier as b, NexusAPIRoutes as q, NexusAPIVersions as K, NexusEndpoints as j } from "./EpigraphLibs/EpigraphNexusApi/epigraphNexusApi.js";
|
|
6
|
+
import { EpigraphQrCodeGenerator as z } from "./EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.js";
|
|
7
|
+
import { Result as W, failureResult as X, successResult as Z } from "./EpigraphLibs/EpigraphResultFactory/epigraphResultFactory.js";
|
|
8
|
+
import { Distance as ee, DistanceUnits as te, UnitTypes as pe } from "./EpigraphLibs/EpigraphUnitsConverter/epigraphUnitsConverter.js";
|
|
9
|
+
import { EpigraphUrlProcessor as Ee, QUERY_PARAMETER_ACTION_NAMES as ne, QUERY_PARAMETER_NAMES as oe } from "./EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.js";
|
|
10
10
|
export {
|
|
11
11
|
i as ConsentPluginNames,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
ee as Distance,
|
|
13
|
+
te as DistanceUnits,
|
|
14
14
|
p as ENVIRONMENT_TYPE,
|
|
15
15
|
r as Epigraph,
|
|
16
16
|
g as EpigraphAddToFavouritesEvent,
|
|
@@ -24,38 +24,39 @@ export {
|
|
|
24
24
|
v as EpigraphCompletionRateEvent,
|
|
25
25
|
m as EpigraphContentSharedEvent,
|
|
26
26
|
A as EpigraphConversionEvent,
|
|
27
|
-
R as
|
|
28
|
-
c as
|
|
29
|
-
x as
|
|
30
|
-
P as
|
|
27
|
+
R as EpigraphCustomEvent,
|
|
28
|
+
c as EpigraphEngagementRateEvent,
|
|
29
|
+
x as EpigraphItemAddedEvent,
|
|
30
|
+
P as EpigraphItemMovedEvent,
|
|
31
|
+
C as EpigraphItemRemovedEvent,
|
|
31
32
|
N as EpigraphKeyboardInteractionEvent,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
33
|
+
V as EpigraphLogger,
|
|
34
|
+
I as EpigraphModuleClosedEvent,
|
|
35
|
+
M as EpigraphModuleFailedEvent,
|
|
36
|
+
T as EpigraphModuleLoadingEvent,
|
|
37
|
+
f as EpigraphModuleReadyEvent,
|
|
38
|
+
G as EpigraphNexusAPI,
|
|
39
|
+
y as EpigraphPanelClosedEvent,
|
|
40
|
+
S as EpigraphPanelOpenedEvent,
|
|
41
|
+
z as EpigraphQrCodeGenerator,
|
|
42
|
+
_ as EpigraphSupportDetectedEvent,
|
|
43
|
+
L as EpigraphTouchInteractionEvent,
|
|
44
|
+
Ee as EpigraphUrlProcessor,
|
|
45
|
+
U as EpigraphVariantChangedEvent,
|
|
46
|
+
O as GA4AnalyticsPlugin,
|
|
47
|
+
H as HTTPMethod,
|
|
48
|
+
Y as LogTypes,
|
|
49
|
+
k as LoggerModeNames,
|
|
50
|
+
b as NexusAPIResourceIdentifier,
|
|
51
|
+
q as NexusAPIRoutes,
|
|
52
|
+
K as NexusAPIVersions,
|
|
53
|
+
B as NexusAnalyticsPlugin,
|
|
54
|
+
j as NexusEndpoints,
|
|
55
|
+
D as OneTrustConsentPlugin,
|
|
56
|
+
ne as QUERY_PARAMETER_ACTION_NAMES,
|
|
57
|
+
oe as QUERY_PARAMETER_NAMES,
|
|
58
|
+
W as Result,
|
|
59
|
+
pe as UnitTypes,
|
|
60
|
+
X as failureResult,
|
|
61
|
+
Z as successResult
|
|
61
62
|
};
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@epigraph/epigraph-std-lib",
|
|
3
|
-
"version": "4.5.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/epigraph-std-lib.cjs",
|
|
6
|
-
"module": "./dist/epigraph-std-lib.js",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"dist/**/*"
|
|
10
|
-
],
|
|
11
|
-
"types": "./dist/epigraph-std-lib.d.ts",
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"types": "./dist/epigraph-std-lib.d.ts",
|
|
15
|
-
"import": "./dist/epigraph-std-lib.js",
|
|
16
|
-
"require": "./dist/epigraph-std-lib.cjs"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "vite",
|
|
21
|
-
"build": "tsc -b ./tsconfig.lib.json && vite build",
|
|
22
|
-
"preview": "vite preview",
|
|
23
|
-
"prepublishOnly": "npm run build",
|
|
24
|
-
"test": "npm run build && vitest"
|
|
25
|
-
},
|
|
26
|
-
"dependencies": {},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"lit": "^3.2.1",
|
|
29
|
-
"qr-creator": "^1.0.0"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/node": "^22.13.0",
|
|
33
|
-
"happy-dom": "^16.8.1",
|
|
34
|
-
"typescript": "^5.8.2",
|
|
35
|
-
"vite": "^6.0.5",
|
|
36
|
-
"vite-plugin-dts": "^4.5.0",
|
|
37
|
-
"vitest": "^3.0.5",
|
|
38
|
-
"@types/google.analytics": "^0.0.42",
|
|
39
|
-
"@types/gtag.js": "^0.0.20"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@epigraph/epigraph-std-lib",
|
|
3
|
+
"version": "4.5.2-alpha",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/epigraph-std-lib.cjs",
|
|
6
|
+
"module": "./dist/epigraph-std-lib.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"dist/**/*"
|
|
10
|
+
],
|
|
11
|
+
"types": "./dist/epigraph-std-lib.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/epigraph-std-lib.d.ts",
|
|
15
|
+
"import": "./dist/epigraph-std-lib.js",
|
|
16
|
+
"require": "./dist/epigraph-std-lib.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "tsc -b ./tsconfig.lib.json && vite build",
|
|
22
|
+
"preview": "vite preview",
|
|
23
|
+
"prepublishOnly": "npm run build",
|
|
24
|
+
"test": "npm run build && vitest"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"lit": "^3.2.1",
|
|
29
|
+
"qr-creator": "^1.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.13.0",
|
|
33
|
+
"happy-dom": "^16.8.1",
|
|
34
|
+
"typescript": "^5.8.2",
|
|
35
|
+
"vite": "^6.0.5",
|
|
36
|
+
"vite-plugin-dts": "^4.5.0",
|
|
37
|
+
"vitest": "^3.0.5",
|
|
38
|
+
"@types/google.analytics": "^0.0.42",
|
|
39
|
+
"@types/gtag.js": "^0.0.20"
|
|
40
|
+
}
|
|
41
|
+
}
|