@dotcms/analytics 1.1.1 → 1.2.0

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.
Files changed (40) hide show
  1. package/README.md +284 -71
  2. package/lib/core/dot-content-analytics.d.ts +8 -1
  3. package/lib/core/dot-content-analytics.js +26 -23
  4. package/lib/core/plugin/dot-analytics.plugin.d.ts +8 -7
  5. package/lib/core/plugin/dot-analytics.plugin.js +25 -62
  6. package/lib/core/plugin/enricher/dot-analytics.enricher.plugin.d.ts +12 -28
  7. package/lib/core/plugin/enricher/dot-analytics.enricher.plugin.js +37 -15
  8. package/lib/core/plugin/identity/dot-analytics.identity.plugin.d.ts +11 -11
  9. package/lib/core/plugin/identity/dot-analytics.identity.plugin.js +13 -11
  10. package/lib/core/plugin/identity/dot-analytics.identity.utils.d.ts +7 -6
  11. package/lib/core/shared/constants/dot-content-analytics.constants.d.ts +70 -0
  12. package/lib/core/shared/constants/dot-content-analytics.constants.js +34 -0
  13. package/lib/core/shared/constants/index.d.ts +4 -0
  14. package/lib/core/shared/dot-content-analytics.activity-tracker.d.ts +9 -2
  15. package/lib/core/shared/dot-content-analytics.activity-tracker.js +11 -10
  16. package/lib/core/shared/dot-content-analytics.http.d.ts +13 -4
  17. package/lib/core/shared/dot-content-analytics.http.js +25 -13
  18. package/lib/core/shared/dot-content-analytics.utils.d.ts +105 -44
  19. package/lib/core/shared/dot-content-analytics.utils.js +92 -68
  20. package/lib/core/shared/models/data.model.d.ts +103 -0
  21. package/lib/core/shared/models/event.model.d.ts +64 -0
  22. package/lib/core/shared/models/index.d.ts +7 -0
  23. package/lib/core/shared/models/library.model.d.ts +191 -0
  24. package/lib/core/shared/models/request.model.d.ts +24 -0
  25. package/lib/core/shared/queue/dot-analytics.queue.utils.d.ts +28 -0
  26. package/lib/core/shared/queue/dot-analytics.queue.utils.js +73 -0
  27. package/lib/core/shared/queue/index.d.ts +1 -0
  28. package/lib/react/components/DotContentAnalytics.d.ts +1 -1
  29. package/lib/react/hook/useContentAnalytics.d.ts +43 -15
  30. package/lib/react/hook/useContentAnalytics.js +18 -21
  31. package/lib/react/hook/useRouterTracker.d.ts +1 -1
  32. package/lib/react/internal/utils.d.ts +1 -1
  33. package/lib/react/internal/utils.js +2 -2
  34. package/lib/react/public-api.d.ts +1 -1
  35. package/lib/standalone.d.ts +2 -2
  36. package/package.json +2 -1
  37. package/uve/src/internal/constants.js +8 -3
  38. package/lib/core/shared/dot-content-analytics.constants.d.ts +0 -37
  39. package/lib/core/shared/dot-content-analytics.constants.js +0 -14
  40. package/lib/core/shared/dot-content-analytics.model.d.ts +0 -351
@@ -0,0 +1,191 @@
1
+ import { DotCMSAnalyticsEventContext, DotCMSEventPageData, DotCMSEventUtmData } from './data.model';
2
+ import { JsonObject } from './event.model';
3
+ import { DotCMSAnalyticsRequestBody } from './request.model';
4
+ import { DotCMSCustomEventType } from '../constants';
5
+ /**
6
+ * Configuration for event queue management.
7
+ * Controls how events are batched before sending to the server.
8
+ */
9
+ export interface QueueConfig {
10
+ /** Maximum events per batch - auto-sends when reached (default: 15) */
11
+ eventBatchSize?: number;
12
+ /** Time in milliseconds between flushes - sends pending events (default: 5000) */
13
+ flushInterval?: number;
14
+ }
15
+ /**
16
+ * Main interface for the DotCMS Analytics SDK.
17
+ * Provides the core methods for tracking page views and custom events.
18
+ */
19
+ export interface DotCMSAnalytics {
20
+ /**
21
+ * Track a page view event.
22
+ * @param payload - Optional custom data to include with the page view (any valid JSON object)
23
+ */
24
+ pageView: (payload?: JsonObject) => void;
25
+ /**
26
+ * Track a custom event.
27
+ * @param eventName - The name/type of the event to track
28
+ * @param payload - Custom data to include with the event (any valid JSON object)
29
+ */
30
+ track: (eventName: string, payload: JsonObject) => void;
31
+ }
32
+ /**
33
+ * Configuration interface for DotCMS Analytics SDK.
34
+ * Contains all necessary settings for initializing and configuring the analytics client.
35
+ */
36
+ export interface DotCMSAnalyticsConfig {
37
+ /**
38
+ * The URL of the Analytics server endpoint.
39
+ */
40
+ server: string;
41
+ /**
42
+ * Enable debug mode to get additional logging information.
43
+ */
44
+ debug: boolean;
45
+ /**
46
+ * Automatically track page views when set to true.
47
+ */
48
+ autoPageView?: boolean;
49
+ /**
50
+ * The site auth for authenticating with the Analytics service.
51
+ */
52
+ siteAuth: string;
53
+ /**
54
+ * Queue configuration for event batching:
55
+ * - `false`: Disable queuing, send events immediately
56
+ * - `true` or `undefined` (default): Enable queuing with default settings
57
+ * - `QueueConfig`: Enable queuing with custom settings
58
+ */
59
+ queue?: QueueConfig | boolean;
60
+ }
61
+ /**
62
+ * Track event payload with context.
63
+ * This is the payload for custom track events after the identity plugin adds context.
64
+ * Used in the track:dot-analytics enricher plugin.
65
+ */
66
+ export interface AnalyticsTrackPayloadWithContext extends AnalyticsBasePayload {
67
+ /** The custom event name (any string except 'pageview') */
68
+ event: DotCMSCustomEventType;
69
+ /** Analytics context added by identity plugin */
70
+ context: DotCMSAnalyticsEventContext;
71
+ }
72
+ /**
73
+ * Parameters passed to DotCMS Analytics plugin methods (after enrichment).
74
+ * The payload is the complete request body ready to send to the server.
75
+ */
76
+ export interface DotCMSAnalyticsParams {
77
+ /** Configuration for the analytics client */
78
+ config: DotCMSAnalyticsConfig;
79
+ /** The complete request body */
80
+ payload: DotCMSAnalyticsRequestBody;
81
+ }
82
+ type AnalyticsBasePayloadType = 'page' | 'track';
83
+ /**
84
+ * Analytics.js hook parameter types for DotCMS.
85
+ * Represents the payload structure used by Analytics.js lifecycle hooks
86
+ * for intercepting and modifying analytics events.
87
+ */
88
+ export interface AnalyticsBasePayload {
89
+ /** The type of analytics event */
90
+ type: AnalyticsBasePayloadType;
91
+ /** Properties associated with the event */
92
+ properties: {
93
+ /** Page title */
94
+ title: string;
95
+ /** Page URL */
96
+ url: string;
97
+ /** Page path */
98
+ path: string;
99
+ /** URL hash fragment */
100
+ hash: string;
101
+ /** URL search parameters */
102
+ search: string;
103
+ /** Viewport width */
104
+ width: number;
105
+ /** Viewport height */
106
+ height: number;
107
+ /** Referrer URL */
108
+ referrer?: string;
109
+ };
110
+ /** Configuration options for the event */
111
+ options: Record<string, unknown>;
112
+ /** User identifier */
113
+ userId: string;
114
+ /** Anonymous user identifier */
115
+ anonymousId: string;
116
+ /** Metadata about the event */
117
+ meta: {
118
+ /** Request identifier */
119
+ rid: string;
120
+ /** Timestamp */
121
+ ts: number;
122
+ /** Whether the event has a callback function */
123
+ hasCallback: boolean;
124
+ };
125
+ }
126
+ /**
127
+ * Analytics.js payload with context.
128
+ * This is the result of enriching the base Analytics.js payload
129
+ * with context data added by the identity plugin.
130
+ */
131
+ export interface AnalyticsBasePayloadWithContext extends AnalyticsBasePayload {
132
+ context: DotCMSAnalyticsEventContext;
133
+ }
134
+ /**
135
+ * Enriched analytics payload with DotCMS-specific data.
136
+ * This is the result of enriching the base Analytics.js payload with context (from identity plugin)
137
+ * and then adding page, UTM, and custom data (from enricher plugin).
138
+ */
139
+ export type EnrichedAnalyticsPayload = AnalyticsBasePayloadWithContext & {
140
+ /** Page data for the current page */
141
+ page: DotCMSEventPageData;
142
+ /** UTM parameters for campaign tracking */
143
+ utm?: DotCMSEventUtmData;
144
+ /** Custom data associated with the event (any valid JSON) */
145
+ custom?: JsonObject;
146
+ /** Local timestamp when the event occurred */
147
+ local_time: string;
148
+ };
149
+ /**
150
+ * Analytics.js instance structure for DotCMS.
151
+ * Represents the internal structure of an Analytics.js instance,
152
+ * providing access to plugins, storage, and event configuration.
153
+ */
154
+ export interface DotCMSAnalyticsInstance {
155
+ /** Available plugins and their configurations */
156
+ plugins: Record<string, unknown>;
157
+ /** Storage mechanisms for analytics data */
158
+ storage: Record<string, unknown>;
159
+ /** Event configuration */
160
+ events: {
161
+ /** Core event types */
162
+ core: string[];
163
+ /** Plugin-specific event types */
164
+ plugins: string[];
165
+ };
166
+ }
167
+ /**
168
+ * Base parameters structure passed by Analytics.js to plugin hooks.
169
+ * Contains all the context and data needed for Analytics.js lifecycle hooks
170
+ * to process and modify analytics events.
171
+ */
172
+ export interface AnalyticsBaseParams {
173
+ /** The event payload data */
174
+ payload: AnalyticsBasePayload;
175
+ /** The analytics instance */
176
+ instance: DotCMSAnalyticsInstance;
177
+ /** Global configuration settings */
178
+ config: Record<string, unknown>;
179
+ /** Available plugins and their status */
180
+ plugins: Record<string, {
181
+ /** Whether the plugin is enabled */
182
+ enabled: boolean;
183
+ /** Whether the plugin is initialized */
184
+ initialized: boolean;
185
+ /** Whether the plugin is loaded */
186
+ loaded: boolean;
187
+ /** Plugin-specific configuration */
188
+ config: Record<string, unknown>;
189
+ }>;
190
+ }
191
+ export {};
@@ -0,0 +1,24 @@
1
+ import { DotCMSAnalyticsEventContext } from './data.model';
2
+ import { DotCMSCustomEvent, DotCMSEvent, DotCMSPageViewEvent } from './event.model';
3
+ /**
4
+ * Analytics request body for DotCMS Analytics.
5
+ * Generic structure sent to the DotCMS analytics server.
6
+ */
7
+ export interface DotCMSRequestBody<T extends DotCMSEvent> {
8
+ /** Context information shared across all events */
9
+ context: DotCMSAnalyticsEventContext;
10
+ /** Array of analytics events to be tracked */
11
+ events: T[];
12
+ }
13
+ /**
14
+ * Specific request body type for PageView events
15
+ */
16
+ export type DotCMSPageViewRequestBody = DotCMSRequestBody<DotCMSPageViewEvent>;
17
+ /**
18
+ * Specific request body type for Custom events
19
+ */
20
+ export type DotCMSCustomEventRequestBody = DotCMSRequestBody<DotCMSCustomEvent>;
21
+ /**
22
+ * Union type for all possible request bodies
23
+ */
24
+ export type DotCMSAnalyticsRequestBody = DotCMSPageViewRequestBody | DotCMSCustomEventRequestBody;
@@ -0,0 +1,28 @@
1
+ import { DotCMSAnalyticsConfig, DotCMSAnalyticsEventContext, DotCMSEvent } from '../models';
2
+ /**
3
+ * Creates a queue manager for batching analytics events.
4
+ * Uses factory function pattern consistent with the plugin architecture.
5
+ */
6
+ export declare const createAnalyticsQueue: (config: DotCMSAnalyticsConfig) => {
7
+ /**
8
+ * Initialize the queue with smart batching
9
+ */
10
+ initialize: () => void;
11
+ /**
12
+ * Add event to queue
13
+ * smartQueue handles all batching logic automatically:
14
+ * - Sends immediately when eventBatchSize reached (with throttle: false)
15
+ * - Sends pending events every flushInterval
16
+ */
17
+ enqueue: (event: DotCMSEvent, context: DotCMSAnalyticsEventContext) => void;
18
+ /**
19
+ * Get queue size for debugging
20
+ * Returns the number of events in smartQueue
21
+ */
22
+ size: () => number;
23
+ /**
24
+ * Clean up queue resources
25
+ * Flushes remaining events and cleans up listeners
26
+ */
27
+ cleanup: () => void;
28
+ };
@@ -0,0 +1,73 @@
1
+ import p from "@analytics/queue-utils";
2
+ import { DEFAULT_QUEUE_CONFIG as c } from "../constants/dot-content-analytics.constants.js";
3
+ import { sendAnalyticsEvent as y } from "../dot-content-analytics.http.js";
4
+ const z = (n) => {
5
+ let e = null, i = null, o = "fetch";
6
+ const l = {
7
+ ...c,
8
+ ...typeof n.queue == "object" ? n.queue : {}
9
+ }, f = (t) => {
10
+ if (!i) return;
11
+ n.debug && console.log(`DotCMS Analytics Queue: Sending batch of ${t.length} event(s)`, {
12
+ events: t,
13
+ transport: o
14
+ }), y({ context: i, events: t }, n, o);
15
+ }, u = () => {
16
+ !e || e.size() === 0 || !i || (n.debug && console.warn(
17
+ `DotCMS Analytics: Flushing ${e.size()} events (page hidden/unload)`
18
+ ), o = "beacon", e.flush(!0));
19
+ }, d = () => {
20
+ document.visibilityState === "hidden" && u();
21
+ };
22
+ return {
23
+ /**
24
+ * Initialize the queue with smart batching
25
+ */
26
+ initialize: () => {
27
+ e = p(
28
+ (t) => {
29
+ f(t);
30
+ },
31
+ {
32
+ max: l.eventBatchSize,
33
+ interval: l.flushInterval,
34
+ throttle: !1
35
+ // Always false - enables both batch size and interval triggers
36
+ }
37
+ ), typeof window < "u" && typeof document < "u" && (document.addEventListener("visibilitychange", d), window.addEventListener("pagehide", u));
38
+ },
39
+ /**
40
+ * Add event to queue
41
+ * smartQueue handles all batching logic automatically:
42
+ * - Sends immediately when eventBatchSize reached (with throttle: false)
43
+ * - Sends pending events every flushInterval
44
+ */
45
+ enqueue: (t, s) => {
46
+ if (i = s, !!e) {
47
+ if (n.debug) {
48
+ const a = e.size() + 1, r = l.eventBatchSize ?? c.eventBatchSize, h = a >= r;
49
+ console.log(
50
+ `DotCMS Analytics Queue: Event added. Queue size: ${a}/${r}${h ? " (full, sending...)" : ""}`,
51
+ { eventType: t.event_type, event: t }
52
+ );
53
+ }
54
+ e.push(t);
55
+ }
56
+ },
57
+ /**
58
+ * Get queue size for debugging
59
+ * Returns the number of events in smartQueue
60
+ */
61
+ size: () => (e == null ? void 0 : e.size()) ?? 0,
62
+ /**
63
+ * Clean up queue resources
64
+ * Flushes remaining events and cleans up listeners
65
+ */
66
+ cleanup: () => {
67
+ u(), typeof window < "u" && typeof document < "u" && (document.removeEventListener("visibilitychange", d), window.removeEventListener("pagehide", u)), e = null, i = null, o = "fetch";
68
+ }
69
+ };
70
+ };
71
+ export {
72
+ z as createAnalyticsQueue
73
+ };
@@ -0,0 +1 @@
1
+ export { createAnalyticsQueue } from './dot-analytics.queue.utils';
@@ -1,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { DotCMSAnalyticsConfig } from '../../core/shared/dot-content-analytics.model';
2
+ import { DotCMSAnalyticsConfig } from '../../core/shared/models';
3
3
  /**
4
4
  * Client bootstrapper for dotCMS Analytics in React/Next.
5
5
  * - No UI: initializes the analytics singleton from props or env config.
@@ -1,29 +1,57 @@
1
- import { DotCMSAnalytics, DotCMSAnalyticsConfig } from '../../core/shared/dot-content-analytics.model';
1
+ import { DotCMSAnalytics, DotCMSAnalyticsConfig } from '../../core/shared/models';
2
2
  /**
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.
3
+ * React hook for tracking user interactions and page views in your DotCMS application.
4
+ *
5
+ * Use this hook to add analytics tracking to your React components. It automatically
6
+ * handles user sessions, device information, and UTM campaign parameters.
7
+ *
8
+ * **Important:** Tracking is automatically disabled when editing content in DotCMS to avoid
9
+ * polluting your analytics data with editor activity.
6
10
  *
7
11
  * @example
12
+ * Basic usage - Track custom events
8
13
  * ```tsx
9
- * function Button({ title, urlTitle }) {
14
+ * function ProductCard({ title, price }) {
10
15
  * const { track } = useContentAnalytics({
11
16
  * server: 'https://demo.dotcms.com',
12
- * siteKey: 'my-site-key',
17
+ * siteAuth: 'my-site-auth',
13
18
  * debug: false
14
19
  * });
15
20
  *
16
- * // Track button click with custom properties
17
- * return (
18
- * <button onClick={() => track('btn-click', { title, urlTitle })}>
19
- * See Details →
20
- * </button>
21
- * );
21
+ * const handleAddToCart = () => {
22
+ * track('add-to-cart', {
23
+ * product: title,
24
+ * price: price
25
+ * });
26
+ * };
27
+ *
28
+ * return <button onClick={handleAddToCart}>Add to Cart</button>;
29
+ * }
30
+ * ```
31
+ *
32
+ * @example
33
+ * Track page views manually
34
+ * ```tsx
35
+ * function ArticlePage({ article }) {
36
+ * const { pageView } = useContentAnalytics({
37
+ * server: 'https://demo.dotcms.com',
38
+ * siteKey: 'your-site-key'
39
+ * });
40
+ *
41
+ * useEffect(() => {
42
+ * pageView({
43
+ * category: article.category,
44
+ * author: article.author
45
+ * });
46
+ * }, [article.id]);
22
47
  * }
23
48
  * ```
24
49
  *
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
+ * @param config - Configuration object with server URL and site key
51
+ * @param config.server - The URL of your DotCMS Analytics server
52
+ * @param config.siteKey - Your unique site key for authentication
53
+ * @param config.debug - Optional. Set to true to see analytics events in the console
54
+ * @returns Object with `track()` and `pageView()` methods for analytics tracking
55
+ * @throws {Error} If the configuration is invalid (missing server or siteKey)
28
56
  */
29
57
  export declare const useContentAnalytics: (config: DotCMSAnalyticsConfig) => DotCMSAnalytics;
@@ -1,32 +1,29 @@
1
- import { useRef as l, useCallback as n } from "react";
2
- import { getUVEState as r } from "../../../uve/src/lib/core/core.utils.js";
1
+ import { useMemo as n, useCallback as o } from "react";
2
+ import { getUVEState as u } from "../../../uve/src/lib/core/core.utils.js";
3
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);
4
+ import { initializeAnalytics as l } from "../internal/utils.js";
5
+ const h = (r) => {
6
+ const t = n(() => l(r), [r.server, r.siteAuth]), e = n(() => !!u(), []);
7
7
  if (!t)
8
8
  throw new Error(
9
- "Failed to initialize DotContentAnalytics. Please verify the required configuration (server and siteKey)."
9
+ "DotCMS Analytics: Failed to initialize. Please verify the required configuration (server and siteAuth)."
10
10
  );
11
- const a = n(
12
- (e, s = {}) => {
13
- r() || t.track(e, {
14
- ...s,
15
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
16
- });
11
+ const a = o(
12
+ (i, c = {}) => {
13
+ e || t.track(i, c);
17
14
  },
18
- [t]
19
- ), c = n(() => {
20
- if (!r()) {
21
- const e = window.location.pathname;
22
- e !== i.current && (i.current = e, t.pageView());
23
- }
24
- }, [t]);
15
+ [t, e]
16
+ ), s = o(
17
+ (i = {}) => {
18
+ e || t.pageView(i);
19
+ },
20
+ [t, e]
21
+ );
25
22
  return {
26
23
  track: a,
27
- pageView: c
24
+ pageView: s
28
25
  };
29
26
  };
30
27
  export {
31
- g as useContentAnalytics
28
+ h as useContentAnalytics
32
29
  };
@@ -1,4 +1,4 @@
1
- import { DotCMSAnalytics } from '../../core/shared/dot-content-analytics.model';
1
+ import { DotCMSAnalytics } from '../../core/shared/models';
2
2
  /**
3
3
  * Tracks page views on route changes using Next.js App Router signals.
4
4
  * - Fires a single pageView per unique path+search.
@@ -1,4 +1,4 @@
1
- import { DotCMSAnalytics, DotCMSAnalyticsConfig } from '../../core/shared/dot-content-analytics.model';
1
+ import { DotCMSAnalytics, DotCMSAnalyticsConfig } from '../../core/shared/models';
2
2
  /**
3
3
  * Initializes analytics with explicit configuration.
4
4
  * Resets singleton if config changes.
@@ -1,6 +1,6 @@
1
1
  import { initializeContentAnalytics as r } from "../../core/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);
2
+ let t, i;
3
+ const s = (e) => (i && (i.server !== e.server || i.siteAuth !== e.siteAuth) && (t = void 0), t !== void 0 || (i = e, t = r(e)), t);
4
4
  export {
5
5
  s as initializeAnalytics
6
6
  };
@@ -1,3 +1,3 @@
1
- export type { DotCMSAnalyticsConfig } from '../core/shared/dot-content-analytics.model';
1
+ export type { DotCMSAnalyticsConfig } from '../core/shared/models';
2
2
  export { DotContentAnalytics } from './components/DotContentAnalytics';
3
3
  export { useContentAnalytics } from './hook/useContentAnalytics';
@@ -1,5 +1,5 @@
1
- import { ANALYTICS_WINDOWS_KEY } from './core/shared/dot-content-analytics.constants';
2
- import { DotCMSAnalytics } from './core/shared/dot-content-analytics.model';
1
+ import { ANALYTICS_WINDOWS_KEY } from './core/shared/constants';
2
+ import { DotCMSAnalytics } from './core/shared/models';
3
3
  declare global {
4
4
  interface Window {
5
5
  [ANALYTICS_WINDOWS_KEY]: DotCMSAnalytics | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/analytics",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Official JavaScript library for Content Analytics with DotCMS.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,6 +23,7 @@
23
23
  "analytics": "^0.8.0",
24
24
  "@analytics/core": "^0.13.0",
25
25
  "@analytics/storage-utils": "^0.4.0",
26
+ "@analytics/queue-utils": "^0.1.3",
26
27
  "@dotcms/uve": "latest"
27
28
  },
28
29
  "peerDependencies": {
@@ -1,3 +1,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
+ import { UVEEventType as t } from "../../../types/src/lib/editor/public.js";
2
+ import { onContentletHovered as e, onIframeScroll as o, onRequestBounds as r, onPageReload as E, onContentChanges as _ } from "./events.js";
3
+ t.CONTENT_CHANGES + "", t.PAGE_RELOAD + "", t.REQUEST_BOUNDS + "", t.IFRAME_SCROLL + "", t.CONTENTLET_HOVERED + "";
4
+ const N = "__dotAnalyticsActive__", T = "__dotAnalyticsCleanup";
5
+ export {
6
+ N as ANALYTICS_WINDOWS_ACTIVE_KEY,
7
+ T as ANALYTICS_WINDOWS_CLEANUP_KEY
8
+ };
@@ -1,37 +0,0 @@
1
- export declare const ANALYTICS_WINDOWS_KEY = "dotAnalytics";
2
- export declare const ANALYTICS_SOURCE_TYPE = "dotAnalytics";
3
- export declare const ANALYTICS_ENDPOINT = "/api/v1/analytics/content/event";
4
- /**
5
- * Event Types
6
- * Only two event types are supported in DotCMS Analytics
7
- */
8
- export declare const EVENT_TYPES: {
9
- readonly PAGEVIEW: "pageview";
10
- readonly TRACK: "track";
11
- };
12
- /**
13
- * Expected UTM parameter keys for campaign tracking
14
- */
15
- export declare const EXPECTED_UTM_KEYS: readonly ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content", "utm_id"];
16
- /**
17
- * Session configuration constants
18
- */
19
- export declare const DEFAULT_SESSION_TIMEOUT_MINUTES = 30;
20
- export declare const SESSION_STORAGE_KEY = "dot_analytics_session_id";
21
- export declare const SESSION_START_KEY = "dot_analytics_session_start";
22
- export declare const SESSION_UTM_KEY = "dot_analytics_session_utm";
23
- /**
24
- * User ID configuration constants
25
- */
26
- export declare const USER_ID_KEY = "dot_analytics_user_id";
27
- /**
28
- * Activity tracking configuration
29
- * Events used to detect user activity for session management
30
- * - click: Detects real user interaction with minimal performance impact
31
- * - visibilitychange: Handled separately to detect tab changes
32
- */
33
- export declare const ACTIVITY_EVENTS: readonly ["click"];
34
- /**
35
- * The name of the analytics minified script.
36
- */
37
- export declare const ANALYTICS_MINIFIED_SCRIPT_NAME = "ca.min.js";
@@ -1,14 +0,0 @@
1
- const t = "dotAnalytics", E = t, _ = "/api/v1/analytics/content/event", c = {
2
- PAGEVIEW: "pageview",
3
- TRACK: "track"
4
- }, n = 30, s = "dot_analytics_session_id", S = "dot_analytics_user_id", T = ["click"];
5
- export {
6
- T as ACTIVITY_EVENTS,
7
- _ as ANALYTICS_ENDPOINT,
8
- E as ANALYTICS_SOURCE_TYPE,
9
- t as ANALYTICS_WINDOWS_KEY,
10
- n as DEFAULT_SESSION_TIMEOUT_MINUTES,
11
- c as EVENT_TYPES,
12
- s as SESSION_STORAGE_KEY,
13
- S as USER_ID_KEY
14
- };