@dotcms/analytics 1.5.4 → 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.
@@ -93,7 +93,10 @@ export interface DotCMSAnalyticsConfig {
93
93
  */
94
94
  logLevel?: LogLevel;
95
95
  /**
96
- * Automatically track page views when set to true.
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
- * - Both debug and autoPageView default to false (must be explicitly set to "true")
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 o } from "react/jsx-runtime";
2
- import { Suspense as e, useMemo as i } from "react";
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 u } from "../internal/utils.js";
5
- function a({
4
+ import { initializeAnalytics as i } from "../internal/utils.js";
5
+ function u({
6
6
  config: t
7
7
  }) {
8
- const n = i(() => u(t), [t]), r = !!t.debug;
9
- return n && l(n, r), null;
8
+ const n = a(() => i(t), [t]), o = !!t.debug;
9
+ return l(n, o, t.autoPageView !== !1), null;
10
10
  }
11
- function p({ config: t }) {
12
- return /* @__PURE__ */ o(e, { fallback: null, children: /* @__PURE__ */ o(a, { config: t }) });
11
+ function f({ config: t }) {
12
+ return /* @__PURE__ */ e(r, { fallback: null, children: /* @__PURE__ */ e(u, { config: t }) });
13
13
  }
14
14
  export {
15
- p as DotContentAnalytics
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 f, useSearchParams as u } from "next/navigation";
2
- import { useRef as i, useEffect as a } from "react";
3
- const m = (e, t) => `${e}${t?.toString() ? "?" + t.toString() : ""}`;
4
- function R(e, t = !1) {
5
- const r = i(null), n = f(), o = u();
6
- a(() => {
7
- if (!e) return;
8
- const c = (s) => {
9
- s !== r.current && (r.current = s, e.pageView());
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
- t && console.info("DotCMS Analytics [React]: using Next.js App Router tracking"), c(m(n, o));
12
- }, [e, n, o, t]);
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
- R as useRouterTracker
15
+ h as useRouterTracker
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/analytics",
3
- "version": "1.5.4",
3
+ "version": "1.5.5-next.2176",
4
4
  "description": "Official JavaScript library for Content Analytics with DotCMS.",
5
5
  "repository": {
6
6
  "type": "git",