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