@dotcms/analytics 1.5.5-next.2131 → 1.5.5-next.2176
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/lib/core/shared/models/library.model.d.ts +4 -1
- package/lib/core/shared/utils/dot-analytics.utils.d.ts +3 -1
- package/lib/react/components/DotContentAnalytics.js +9 -9
- package/lib/react/hook/useRouterTracker.d.ts +2 -1
- package/lib/react/hook/useRouterTracker.js +12 -12
- package/package.json +1 -1
|
@@ -93,7 +93,10 @@ export interface DotCMSAnalyticsConfig {
|
|
|
93
93
|
*/
|
|
94
94
|
logLevel?: LogLevel;
|
|
95
95
|
/**
|
|
96
|
-
* Automatically track page views
|
|
96
|
+
* Automatically track page views. Defaults to `true` (opt-out).
|
|
97
|
+
* Set explicitly to `false` to disable automatic page view tracking.
|
|
98
|
+
* Via the HTML `data-analytics-auto-page-view` attribute, only the literal string "false"
|
|
99
|
+
* disables it (any other value, including "", enables it).
|
|
97
100
|
*/
|
|
98
101
|
autoPageView?: boolean;
|
|
99
102
|
/**
|
|
@@ -92,7 +92,9 @@ export interface AnalyticsConfigResult {
|
|
|
92
92
|
* Always returns a config (with defaults if needed).
|
|
93
93
|
*
|
|
94
94
|
* - If no data-analytics-server attribute is found, uses the current domain as the server endpoint
|
|
95
|
-
* -
|
|
95
|
+
* - debug defaults to false (opt-in: must be explicitly set to "true")
|
|
96
|
+
* - autoPageView defaults to true (opt-out: only the literal string "false" disables it via
|
|
97
|
+
* `data-analytics-auto-page-view="false"`)
|
|
96
98
|
*
|
|
97
99
|
* @returns The analytics configuration object
|
|
98
100
|
*/
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Suspense as
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense as r, useMemo as a } from "react";
|
|
3
3
|
import { useRouterTracker as l } from "../hook/useRouterTracker.js";
|
|
4
|
-
import { initializeAnalytics as
|
|
5
|
-
function
|
|
4
|
+
import { initializeAnalytics as i } from "../internal/utils.js";
|
|
5
|
+
function u({
|
|
6
6
|
config: t
|
|
7
7
|
}) {
|
|
8
|
-
const n =
|
|
9
|
-
return
|
|
8
|
+
const n = a(() => i(t), [t]), o = !!t.debug;
|
|
9
|
+
return l(n, o, t.autoPageView !== !1), null;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return /* @__PURE__ */
|
|
11
|
+
function f({ config: t }) {
|
|
12
|
+
return /* @__PURE__ */ e(r, { fallback: null, children: /* @__PURE__ */ e(u, { config: t }) });
|
|
13
13
|
}
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
f as DotContentAnalytics
|
|
16
16
|
};
|
|
@@ -7,5 +7,6 @@ import { DotCMSAnalytics } from '../../core/shared/models';
|
|
|
7
7
|
*
|
|
8
8
|
* @param analytics Analytics singleton instance; if null, does nothing
|
|
9
9
|
* @param debug When true, logs which tracking path is used
|
|
10
|
+
* @param enabled When false, tracking is disabled even if analytics is present (defaults to true)
|
|
10
11
|
*/
|
|
11
|
-
export declare function useRouterTracker(analytics: DotCMSAnalytics | null, debug?: boolean): void;
|
|
12
|
+
export declare function useRouterTracker(analytics: DotCMSAnalytics | null, debug?: boolean, enabled?: boolean): void;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { usePathname as
|
|
2
|
-
import { useRef as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
if (!
|
|
8
|
-
const
|
|
9
|
-
|
|
1
|
+
import { usePathname as c, useSearchParams as i } from "next/navigation";
|
|
2
|
+
import { useRef as a, useEffect as m } from "react";
|
|
3
|
+
const p = (t, e) => `${t}${e?.toString() ? "?" + e.toString() : ""}`;
|
|
4
|
+
function h(t, e = !1, r = !0) {
|
|
5
|
+
const n = a(null), o = c(), u = i();
|
|
6
|
+
m(() => {
|
|
7
|
+
if (!r || !t) return;
|
|
8
|
+
const s = (f) => {
|
|
9
|
+
f !== n.current && (n.current = f, t.pageView());
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
}, [
|
|
11
|
+
e && console.info("DotCMS Analytics [React]: using Next.js App Router tracking"), s(p(o, u));
|
|
12
|
+
}, [t, o, u, e, r]);
|
|
13
13
|
}
|
|
14
14
|
export {
|
|
15
|
-
|
|
15
|
+
h as useRouterTracker
|
|
16
16
|
};
|