@epigraph/epigraph-std-lib 4.4.0 → 4.5.0-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.
@@ -1,32 +1,33 @@
1
- const d = Symbol("data"), u = Symbol("next"), v = class y {
1
+ var o = /* @__PURE__ */ ((s) => (s.UNAVAILABLE = "unavailable", s.AVAILABLE = "available", s.RESTRICTED = "restricted", s))(o || {});
2
+ const l = Symbol("data"), d = Symbol("next"), P = class m {
2
3
  constructor(e) {
3
- this[d] = e, this[u] = null;
4
+ this[l] = e, this[d] = null;
4
5
  }
5
6
  get data() {
6
- return this[d];
7
+ return this[l];
7
8
  }
8
9
  set next(e) {
9
- if (!(e instanceof y) && e !== null)
10
+ if (!(e instanceof m) && e !== null)
10
11
  throw new Error(
11
12
  "This node is not an instance of the custom class 'Node'."
12
13
  );
13
- this[u] = e;
14
+ this[d] = e;
14
15
  }
15
16
  get next() {
16
- return this[u];
17
+ return this[d];
17
18
  }
18
19
  };
19
- let g = v;
20
- const h = Symbol("head");
21
- class m {
20
+ let g = P;
21
+ const p = Symbol("head");
22
+ class C {
22
23
  constructor() {
23
- this[h] = null;
24
+ this[p] = null;
24
25
  }
25
26
  set head(e) {
26
- this[h] = e;
27
+ this[p] = e;
27
28
  }
28
29
  get head() {
29
- return this[h];
30
+ return this[p];
30
31
  }
31
32
  addToTail(e) {
32
33
  let t = this.head;
@@ -43,168 +44,106 @@ class m {
43
44
  return this.head = e.next, e.data;
44
45
  }
45
46
  }
46
- const f = Symbol("queue"), o = Symbol("size");
47
- class l {
47
+ const v = Symbol("queue"), h = Symbol("size");
48
+ class _ {
48
49
  constructor() {
49
- this[f] = new m(), this[o] = 0;
50
+ this[v] = new C(), this[h] = 0;
50
51
  }
51
52
  get queue() {
52
- return this[f];
53
+ return this[v];
53
54
  }
54
55
  get size() {
55
- return this[o];
56
+ return this[h];
56
57
  }
57
58
  enqueue(e) {
58
- this.queue.addToTail(e), this[o]++;
59
+ this.queue.addToTail(e), this[h]++;
59
60
  }
60
61
  dequeue() {
61
62
  const e = this.queue.removeHead();
62
- return this[o]--, e;
63
+ return this[h]--, e;
63
64
  }
64
65
  }
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;
66
+ class N {
67
+ constructor({
68
+ trackingID: e,
69
+ experienceID: t,
70
+ solution: n,
71
+ verboseLogging: r = !1
72
+ }) {
73
+ 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);
68
74
  }
69
- /**
70
- * This function will send an Event to GA3.
71
- *
72
- * @param eventData AnalyticsEvent The event to be tracked
73
- */
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);
80
- }
81
- else
82
- this.logger("Cannot send Google Analytics 3 event: ga function is not defined.");
83
- return !0;
75
+ getStatus() {
76
+ return this.__status;
84
77
  }
85
- /**
86
- * Send all events that are in the queue
87
- * @private
88
- */
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}`);
102
- }
103
- } else
104
- this.logger("Cannot sent Google Analytics 3 event: tracker was not created.");
78
+ setStatus(e) {
79
+ this.__status = e;
105
80
  }
106
- /**
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
- *
112
- * @private
113
- */
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.");
81
+ getPendingEventCount() {
82
+ return this.__queue.size;
127
83
  }
128
- /**
129
- * Checks if verboseLogging is enabled, then logs the error
130
- * @param err
131
- */
132
- logger(e) {
133
- this.verboseLogging && console.warn(e);
84
+ getSentEventCount() {
85
+ return this.__sentEventCount;
86
+ }
87
+ getTotalEventCount() {
88
+ return this.getPendingEventCount() + this.getSentEventCount();
134
89
  }
135
90
  /**
136
91
  * Returns a unique plugin identifier so that tracking ID's can be the same across multiple plugins.
137
92
  */
138
93
  getUniquePluginIdentifier() {
139
- return this.pluginName + "-" + this.trackingID;
94
+ return `${this.name}-${this.trackingID}`;
140
95
  }
141
96
  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 }));
97
+ this.dataLayer !== void 0 && this.dequeueAndSendEvents();
161
98
  }
162
99
  /**
163
- * This function will send an Event to GA3.
100
+ * This function will send an Event to Google Analytics 4.
164
101
  *
165
- * @param eventData AnalyticsEvent The event to be tracked
102
+ * @param eventData IAnalyticsEvent The event to be tracked
166
103
  * @param consentPlugin
167
104
  */
168
105
  async sendEvent(e, t) {
169
- this.queue.enqueue(e);
170
- let n = !0;
171
- if (t && (n = t.hasConsent()), this.dataLayer !== void 0 && n)
106
+ if (this.__queue.enqueue(e), !t) {
107
+ this.__status = o.RESTRICTED;
108
+ return;
109
+ }
110
+ if (this.dataLayer !== void 0)
172
111
  try {
173
112
  await this.dequeueAndSendEvents();
174
- } catch (s) {
175
- this.logger(s);
113
+ } catch (n) {
114
+ this.logger(n);
176
115
  }
177
116
  else
178
117
  this.logger("Cannot send Google Analytics 4 event: dataLayer is not defined.");
179
118
  }
119
+ setupDataLayer() {
120
+ if (this.dataLayer) {
121
+ this.__status = o.AVAILABLE;
122
+ return;
123
+ }
124
+ const t = this.findGA4ScriptInfo(this.trackingID)?.l;
125
+ t && (this.dataLayerName = t, this.dataLayer = window[t]);
126
+ }
127
+ initGtag(e = "dataLayer", t) {
128
+ window.epgDataLayerName = e, typeof window.gtag != "function" && (window.gtag = function() {
129
+ window[window.epgDataLayerName].push(arguments);
130
+ }, window.gtag("js", /* @__PURE__ */ new Date()), window.gtag("config", t, { send_page_view: !1 }));
131
+ }
180
132
  /**
181
133
  * Send all events that are in the queue
182
134
  * @private
183
135
  */
184
136
  async dequeueAndSendEvents() {
185
- let e = this.queue.size;
137
+ let e = this.__queue.size;
186
138
  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: ""
194
- };
195
- if ("parameters" in n && Object.assign(s, n.parameters), JSON.stringify(s).length > 459)
139
+ const n = this.__queue.dequeue(), r = n.getGa4Parameters(this.solution, this.experienceID);
140
+ if (n.customParameters && Object.assign(r, n.customParameters), JSON.stringify(r).length > 459)
196
141
  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
- };
142
+ let u = await this.sendGA4LongParameters(r);
143
+ r.epg_event_tag = u;
205
144
  } catch {
206
145
  }
207
- gtag("event", n.action, s), this.logger(`Google Analytics 4 event successfully sent: ${n.action}`);
146
+ gtag("event", n.eventName, r), this.__sentEventCount++, this.logger(`Google Analytics 4 event successfully sent: ${n.eventName}`);
208
147
  }
209
148
  }
210
149
  /**
@@ -214,21 +153,12 @@ class I {
214
153
  logger(e) {
215
154
  this.verboseLogging && console.warn(e);
216
155
  }
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
- }
226
156
  async sendGA4LongParameters(e) {
227
157
  const t = "https://api.myepigraph.com/api/analytics/ga4/custom", n = {
228
158
  parameters: e
229
159
  };
230
160
  try {
231
- const s = await fetch(t, {
161
+ const r = await fetch(t, {
232
162
  method: "POST",
233
163
  // Assuming it's a POST request, adjust if necessary
234
164
  headers: {
@@ -237,9 +167,9 @@ class I {
237
167
  },
238
168
  body: JSON.stringify(n)
239
169
  });
240
- if (s.ok) {
241
- const a = await s.json();
242
- return a && a.id ? a.id : "";
170
+ if (r.ok) {
171
+ const i = await r.json();
172
+ return i && i.id ? i.id : "";
243
173
  } else
244
174
  return "";
245
175
  } catch {
@@ -249,34 +179,67 @@ class I {
249
179
  findGA4ScriptInfo(e) {
250
180
  const t = document.querySelectorAll("script[src]");
251
181
  for (const n of t) {
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());
182
+ const r = n.getAttribute("src");
183
+ if (r && r.includes(e)) {
184
+ const i = new URL(r, location.href), u = Object.fromEntries(i.searchParams.entries());
255
185
  return {
256
- fullSrc: a.href,
257
- id: r.id || void 0,
258
- l: r.l || void 0
186
+ fullSrc: i.href,
187
+ id: u.id || void 0,
188
+ l: u.l || void 0
259
189
  };
260
190
  }
261
191
  }
262
192
  return null;
263
193
  }
264
194
  }
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";
195
+ class S {
196
+ constructor({
197
+ trackingID: e,
198
+ experienceID: t,
199
+ solution: n,
200
+ sessionId: r,
201
+ xPath: i,
202
+ verboseLogging: u = !1,
203
+ sendToStaging: y = !1
204
+ }) {
205
+ 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 = y ? "https://nexus.epigraph.dev/api/analytics/event" : "https://api.myepigraph.com/api/analytics/event", this.__status = o.AVAILABLE;
206
+ }
207
+ getStatus() {
208
+ return this.__status;
209
+ }
210
+ setStatus(e) {
211
+ this.__status = e;
212
+ }
213
+ getPendingEventCount() {
214
+ return this.__queue.size;
215
+ }
216
+ getSentEventCount() {
217
+ return this.__sentEventCount;
218
+ }
219
+ getTotalEventCount() {
220
+ return this.getPendingEventCount() + this.getSentEventCount();
221
+ }
222
+ getUniquePluginIdentifier() {
223
+ return this.name + "-" + this.trackingID;
224
+ }
225
+ setupPlugin() {
268
226
  }
269
227
  async sendEvent(e, t) {
270
- this.queue.enqueue(e);
271
- let n = !0;
272
- t && (n = t.hasConsent()), n && await this.dequeueAndSendEvents();
228
+ if (this.__queue.enqueue(e), !t) {
229
+ this.__status = o.RESTRICTED;
230
+ return;
231
+ }
232
+ await this.dequeueAndSendEvents();
273
233
  }
274
234
  async dequeueAndSendEvents() {
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
235
+ for (let e = 0; e < this.__queue.size; e++) {
236
+ const t = this.__queue.dequeue();
237
+ t.customParameters.solution = this.solution;
238
+ const n = {
239
+ trackingID: this.trackingID,
240
+ experience_id: this.experienceID,
241
+ action: t.eventName,
242
+ parameters: t.getNexusParameters()
280
243
  };
281
244
  try {
282
245
  return (await fetch(this.url, {
@@ -290,20 +253,16 @@ class A {
290
253
  Origin: typeof window < "u" ? window.location.origin : ""
291
254
  },
292
255
  body: JSON.stringify(n)
293
- })).status === 204, "";
256
+ })).status === 200, "";
294
257
  } catch {
295
258
  return "";
296
259
  }
260
+ this.__sentEventCount++;
297
261
  }
298
262
  return "";
299
263
  }
300
- getUniquePluginIdentifier() {
301
- return this.name + "-" + this.trackingID;
302
- }
303
- setupPlugin() {
304
- }
305
264
  }
306
- class q {
265
+ class w {
307
266
  constructor(e) {
308
267
  this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = e, this.consent = !1, this.addConsentChangedListener();
309
268
  }
@@ -313,8 +272,8 @@ class q {
313
272
  hasConsent() {
314
273
  if (this.consentSet)
315
274
  return this.consent;
316
- if (window.OnetrustActiveGroup !== void 0) {
317
- let e = window.OnetrustActiveGroup;
275
+ if (window.OnetrustActiveGroups !== void 0) {
276
+ let e = window.OnetrustActiveGroups;
318
277
  e !== void 0 && e.split(",").forEach((n) => {
319
278
  n === this.consentIdentifier && (this.consent = !0, this.consentSet = !0);
320
279
  });
@@ -329,7 +288,309 @@ class q {
329
288
  });
330
289
  }
331
290
  }
332
- var p = /* @__PURE__ */ ((i) => (i.OneTrust = "onetrust", i))(p || {});
291
+ var E = /* @__PURE__ */ ((s) => (s.OneTrust = "onetrust", s))(E || {});
292
+ class a {
293
+ constructor({
294
+ eventName: e,
295
+ interactiveEvent: t,
296
+ customParameters: n
297
+ }) {
298
+ this.eventName = e, this.interactiveEvent = t, this.customParameters = n;
299
+ }
300
+ getGa4Parameters(e, t) {
301
+ let n = {
302
+ solution: e,
303
+ experience_id: t,
304
+ interactive_event: this.interactiveEvent,
305
+ items: [],
306
+ epg_event_tag: ""
307
+ };
308
+ return n = Object.assign(n, JSON.parse(JSON.stringify(this.customParameters))), n;
309
+ }
310
+ getGTMParameters() {
311
+ return {};
312
+ }
313
+ getNexusParameters() {
314
+ let e = {
315
+ interactive_event: this.interactiveEvent,
316
+ items: []
317
+ };
318
+ return e = Object.assign(e, JSON.parse(JSON.stringify(this.customParameters))), e;
319
+ }
320
+ }
321
+ class L extends a {
322
+ constructor(e = []) {
323
+ super({
324
+ eventName: "epigraph_ar_requested",
325
+ interactiveEvent: !0,
326
+ customParameters: {
327
+ items: e
328
+ }
329
+ });
330
+ }
331
+ }
332
+ class A extends a {
333
+ constructor(e = [], t) {
334
+ super({
335
+ eventName: "epigraph_module_loading",
336
+ interactiveEvent: !1,
337
+ customParameters: {
338
+ items: e,
339
+ is_pre_config: t
340
+ }
341
+ });
342
+ }
343
+ }
344
+ class x extends a {
345
+ constructor(e = [], t, n) {
346
+ super({
347
+ eventName: "epigraph_module_ready",
348
+ interactiveEvent: !1,
349
+ customParameters: {
350
+ items: e,
351
+ is_pre_config: t,
352
+ load_time_ms: n
353
+ }
354
+ });
355
+ }
356
+ }
357
+ class I extends a {
358
+ constructor(e = [], t, n, r) {
359
+ super({
360
+ eventName: "epigraph_module_failed",
361
+ interactiveEvent: !1,
362
+ customParameters: {
363
+ items: e,
364
+ is_pre_config: t,
365
+ load_time_ms: n,
366
+ error_type: r
367
+ }
368
+ });
369
+ }
370
+ }
371
+ class q extends a {
372
+ constructor(e = []) {
373
+ super({
374
+ eventName: "epigraph_module_closed",
375
+ interactiveEvent: !0,
376
+ customParameters: {
377
+ items: e
378
+ }
379
+ });
380
+ }
381
+ }
382
+ class T extends a {
383
+ constructor(e = [], t, n = {}) {
384
+ super({
385
+ eventName: "epigraph_support_detected",
386
+ interactiveEvent: !1,
387
+ customParameters: {
388
+ items: e,
389
+ support_type: t,
390
+ device_capabilities: n
391
+ }
392
+ });
393
+ }
394
+ }
395
+ class b extends a {
396
+ constructor(e = [], t, n) {
397
+ super({
398
+ eventName: "epigraph_button_click",
399
+ interactiveEvent: !0,
400
+ customParameters: {
401
+ items: e,
402
+ button_type: t,
403
+ button_name: n
404
+ }
405
+ });
406
+ }
407
+ }
408
+ class O extends a {
409
+ constructor(e = [], t, n, r) {
410
+ super({
411
+ eventName: "epigraph_panel_opened",
412
+ interactiveEvent: t,
413
+ customParameters: {
414
+ items: e,
415
+ panel_type: n,
416
+ trigger_source: r
417
+ }
418
+ });
419
+ }
420
+ }
421
+ class D extends a {
422
+ constructor(e = [], t, n, r) {
423
+ super({
424
+ eventName: "epigraph_panel_closed",
425
+ interactiveEvent: t,
426
+ customParameters: {
427
+ items: e,
428
+ panel_type: n,
429
+ trigger_source: r
430
+ }
431
+ });
432
+ }
433
+ }
434
+ class R extends a {
435
+ constructor(e = []) {
436
+ super({
437
+ eventName: "epigraph_add_to_favourites",
438
+ interactiveEvent: !0,
439
+ customParameters: {
440
+ items: e
441
+ }
442
+ });
443
+ }
444
+ }
445
+ class G extends a {
446
+ constructor(e = [], t) {
447
+ super({
448
+ eventName: "epigraph_keyboard_interaction",
449
+ interactiveEvent: !0,
450
+ customParameters: {
451
+ items: e,
452
+ action_performed: t
453
+ }
454
+ });
455
+ }
456
+ }
457
+ class k extends a {
458
+ constructor(e = [], t) {
459
+ super({
460
+ eventName: "epigraph_touch_interaction",
461
+ interactiveEvent: !0,
462
+ customParameters: {
463
+ items: e,
464
+ interaction_type: t
465
+ }
466
+ });
467
+ }
468
+ }
469
+ class j extends a {
470
+ constructor(e = [], t, n, r, i) {
471
+ super({
472
+ eventName: "epigraph_item_added",
473
+ interactiveEvent: t,
474
+ customParameters: {
475
+ items: e,
476
+ value: n,
477
+ currency: r,
478
+ quantity: i
479
+ }
480
+ });
481
+ }
482
+ }
483
+ class U extends a {
484
+ constructor(e = []) {
485
+ super({
486
+ eventName: "epigraph_item_moved",
487
+ interactiveEvent: !0,
488
+ customParameters: {
489
+ items: e
490
+ }
491
+ });
492
+ }
493
+ }
494
+ class B extends a {
495
+ constructor(e = [], t, n) {
496
+ super({
497
+ eventName: "epigraph_item_removed",
498
+ interactiveEvent: !0,
499
+ customParameters: {
500
+ items: e,
501
+ currency: t,
502
+ quantity: n
503
+ }
504
+ });
505
+ }
506
+ }
507
+ class M extends a {
508
+ constructor(e = [], t) {
509
+ super({
510
+ eventName: "epigraph_variant_changed",
511
+ interactiveEvent: !0,
512
+ customParameters: {
513
+ items: e,
514
+ change_type: t
515
+ }
516
+ });
517
+ }
518
+ }
519
+ class $ extends a {
520
+ constructor(e = [], t, n) {
521
+ super({
522
+ eventName: "epigraph_content_shared",
523
+ interactiveEvent: !0,
524
+ customParameters: {
525
+ items: e,
526
+ content_type: t,
527
+ share_destination: n
528
+ }
529
+ });
530
+ }
531
+ }
532
+ class z extends a {
533
+ constructor(e = [], t, n) {
534
+ super({
535
+ eventName: "epigraph_checkout",
536
+ interactiveEvent: !0,
537
+ customParameters: {
538
+ items: e,
539
+ value: t,
540
+ currency: n
541
+ }
542
+ });
543
+ }
544
+ }
545
+ class J extends a {
546
+ constructor(e = [], t, n) {
547
+ super({
548
+ eventName: "epigraph_conversion",
549
+ interactiveEvent: !0,
550
+ customParameters: {
551
+ items: e,
552
+ value: t,
553
+ currency: n
554
+ }
555
+ });
556
+ }
557
+ }
558
+ class V extends a {
559
+ constructor(e = [], t) {
560
+ super({
561
+ eventName: "epigraph_changeRate",
562
+ interactiveEvent: !1,
563
+ customParameters: {
564
+ items: e,
565
+ value: t
566
+ }
567
+ });
568
+ }
569
+ }
570
+ class F extends a {
571
+ constructor(e = [], t) {
572
+ super({
573
+ eventName: "epigraph_completionRate",
574
+ interactiveEvent: !1,
575
+ customParameters: {
576
+ items: e,
577
+ value: t
578
+ }
579
+ });
580
+ }
581
+ }
582
+ class H extends a {
583
+ constructor(e = [], t) {
584
+ super({
585
+ eventName: "epigraph_engagementRate",
586
+ interactiveEvent: !1,
587
+ customParameters: {
588
+ items: e,
589
+ value: t
590
+ }
591
+ });
592
+ }
593
+ }
333
594
  /**
334
595
  * @license
335
596
  * Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
@@ -346,12 +607,18 @@ var p = /* @__PURE__ */ ((i) => (i.OneTrust = "onetrust", i))(p || {});
346
607
  * See the License for the specific language governing permissions and
347
608
  * limitations under the License.
348
609
  */
349
- var w;
610
+ var f;
350
611
  const c = Symbol("analyticsPluginsMap");
351
- w = c;
352
- class S {
612
+ f = c;
613
+ class X {
353
614
  constructor(e, t) {
354
- this[w] = /* @__PURE__ */ new Map(), this._consentPlugin = null, e && t && (this._consentPlugin = this.buildConsentPlugin(e, t));
615
+ this[f] = /* @__PURE__ */ new Map(), this.__consentPlugin = null, e && t && (this.__consentPlugin = this.buildConsentPlugin(e, t)), window.addEventListener("epigraphAnalyticsConsentChange", this.__onConsentChangeFromEvent);
616
+ }
617
+ __onConsentChangeFromEvent(e) {
618
+ let t = e;
619
+ this.__overrideConsent = t.detail.hasConsent;
620
+ for (const n of this[c].values())
621
+ this.__hasConsent() || n.setStatus(o.RESTRICTED);
355
622
  }
356
623
  /**
357
624
  * Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
@@ -366,6 +633,16 @@ class S {
366
633
  e
367
634
  ), e.setupPlugin());
368
635
  }
636
+ /**
637
+ * Resolves session consent by prioritizing this._overrideConsent and if not found,
638
+ * getting the value from the consent plugin, if available.
639
+ *
640
+ * @returns {boolean} Whether the session has consent to track analytics or not.
641
+ */
642
+ __hasConsent() {
643
+ let e = !0;
644
+ return this.__overrideConsent !== void 0 ? (e = this.__overrideConsent, e) : (this.__consentPlugin && (e = this.__consentPlugin.hasConsent()), e);
645
+ }
369
646
  /**
370
647
  * Send an Event to all plugins
371
648
  *
@@ -373,7 +650,7 @@ class S {
373
650
  */
374
651
  sendEvent(e) {
375
652
  this[c].forEach((t) => {
376
- t.sendEvent(e, this._consentPlugin);
653
+ t.sendEvent(e, this.__hasConsent());
377
654
  });
378
655
  }
379
656
  /**
@@ -383,14 +660,35 @@ class S {
383
660
  * @private
384
661
  */
385
662
  buildConsentPlugin(e, t) {
386
- return e.toLowerCase() === p.OneTrust.toLowerCase() ? new q(t) : null;
663
+ return e.toLowerCase() === E.OneTrust.toLowerCase() ? new w(t) : null;
387
664
  }
388
665
  }
389
666
  export {
390
- p as ConsentPluginNames,
391
- S as EpigraphAnalytics,
392
- L as GA3AnalyticsPlugin,
393
- I as GA4AnalyticsPlugin,
394
- A as NexusAnalyticsPlugin,
395
- q as OneTrustConsentPlugin
667
+ E as ConsentPluginNames,
668
+ R as EpigraphAddToFavouritesEvent,
669
+ X as EpigraphAnalytics,
670
+ L as EpigraphArRequestedEvent,
671
+ b as EpigraphButtonClickEvent,
672
+ V as EpigraphChangeRateEvent,
673
+ z as EpigraphCheckoutEvent,
674
+ F as EpigraphCompletionRateEvent,
675
+ $ as EpigraphContentSharedEvent,
676
+ J as EpigraphConversionEvent,
677
+ H as EpigraphEngagementRateEvent,
678
+ j as EpigraphItemAddedEvent,
679
+ U as EpigraphItemMovedEvent,
680
+ B as EpigraphItemRemovedEvent,
681
+ G as EpigraphKeyboardInteractionEvent,
682
+ q as EpigraphModuleClosedEvent,
683
+ I as EpigraphModuleFailedEvent,
684
+ A as EpigraphModuleLoadingEvent,
685
+ x as EpigraphModuleReadyEvent,
686
+ D as EpigraphPanelClosedEvent,
687
+ O as EpigraphPanelOpenedEvent,
688
+ T as EpigraphSupportDetectedEvent,
689
+ k as EpigraphTouchInteractionEvent,
690
+ M as EpigraphVariantChangedEvent,
691
+ N as GA4AnalyticsPlugin,
692
+ S as NexusAnalyticsPlugin,
693
+ w as OneTrustConsentPlugin
396
694
  };