@dotcms/analytics 1.0.3 → 1.0.4-next.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/index.js +2 -2
- package/lib/dotAnalytics/shared/dot-content-analytics.model.d.ts +0 -6
- package/lib/react/components/DotContentAnalytics.d.ts +13 -0
- package/lib/react/components/DotContentAnalytics.js +10 -0
- package/lib/react/hook/useContentAnalytics.d.ts +12 -34
- package/lib/react/hook/useContentAnalytics.js +18 -17
- package/lib/react/hook/useRouterTracker.d.ts +7 -5
- package/lib/react/hook/useRouterTracker.js +14 -14
- package/lib/react/internal/index.d.ts +1 -1
- package/lib/react/internal/utils.d.ts +6 -0
- package/lib/react/internal/utils.js +6 -0
- package/lib/react/public-api.d.ts +2 -1
- package/package.json +5 -3
- package/react/index.js +3 -2
- package/types/src/lib/editor/public.js +5 -0
- package/types/src/lib/events/internal.js +4 -0
- package/uve/src/internal/constants.js +3 -0
- package/uve/src/internal/events.js +107 -0
- package/uve/src/lib/core/core.utils.js +21 -0
- package/uve/src/lib/dom/dom.utils.js +80 -0
- package/lib/react/components/DotContentAnalyticsProvider.d.ts +0 -19
- package/lib/react/components/DotContentAnalyticsProvider.js +0 -18
- package/lib/react/contexts/DotContentAnalyticsContext.d.ts +0 -12
- package/lib/react/contexts/DotContentAnalyticsContext.js +0 -5
- package/lib/react/internal/uve.utils.d.ts +0 -17
- package/lib/react/internal/uve.utils.js +0 -6
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DotContentAnalytics as n } from "./lib/react/components/DotContentAnalytics.js";
|
|
2
2
|
import { useContentAnalytics as r } from "./lib/react/hook/useContentAnalytics.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
4
|
+
n as DotContentAnalytics,
|
|
5
5
|
r as useContentAnalytics
|
|
6
6
|
};
|
|
@@ -25,12 +25,6 @@ export interface DotCMSAnalyticsConfig {
|
|
|
25
25
|
* The site key for authenticating with the Analytics service.
|
|
26
26
|
*/
|
|
27
27
|
siteKey: string;
|
|
28
|
-
/**
|
|
29
|
-
* Custom redirect function handler.
|
|
30
|
-
* When provided, this function will be called instead of the default browser redirect
|
|
31
|
-
* for handling URL redirections.
|
|
32
|
-
*/
|
|
33
|
-
redirectFn?: (url: string) => void;
|
|
34
28
|
}
|
|
35
29
|
/**
|
|
36
30
|
* Supported event types in DotCMS Analytics.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { DotCMSAnalyticsConfig } from '../../dotAnalytics/shared/dot-content-analytics.model';
|
|
3
|
+
/**
|
|
4
|
+
* Client bootstrapper for dotCMS Analytics in React/Next.
|
|
5
|
+
* - No UI: initializes the analytics singleton from props or env config.
|
|
6
|
+
* - If auto tracking is enabled, hooks into Next App Router to send page views.
|
|
7
|
+
*
|
|
8
|
+
* @param props.config - Optional analytics configuration. If provided, overrides env config.
|
|
9
|
+
*/
|
|
10
|
+
export interface DotContentAnalyticsProps {
|
|
11
|
+
config: DotCMSAnalyticsConfig;
|
|
12
|
+
}
|
|
13
|
+
export declare function DotContentAnalytics({ config }: DotContentAnalyticsProps): ReactElement | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useMemo as r } from "react";
|
|
2
|
+
import { useRouterTracker as n } from "../hook/useRouterTracker.js";
|
|
3
|
+
import { initializeAnalytics as i } from "../internal/utils.js";
|
|
4
|
+
function m({ config: t }) {
|
|
5
|
+
const o = r(() => i(t), [t]), e = !!t.debug;
|
|
6
|
+
return o && n(o, e), null;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
m as DotContentAnalytics
|
|
10
|
+
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { DotCMSAnalytics } from '../../dotAnalytics/shared/dot-content-analytics.model';
|
|
1
|
+
import { DotCMSAnalytics, DotCMSAnalyticsConfig } from '../../dotAnalytics/shared/dot-content-analytics.model';
|
|
2
2
|
/**
|
|
3
3
|
* Custom hook that handles analytics tracking for anonymous users.
|
|
4
|
+
* Provides methods to track events and page views with automatic timestamp injection.
|
|
5
|
+
* Automatically disables tracking when inside the UVE editor.
|
|
4
6
|
*
|
|
5
7
|
* @example
|
|
6
8
|
* ```tsx
|
|
7
9
|
* function Button({ title, urlTitle }) {
|
|
8
|
-
* const { track } = useContentAnalytics(
|
|
10
|
+
* const { track } = useContentAnalytics({
|
|
11
|
+
* server: 'https://demo.dotcms.com',
|
|
12
|
+
* siteKey: 'my-site-key',
|
|
13
|
+
* debug: false
|
|
14
|
+
* });
|
|
9
15
|
*
|
|
10
16
|
* // Track button click with custom properties
|
|
11
17
|
* return (
|
|
@@ -16,36 +22,8 @@ import { DotCMSAnalytics } from '../../dotAnalytics/shared/dot-content-analytics
|
|
|
16
22
|
* }
|
|
17
23
|
* ```
|
|
18
24
|
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* function AnalyticsDebugComponent() {
|
|
23
|
-
* const { getAnonymousUserId, getSessionInfo, updateSessionActivity } = useContentAnalytics();
|
|
24
|
-
*
|
|
25
|
-
* const handleManualActivity = () => {
|
|
26
|
-
* updateSessionActivity();
|
|
27
|
-
* // Manual activity updated
|
|
28
|
-
* };
|
|
29
|
-
*
|
|
30
|
-
* // Debug session info in development
|
|
31
|
-
* const debugInfo = () => {
|
|
32
|
-
* if (process.env.NODE_ENV === 'development') {
|
|
33
|
-
* console.log('Anonymous ID:', getAnonymousUserId());
|
|
34
|
-
* console.log('Session info:', getSessionInfo());
|
|
35
|
-
* }
|
|
36
|
-
* };
|
|
37
|
-
*
|
|
38
|
-
* return (
|
|
39
|
-
* <div>
|
|
40
|
-
* <button onClick={handleManualActivity}>Update Activity</button>
|
|
41
|
-
* <button onClick={debugInfo}>Debug Session</button>
|
|
42
|
-
* <p>User ID: {getAnonymousUserId()}</p>
|
|
43
|
-
* </div>
|
|
44
|
-
* );
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @returns {DotCMSAnalytics} - The analytics instance with tracking capabilities for anonymous users
|
|
49
|
-
* @throws {Error} - Throws error if used outside of DotContentAnalyticsProvider or if analytics failed to initialize
|
|
25
|
+
* @param {DotCMSAnalyticsConfig} config - Required configuration object for analytics initialization
|
|
26
|
+
* @returns {DotCMSAnalytics} The analytics instance with tracking capabilities
|
|
27
|
+
* @throws {Error} When analytics initialization fails due to invalid configuration
|
|
50
28
|
*/
|
|
51
|
-
export declare const useContentAnalytics: () => DotCMSAnalytics;
|
|
29
|
+
export declare const useContentAnalytics: (config: DotCMSAnalyticsConfig) => DotCMSAnalytics;
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { useRef as l, useCallback as n } from "react";
|
|
2
|
+
import { getUVEState as r } from "../../../uve/src/lib/core/core.utils.js";
|
|
3
|
+
import "../../../uve/src/internal/constants.js";
|
|
4
|
+
import { initializeAnalytics as f } from "../internal/utils.js";
|
|
5
|
+
const g = (o) => {
|
|
6
|
+
const t = f(o), i = l(null);
|
|
6
7
|
if (!t)
|
|
7
8
|
throw new Error(
|
|
8
|
-
"
|
|
9
|
+
"Failed to initialize DotContentAnalytics. Please verify the required configuration (server and siteKey)."
|
|
9
10
|
);
|
|
10
|
-
const
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
...
|
|
11
|
+
const a = n(
|
|
12
|
+
(e, s = {}) => {
|
|
13
|
+
r() || t.track(e, {
|
|
14
|
+
...s,
|
|
14
15
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
15
16
|
});
|
|
16
17
|
},
|
|
17
18
|
[t]
|
|
18
|
-
),
|
|
19
|
-
if (!
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
), c = n(() => {
|
|
20
|
+
if (!r()) {
|
|
21
|
+
const e = window.location.pathname;
|
|
22
|
+
e !== i.current && (i.current = e, t.pageView());
|
|
22
23
|
}
|
|
23
24
|
}, [t]);
|
|
24
25
|
return {
|
|
25
|
-
track:
|
|
26
|
-
pageView:
|
|
26
|
+
track: a,
|
|
27
|
+
pageView: c
|
|
27
28
|
};
|
|
28
29
|
};
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
g as useContentAnalytics
|
|
31
32
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { DotCMSAnalytics } from '../../dotAnalytics/shared/dot-content-analytics.model';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* Tracks page views on route changes using Next.js App Router signals.
|
|
4
|
+
* - Fires a single pageView per unique path+search.
|
|
5
|
+
* - Disabled inside UVE editor.
|
|
6
|
+
* - Requires Next.js App Router; no SPA fallback.
|
|
7
7
|
*
|
|
8
|
+
* @param analytics Analytics singleton instance; if null, does nothing
|
|
9
|
+
* @param debug When true, logs which tracking path is used
|
|
8
10
|
*/
|
|
9
|
-
export declare function useRouterTracker(analytics: DotCMSAnalytics | null): void;
|
|
11
|
+
export declare function useRouterTracker(analytics: DotCMSAnalytics | null, debug?: boolean): void;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
window.removeEventListener("popstate", e), window.removeEventListener("beforeunload", e);
|
|
1
|
+
import { usePathname as u, useSearchParams as p } from "next/navigation";
|
|
2
|
+
import { useRef as c, useEffect as m } from "react";
|
|
3
|
+
import { getUVEState as s } from "../../../uve/src/lib/core/core.utils.js";
|
|
4
|
+
import "../../../uve/src/internal/constants.js";
|
|
5
|
+
const g = (e, t) => `${e}${t != null && t.toString() ? "?" + t.toString() : ""}`;
|
|
6
|
+
function A(e, t = !1) {
|
|
7
|
+
const o = c(null), n = u(), r = p();
|
|
8
|
+
m(() => {
|
|
9
|
+
if (!e) return;
|
|
10
|
+
const i = (f) => {
|
|
11
|
+
s() || f !== o.current && (o.current = f, e.pageView());
|
|
13
12
|
};
|
|
14
|
-
|
|
13
|
+
t && console.info("DotContentAnalytics: using Next.js App Router tracking"), i(g(n, r));
|
|
14
|
+
}, [e, n, r, t]);
|
|
15
15
|
}
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
A as useRouterTracker
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { initializeAnalytics } from './utils';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DotCMSAnalytics, DotCMSAnalyticsConfig } from '../../dotAnalytics/shared/dot-content-analytics.model';
|
|
2
|
+
/**
|
|
3
|
+
* Initializes analytics with explicit configuration.
|
|
4
|
+
* Resets singleton if config changes.
|
|
5
|
+
*/
|
|
6
|
+
export declare const initializeAnalytics: (config: DotCMSAnalyticsConfig) => DotCMSAnalytics | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { initializeContentAnalytics as r } from "../../dotAnalytics/dot-content-analytics.js";
|
|
2
|
+
let e, t;
|
|
3
|
+
const s = (i) => (t && (t.server !== i.server || t.siteKey !== i.siteKey) && (e = void 0), e !== void 0 || (t = i, e = r(i)), e);
|
|
4
|
+
export {
|
|
5
|
+
s as initializeAnalytics
|
|
6
|
+
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export type { DotCMSAnalyticsConfig } from '../dotAnalytics/shared/dot-content-analytics.model';
|
|
2
|
+
export { DotContentAnalytics } from './components/DotContentAnalytics';
|
|
2
3
|
export { useContentAnalytics } from './hook/useContentAnalytics';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/analytics",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4-next.1",
|
|
4
4
|
"description": "Official JavaScript library for Content Analytics with DotCMS.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"analytics": "^0.8.0",
|
|
24
24
|
"@analytics/core": "^0.13.0",
|
|
25
|
-
"@analytics/storage-utils": "^0.4.0"
|
|
25
|
+
"@analytics/storage-utils": "^0.4.0",
|
|
26
|
+
"@dotcms/uve": "latest"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"react": "^18 || ^19"
|
|
@@ -30,7 +31,8 @@
|
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@testing-library/jest-dom": "^6.1.6",
|
|
32
33
|
"@testing-library/react": "^14.0.0",
|
|
33
|
-
"vite": "~5.0.0"
|
|
34
|
+
"vite": "~5.0.0",
|
|
35
|
+
"@dotcms/types": "latest"
|
|
34
36
|
},
|
|
35
37
|
"main": "./index.js",
|
|
36
38
|
"module": "./index.js",
|
package/react/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { DotContentAnalytics as n } from "../lib/react/components/DotContentAnalytics.js";
|
|
2
3
|
import { useContentAnalytics as r } from "../lib/react/hook/useContentAnalytics.js";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
+
n as DotContentAnalytics,
|
|
5
6
|
r as useContentAnalytics
|
|
6
7
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var N = /* @__PURE__ */ ((r) => (r.EDIT = "EDIT_MODE", r.PREVIEW = "PREVIEW_MODE", r.LIVE = "LIVE", r.UNKNOWN = "UNKNOWN", r))(N || {}), E = /* @__PURE__ */ ((r) => (r.CONTENT_CHANGES = "changes", r.PAGE_RELOAD = "page-reload", r.REQUEST_BOUNDS = "request-bounds", r.IFRAME_SCROLL = "iframe-scroll", r.CONTENTLET_HOVERED = "contentlet-hovered", r))(E || {});
|
|
2
|
+
export {
|
|
3
|
+
E as UVEEventType,
|
|
4
|
+
N as UVE_MODE
|
|
5
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var t = /* @__PURE__ */ ((e) => (e.UVE_RELOAD_PAGE = "uve-reload-page", e.UVE_REQUEST_BOUNDS = "uve-request-bounds", e.UVE_EDITOR_PONG = "uve-editor-pong", e.UVE_SCROLL_INSIDE_IFRAME = "uve-scroll-inside-iframe", e.UVE_SET_PAGE_DATA = "uve-set-page-data", e.UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS = "uve-copy-contentlet-inline-editing-success", e))(t || {});
|
|
2
|
+
export {
|
|
3
|
+
t as __DOTCMS_UVE_EVENT__
|
|
4
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
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 + "";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { UVEEventType as a } from "../../../types/src/lib/editor/public.js";
|
|
2
|
+
import { __DOTCMS_UVE_EVENT__ as s } from "../../../types/src/lib/events/internal.js";
|
|
3
|
+
import { findDotCMSElement as M, findDotCMSVTLData as p, getClosestDotCMSContainerData as w, getDotCMSPageBounds as S } from "../lib/dom/dom.utils.js";
|
|
4
|
+
function U(o) {
|
|
5
|
+
const t = (n) => {
|
|
6
|
+
n.data.name === s.UVE_SET_PAGE_DATA && o(n.data.payload);
|
|
7
|
+
};
|
|
8
|
+
return window.addEventListener("message", t), {
|
|
9
|
+
unsubscribe: () => {
|
|
10
|
+
window.removeEventListener("message", t);
|
|
11
|
+
},
|
|
12
|
+
event: a.CONTENT_CHANGES
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function V(o) {
|
|
16
|
+
const t = (n) => {
|
|
17
|
+
n.data.name === s.UVE_RELOAD_PAGE && o();
|
|
18
|
+
};
|
|
19
|
+
return window.addEventListener("message", t), {
|
|
20
|
+
unsubscribe: () => {
|
|
21
|
+
window.removeEventListener("message", t);
|
|
22
|
+
},
|
|
23
|
+
event: a.PAGE_RELOAD
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function I(o) {
|
|
27
|
+
const t = (n) => {
|
|
28
|
+
if (n.data.name === s.UVE_REQUEST_BOUNDS) {
|
|
29
|
+
const e = Array.from(
|
|
30
|
+
document.querySelectorAll('[data-dot-object="container"]')
|
|
31
|
+
), i = S(e);
|
|
32
|
+
o(i);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return window.addEventListener("message", t), {
|
|
36
|
+
unsubscribe: () => {
|
|
37
|
+
window.removeEventListener("message", t);
|
|
38
|
+
},
|
|
39
|
+
event: a.REQUEST_BOUNDS
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function Y(o) {
|
|
43
|
+
const t = (n) => {
|
|
44
|
+
if (n.data.name === s.UVE_SCROLL_INSIDE_IFRAME) {
|
|
45
|
+
const e = n.data.direction;
|
|
46
|
+
o(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return window.addEventListener("message", t), {
|
|
50
|
+
unsubscribe: () => {
|
|
51
|
+
window.removeEventListener("message", t);
|
|
52
|
+
},
|
|
53
|
+
event: a.IFRAME_SCROLL
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function B(o) {
|
|
57
|
+
const t = (n) => {
|
|
58
|
+
var d, r, E, c, T, l, m, _, u, C;
|
|
59
|
+
const e = M(n.target);
|
|
60
|
+
if (!e) return;
|
|
61
|
+
const { x: i, y: g, width: v, height: N } = e.getBoundingClientRect(), f = ((d = e.dataset) == null ? void 0 : d.dotObject) === "container", L = {
|
|
62
|
+
identifier: "TEMP_EMPTY_CONTENTLET",
|
|
63
|
+
title: "TEMP_EMPTY_CONTENTLET",
|
|
64
|
+
contentType: "TEMP_EMPTY_CONTENTLET_TYPE",
|
|
65
|
+
inode: "TEMPY_EMPTY_CONTENTLET_INODE",
|
|
66
|
+
widgetTitle: "TEMP_EMPTY_CONTENTLET",
|
|
67
|
+
baseType: "TEMP_EMPTY_CONTENTLET",
|
|
68
|
+
onNumberOfPages: 1
|
|
69
|
+
}, P = {
|
|
70
|
+
identifier: (r = e.dataset) == null ? void 0 : r.dotIdentifier,
|
|
71
|
+
title: (E = e.dataset) == null ? void 0 : E.dotTitle,
|
|
72
|
+
inode: (c = e.dataset) == null ? void 0 : c.dotInode,
|
|
73
|
+
contentType: (T = e.dataset) == null ? void 0 : T.dotType,
|
|
74
|
+
baseType: (l = e.dataset) == null ? void 0 : l.dotBasetype,
|
|
75
|
+
widgetTitle: (m = e.dataset) == null ? void 0 : m.dotWidgetTitle,
|
|
76
|
+
onNumberOfPages: (_ = e.dataset) == null ? void 0 : _.dotOnNumberOfPages
|
|
77
|
+
}, O = p(e), b = {
|
|
78
|
+
container: (
|
|
79
|
+
// Here extract dot-container from contentlet if it is Headless
|
|
80
|
+
// or search in parent container if it is VTL
|
|
81
|
+
(u = e.dataset) != null && u.dotContainer ? JSON.parse((C = e.dataset) == null ? void 0 : C.dotContainer) : w(e)
|
|
82
|
+
),
|
|
83
|
+
contentlet: f ? L : P,
|
|
84
|
+
vtlFiles: O
|
|
85
|
+
};
|
|
86
|
+
o({
|
|
87
|
+
x: i,
|
|
88
|
+
y: g,
|
|
89
|
+
width: v,
|
|
90
|
+
height: N,
|
|
91
|
+
payload: b
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return document.addEventListener("pointermove", t), {
|
|
95
|
+
unsubscribe: () => {
|
|
96
|
+
document.removeEventListener("pointermove", t);
|
|
97
|
+
},
|
|
98
|
+
event: a.CONTENTLET_HOVERED
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
U as onContentChanges,
|
|
103
|
+
B as onContentletHovered,
|
|
104
|
+
Y as onIframeScroll,
|
|
105
|
+
V as onPageReload,
|
|
106
|
+
I as onRequestBounds
|
|
107
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UVE_MODE as t } from "../../../../types/src/lib/editor/public.js";
|
|
2
|
+
import "../../internal/constants.js";
|
|
3
|
+
function p() {
|
|
4
|
+
if (typeof window > "u" || window.parent === window || !window.location)
|
|
5
|
+
return;
|
|
6
|
+
const e = new URL(window.location.href), o = Object.values(t);
|
|
7
|
+
let a = e.searchParams.get("mode") ?? t.EDIT;
|
|
8
|
+
const s = e.searchParams.get("language_id"), n = e.searchParams.get("personaId"), r = e.searchParams.get("variantName"), i = e.searchParams.get("experimentId"), c = e.searchParams.get("publishDate"), d = e.searchParams.get("dotCMSHost");
|
|
9
|
+
return o.includes(a) || (a = t.EDIT), {
|
|
10
|
+
mode: a,
|
|
11
|
+
languageId: s,
|
|
12
|
+
persona: n,
|
|
13
|
+
variantName: r,
|
|
14
|
+
experimentId: i,
|
|
15
|
+
publishDate: c,
|
|
16
|
+
dotCMSHost: d
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
p as getUVEState
|
|
21
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import "../../internal/constants.js";
|
|
2
|
+
function C(t) {
|
|
3
|
+
return t.map((a) => {
|
|
4
|
+
const o = a.getBoundingClientRect(), n = Array.from(
|
|
5
|
+
a.querySelectorAll('[data-dot-object="contentlet"]')
|
|
6
|
+
);
|
|
7
|
+
return {
|
|
8
|
+
x: o.x,
|
|
9
|
+
y: o.y,
|
|
10
|
+
width: o.width,
|
|
11
|
+
height: o.height,
|
|
12
|
+
payload: JSON.stringify({
|
|
13
|
+
container: u(a)
|
|
14
|
+
}),
|
|
15
|
+
contentlets: f(o, n)
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function f(t, a) {
|
|
20
|
+
return a.map((o) => {
|
|
21
|
+
var d, r, i, e, s, c;
|
|
22
|
+
const n = o.getBoundingClientRect();
|
|
23
|
+
return {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: n.y - t.y,
|
|
26
|
+
width: n.width,
|
|
27
|
+
height: n.height,
|
|
28
|
+
payload: JSON.stringify({
|
|
29
|
+
container: (d = o.dataset) != null && d.dotContainer ? JSON.parse((r = o.dataset) == null ? void 0 : r.dotContainer) : y(o),
|
|
30
|
+
contentlet: {
|
|
31
|
+
identifier: (i = o.dataset) == null ? void 0 : i.dotIdentifier,
|
|
32
|
+
title: (e = o.dataset) == null ? void 0 : e.dotTitle,
|
|
33
|
+
inode: (s = o.dataset) == null ? void 0 : s.dotInode,
|
|
34
|
+
contentType: (c = o.dataset) == null ? void 0 : c.dotType
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function u(t) {
|
|
41
|
+
var a, o, n, d;
|
|
42
|
+
return {
|
|
43
|
+
acceptTypes: ((a = t.dataset) == null ? void 0 : a.dotAcceptTypes) || "",
|
|
44
|
+
identifier: ((o = t.dataset) == null ? void 0 : o.dotIdentifier) || "",
|
|
45
|
+
maxContentlets: ((n = t.dataset) == null ? void 0 : n.maxContentlets) || "",
|
|
46
|
+
uuid: ((d = t.dataset) == null ? void 0 : d.dotUuid) || ""
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function y(t) {
|
|
50
|
+
const a = t.closest('[data-dot-object="container"]');
|
|
51
|
+
return a ? u(a) : (console.warn("No container found for the contentlet"), null);
|
|
52
|
+
}
|
|
53
|
+
function g(t) {
|
|
54
|
+
var o, n, d;
|
|
55
|
+
if (!t) return null;
|
|
56
|
+
const a = t.querySelector('[data-dot-object="empty-content"]');
|
|
57
|
+
return ((o = t == null ? void 0 : t.dataset) == null ? void 0 : o.dotObject) === "contentlet" || // The container inside Headless components have a span with the data-dot-object="container" attribute
|
|
58
|
+
((n = t == null ? void 0 : t.dataset) == null ? void 0 : n.dotObject) === "container" && a || // The container inside Traditional have no content inside
|
|
59
|
+
((d = t == null ? void 0 : t.dataset) == null ? void 0 : d.dotObject) === "container" && t.children.length === 0 ? t : g(t == null ? void 0 : t.parentElement);
|
|
60
|
+
}
|
|
61
|
+
function h(t) {
|
|
62
|
+
const a = t.querySelectorAll(
|
|
63
|
+
'[data-dot-object="vtl-file"]'
|
|
64
|
+
);
|
|
65
|
+
return a.length ? Array.from(a).map((o) => {
|
|
66
|
+
var n, d;
|
|
67
|
+
return {
|
|
68
|
+
inode: (n = o.dataset) == null ? void 0 : n.dotInode,
|
|
69
|
+
name: (d = o.dataset) == null ? void 0 : d.dotUrl
|
|
70
|
+
};
|
|
71
|
+
}) : null;
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
g as findDotCMSElement,
|
|
75
|
+
h as findDotCMSVTLData,
|
|
76
|
+
y as getClosestDotCMSContainerData,
|
|
77
|
+
u as getDotCMSContainerData,
|
|
78
|
+
f as getDotCMSContentletsBound,
|
|
79
|
+
C as getDotCMSPageBounds
|
|
80
|
+
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import { DotCMSAnalyticsConfig } from '../../dotAnalytics/shared/dot-content-analytics.model';
|
|
3
|
-
interface DotContentAnalyticsProviderProps {
|
|
4
|
-
children?: ReactNode;
|
|
5
|
-
config: DotCMSAnalyticsConfig;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Provider component that initializes and manages DotCMSAnalytics instance.
|
|
9
|
-
* It makes the analytics functionality available to all child components through React Context.
|
|
10
|
-
* This component is responsible for:
|
|
11
|
-
* - Initializing the DotCMSAnalytics singleton instance with the provided config
|
|
12
|
-
* - Making the instance accessible via useContext hook to child components
|
|
13
|
-
* - Managing the lifecycle of the analytics instance
|
|
14
|
-
*
|
|
15
|
-
* @param {DotContentAnalyticsProviderProps} props - Configuration and children to render
|
|
16
|
-
* @returns {ReactElement} Provider component that enables analytics tracking
|
|
17
|
-
*/
|
|
18
|
-
export declare const DotContentAnalyticsProvider: ({ children, config }: DotContentAnalyticsProviderProps) => ReactElement;
|
|
19
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as i } from "react";
|
|
3
|
-
import { initializeContentAnalytics as n } from "../../dotAnalytics/dot-content-analytics.js";
|
|
4
|
-
import a from "../contexts/DotContentAnalyticsContext.js";
|
|
5
|
-
import { useRouterTracker as m } from "../hook/useRouterTracker.js";
|
|
6
|
-
const f = ({
|
|
7
|
-
children: r,
|
|
8
|
-
config: t
|
|
9
|
-
}) => {
|
|
10
|
-
const o = i(
|
|
11
|
-
() => n(t),
|
|
12
|
-
[t]
|
|
13
|
-
);
|
|
14
|
-
return t.autoPageView !== !1 && o && m(o), /* @__PURE__ */ e(a.Provider, { value: o, children: r });
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
f as DotContentAnalyticsProvider
|
|
18
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DotCMSAnalytics } from '../../dotAnalytics/shared/dot-content-analytics.model';
|
|
2
|
-
/**
|
|
3
|
-
* `DotContentAnalyticsContext` is a React context that is designed to provide an instance of
|
|
4
|
-
* `DotCMSAnalytics` to all of the components within its tree that are Consumers of this context.
|
|
5
|
-
*
|
|
6
|
-
* The context is created with a default value of `null`. It is meant to be provided a real value
|
|
7
|
-
* using the `DotContentAnalyticsProvider` component.
|
|
8
|
-
*
|
|
9
|
-
* @see {@link https://reactjs.org/docs/context.html|React Context}
|
|
10
|
-
*/
|
|
11
|
-
declare const DotContentAnalyticsContext: import('react').Context<DotCMSAnalytics | null>;
|
|
12
|
-
export default DotContentAnalyticsContext;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the code is running inside the DotCMS Universal Visual Editor (UVE).
|
|
3
|
-
*
|
|
4
|
-
* @returns {boolean} Returns true if running inside the editor, false otherwise.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* if (isInsideUVE()) {
|
|
9
|
-
* // Running inside UVE editor
|
|
10
|
-
* console.log('Inside editor');
|
|
11
|
-
* } else {
|
|
12
|
-
* // Running in normal mode
|
|
13
|
-
* console.log('Outside editor');
|
|
14
|
-
* }
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare function isInsideUVE(): boolean;
|