@dotcms/analytics 26.9.18-1 → 26.9.23-1
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/MIGRATION.md +42 -0
- package/README.md +10 -1
- package/index.d.ts +1 -1
- package/index.js +4 -4
- package/lib/core/dot-analytics.content.js +10 -11
- package/lib/core/plugin/identity/dot-analytics.identity.plugin.d.ts +4 -4
- package/lib/core/plugin/impression/dot-analytics.impression-tracker.js +13 -13
- package/lib/core/public-api.d.ts +12 -0
- package/lib/core/shared/constants/dot-analytics.constants.js +24 -23
- package/lib/core/shared/http/dot-analytics.http.js +3 -3
- package/lib/core/shared/queue/dot-analytics.queue.utils.js +13 -13
- package/lib/core/shared/utils/dot-analytics.utils.js +223 -153
- package/lib/react/hook/useContentAnalytics.js +6 -7
- package/package.json +19 -7
- package/types/src/lib/editor/public.js +2 -3
- package/uve/src/lib/core/core.utils.js +2 -3
- package/types/src/lib/events/internal.js +0 -4
- package/uve/src/internal/constants.js +0 -7
- package/uve/src/internal/contentlet-sentinel.constants.js +0 -5
- package/uve/src/internal/events.js +0 -196
- package/uve/src/lib/dom/dom.utils.js +0 -103
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { UVEEventType as u } from "../../../types/src/lib/editor/public.js";
|
|
2
|
-
import { __DOTCMS_UVE_EVENT__ as f } from "../../../types/src/lib/events/internal.js";
|
|
3
|
-
import { DOT_SECTION_ID_PREFIX as S } from "./constants.js";
|
|
4
|
-
import { TEMP_EMPTY_CONTENTLET as _, TEMP_EMPTY_CONTENTLET_TYPE as p } from "./contentlet-sentinel.constants.js";
|
|
5
|
-
import { getNativeEventBinder as T, findDotCMSElement as L, readContentletDataset as O, findDotCMSVTLData as g, getClosestDotCMSContainerData as N, getDotCMSPageBounds as D } from "../lib/dom/dom.utils.js";
|
|
6
|
-
function R(a) {
|
|
7
|
-
const e = (o) => {
|
|
8
|
-
o.data.name === f.UVE_SET_PAGE_DATA && a(o.data.payload);
|
|
9
|
-
}, t = T(window);
|
|
10
|
-
return t.addEventListener("message", e), {
|
|
11
|
-
unsubscribe: () => {
|
|
12
|
-
t.removeEventListener("message", e);
|
|
13
|
-
},
|
|
14
|
-
event: u.CONTENT_CHANGES
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function U(a) {
|
|
18
|
-
const e = (o) => {
|
|
19
|
-
o.data.name === f.UVE_RELOAD_PAGE && a();
|
|
20
|
-
}, t = T(window);
|
|
21
|
-
return t.addEventListener("message", e), {
|
|
22
|
-
unsubscribe: () => {
|
|
23
|
-
t.removeEventListener("message", e);
|
|
24
|
-
},
|
|
25
|
-
event: u.PAGE_RELOAD
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const w = 100;
|
|
29
|
-
function h(a) {
|
|
30
|
-
let e = null, t = [];
|
|
31
|
-
const o = () => {
|
|
32
|
-
const r = Array.from(
|
|
33
|
-
document.querySelectorAll('[data-dot-object="container"]')
|
|
34
|
-
);
|
|
35
|
-
a(D(r));
|
|
36
|
-
}, n = () => {
|
|
37
|
-
e !== null && clearTimeout(e), e = setTimeout(() => {
|
|
38
|
-
e = null, o();
|
|
39
|
-
}, w);
|
|
40
|
-
}, s = new ResizeObserver(() => {
|
|
41
|
-
n();
|
|
42
|
-
}), i = () => {
|
|
43
|
-
for (const r of t)
|
|
44
|
-
s.unobserve(r);
|
|
45
|
-
t = Array.from(
|
|
46
|
-
document.querySelectorAll('[data-dot-object="container"]')
|
|
47
|
-
), s.observe(document.documentElement);
|
|
48
|
-
for (const r of t)
|
|
49
|
-
s.observe(r);
|
|
50
|
-
};
|
|
51
|
-
i();
|
|
52
|
-
const C = (r) => {
|
|
53
|
-
for (let c = 0; c < r.length; c++) {
|
|
54
|
-
const v = r[c];
|
|
55
|
-
if (v.nodeType !== Node.ELEMENT_NODE)
|
|
56
|
-
continue;
|
|
57
|
-
const b = v;
|
|
58
|
-
if (b.matches?.('[data-dot-object="container"]') || b.querySelector?.('[data-dot-object="container"]'))
|
|
59
|
-
return !0;
|
|
60
|
-
}
|
|
61
|
-
return !1;
|
|
62
|
-
}, d = new MutationObserver((r) => {
|
|
63
|
-
for (const c of r)
|
|
64
|
-
if (c.type === "childList" && (C(c.addedNodes) || C(c.removedNodes))) {
|
|
65
|
-
i(), n();
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
d.observe(document.body ?? document.documentElement, {
|
|
70
|
-
childList: !0,
|
|
71
|
-
subtree: !0
|
|
72
|
-
});
|
|
73
|
-
const l = T(window), E = () => n();
|
|
74
|
-
l.addEventListener("scroll", E, { passive: !0 });
|
|
75
|
-
const m = (r) => {
|
|
76
|
-
r?.data?.name === f.UVE_FLUSH_BOUNDS && (e !== null && (clearTimeout(e), e = null), o());
|
|
77
|
-
};
|
|
78
|
-
return l.addEventListener("message", m), {
|
|
79
|
-
unsubscribe: () => {
|
|
80
|
-
e !== null && (clearTimeout(e), e = null), s.disconnect(), d.disconnect(), l.removeEventListener("scroll", E), l.removeEventListener("message", m), t = [];
|
|
81
|
-
},
|
|
82
|
-
event: u.AUTO_BOUNDS
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function V(a) {
|
|
86
|
-
const e = (o) => {
|
|
87
|
-
if (o.data.name === f.UVE_SCROLL_INSIDE_IFRAME) {
|
|
88
|
-
const n = o.data.direction;
|
|
89
|
-
a(n);
|
|
90
|
-
}
|
|
91
|
-
}, t = T(window);
|
|
92
|
-
return t.addEventListener("message", e), {
|
|
93
|
-
unsubscribe: () => {
|
|
94
|
-
t.removeEventListener("message", e);
|
|
95
|
-
},
|
|
96
|
-
event: u.IFRAME_SCROLL
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function k(a) {
|
|
100
|
-
const e = (o) => {
|
|
101
|
-
if (o.data.name !== f.UVE_SCROLL_TO_SECTION)
|
|
102
|
-
return;
|
|
103
|
-
const n = o.data.sectionIndex, s = document.querySelector(`#${S}${n}`) ?? document.querySelector(`#section-${n}`);
|
|
104
|
-
s && a({ sectionIndex: n, offsetTop: s.offsetTop });
|
|
105
|
-
}, t = T(window);
|
|
106
|
-
return t.addEventListener("message", e), {
|
|
107
|
-
unsubscribe: () => {
|
|
108
|
-
t.removeEventListener("message", e);
|
|
109
|
-
},
|
|
110
|
-
event: u.SCROLL_TO_SECTION
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function B(a) {
|
|
114
|
-
let e = !1;
|
|
115
|
-
const t = (o) => {
|
|
116
|
-
const n = L(o.target);
|
|
117
|
-
if (!n) {
|
|
118
|
-
e && (e = !1, a(null));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const { x: s, y: i, width: C, height: d } = n.getBoundingClientRect(), l = n.dataset?.dotObject === "container", E = {
|
|
122
|
-
identifier: _,
|
|
123
|
-
title: _,
|
|
124
|
-
contentType: p,
|
|
125
|
-
inode: "TEMPY_EMPTY_CONTENTLET_INODE",
|
|
126
|
-
widgetTitle: _,
|
|
127
|
-
baseType: _,
|
|
128
|
-
onNumberOfPages: 1
|
|
129
|
-
}, m = O(n), r = g(n), c = {
|
|
130
|
-
container: (
|
|
131
|
-
// Here extract dot-container from contentlet if it is Headless
|
|
132
|
-
// or search in parent container if it is VTL
|
|
133
|
-
n.dataset?.dotContainer ? JSON.parse(n.dataset?.dotContainer) : N(n)
|
|
134
|
-
),
|
|
135
|
-
contentlet: l ? E : m,
|
|
136
|
-
vtlFiles: r
|
|
137
|
-
}, v = {
|
|
138
|
-
x: s,
|
|
139
|
-
y: i,
|
|
140
|
-
width: C,
|
|
141
|
-
height: d,
|
|
142
|
-
payload: c
|
|
143
|
-
};
|
|
144
|
-
e = !0, a(v);
|
|
145
|
-
};
|
|
146
|
-
return document.documentElement.addEventListener("pointermove", t), {
|
|
147
|
-
unsubscribe: () => {
|
|
148
|
-
document.documentElement.removeEventListener("pointermove", t);
|
|
149
|
-
},
|
|
150
|
-
event: u.CONTENTLET_HOVERED
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function F(a) {
|
|
154
|
-
let e;
|
|
155
|
-
const t = (s) => {
|
|
156
|
-
const i = L(s.target);
|
|
157
|
-
if (!i || i.dataset?.dotObject === "container") return;
|
|
158
|
-
const d = i.dataset?.dotInode;
|
|
159
|
-
if (d && d === e)
|
|
160
|
-
return;
|
|
161
|
-
s.preventDefault(), s.stopPropagation(), e = d;
|
|
162
|
-
const { x: l, y: E, width: m, height: r } = i.getBoundingClientRect(), c = O(i), v = g(i);
|
|
163
|
-
a({
|
|
164
|
-
x: l,
|
|
165
|
-
y: E,
|
|
166
|
-
width: m,
|
|
167
|
-
height: r,
|
|
168
|
-
payload: {
|
|
169
|
-
container: i.dataset?.dotContainer ? JSON.parse(i.dataset?.dotContainer) : N(i),
|
|
170
|
-
contentlet: c,
|
|
171
|
-
vtlFiles: v
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}, o = (s) => {
|
|
175
|
-
s?.data?.name === f.UVE_SELECTION_CLEARED && (e = void 0);
|
|
176
|
-
};
|
|
177
|
-
document.documentElement.addEventListener("click", t, { capture: !0 });
|
|
178
|
-
const n = T(window);
|
|
179
|
-
return n.addEventListener("message", o), {
|
|
180
|
-
unsubscribe: () => {
|
|
181
|
-
document.documentElement.removeEventListener("click", t, {
|
|
182
|
-
capture: !0
|
|
183
|
-
}), n.removeEventListener("message", o);
|
|
184
|
-
},
|
|
185
|
-
event: u.CONTENTLET_CLICKED
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
export {
|
|
189
|
-
h as onAutoBounds,
|
|
190
|
-
R as onContentChanges,
|
|
191
|
-
F as onContentletClicked,
|
|
192
|
-
B as onContentletHovered,
|
|
193
|
-
V as onIframeScroll,
|
|
194
|
-
U as onPageReload,
|
|
195
|
-
k as onScrollToSection
|
|
196
|
-
};
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import "../../internal/constants.js";
|
|
2
|
-
function p(t) {
|
|
3
|
-
return t.map((e) => {
|
|
4
|
-
const n = e.getBoundingClientRect(), o = Array.from(
|
|
5
|
-
e.querySelectorAll('[data-dot-object="contentlet"]')
|
|
6
|
-
);
|
|
7
|
-
return {
|
|
8
|
-
x: n.x,
|
|
9
|
-
y: n.y,
|
|
10
|
-
width: n.width,
|
|
11
|
-
height: n.height,
|
|
12
|
-
payload: JSON.stringify({
|
|
13
|
-
container: r(e)
|
|
14
|
-
}),
|
|
15
|
-
contentlets: u(n, o)
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function i(t) {
|
|
20
|
-
return t?.dotCanEdit !== "false";
|
|
21
|
-
}
|
|
22
|
-
function u(t, e) {
|
|
23
|
-
return e.map((n) => {
|
|
24
|
-
const o = n.getBoundingClientRect();
|
|
25
|
-
return {
|
|
26
|
-
x: 0,
|
|
27
|
-
y: o.y - t.y,
|
|
28
|
-
width: o.width,
|
|
29
|
-
height: o.height,
|
|
30
|
-
payload: JSON.stringify({
|
|
31
|
-
container: n.dataset?.dotContainer ? JSON.parse(n.dataset?.dotContainer) : l(n),
|
|
32
|
-
contentlet: {
|
|
33
|
-
identifier: n.dataset?.dotIdentifier,
|
|
34
|
-
title: n.dataset?.dotTitle,
|
|
35
|
-
inode: n.dataset?.dotInode,
|
|
36
|
-
contentType: n.dataset?.dotType,
|
|
37
|
-
canEdit: i(n.dataset)
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function r(t) {
|
|
44
|
-
return {
|
|
45
|
-
acceptTypes: t.dataset?.dotAcceptTypes || "",
|
|
46
|
-
identifier: t.dataset?.dotIdentifier || "",
|
|
47
|
-
maxContentlets: t.dataset?.maxContentlets || "",
|
|
48
|
-
uuid: t.dataset?.dotUuid || ""
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function l(t) {
|
|
52
|
-
const e = t.closest('[data-dot-object="container"]');
|
|
53
|
-
return e ? r(e) : (console.warn("No container found for the contentlet"), null);
|
|
54
|
-
}
|
|
55
|
-
function f(t) {
|
|
56
|
-
if (!t) return null;
|
|
57
|
-
const e = t.querySelector('[data-dot-object="empty-content"]');
|
|
58
|
-
return t?.dataset?.dotObject === "contentlet" || // The container inside Headless components have a span with the data-dot-object="container" attribute
|
|
59
|
-
t?.dataset?.dotObject === "container" && e || // The container inside Traditional have no content inside
|
|
60
|
-
t?.dataset?.dotObject === "container" && t.children.length === 0 ? t : f(t?.parentElement);
|
|
61
|
-
}
|
|
62
|
-
function g(t) {
|
|
63
|
-
const e = t.querySelectorAll(
|
|
64
|
-
'[data-dot-object="vtl-file"]'
|
|
65
|
-
);
|
|
66
|
-
return e.length ? Array.from(e).map((n) => ({
|
|
67
|
-
inode: n.dataset?.dotInode,
|
|
68
|
-
name: n.dataset?.dotUrl
|
|
69
|
-
})) : null;
|
|
70
|
-
}
|
|
71
|
-
function C(t) {
|
|
72
|
-
const e = t.dataset ?? {};
|
|
73
|
-
return {
|
|
74
|
-
identifier: e.dotIdentifier,
|
|
75
|
-
title: e.dotTitle,
|
|
76
|
-
inode: e.dotInode,
|
|
77
|
-
contentType: e.dotType,
|
|
78
|
-
baseType: e.dotBasetype,
|
|
79
|
-
widgetTitle: e.dotWidgetTitle,
|
|
80
|
-
onNumberOfPages: e.dotOnNumberOfPages,
|
|
81
|
-
canEdit: i(e),
|
|
82
|
-
...e.dotStyleProperties && {
|
|
83
|
-
dotStyleProperties: JSON.parse(e.dotStyleProperties)
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function b(t) {
|
|
88
|
-
const e = globalThis.Zone, n = (a) => typeof e?.__symbol__ == "function" ? e.__symbol__(a) : `__zone_symbol__${a}`, o = t, d = t, s = o[n("addEventListener")], c = o[n("removeEventListener")];
|
|
89
|
-
return {
|
|
90
|
-
addEventListener: (s ?? d.addEventListener).bind(d),
|
|
91
|
-
removeEventListener: (c ?? d.removeEventListener).bind(d)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export {
|
|
95
|
-
f as findDotCMSElement,
|
|
96
|
-
g as findDotCMSVTLData,
|
|
97
|
-
l as getClosestDotCMSContainerData,
|
|
98
|
-
r as getDotCMSContainerData,
|
|
99
|
-
u as getDotCMSContentletsBound,
|
|
100
|
-
p as getDotCMSPageBounds,
|
|
101
|
-
b as getNativeEventBinder,
|
|
102
|
-
C as readContentletDataset
|
|
103
|
-
};
|