@phantomstudios/ft-lib 0.2.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.
Files changed (88) hide show
  1. package/.babelrc +6 -0
  2. package/.eslintrc +58 -0
  3. package/.github/CODEOWNERS +1 -0
  4. package/.github/workflows/pr.yml +31 -0
  5. package/.github/workflows/release.yml +44 -0
  6. package/.nvmrc +1 -0
  7. package/.prettierignore +5 -0
  8. package/CODE_OF_CONDUCT.md +76 -0
  9. package/CONTRIBUTING.md +48 -0
  10. package/LICENSE +21 -0
  11. package/README.md +158 -0
  12. package/SUPPORT.md +4 -0
  13. package/jest.config.js +24 -0
  14. package/lib/FTTracking/index.d.ts +24 -0
  15. package/lib/FTTracking/index.d.ts.map +1 -0
  16. package/lib/FTTracking/index.js +69 -0
  17. package/lib/FTTracking/index.js.map +1 -0
  18. package/lib/consentMonitor/index.d.ts +19 -0
  19. package/lib/consentMonitor/index.d.ts.map +1 -0
  20. package/lib/consentMonitor/index.js +117 -0
  21. package/lib/consentMonitor/index.js.map +1 -0
  22. package/lib/gaTracker/index.d.ts +13 -0
  23. package/lib/gaTracker/index.d.ts.map +1 -0
  24. package/lib/gaTracker/index.js +120 -0
  25. package/lib/gaTracker/index.js.map +1 -0
  26. package/lib/index.d.ts +9 -0
  27. package/lib/index.d.ts.map +1 -0
  28. package/lib/index.js +18 -0
  29. package/lib/index.js.map +1 -0
  30. package/lib/oTracker/index.d.ts +14 -0
  31. package/lib/oTracker/index.d.ts.map +1 -0
  32. package/lib/oTracker/index.js +114 -0
  33. package/lib/oTracker/index.js.map +1 -0
  34. package/lib/permutiveVideoUtils/index.d.ts +12 -0
  35. package/lib/permutiveVideoUtils/index.d.ts.map +1 -0
  36. package/lib/permutiveVideoUtils/index.js +59 -0
  37. package/lib/permutiveVideoUtils/index.js.map +1 -0
  38. package/lib/reactPlayerTracking/index.d.ts +30 -0
  39. package/lib/reactPlayerTracking/index.d.ts.map +1 -0
  40. package/lib/reactPlayerTracking/index.js +85 -0
  41. package/lib/reactPlayerTracking/index.js.map +1 -0
  42. package/lib/utils/attention.d.ts +20 -0
  43. package/lib/utils/attention.d.ts.map +1 -0
  44. package/lib/utils/attention.js +142 -0
  45. package/lib/utils/attention.js.map +1 -0
  46. package/lib/utils/cookies.d.ts +2 -0
  47. package/lib/utils/cookies.d.ts.map +1 -0
  48. package/lib/utils/cookies.js +14 -0
  49. package/lib/utils/cookies.js.map +1 -0
  50. package/lib/utils/getTrace.d.ts +6 -0
  51. package/lib/utils/getTrace.d.ts.map +1 -0
  52. package/lib/utils/getTrace.js +109 -0
  53. package/lib/utils/getTrace.js.map +1 -0
  54. package/lib/utils/intersectionObserverPolyfill.d.ts +1 -0
  55. package/lib/utils/intersectionObserverPolyfill.d.ts.map +1 -0
  56. package/lib/utils/intersectionObserverPolyfill.js +421 -0
  57. package/lib/utils/intersectionObserverPolyfill.js.map +1 -0
  58. package/lib/utils/scroll.d.ts +18 -0
  59. package/lib/utils/scroll.d.ts.map +1 -0
  60. package/lib/utils/scroll.js +75 -0
  61. package/lib/utils/scroll.js.map +1 -0
  62. package/lib/utils/yupValidator.d.ts +87 -0
  63. package/lib/utils/yupValidator.d.ts.map +1 -0
  64. package/lib/utils/yupValidator.js +189 -0
  65. package/lib/utils/yupValidator.js.map +1 -0
  66. package/lib/ytIframeTracking/index.d.ts +27 -0
  67. package/lib/ytIframeTracking/index.d.ts.map +1 -0
  68. package/lib/ytIframeTracking/index.js +165 -0
  69. package/lib/ytIframeTracking/index.js.map +1 -0
  70. package/package.json +75 -0
  71. package/src/FTTracking/index.ts +74 -0
  72. package/src/consentMonitor/index.ts +120 -0
  73. package/src/gaTracker/index.ts +136 -0
  74. package/src/index.ts +12 -0
  75. package/src/oTracker/index.ts +122 -0
  76. package/src/permutiveVideoUtils/index.ts +53 -0
  77. package/src/reactPlayerTracking/index.ts +105 -0
  78. package/src/types.d.ts +33 -0
  79. package/src/utils/attention.js +138 -0
  80. package/src/utils/cookies.js +9 -0
  81. package/src/utils/getTrace.js +122 -0
  82. package/src/utils/intersectionObserverPolyfill.js +470 -0
  83. package/src/utils/scroll.ts +94 -0
  84. package/src/utils/yupValidator.ts +205 -0
  85. package/src/ytIframeTracking/index.ts +210 -0
  86. package/test/index.test.tsx +63 -0
  87. package/tsconfig.json +26 -0
  88. package/tsconfig.test.json +6 -0
@@ -0,0 +1,470 @@
1
+ !(function () {
2
+ "use strict";
3
+ if ("object" == typeof window)
4
+ if (
5
+ "IntersectionObserver" in window &&
6
+ "IntersectionObserverEntry" in window &&
7
+ "intersectionRatio" in window.IntersectionObserverEntry.prototype
8
+ )
9
+ "isIntersecting" in window.IntersectionObserverEntry.prototype ||
10
+ Object.defineProperty(
11
+ window.IntersectionObserverEntry.prototype,
12
+ "isIntersecting",
13
+ {
14
+ get: function () {
15
+ return this.intersectionRatio > 0;
16
+ },
17
+ }
18
+ );
19
+ else {
20
+ var t = window.document,
21
+ e = [],
22
+ n = null,
23
+ o = null;
24
+ (r.prototype.THROTTLE_TIMEOUT = 100),
25
+ (r.prototype.POLL_INTERVAL = null),
26
+ (r.prototype.USE_MUTATION_OBSERVER = !0),
27
+ (r._setupCrossOriginUpdater = function () {
28
+ return (
29
+ n ||
30
+ (n = function (t, n) {
31
+ (o =
32
+ t && n
33
+ ? a(t, n)
34
+ : {
35
+ top: 0,
36
+ bottom: 0,
37
+ left: 0,
38
+ right: 0,
39
+ width: 0,
40
+ height: 0,
41
+ }),
42
+ e.forEach(function (t) {
43
+ t._checkForIntersections();
44
+ });
45
+ }),
46
+ n
47
+ );
48
+ }),
49
+ (r._resetCrossOriginUpdater = function () {
50
+ (n = null), (o = null);
51
+ }),
52
+ (r.prototype.observe = function (t) {
53
+ if (
54
+ !this._observationTargets.some(function (e) {
55
+ return e.element == t;
56
+ })
57
+ ) {
58
+ if (!t || 1 != t.nodeType)
59
+ throw new Error("target must be an Element");
60
+ this._registerInstance(),
61
+ this._observationTargets.push({ element: t, entry: null }),
62
+ this._monitorIntersections(t.ownerDocument),
63
+ this._checkForIntersections();
64
+ }
65
+ }),
66
+ (r.prototype.unobserve = function (t) {
67
+ (this._observationTargets = this._observationTargets.filter(function (
68
+ e
69
+ ) {
70
+ return e.element != t;
71
+ })),
72
+ this._unmonitorIntersections(t.ownerDocument),
73
+ 0 == this._observationTargets.length && this._unregisterInstance();
74
+ }),
75
+ (r.prototype.disconnect = function () {
76
+ (this._observationTargets = []),
77
+ this._unmonitorAllIntersections(),
78
+ this._unregisterInstance();
79
+ }),
80
+ (r.prototype.takeRecords = function () {
81
+ var t = this._queuedEntries.slice();
82
+ return (this._queuedEntries = []), t;
83
+ }),
84
+ (r.prototype._initThresholds = function (t) {
85
+ var e = t || [0];
86
+ return (
87
+ Array.isArray(e) || (e = [e]),
88
+ e.sort().filter(function (t, e, n) {
89
+ if ("number" != typeof t || isNaN(t) || t < 0 || t > 1)
90
+ throw new Error(
91
+ "threshold must be a number between 0 and 1 inclusively"
92
+ );
93
+ return t !== n[e - 1];
94
+ })
95
+ );
96
+ }),
97
+ (r.prototype._parseRootMargin = function (t) {
98
+ var e = (t || "0px").split(/\s+/).map(function (t) {
99
+ var e = /^(-?\d*\.?\d+)(px|%)$/.exec(t);
100
+ if (!e)
101
+ throw new Error(
102
+ "rootMargin must be specified in pixels or percent"
103
+ );
104
+ return { value: parseFloat(e[1]), unit: e[2] };
105
+ });
106
+ return (
107
+ (e[1] = e[1] || e[0]),
108
+ (e[2] = e[2] || e[0]),
109
+ (e[3] = e[3] || e[1]),
110
+ e
111
+ );
112
+ }),
113
+ (r.prototype._monitorIntersections = function (e) {
114
+ var n = e.defaultView;
115
+ if (n && -1 == this._monitoringDocuments.indexOf(e)) {
116
+ var o = this._checkForIntersections,
117
+ i = null,
118
+ r = null;
119
+ if (
120
+ (this.POLL_INTERVAL
121
+ ? (i = n.setInterval(o, this.POLL_INTERVAL))
122
+ : (s(n, "resize", o, !0),
123
+ s(e, "scroll", o, !0),
124
+ this.USE_MUTATION_OBSERVER &&
125
+ "MutationObserver" in n &&
126
+ (r = new n.MutationObserver(o)).observe(e, {
127
+ attributes: !0,
128
+ childList: !0,
129
+ characterData: !0,
130
+ subtree: !0,
131
+ })),
132
+ this._monitoringDocuments.push(e),
133
+ this._monitoringUnsubscribes.push(function () {
134
+ var t = e.defaultView;
135
+ t && (i && t.clearInterval(i), h(t, "resize", o, !0)),
136
+ h(e, "scroll", o, !0),
137
+ r && r.disconnect();
138
+ }),
139
+ e != ((this.root && this.root.ownerDocument) || t))
140
+ ) {
141
+ var c = p(e);
142
+ c && this._monitorIntersections(c.ownerDocument);
143
+ }
144
+ }
145
+ }),
146
+ (r.prototype._unmonitorIntersections = function (e) {
147
+ var n = this._monitoringDocuments.indexOf(e);
148
+ if (-1 != n) {
149
+ var o = (this.root && this.root.ownerDocument) || t;
150
+ if (
151
+ !this._observationTargets.some(function (t) {
152
+ var n = t.element.ownerDocument;
153
+ if (n == e) return !0;
154
+ for (; n && n != o; ) {
155
+ var i = p(n);
156
+ if ((n = i && i.ownerDocument) == e) return !0;
157
+ }
158
+ return !1;
159
+ })
160
+ ) {
161
+ var i = this._monitoringUnsubscribes[n];
162
+ if (
163
+ (this._monitoringDocuments.splice(n, 1),
164
+ this._monitoringUnsubscribes.splice(n, 1),
165
+ i(),
166
+ e != o)
167
+ ) {
168
+ var r = p(e);
169
+ r && this._unmonitorIntersections(r.ownerDocument);
170
+ }
171
+ }
172
+ }
173
+ }),
174
+ (r.prototype._unmonitorAllIntersections = function () {
175
+ var t = this._monitoringUnsubscribes.slice(0);
176
+ (this._monitoringDocuments.length = 0),
177
+ (this._monitoringUnsubscribes.length = 0);
178
+ for (var e = 0; e < t.length; e++) t[e]();
179
+ }),
180
+ (r.prototype._checkForIntersections = function () {
181
+ if (this.root || !n || o) {
182
+ var t = this._rootIsInDom(),
183
+ e = t
184
+ ? this._getRootRect()
185
+ : { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
186
+ this._observationTargets.forEach(function (o) {
187
+ var r = o.element,
188
+ s = c(r),
189
+ h = this._rootContainsTarget(r),
190
+ u = o.entry,
191
+ a = t && h && this._computeTargetAndRootIntersection(r, s, e),
192
+ l = (o.entry = new i({
193
+ time:
194
+ window.performance && performance.now && performance.now(),
195
+ target: r,
196
+ boundingClientRect: s,
197
+ rootBounds: n && !this.root ? null : e,
198
+ intersectionRect: a,
199
+ }));
200
+ u
201
+ ? t && h
202
+ ? this._hasCrossedThreshold(u, l) &&
203
+ this._queuedEntries.push(l)
204
+ : u && u.isIntersecting && this._queuedEntries.push(l)
205
+ : this._queuedEntries.push(l);
206
+ }, this),
207
+ this._queuedEntries.length &&
208
+ this._callback(this.takeRecords(), this);
209
+ }
210
+ }),
211
+ (r.prototype._computeTargetAndRootIntersection = function (e, i, r) {
212
+ if ("none" != window.getComputedStyle(e).display) {
213
+ for (
214
+ var s, h, u, l, p, d, g, m, v = i, _ = f(e), b = !1;
215
+ !b && _;
216
+
217
+ ) {
218
+ var w = null,
219
+ y = 1 == _.nodeType ? window.getComputedStyle(_) : {};
220
+ if ("none" == y.display) return null;
221
+ if (_ == this.root || 9 == _.nodeType)
222
+ if (((b = !0), _ == this.root || _ == t))
223
+ n && !this.root
224
+ ? !o || (0 == o.width && 0 == o.height)
225
+ ? ((_ = null), (w = null), (v = null))
226
+ : (w = o)
227
+ : (w = r);
228
+ else {
229
+ var I = f(_),
230
+ E = I && c(I),
231
+ T = I && this._computeTargetAndRootIntersection(I, E, r);
232
+ E && T ? ((_ = I), (w = a(E, T))) : ((_ = null), (v = null));
233
+ }
234
+ else {
235
+ var R = _.ownerDocument;
236
+ _ != R.body &&
237
+ _ != R.documentElement &&
238
+ "visible" != y.overflow &&
239
+ (w = c(_));
240
+ }
241
+ if (
242
+ (w &&
243
+ ((s = w),
244
+ (h = v),
245
+ (u = void 0),
246
+ (l = void 0),
247
+ (p = void 0),
248
+ (d = void 0),
249
+ (g = void 0),
250
+ (m = void 0),
251
+ (u = Math.max(s.top, h.top)),
252
+ (l = Math.min(s.bottom, h.bottom)),
253
+ (p = Math.max(s.left, h.left)),
254
+ (d = Math.min(s.right, h.right)),
255
+ (m = l - u),
256
+ (v =
257
+ ((g = d - p) >= 0 &&
258
+ m >= 0 && {
259
+ top: u,
260
+ bottom: l,
261
+ left: p,
262
+ right: d,
263
+ width: g,
264
+ height: m,
265
+ }) ||
266
+ null)),
267
+ !v)
268
+ )
269
+ break;
270
+ _ = _ && f(_);
271
+ }
272
+ return v;
273
+ }
274
+ }),
275
+ (r.prototype._getRootRect = function () {
276
+ var e;
277
+ if (this.root) e = c(this.root);
278
+ else {
279
+ var n = t.documentElement,
280
+ o = t.body;
281
+ e = {
282
+ top: 0,
283
+ left: 0,
284
+ right: n.clientWidth || o.clientWidth,
285
+ width: n.clientWidth || o.clientWidth,
286
+ bottom: n.clientHeight || o.clientHeight,
287
+ height: n.clientHeight || o.clientHeight,
288
+ };
289
+ }
290
+ return this._expandRectByRootMargin(e);
291
+ }),
292
+ (r.prototype._expandRectByRootMargin = function (t) {
293
+ var e = this._rootMarginValues.map(function (e, n) {
294
+ return "px" == e.unit
295
+ ? e.value
296
+ : (e.value * (n % 2 ? t.width : t.height)) / 100;
297
+ }),
298
+ n = {
299
+ top: t.top - e[0],
300
+ right: t.right + e[1],
301
+ bottom: t.bottom + e[2],
302
+ left: t.left - e[3],
303
+ };
304
+ return (n.width = n.right - n.left), (n.height = n.bottom - n.top), n;
305
+ }),
306
+ (r.prototype._hasCrossedThreshold = function (t, e) {
307
+ var n = t && t.isIntersecting ? t.intersectionRatio || 0 : -1,
308
+ o = e.isIntersecting ? e.intersectionRatio || 0 : -1;
309
+ if (n !== o)
310
+ for (var i = 0; i < this.thresholds.length; i++) {
311
+ var r = this.thresholds[i];
312
+ if (r == n || r == o || r < n != r < o) return !0;
313
+ }
314
+ }),
315
+ (r.prototype._rootIsInDom = function () {
316
+ return !this.root || l(t, this.root);
317
+ }),
318
+ (r.prototype._rootContainsTarget = function (e) {
319
+ return (
320
+ l(this.root || t, e) &&
321
+ (!this.root || this.root.ownerDocument == e.ownerDocument)
322
+ );
323
+ }),
324
+ (r.prototype._registerInstance = function () {
325
+ e.indexOf(this) < 0 && e.push(this);
326
+ }),
327
+ (r.prototype._unregisterInstance = function () {
328
+ var t = e.indexOf(this);
329
+ -1 != t && e.splice(t, 1);
330
+ }),
331
+ (window.IntersectionObserver = r),
332
+ (window.IntersectionObserverEntry = i);
333
+ }
334
+ function i(t) {
335
+ (this.time = t.time),
336
+ (this.target = t.target),
337
+ (this.rootBounds = u(t.rootBounds)),
338
+ (this.boundingClientRect = u(t.boundingClientRect)),
339
+ (this.intersectionRect = u(
340
+ t.intersectionRect || {
341
+ top: 0,
342
+ bottom: 0,
343
+ left: 0,
344
+ right: 0,
345
+ width: 0,
346
+ height: 0,
347
+ }
348
+ )),
349
+ (this.isIntersecting = !!t.intersectionRect);
350
+ var e = this.boundingClientRect,
351
+ n = e.width * e.height,
352
+ o = this.intersectionRect,
353
+ i = o.width * o.height;
354
+ this.intersectionRatio = n
355
+ ? Number((i / n).toFixed(4))
356
+ : this.isIntersecting
357
+ ? 1
358
+ : 0;
359
+ }
360
+ function r(t, e) {
361
+ var n,
362
+ o,
363
+ i,
364
+ r = e || {};
365
+ if ("function" != typeof t) throw new Error("callback must be a function");
366
+ if (r.root && 1 != r.root.nodeType)
367
+ throw new Error("root must be an Element");
368
+ (this._checkForIntersections =
369
+ ((n = this._checkForIntersections.bind(this)),
370
+ (o = this.THROTTLE_TIMEOUT),
371
+ (i = null),
372
+ function () {
373
+ i ||
374
+ (i = setTimeout(function () {
375
+ n(), (i = null);
376
+ }, o));
377
+ })),
378
+ (this._callback = t),
379
+ (this._observationTargets = []),
380
+ (this._queuedEntries = []),
381
+ (this._rootMarginValues = this._parseRootMargin(r.rootMargin)),
382
+ (this.thresholds = this._initThresholds(r.threshold)),
383
+ (this.root = r.root || null),
384
+ (this.rootMargin = this._rootMarginValues
385
+ .map(function (t) {
386
+ return t.value + t.unit;
387
+ })
388
+ .join(" ")),
389
+ (this._monitoringDocuments = []),
390
+ (this._monitoringUnsubscribes = []);
391
+ }
392
+ function s(t, e, n, o) {
393
+ "function" == typeof t.addEventListener
394
+ ? t.addEventListener(e, n, o || !1)
395
+ : "function" == typeof t.attachEvent && t.attachEvent("on" + e, n);
396
+ }
397
+ function h(t, e, n, o) {
398
+ "function" == typeof t.removeEventListener
399
+ ? t.removeEventListener(e, n, o || !1)
400
+ : "function" == typeof t.detatchEvent && t.detatchEvent("on" + e, n);
401
+ }
402
+ function c(t) {
403
+ var e;
404
+ try {
405
+ e = t.getBoundingClientRect();
406
+ } catch (t) {}
407
+ return e
408
+ ? ((e.width && e.height) ||
409
+ (e = {
410
+ top: e.top,
411
+ right: e.right,
412
+ bottom: e.bottom,
413
+ left: e.left,
414
+ width: e.right - e.left,
415
+ height: e.bottom - e.top,
416
+ }),
417
+ e)
418
+ : { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
419
+ }
420
+ function u(t) {
421
+ return !t || "x" in t
422
+ ? t
423
+ : {
424
+ top: t.top,
425
+ y: t.top,
426
+ bottom: t.bottom,
427
+ left: t.left,
428
+ x: t.left,
429
+ right: t.right,
430
+ width: t.width,
431
+ height: t.height,
432
+ };
433
+ }
434
+ function a(t, e) {
435
+ var n = e.top - t.top,
436
+ o = e.left - t.left;
437
+ return {
438
+ top: n,
439
+ left: o,
440
+ height: e.height,
441
+ width: e.width,
442
+ bottom: n + e.height,
443
+ right: o + e.width,
444
+ };
445
+ }
446
+ function l(t, e) {
447
+ for (var n = e; n; ) {
448
+ if (n == t) return !0;
449
+ n = f(n);
450
+ }
451
+ return !1;
452
+ }
453
+ function f(e) {
454
+ var n = e.parentNode;
455
+ return 9 == e.nodeType && e != t
456
+ ? p(e)
457
+ : n && 11 == n.nodeType && n.host
458
+ ? n.host
459
+ : n && n.assignedSlot
460
+ ? n.assignedSlot.parentNode
461
+ : n;
462
+ }
463
+ function p(t) {
464
+ try {
465
+ return (t.defaultView && t.defaultView.frameElement) || null;
466
+ } catch (t) {
467
+ return null;
468
+ }
469
+ }
470
+ })();
@@ -0,0 +1,94 @@
1
+ import { TrackingOptions } from "../FTTracking";
2
+ import { FTTracking } from "../FTTracking";
3
+ import { gaTracker } from "../gaTracker";
4
+ import { oTracker } from "../oTracker";
5
+ import { Attention } from "./attention";
6
+ import { ConfigType, OrigamiEventType } from "./yupValidator";
7
+
8
+ import "./intersectionObserverPolyfill";
9
+
10
+ export class ScrollTracker {
11
+ oTracker: oTracker;
12
+ gaTracker: gaTracker;
13
+ options: TrackingOptions;
14
+ attention: any;
15
+ config: ConfigType;
16
+ constructor(FTTracker: FTTracking) {
17
+ this.oTracker = FTTracker.oTracker;
18
+ this.gaTracker = FTTracker.gaTracker;
19
+ this.options = FTTracker.options;
20
+ this.config = FTTracker.config;
21
+
22
+ this.attention = new Attention(this.oTracker);
23
+ this.scrollDepthInit([25, 50, 75, 100], this.options.scrollTrackerSelector);
24
+ }
25
+
26
+ reset() {
27
+ document.querySelectorAll("[data-percentage]").forEach((element) => {
28
+ element.remove();
29
+ });
30
+ this.attention = new Attention(this.oTracker);
31
+ this.scrollDepthInit([25, 50, 75, 100], this.options.scrollTrackerSelector);
32
+ }
33
+
34
+ scrollDepthInit(percentages: number[], selector = "") {
35
+ const element = document.querySelector(selector);
36
+ if (element && window.IntersectionObserver) {
37
+ const observer = new IntersectionObserver((changes) => {
38
+ this.intersectionCallback(observer, changes);
39
+ });
40
+
41
+ percentages.forEach((percentage) => {
42
+ // add a scroll depth marker element
43
+ const targetEl = document.createElement("div");
44
+ targetEl.className = "n-ui__scroll-depth-marker";
45
+ targetEl.style.position = "absolute";
46
+ targetEl.style.top = `${percentage}%`;
47
+ targetEl.style.bottom = "0";
48
+ targetEl.style.width = "100%";
49
+ targetEl.style.zIndex = "-1";
50
+ targetEl.setAttribute("data-percentage", percentage.toString());
51
+ element.appendChild(targetEl);
52
+ observer.observe(targetEl);
53
+ });
54
+ }
55
+ }
56
+
57
+ intersectionCallback(
58
+ observer: IntersectionObserver,
59
+ changes: IntersectionObserverEntry[]
60
+ ) {
61
+ changes.forEach((change) => {
62
+ if (change.isIntersecting || change.intersectionRatio > 0) {
63
+ const scrollDepthMarkerEl = change.target;
64
+ const percentagesViewed =
65
+ scrollDepthMarkerEl.getAttribute("data-percentage");
66
+ const data = {
67
+ action: "scrolldepth",
68
+ category: "page",
69
+ meta: {
70
+ percentagesViewed,
71
+ },
72
+ product: this.config.product,
73
+ source: this.config.product,
74
+ app: this.config.app,
75
+ };
76
+
77
+ this.oTracker.eventDispatcher(data as OrigamiEventType);
78
+
79
+ //send GA scroll events if not GTM
80
+ if (!this.options.isCustomGTMEvent) {
81
+ this.gaTracker.GtagEventDispatcher(
82
+ "Scroll",
83
+ `scroll - ${percentagesViewed}%`,
84
+ window.location.pathname
85
+ );
86
+ }
87
+
88
+ if (scrollDepthMarkerEl.parentNode) {
89
+ scrollDepthMarkerEl.parentNode.removeChild(scrollDepthMarkerEl);
90
+ }
91
+ }
92
+ });
93
+ }
94
+ }