@dotcms/analytics 1.2.1-next.13 → 1.2.1-next.15
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 +3 -3
- package/lib/core/dot-analytics.content.d.ts +1 -1
- package/lib/core/dot-analytics.content.js +10 -11
- package/lib/core/plugin/identity/dot-analytics.identity.activity-tracker.d.ts +1 -1
- package/lib/core/plugin/identity/dot-analytics.identity.activity-tracker.js +7 -8
- package/lib/core/plugin/impression/dot-analytics.impression-tracker.js +2 -2
- package/lib/core/shared/constants/dot-analytics.constants.d.ts +29 -3
- package/lib/core/shared/constants/dot-analytics.constants.js +23 -21
- package/lib/core/shared/utils/dot-analytics.utils.js +38 -39
- package/package.json +1 -1
- package/uve/src/internal/constants.js +3 -8
- package/uve/src/internal/events.js +14 -11
package/README.md
CHANGED
|
@@ -247,7 +247,7 @@ The `impressions` option controls automatic tracking of content visibility:
|
|
|
247
247
|
|
|
248
248
|
**How it works:**
|
|
249
249
|
|
|
250
|
-
- ✅ Tracks contentlets marked with `dotcms-
|
|
250
|
+
- ✅ Tracks contentlets marked with `dotcms-contentlet` class and `data-dot-*` attributes (e.g., `data-dot-identifier`, `data-dot-inode`, `data-dot-type`)
|
|
251
251
|
- ✅ Uses Intersection Observer API for high performance and battery efficiency
|
|
252
252
|
- ✅ Only fires when element is ≥50% visible for ≥750ms (configurable)
|
|
253
253
|
- ✅ Only tracks during active tab (respects page visibility)
|
|
@@ -299,7 +299,7 @@ The `clicks` option controls automatic tracking of user interactions with conten
|
|
|
299
299
|
**How it works:**
|
|
300
300
|
|
|
301
301
|
- ✅ Tracks clicks on `<a>` and `<button>` elements within contentlets
|
|
302
|
-
- ✅ Contentlets must be marked with `dotcms-
|
|
302
|
+
- ✅ Contentlets must be marked with `dotcms-contentlet` class and `data-dot-*` attributes (e.g., `data-dot-identifier`, `data-dot-inode`, `data-dot-type`)
|
|
303
303
|
- ✅ Captures semantic attributes (`href`, `aria-label`, `data-*`) and excludes CSS classes
|
|
304
304
|
- ✅ Throttles rapid clicks to prevent duplicate tracking (300ms fixed)
|
|
305
305
|
- ✅ One click event per interaction
|
|
@@ -341,7 +341,7 @@ The `attributes` array captures additional semantic data in `'key:value'` string
|
|
|
341
341
|
- `class` - Already captured as top-level property
|
|
342
342
|
- `id` - Already captured as top-level property
|
|
343
343
|
- `href` - Already captured as top-level property
|
|
344
|
-
- `data-dot
|
|
344
|
+
- `data-dot-*` - Internal SDK attributes (e.g., `data-dot-identifier`, `data-dot-inode`, `data-dot-type`)
|
|
345
345
|
|
|
346
346
|
**Example: Enable click tracking**
|
|
347
347
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANALYTICS_WINDOWS_ACTIVE_KEY, ANALYTICS_WINDOWS_CLEANUP_KEY } from '
|
|
1
|
+
import { ANALYTICS_WINDOWS_ACTIVE_KEY, ANALYTICS_WINDOWS_CLEANUP_KEY } from './shared/constants/dot-analytics.constants';
|
|
2
2
|
import { DotCMSAnalytics, DotCMSAnalyticsConfig } from './shared/models';
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Analytics as l } from "analytics";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { dotAnalyticsEnricherPlugin as m } from "./plugin/enricher/dot-analytics.enricher.plugin.js";
|
|
2
|
+
import { dotAnalyticsClickPlugin as d } from "./plugin/click/dot-analytics.click.plugin.js";
|
|
3
|
+
import { dotAnalyticsEnricherPlugin as y } from "./plugin/enricher/dot-analytics.enricher.plugin.js";
|
|
5
4
|
import { dotAnalyticsIdentityPlugin as u } from "./plugin/identity/dot-analytics.identity.plugin.js";
|
|
6
|
-
import { dotAnalyticsImpressionPlugin as
|
|
5
|
+
import { dotAnalyticsImpressionPlugin as m } from "./plugin/impression/dot-analytics.impression.plugin.js";
|
|
7
6
|
import { dotAnalytics as A } from "./plugin/main/dot-analytics.plugin.js";
|
|
8
|
-
import { DotCMSPredefinedEventType as f } from "./shared/constants/dot-analytics.constants.js";
|
|
7
|
+
import { ANALYTICS_WINDOWS_ACTIVE_KEY as a, ANALYTICS_WINDOWS_CLEANUP_KEY as p, DotCMSPredefinedEventType as f } from "./shared/constants/dot-analytics.constants.js";
|
|
9
8
|
import { validateAnalyticsConfig as C, getEnhancedTrackingPlugins as w } from "./shared/utils/dot-analytics.utils.js";
|
|
10
9
|
import { cleanupActivityTracking as g } from "./plugin/identity/dot-analytics.identity.activity-tracker.js";
|
|
11
|
-
const
|
|
10
|
+
const T = (t) => {
|
|
12
11
|
const e = C(t);
|
|
13
12
|
if (e)
|
|
14
13
|
return console.error(
|
|
@@ -16,8 +15,8 @@ const _ = (t) => {
|
|
|
16
15
|
), typeof window < "u" && (window[a] = !1), null;
|
|
17
16
|
const s = w(
|
|
18
17
|
t,
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
m,
|
|
19
|
+
d
|
|
21
20
|
), i = l({
|
|
22
21
|
app: "dotAnalytics",
|
|
23
22
|
debug: t.debug,
|
|
@@ -26,13 +25,13 @@ const _ = (t) => {
|
|
|
26
25
|
// Inject identity context
|
|
27
26
|
...s,
|
|
28
27
|
//Track content impressions & clicks (conditionally loaded)
|
|
29
|
-
|
|
28
|
+
y(),
|
|
30
29
|
// Enrich and clean payload with page, device, utm data and custom data
|
|
31
30
|
A(t)
|
|
32
31
|
// Send events to server
|
|
33
32
|
]
|
|
34
33
|
}), r = () => g();
|
|
35
|
-
return typeof window < "u" && (window.addEventListener("beforeunload", r), window[
|
|
34
|
+
return typeof window < "u" && (window.addEventListener("beforeunload", r), window[p] = r, window[a] = !0, window.dispatchEvent(new CustomEvent("dotcms:analytics:ready"))), {
|
|
36
35
|
/**
|
|
37
36
|
* Track a page view.
|
|
38
37
|
* Session activity is automatically updated by the identity plugin.
|
|
@@ -80,5 +79,5 @@ const _ = (t) => {
|
|
|
80
79
|
};
|
|
81
80
|
};
|
|
82
81
|
export {
|
|
83
|
-
|
|
82
|
+
T as initializeContentAnalytics
|
|
84
83
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANALYTICS_WINDOWS_ACTIVE_KEY, ANALYTICS_WINDOWS_CLEANUP_KEY } from '
|
|
1
|
+
import { ANALYTICS_WINDOWS_ACTIVE_KEY, ANALYTICS_WINDOWS_CLEANUP_KEY } from '../../shared/constants';
|
|
2
2
|
import { DotCMSAnalyticsConfig } from '../../shared/models';
|
|
3
3
|
declare global {
|
|
4
4
|
interface Window {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ANALYTICS_WINDOWS_ACTIVE_KEY as a, ANALYTICS_WINDOWS_CLEANUP_KEY as o } from "
|
|
2
|
-
import { DEFAULT_SESSION_TIMEOUT_MINUTES as r, ACTIVITY_EVENTS as l } from "../../shared/constants/dot-analytics.constants.js";
|
|
1
|
+
import { ANALYTICS_WINDOWS_ACTIVE_KEY as a, ANALYTICS_WINDOWS_CLEANUP_KEY as o, DEFAULT_SESSION_TIMEOUT_MINUTES as r, ACTIVITY_EVENTS as l } from "../../shared/constants/dot-analytics.constants.js";
|
|
3
2
|
class v {
|
|
4
3
|
constructor() {
|
|
5
4
|
this.activityListeners = [], this.lastActivityTime = Date.now(), this.inactivityTimer = null, this.isThrottled = !1, this.config = null, this.ACTIVITY_THROTTLE_MS = 1e3;
|
|
@@ -52,15 +51,15 @@ class v {
|
|
|
52
51
|
this.activityListeners.forEach((i) => i()), this.activityListeners = [], this.inactivityTimer && (clearTimeout(this.inactivityTimer), this.inactivityTimer = null), this.config = null;
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
|
-
const t = new v(),
|
|
54
|
+
const t = new v(), T = () => {
|
|
56
55
|
t.updateSessionActivity();
|
|
57
|
-
},
|
|
56
|
+
}, d = (e) => {
|
|
58
57
|
t.initialize(e);
|
|
59
|
-
},
|
|
58
|
+
}, u = () => {
|
|
60
59
|
t.cleanup(), typeof window < "u" && (window[a] = !1, window[o] = void 0, window.dispatchEvent(new CustomEvent("dotcms:analytics:cleanup")));
|
|
61
60
|
};
|
|
62
61
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
u as cleanupActivityTracking,
|
|
63
|
+
d as initializeActivityTracking,
|
|
64
|
+
T as updateSessionActivity
|
|
66
65
|
};
|
|
@@ -78,7 +78,7 @@ class E {
|
|
|
78
78
|
this.logger.debug(`Skipping element ${r} (${o})`);
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
|
-
this.elementImpressionStates.has(r) || (n.dataset.
|
|
81
|
+
this.elementImpressionStates.has(r) || (n.dataset.dotDomIndex || (n.dataset.dotDomIndex = String(s)), this.observer.observe(n), this.elementImpressionStates.set(r, {
|
|
82
82
|
timer: null,
|
|
83
83
|
visibleSince: null,
|
|
84
84
|
tracked: this.hasBeenTrackedInSession(r),
|
|
@@ -150,7 +150,7 @@ class E {
|
|
|
150
150
|
trackAndSendImpression(e, i) {
|
|
151
151
|
const t = this.elementImpressionStates.get(e);
|
|
152
152
|
if (!t) return;
|
|
153
|
-
const s = t.visibleSince ? Date.now() - t.visibleSince : 0, n = I(i), r = d(i), o = parseInt(i.dataset.
|
|
153
|
+
const s = t.visibleSince ? Date.now() - t.visibleSince : 0, n = I(i), r = d(i), o = parseInt(i.dataset.dotDomIndex || "-1", 10), h = {
|
|
154
154
|
content: {
|
|
155
155
|
identifier: n.identifier,
|
|
156
156
|
inode: n.inode,
|
|
@@ -127,6 +127,32 @@ export declare const CLICKABLE_ELEMENTS_SELECTOR = "a, button";
|
|
|
127
127
|
*/
|
|
128
128
|
export declare const IMPRESSION_SESSION_KEY = "dot_analytics_impressions";
|
|
129
129
|
/**
|
|
130
|
-
*
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
* Window property key for analytics active state
|
|
131
|
+
* Used to track if analytics is initialized and active
|
|
132
|
+
*/
|
|
133
|
+
export declare const ANALYTICS_WINDOWS_ACTIVE_KEY = "__dotAnalyticsActive__";
|
|
134
|
+
/**
|
|
135
|
+
* Window property key for analytics cleanup function
|
|
136
|
+
* Used to store the cleanup function for analytics instance
|
|
137
|
+
*/
|
|
138
|
+
export declare const ANALYTICS_WINDOWS_CLEANUP_KEY = "__dotAnalyticsCleanup__";
|
|
139
|
+
/**
|
|
140
|
+
* CSS class selector for contentlet elements
|
|
141
|
+
*
|
|
142
|
+
* @important This constant is intentionally duplicated in @dotcms/react SDK
|
|
143
|
+
* (core-web/libs/sdk/react/src/lib/next/components/Contentlet/Contentlet.tsx).
|
|
144
|
+
* Both constants MUST have the same value ('dotcms-contentlet') for analytics
|
|
145
|
+
* tracking to work correctly with React-rendered contentlets.
|
|
146
|
+
*
|
|
147
|
+
* This duplication is intentional to maintain SDK independence:
|
|
148
|
+
* - @dotcms/analytics can be used standalone without React
|
|
149
|
+
* - @dotcms/react can be used without analytics
|
|
150
|
+
* - When both are used together, they must share the same class name
|
|
151
|
+
*
|
|
152
|
+
* If you need to change this value, you MUST update it in both locations:
|
|
153
|
+
* 1. This file (analytics SDK)
|
|
154
|
+
* 2. Contentlet.tsx in React SDK
|
|
155
|
+
*
|
|
156
|
+
* @see core-web/libs/sdk/react/src/lib/next/components/Contentlet/Contentlet.tsx
|
|
157
|
+
*/
|
|
158
|
+
export declare const CONTENTLET_CLASS = "dotcms-contentlet";
|
|
@@ -3,18 +3,18 @@ const I = "/api/v1/analytics/content/event", c = {
|
|
|
3
3
|
CONTENT_IMPRESSION: "content_impression",
|
|
4
4
|
CONTENT_CLICK: "content_click",
|
|
5
5
|
CONVERSION: "conversion"
|
|
6
|
-
},
|
|
6
|
+
}, o = [
|
|
7
7
|
"utm_source",
|
|
8
8
|
"utm_medium",
|
|
9
9
|
"utm_campaign",
|
|
10
10
|
"utm_term",
|
|
11
11
|
"utm_content"
|
|
12
|
-
],
|
|
13
|
-
eventBatchSize:
|
|
12
|
+
], s = 30, e = "dot_analytics_session_id", N = "dot_analytics_user_id", _ = 15, E = 5e3, A = ["click"], L = {
|
|
13
|
+
eventBatchSize: _,
|
|
14
14
|
// Max events per batch - auto-sends when reached
|
|
15
|
-
flushInterval:
|
|
15
|
+
flushInterval: E
|
|
16
16
|
// Time between flushes - sends whatever is queued
|
|
17
|
-
},
|
|
17
|
+
}, O = [
|
|
18
18
|
"title",
|
|
19
19
|
"url",
|
|
20
20
|
"path",
|
|
@@ -23,30 +23,32 @@ const I = "/api/v1/analytics/content/event", c = {
|
|
|
23
23
|
"width",
|
|
24
24
|
"height",
|
|
25
25
|
"referrer"
|
|
26
|
-
], t = 0.5,
|
|
26
|
+
], t = 0.5, n = 750, T = 100, S = 100, i = 250, C = {
|
|
27
27
|
visibilityThreshold: t,
|
|
28
|
-
dwellMs:
|
|
29
|
-
maxNodes:
|
|
28
|
+
dwellMs: n,
|
|
29
|
+
maxNodes: T,
|
|
30
30
|
throttleMs: S
|
|
31
|
-
}, U = "content_impression",
|
|
31
|
+
}, U = "content_impression", D = "content_click", M = 300, a = "a, button", R = "__dotAnalyticsActive__", l = "__dotAnalyticsCleanup__", r = "dotcms-contentlet";
|
|
32
32
|
export {
|
|
33
|
-
|
|
34
|
-
a as ANALYTICS_CONTENTLET_CLASS,
|
|
33
|
+
A as ACTIVITY_EVENTS,
|
|
35
34
|
I as ANALYTICS_ENDPOINT,
|
|
36
|
-
|
|
37
|
-
R as
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
O as ANALYTICS_JS_DEFAULT_PROPERTIES,
|
|
36
|
+
R as ANALYTICS_WINDOWS_ACTIVE_KEY,
|
|
37
|
+
l as ANALYTICS_WINDOWS_CLEANUP_KEY,
|
|
38
|
+
a as CLICKABLE_ELEMENTS_SELECTOR,
|
|
39
|
+
D as CLICK_EVENT_TYPE,
|
|
40
|
+
r as CONTENTLET_CLASS,
|
|
41
|
+
M as DEFAULT_CLICK_THROTTLE_MS,
|
|
40
42
|
C as DEFAULT_IMPRESSION_CONFIG,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
n as DEFAULT_IMPRESSION_DWELL_MS,
|
|
44
|
+
T as DEFAULT_IMPRESSION_MAX_NODES,
|
|
45
|
+
i as DEFAULT_IMPRESSION_MUTATION_OBSERVER_DEBOUNCE_MS,
|
|
44
46
|
S as DEFAULT_IMPRESSION_THROTTLE_MS,
|
|
45
47
|
t as DEFAULT_IMPRESSION_VISIBILITY_THRESHOLD,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
L as DEFAULT_QUEUE_CONFIG,
|
|
49
|
+
s as DEFAULT_SESSION_TIMEOUT_MINUTES,
|
|
48
50
|
c as DotCMSPredefinedEventType,
|
|
49
|
-
|
|
51
|
+
o as EXPECTED_UTM_KEYS,
|
|
50
52
|
U as IMPRESSION_EVENT_TYPE,
|
|
51
53
|
e as SESSION_STORAGE_KEY,
|
|
52
54
|
N as USER_ID_KEY
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ANALYTICS_JS_DEFAULT_PROPERTIES as _, SESSION_STORAGE_KEY as g, DEFAULT_SESSION_TIMEOUT_MINUTES as p, USER_ID_KEY as m, DEFAULT_IMPRESSION_MUTATION_OBSERVER_DEBOUNCE_MS as T, EXPECTED_UTM_KEYS as
|
|
2
|
-
import { DotLogger as
|
|
3
|
-
|
|
4
|
-
function P(t) {
|
|
1
|
+
import { ANALYTICS_JS_DEFAULT_PROPERTIES as _, SESSION_STORAGE_KEY as g, DEFAULT_SESSION_TIMEOUT_MINUTES as p, USER_ID_KEY as m, DEFAULT_IMPRESSION_MUTATION_OBSERVER_DEBOUNCE_MS as T, EXPECTED_UTM_KEYS as D, CONTENTLET_CLASS as h } from "../constants/dot-analytics.constants.js";
|
|
2
|
+
import { DotLogger as E } from "../dot-analytics.logger.js";
|
|
3
|
+
function $(t) {
|
|
5
4
|
const e = [];
|
|
6
5
|
return t.siteAuth?.trim() || e.push('"siteAuth"'), t.server?.trim() || e.push('"server"'), e.length > 0 ? e : null;
|
|
7
6
|
}
|
|
@@ -24,24 +23,24 @@ const l = (t) => {
|
|
|
24
23
|
console.warn(`DotCMS Analytics [Core]: Could not save ${t} to localStorage`);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
},
|
|
26
|
+
}, I = () => {
|
|
28
27
|
let t = f.getItem(m);
|
|
29
28
|
return t || (t = l("user"), f.setItem(m, t)), t;
|
|
30
|
-
},
|
|
29
|
+
}, y = (t) => {
|
|
31
30
|
const e = new Date(t), n = /* @__PURE__ */ new Date(), s = new Date(
|
|
32
31
|
e.getUTCFullYear(),
|
|
33
32
|
e.getUTCMonth(),
|
|
34
33
|
e.getUTCDate()
|
|
35
34
|
), r = new Date(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate());
|
|
36
35
|
return s.getTime() !== r.getTime();
|
|
37
|
-
},
|
|
36
|
+
}, v = () => {
|
|
38
37
|
const t = Date.now();
|
|
39
38
|
if (typeof window > "u")
|
|
40
39
|
return l("session_fallback");
|
|
41
40
|
try {
|
|
42
41
|
const e = sessionStorage.getItem(g);
|
|
43
42
|
if (e) {
|
|
44
|
-
const { sessionId: r, startTime: o, lastActivity: a } = JSON.parse(e), i = !
|
|
43
|
+
const { sessionId: r, startTime: o, lastActivity: a } = JSON.parse(e), i = !y(o), c = t - a < p * 60 * 1e3;
|
|
45
44
|
if (i && c)
|
|
46
45
|
return sessionStorage.setItem(
|
|
47
46
|
g,
|
|
@@ -61,8 +60,8 @@ const l = (t) => {
|
|
|
61
60
|
} catch {
|
|
62
61
|
return l("session_fallback");
|
|
63
62
|
}
|
|
64
|
-
},
|
|
65
|
-
const e =
|
|
63
|
+
}, P = (t) => {
|
|
64
|
+
const e = v(), n = I(), s = C();
|
|
66
65
|
return {
|
|
67
66
|
site_auth: t.siteAuth,
|
|
68
67
|
session_id: e,
|
|
@@ -81,12 +80,12 @@ const l = (t) => {
|
|
|
81
80
|
viewport_width: String(e),
|
|
82
81
|
viewport_height: String(n)
|
|
83
82
|
};
|
|
84
|
-
},
|
|
83
|
+
}, A = (t) => {
|
|
85
84
|
const e = t.search;
|
|
86
85
|
if (u && u.search === e)
|
|
87
86
|
return u.params;
|
|
88
87
|
const n = new URLSearchParams(e), s = {};
|
|
89
|
-
return
|
|
88
|
+
return D.forEach((r) => {
|
|
90
89
|
const o = n.get(r);
|
|
91
90
|
if (o) {
|
|
92
91
|
const a = r.replace("utm_", "");
|
|
@@ -107,7 +106,7 @@ const l = (t) => {
|
|
|
107
106
|
} catch {
|
|
108
107
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
109
108
|
}
|
|
110
|
-
},
|
|
109
|
+
}, R = (t, e = typeof window < "u" ? window.location : {}) => {
|
|
111
110
|
const n = N(), s = w(), { properties: r } = t, o = {};
|
|
112
111
|
Object.keys(r).forEach((c) => {
|
|
113
112
|
_.includes(c) || (o[c] = r[c]);
|
|
@@ -121,7 +120,7 @@ const l = (t) => {
|
|
|
121
120
|
doc_host: e.hostname,
|
|
122
121
|
doc_path: e.pathname,
|
|
123
122
|
title: r.title ?? document?.title
|
|
124
|
-
}, i =
|
|
123
|
+
}, i = A(e);
|
|
125
124
|
return {
|
|
126
125
|
...t,
|
|
127
126
|
page: a,
|
|
@@ -139,18 +138,18 @@ function b(t, e) {
|
|
|
139
138
|
};
|
|
140
139
|
}
|
|
141
140
|
function x(t) {
|
|
142
|
-
return t.dataset.
|
|
141
|
+
return t.dataset.dotIdentifier || null;
|
|
143
142
|
}
|
|
144
|
-
function
|
|
143
|
+
function Y(t) {
|
|
145
144
|
return {
|
|
146
|
-
identifier: t.dataset.
|
|
147
|
-
inode: t.dataset.
|
|
148
|
-
contentType: t.dataset.
|
|
149
|
-
title: t.dataset.
|
|
150
|
-
baseType: t.dataset.
|
|
145
|
+
identifier: t.dataset.dotIdentifier || "",
|
|
146
|
+
inode: t.dataset.dotInode || "",
|
|
147
|
+
contentType: t.dataset.dotType || "",
|
|
148
|
+
title: t.dataset.dotTitle || "",
|
|
149
|
+
baseType: t.dataset.dotBasetype || ""
|
|
151
150
|
};
|
|
152
151
|
}
|
|
153
|
-
const
|
|
152
|
+
const B = 100, M = () => typeof window < "u" && typeof document < "u", F = () => Array.from(document.querySelectorAll(`.${h}`)), k = (t, e = T) => {
|
|
154
153
|
const n = b(t, e), s = new MutationObserver((r) => {
|
|
155
154
|
r.some((a) => a.addedNodes.length === 0 && a.removedNodes.length === 0 ? !1 : [
|
|
156
155
|
...Array.from(a.addedNodes),
|
|
@@ -168,33 +167,33 @@ const F = 100, M = () => typeof window < "u" && typeof document < "u", k = () =>
|
|
|
168
167
|
attributes: !1,
|
|
169
168
|
characterData: !1
|
|
170
169
|
}), s;
|
|
171
|
-
},
|
|
170
|
+
}, z = (t) => {
|
|
172
171
|
M() && (window.addEventListener("beforeunload", t), window.addEventListener("pagehide", t));
|
|
173
|
-
},
|
|
172
|
+
}, H = (t, e) => {
|
|
174
173
|
const n = e.logLevel ?? (e.debug ? "debug" : "warn");
|
|
175
|
-
return new
|
|
176
|
-
},
|
|
174
|
+
return new E("Analytics", t, n);
|
|
175
|
+
}, J = (t, e, n) => [
|
|
177
176
|
t.impressions && e(t),
|
|
178
177
|
t.clicks && n(t)
|
|
179
178
|
].filter(Boolean);
|
|
180
179
|
export {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
B as INITIAL_SCAN_DELAY_MS,
|
|
181
|
+
k as createContentletObserver,
|
|
182
|
+
H as createPluginLogger,
|
|
184
183
|
b as createThrottle,
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
R as enrichPagePayloadOptimized,
|
|
185
|
+
Y as extractContentletData,
|
|
187
186
|
x as extractContentletIdentifier,
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
A as extractUTMParameters,
|
|
188
|
+
F as findContentlets,
|
|
190
189
|
l as generateSecureId,
|
|
191
|
-
|
|
190
|
+
P as getAnalyticsContext,
|
|
192
191
|
C as getDeviceDataForContext,
|
|
193
|
-
|
|
192
|
+
J as getEnhancedTrackingPlugins,
|
|
194
193
|
N as getLocalTime,
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
v as getSessionId,
|
|
195
|
+
I as getUserId,
|
|
197
196
|
M as isBrowser,
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
z as setupPluginCleanup,
|
|
198
|
+
$ as validateAnalyticsConfig
|
|
200
199
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { UVEEventType as
|
|
2
|
-
import { onContentletHovered as
|
|
3
|
-
|
|
4
|
-
const N = "__dotAnalyticsActive__", T = "__dotAnalyticsCleanup";
|
|
5
|
-
export {
|
|
6
|
-
N as ANALYTICS_WINDOWS_ACTIVE_KEY,
|
|
7
|
-
T as ANALYTICS_WINDOWS_CLEANUP_KEY
|
|
8
|
-
};
|
|
1
|
+
import { UVEEventType as n } from "../../../types/src/lib/editor/public.js";
|
|
2
|
+
import { onContentletHovered as r, onIframeScroll as o, onRequestBounds as t, onPageReload as E, onContentChanges as u } from "./events.js";
|
|
3
|
+
n.CONTENT_CHANGES + "", n.PAGE_RELOAD + "", n.REQUEST_BOUNDS + "", n.IFRAME_SCROLL + "", n.CONTENTLET_HOVERED + "";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UVEEventType as a } from "../../../types/src/lib/editor/public.js";
|
|
2
2
|
import { __DOTCMS_UVE_EVENT__ as s } from "../../../types/src/lib/events/internal.js";
|
|
3
|
-
import { findDotCMSElement as u, findDotCMSVTLData as C, getClosestDotCMSContainerData as g, getDotCMSPageBounds as
|
|
3
|
+
import { findDotCMSElement as u, findDotCMSVTLData as C, getClosestDotCMSContainerData as g, getDotCMSPageBounds as N } from "../lib/dom/dom.utils.js";
|
|
4
4
|
function O(o) {
|
|
5
5
|
const t = (n) => {
|
|
6
6
|
n.data.name === s.UVE_SET_PAGE_DATA && o(n.data.payload);
|
|
@@ -12,7 +12,7 @@ function O(o) {
|
|
|
12
12
|
event: a.CONTENT_CHANGES
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function p(o) {
|
|
16
16
|
const t = (n) => {
|
|
17
17
|
n.data.name === s.UVE_RELOAD_PAGE && o();
|
|
18
18
|
};
|
|
@@ -23,12 +23,12 @@ function b(o) {
|
|
|
23
23
|
event: a.PAGE_RELOAD
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function b(o) {
|
|
27
27
|
const t = (n) => {
|
|
28
28
|
if (n.data.name === s.UVE_REQUEST_BOUNDS) {
|
|
29
29
|
const e = Array.from(
|
|
30
30
|
document.querySelectorAll('[data-dot-object="container"]')
|
|
31
|
-
), i =
|
|
31
|
+
), i = N(e);
|
|
32
32
|
o(i);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
@@ -39,7 +39,7 @@ function M(o) {
|
|
|
39
39
|
event: a.REQUEST_BOUNDS
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function M(o) {
|
|
43
43
|
const t = (n) => {
|
|
44
44
|
if (n.data.name === s.UVE_SCROLL_INSIDE_IFRAME) {
|
|
45
45
|
const e = n.data.direction;
|
|
@@ -53,7 +53,7 @@ function p(o) {
|
|
|
53
53
|
event: a.IFRAME_SCROLL
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function S(o) {
|
|
57
57
|
const t = (n) => {
|
|
58
58
|
const e = u(n.target);
|
|
59
59
|
if (!e) return;
|
|
@@ -72,7 +72,10 @@ function w(o) {
|
|
|
72
72
|
contentType: e.dataset?.dotType,
|
|
73
73
|
baseType: e.dataset?.dotBasetype,
|
|
74
74
|
widgetTitle: e.dataset?.dotWidgetTitle,
|
|
75
|
-
onNumberOfPages: e.dataset?.dotOnNumberOfPages
|
|
75
|
+
onNumberOfPages: e.dataset?.dotOnNumberOfPages,
|
|
76
|
+
...e.dataset?.dotStyleProperties && {
|
|
77
|
+
styleProperties: JSON.parse(e.dataset.dotStyleProperties)
|
|
78
|
+
}
|
|
76
79
|
}, m = C(e), _ = {
|
|
77
80
|
container: (
|
|
78
81
|
// Here extract dot-container from contentlet if it is Headless
|
|
@@ -99,8 +102,8 @@ function w(o) {
|
|
|
99
102
|
}
|
|
100
103
|
export {
|
|
101
104
|
O as onContentChanges,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
S as onContentletHovered,
|
|
106
|
+
M as onIframeScroll,
|
|
107
|
+
p as onPageReload,
|
|
108
|
+
b as onRequestBounds
|
|
106
109
|
};
|