@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.
- package/README.md +284 -71
- package/lib/core/dot-content-analytics.d.ts +8 -1
- package/lib/core/dot-content-analytics.js +26 -23
- package/lib/core/plugin/dot-analytics.plugin.d.ts +8 -7
- package/lib/core/plugin/dot-analytics.plugin.js +25 -62
- package/lib/core/plugin/enricher/dot-analytics.enricher.plugin.d.ts +12 -28
- package/lib/core/plugin/enricher/dot-analytics.enricher.plugin.js +37 -15
- package/lib/core/plugin/identity/dot-analytics.identity.plugin.d.ts +11 -11
- package/lib/core/plugin/identity/dot-analytics.identity.plugin.js +13 -11
- package/lib/core/plugin/identity/dot-analytics.identity.utils.d.ts +7 -6
- package/lib/core/shared/constants/dot-content-analytics.constants.d.ts +70 -0
- package/lib/core/shared/constants/dot-content-analytics.constants.js +34 -0
- package/lib/core/shared/constants/index.d.ts +4 -0
- package/lib/core/shared/dot-content-analytics.activity-tracker.d.ts +9 -2
- package/lib/core/shared/dot-content-analytics.activity-tracker.js +11 -10
- package/lib/core/shared/dot-content-analytics.http.d.ts +13 -4
- package/lib/core/shared/dot-content-analytics.http.js +25 -13
- package/lib/core/shared/dot-content-analytics.utils.d.ts +105 -44
- package/lib/core/shared/dot-content-analytics.utils.js +92 -68
- package/lib/core/shared/models/data.model.d.ts +103 -0
- package/lib/core/shared/models/event.model.d.ts +64 -0
- package/lib/core/shared/models/index.d.ts +7 -0
- package/lib/core/shared/models/library.model.d.ts +191 -0
- package/lib/core/shared/models/request.model.d.ts +24 -0
- package/lib/core/shared/queue/dot-analytics.queue.utils.d.ts +28 -0
- package/lib/core/shared/queue/dot-analytics.queue.utils.js +73 -0
- package/lib/core/shared/queue/index.d.ts +1 -0
- package/lib/react/components/DotContentAnalytics.d.ts +1 -1
- package/lib/react/hook/useContentAnalytics.d.ts +43 -15
- package/lib/react/hook/useContentAnalytics.js +18 -21
- package/lib/react/hook/useRouterTracker.d.ts +1 -1
- package/lib/react/internal/utils.d.ts +1 -1
- package/lib/react/internal/utils.js +2 -2
- package/lib/react/public-api.d.ts +1 -1
- package/lib/standalone.d.ts +2 -2
- package/package.json +2 -1
- package/uve/src/internal/constants.js +8 -3
- package/lib/core/shared/dot-content-analytics.constants.d.ts +0 -37
- package/lib/core/shared/dot-content-analytics.constants.js +0 -14
- package/lib/core/shared/dot-content-analytics.model.d.ts +0 -351
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
import { EVENT_TYPES } from './dot-content-analytics.constants';
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
__dotAnalyticsCleanup?: () => void;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Configuration interface for DotCMS Analytics SDK.
|
|
9
|
-
* Contains all necessary settings for initializing and configuring the analytics client.
|
|
10
|
-
*/
|
|
11
|
-
export interface DotCMSAnalyticsConfig {
|
|
12
|
-
/**
|
|
13
|
-
* The URL of the Analytics server endpoint.
|
|
14
|
-
*/
|
|
15
|
-
server: string;
|
|
16
|
-
/**
|
|
17
|
-
* Enable debug mode to get additional logging information.
|
|
18
|
-
*/
|
|
19
|
-
debug: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Automatically track page views when set to true.
|
|
22
|
-
*/
|
|
23
|
-
autoPageView?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* The site key for authenticating with the Analytics service.
|
|
26
|
-
*/
|
|
27
|
-
siteKey: string;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Supported event types in DotCMS Analytics.
|
|
31
|
-
* Only two event types are supported: pageview and track.
|
|
32
|
-
*/
|
|
33
|
-
export type DotCMSEventType = (typeof EVENT_TYPES)[keyof typeof EVENT_TYPES];
|
|
34
|
-
/**
|
|
35
|
-
* Base structure for all analytics events.
|
|
36
|
-
* All events share this common structure.
|
|
37
|
-
*/
|
|
38
|
-
export interface DotCMSEventBase {
|
|
39
|
-
/** The type of event being tracked */
|
|
40
|
-
event_type: DotCMSEventType;
|
|
41
|
-
/** Local timestamp when the event occurred */
|
|
42
|
-
local_time: string;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Pageview-specific analytics event structure.
|
|
46
|
-
* Contains data specific to page view tracking.
|
|
47
|
-
*/
|
|
48
|
-
export interface DotCMSPageViewEvent extends DotCMSEventBase {
|
|
49
|
-
event_type: 'pageview';
|
|
50
|
-
/** Pageview-specific event data with structured format */
|
|
51
|
-
data: {
|
|
52
|
-
/** Page data associated with the event */
|
|
53
|
-
page: DotCMSPageData;
|
|
54
|
-
/** Device and browser information */
|
|
55
|
-
device: DotCMSDeviceData;
|
|
56
|
-
/** UTM parameters for campaign tracking (optional) */
|
|
57
|
-
utm?: DotCMSUtmData;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Track-specific analytics event structure.
|
|
62
|
-
* Contains data specific to custom event tracking.
|
|
63
|
-
*/
|
|
64
|
-
export interface DotCMSTrackEvent extends DotCMSEventBase {
|
|
65
|
-
event_type: 'track';
|
|
66
|
-
/** Track-specific event data with flexible structure */
|
|
67
|
-
data: Record<string, unknown>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Union type for all possible analytics events.
|
|
71
|
-
*/
|
|
72
|
-
export type DotCMSEvent = DotCMSPageViewEvent | DotCMSTrackEvent;
|
|
73
|
-
/**
|
|
74
|
-
* Analytics request body for page view events in DotCMS.
|
|
75
|
-
* Structure sent to the DotCMS analytics server for page tracking.
|
|
76
|
-
*/
|
|
77
|
-
export interface DotCMSPageViewRequestBody {
|
|
78
|
-
/** Context information shared across all events */
|
|
79
|
-
context: DotCMSAnalyticsContext;
|
|
80
|
-
/** Array of pageview analytics events to be tracked */
|
|
81
|
-
events: DotCMSPageViewEvent[];
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Analytics request body for track events in DotCMS.
|
|
85
|
-
* Structure sent to the DotCMS analytics server for custom event tracking.
|
|
86
|
-
*/
|
|
87
|
-
export interface DotCMSTrackRequestBody {
|
|
88
|
-
/** Context information shared across all events */
|
|
89
|
-
context: DotCMSAnalyticsContext;
|
|
90
|
-
/** Array of track analytics events to be tracked */
|
|
91
|
-
events: DotCMSTrackEvent[];
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Union type for all possible request bodies.
|
|
95
|
-
*/
|
|
96
|
-
export type DotCMSAnalyticsRequestBody = DotCMSPageViewRequestBody | DotCMSTrackRequestBody;
|
|
97
|
-
/**
|
|
98
|
-
* Enriched payload structure returned by the enricher plugin.
|
|
99
|
-
* Contains pre-structured events and context for direct use in analytics requests.
|
|
100
|
-
*/
|
|
101
|
-
export interface DotCMSEnrichedPayload {
|
|
102
|
-
/** Analytics context shared across events */
|
|
103
|
-
context: DotCMSAnalyticsContext;
|
|
104
|
-
/** Array of pre-structured analytics events */
|
|
105
|
-
events: DotCMSEvent[];
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Browser event data collected from the user's session in DotCMS.
|
|
109
|
-
* Contains comprehensive information about the user's browser environment,
|
|
110
|
-
* page context, and session details for analytics tracking.
|
|
111
|
-
*/
|
|
112
|
-
export interface DotCMSBrowserEventData {
|
|
113
|
-
/** UTC timestamp when the event occurred */
|
|
114
|
-
utc_time: string;
|
|
115
|
-
/** Local timezone offset in minutes */
|
|
116
|
-
local_tz_offset: number;
|
|
117
|
-
/** Screen resolution as a string (e.g., "1920x1080") */
|
|
118
|
-
screen_resolution: string | undefined;
|
|
119
|
-
/** Viewport size as a string (e.g., "1200x800") */
|
|
120
|
-
vp_size: string | undefined;
|
|
121
|
-
/** User's preferred language */
|
|
122
|
-
user_language: string | undefined;
|
|
123
|
-
/** Document encoding */
|
|
124
|
-
doc_encoding: string | undefined;
|
|
125
|
-
/** Document path */
|
|
126
|
-
doc_path: string | undefined;
|
|
127
|
-
/** Document host */
|
|
128
|
-
doc_host: string | undefined;
|
|
129
|
-
/** Document protocol (http/https) */
|
|
130
|
-
doc_protocol: string | undefined;
|
|
131
|
-
/** Document hash fragment */
|
|
132
|
-
doc_hash: string;
|
|
133
|
-
/** Document search parameters */
|
|
134
|
-
doc_search: string;
|
|
135
|
-
/** Referrer URL */
|
|
136
|
-
referrer: string | undefined;
|
|
137
|
-
/** Page title */
|
|
138
|
-
page_title: string | undefined;
|
|
139
|
-
/** Current page URL */
|
|
140
|
-
url: string | undefined;
|
|
141
|
-
/** UTM parameters for campaign tracking */
|
|
142
|
-
utm: Record<string, string>;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* The payload structure for DotCMS analytics events.
|
|
146
|
-
* This interface represents the complete data structure that flows through
|
|
147
|
-
* the analytics pipeline, including original event data and enriched context.
|
|
148
|
-
*
|
|
149
|
-
* This is the internal payload used by Analytics.js and our plugins.
|
|
150
|
-
*/
|
|
151
|
-
export interface DotCMSAnalyticsPayload {
|
|
152
|
-
/** The event name or identifier */
|
|
153
|
-
event: string;
|
|
154
|
-
/** Additional properties associated with the event */
|
|
155
|
-
properties: Record<string, unknown>;
|
|
156
|
-
/** Configuration options for the event */
|
|
157
|
-
options: Record<string, unknown>;
|
|
158
|
-
/** Analytics context shared across events */
|
|
159
|
-
context?: DotCMSAnalyticsContext;
|
|
160
|
-
/** Page data for the current page */
|
|
161
|
-
page?: DotCMSPageData;
|
|
162
|
-
/** Device and browser information */
|
|
163
|
-
device?: DotCMSDeviceData;
|
|
164
|
-
/** UTM parameters for campaign tracking */
|
|
165
|
-
utm?: DotCMSUtmData;
|
|
166
|
-
/** Local timestamp when the event occurred */
|
|
167
|
-
local_time: string;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Parameters passed to DotCMS Analytics plugin methods.
|
|
171
|
-
* Contains the configuration and payload data needed for processing analytics events.
|
|
172
|
-
*/
|
|
173
|
-
export interface DotCMSAnalyticsParams {
|
|
174
|
-
/** Configuration for the analytics client */
|
|
175
|
-
config: DotCMSAnalyticsConfig;
|
|
176
|
-
/** The event payload to be processed */
|
|
177
|
-
payload: DotCMSAnalyticsPayload;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Main interface for the DotCMS Analytics SDK.
|
|
181
|
-
* Provides the core methods for tracking page views and custom events.
|
|
182
|
-
*/
|
|
183
|
-
export interface DotCMSAnalytics {
|
|
184
|
-
/**
|
|
185
|
-
* Track a page view event.
|
|
186
|
-
*/
|
|
187
|
-
pageView: () => void;
|
|
188
|
-
/**
|
|
189
|
-
* Track a custom event.
|
|
190
|
-
* @param eventName - The name/type of the event to track
|
|
191
|
-
* @param payload - Optional additional data to include with the event
|
|
192
|
-
*/
|
|
193
|
-
track: (eventName: string, payload?: Record<string, unknown>) => void;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Analytics context shared across all events in DotCMS.
|
|
197
|
-
* Contains session and user identification data that provides
|
|
198
|
-
* continuity across multiple analytics events.
|
|
199
|
-
*/
|
|
200
|
-
export interface DotCMSAnalyticsContext {
|
|
201
|
-
/** The site key for the DotCMS instance */
|
|
202
|
-
site_key: string;
|
|
203
|
-
/** Unique session identifier */
|
|
204
|
-
session_id: string;
|
|
205
|
-
/** Unique user identifier */
|
|
206
|
-
user_id: string;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Device and browser information for DotCMS analytics tracking.
|
|
210
|
-
* Contains technical details about the user's device and browser environment.
|
|
211
|
-
*/
|
|
212
|
-
export interface DotCMSDeviceData {
|
|
213
|
-
/** Screen resolution as a string (e.g., "1920x1080") */
|
|
214
|
-
screen_resolution: string | undefined;
|
|
215
|
-
/** User's preferred language */
|
|
216
|
-
language: string | undefined;
|
|
217
|
-
/** Viewport width in pixels */
|
|
218
|
-
viewport_width: string | undefined;
|
|
219
|
-
/** Viewport height in pixels */
|
|
220
|
-
viewport_height: string | undefined;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* UTM (Urchin Tracking Module) parameters for DotCMS campaign tracking.
|
|
224
|
-
* Contains marketing campaign attribution data extracted from URL parameters.
|
|
225
|
-
*/
|
|
226
|
-
export interface DotCMSUtmData {
|
|
227
|
-
/** The marketing medium (e.g., email, social, cpc) */
|
|
228
|
-
medium?: string;
|
|
229
|
-
/** The traffic source (e.g., google, newsletter) */
|
|
230
|
-
source?: string;
|
|
231
|
-
/** The campaign name */
|
|
232
|
-
campaign?: string;
|
|
233
|
-
/** The campaign term or keyword */
|
|
234
|
-
term?: string;
|
|
235
|
-
/** The campaign content or ad variation */
|
|
236
|
-
content?: string;
|
|
237
|
-
/** The campaign ID for tracking specific campaigns */
|
|
238
|
-
id?: string;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Page data structure for DotCMS analytics.
|
|
242
|
-
* Contains comprehensive information about the current page and its context
|
|
243
|
-
* within the DotCMS environment.
|
|
244
|
-
*/
|
|
245
|
-
export interface DotCMSPageData {
|
|
246
|
-
/** The current page URL */
|
|
247
|
-
url: string | undefined;
|
|
248
|
-
/** Document encoding */
|
|
249
|
-
doc_encoding: string | undefined;
|
|
250
|
-
/** Document hash fragment */
|
|
251
|
-
doc_hash: string;
|
|
252
|
-
/** Document protocol (http/https) */
|
|
253
|
-
doc_protocol: string | undefined;
|
|
254
|
-
/** Document search parameters */
|
|
255
|
-
doc_search: string;
|
|
256
|
-
/** Document host domain */
|
|
257
|
-
doc_host: string | undefined;
|
|
258
|
-
/** Document path */
|
|
259
|
-
doc_path: string | undefined;
|
|
260
|
-
/** Page title */
|
|
261
|
-
title: string | undefined;
|
|
262
|
-
/** Language identifier */
|
|
263
|
-
language_id?: string;
|
|
264
|
-
/** Persona identifier */
|
|
265
|
-
persona?: string;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Analytics.js hook parameter types for DotCMS.
|
|
269
|
-
* Represents the payload structure used by Analytics.js lifecycle hooks
|
|
270
|
-
* for intercepting and modifying analytics events.
|
|
271
|
-
*/
|
|
272
|
-
export interface DotCMSAnalyticsHookPayload {
|
|
273
|
-
/** The type of analytics event */
|
|
274
|
-
type: string;
|
|
275
|
-
/** Properties associated with the event */
|
|
276
|
-
properties: {
|
|
277
|
-
/** Page title */
|
|
278
|
-
title: string;
|
|
279
|
-
/** Page URL */
|
|
280
|
-
url: string;
|
|
281
|
-
/** Page path */
|
|
282
|
-
path: string;
|
|
283
|
-
/** URL hash fragment */
|
|
284
|
-
hash: string;
|
|
285
|
-
/** URL search parameters */
|
|
286
|
-
search: string;
|
|
287
|
-
/** Viewport width */
|
|
288
|
-
width: number;
|
|
289
|
-
/** Viewport height */
|
|
290
|
-
height: number;
|
|
291
|
-
/** Referrer URL */
|
|
292
|
-
referrer?: string;
|
|
293
|
-
};
|
|
294
|
-
/** Configuration options for the event */
|
|
295
|
-
options: Record<string, unknown>;
|
|
296
|
-
/** User identifier */
|
|
297
|
-
userId: string | null;
|
|
298
|
-
/** Anonymous user identifier */
|
|
299
|
-
anonymousId: string;
|
|
300
|
-
/** Metadata about the event */
|
|
301
|
-
meta: {
|
|
302
|
-
/** Request identifier */
|
|
303
|
-
rid: string;
|
|
304
|
-
/** Timestamp */
|
|
305
|
-
ts: number;
|
|
306
|
-
/** Whether the event has a callback function */
|
|
307
|
-
hasCallback: boolean;
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Analytics.js instance structure for DotCMS.
|
|
312
|
-
* Represents the internal structure of an Analytics.js instance,
|
|
313
|
-
* providing access to plugins, storage, and event configuration.
|
|
314
|
-
*/
|
|
315
|
-
export interface DotCMSAnalyticsInstance {
|
|
316
|
-
/** Available plugins and their configurations */
|
|
317
|
-
plugins: Record<string, unknown>;
|
|
318
|
-
/** Storage mechanisms for analytics data */
|
|
319
|
-
storage: Record<string, unknown>;
|
|
320
|
-
/** Event configuration */
|
|
321
|
-
events: {
|
|
322
|
-
/** Core event types */
|
|
323
|
-
core: string[];
|
|
324
|
-
/** Plugin-specific event types */
|
|
325
|
-
plugins: string[];
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Parameters passed to Analytics.js hook functions in DotCMS.
|
|
330
|
-
* Contains all the context and data needed for Analytics.js lifecycle hooks
|
|
331
|
-
* to process and modify analytics events.
|
|
332
|
-
*/
|
|
333
|
-
export interface DotCMSAnalyticsHookParams {
|
|
334
|
-
/** The event payload data */
|
|
335
|
-
payload: DotCMSAnalyticsHookPayload;
|
|
336
|
-
/** The analytics instance */
|
|
337
|
-
instance: DotCMSAnalyticsInstance;
|
|
338
|
-
/** Global configuration settings */
|
|
339
|
-
config: Record<string, unknown>;
|
|
340
|
-
/** Available plugins and their status */
|
|
341
|
-
plugins: Record<string, {
|
|
342
|
-
/** Whether the plugin is enabled */
|
|
343
|
-
enabled: boolean;
|
|
344
|
-
/** Whether the plugin is initialized */
|
|
345
|
-
initialized: boolean;
|
|
346
|
-
/** Whether the plugin is loaded */
|
|
347
|
-
loaded: boolean;
|
|
348
|
-
/** Plugin-specific configuration */
|
|
349
|
-
config: Record<string, unknown>;
|
|
350
|
-
}>;
|
|
351
|
-
}
|