@dotcms/analytics 1.1.1-next.1 → 1.1.1-next.2
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 +8 -8
- package/lib/core/dot-content-analytics.js +6 -6
- package/lib/core/plugin/enricher/dot-analytics.enricher.plugin.d.ts +1 -1
- package/lib/core/shared/dot-content-analytics.model.d.ts +4 -4
- package/lib/core/shared/dot-content-analytics.utils.js +3 -3
- package/lib/react/hook/useContentAnalytics.d.ts +1 -1
- package/lib/react/hook/useContentAnalytics.js +3 -3
- package/lib/react/internal/utils.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Lightweight JavaScript SDK for tracking content-aware events in dotCMS. Works in
|
|
|
10
10
|
<script
|
|
11
11
|
src="ca.min.js"
|
|
12
12
|
data-analytics-server="https://demo.dotcms.com"
|
|
13
|
-
data-analytics-auth="
|
|
13
|
+
data-analytics-auth="SITE_AUTH"
|
|
14
14
|
data-analytics-auto-page-view="true"
|
|
15
15
|
data-analytics-debug="false"></script>
|
|
16
16
|
```
|
|
@@ -25,7 +25,7 @@ npm install @dotcms/analytics
|
|
|
25
25
|
import { initializeContentAnalytics } from '@dotcms/analytics';
|
|
26
26
|
|
|
27
27
|
const analytics = initializeContentAnalytics({
|
|
28
|
-
|
|
28
|
+
siteAuth: 'SITE_AUTH',
|
|
29
29
|
server: 'https://demo.dotcms.com'
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -42,7 +42,7 @@ npm install @dotcms/analytics
|
|
|
42
42
|
import { DotContentAnalytics } from '@dotcms/analytics/react';
|
|
43
43
|
|
|
44
44
|
const config = {
|
|
45
|
-
|
|
45
|
+
siteAuth: 'SITE_AUTH',
|
|
46
46
|
server: 'https://demo.dotcms.com',
|
|
47
47
|
autoPageView: true // Optional, default is true in React
|
|
48
48
|
};
|
|
@@ -78,7 +78,7 @@ Track any user action as an event using `track('event-name', { payload })`.
|
|
|
78
78
|
|
|
79
79
|
| Option | Type | Required | Default | Description |
|
|
80
80
|
| -------------- | --------- | -------- | ----------------------------------- | -------------------------------------- |
|
|
81
|
-
| `
|
|
81
|
+
| `siteAuth` | `string` | ✅ | - | Site auth from dotCMS Analytics app |
|
|
82
82
|
| `server` | `string` | ✅ | - | Your dotCMS server URL |
|
|
83
83
|
| `debug` | `boolean` | ❌ | `false` | Enable verbose logging |
|
|
84
84
|
| `autoPageView` | `boolean` | ❌ | React: `true` / Standalone: `false` | Auto track page views on route changes |
|
|
@@ -99,7 +99,7 @@ window.dotAnalytics.pageView();
|
|
|
99
99
|
|
|
100
100
|
```javascript
|
|
101
101
|
const analytics = initializeContentAnalytics({
|
|
102
|
-
|
|
102
|
+
siteAuth: 'abc123',
|
|
103
103
|
server: 'https://your-dotcms.com',
|
|
104
104
|
debug: true,
|
|
105
105
|
autoPageView: false
|
|
@@ -121,7 +121,7 @@ analytics.pageView();
|
|
|
121
121
|
import { useContentAnalytics } from '@dotcms/analytics/react';
|
|
122
122
|
|
|
123
123
|
const { track } = useContentAnalytics({
|
|
124
|
-
|
|
124
|
+
siteAuth: 'SITE_AUTH',
|
|
125
125
|
server: 'https://demo.dotcms.com'
|
|
126
126
|
});
|
|
127
127
|
|
|
@@ -134,7 +134,7 @@ track('cta-click', { label: 'Download PDF' });
|
|
|
134
134
|
import { useContentAnalytics } from '@dotcms/analytics/react';
|
|
135
135
|
|
|
136
136
|
const { pageView } = useContentAnalytics({
|
|
137
|
-
|
|
137
|
+
siteAuth: 'SITE_AUTH',
|
|
138
138
|
server: 'https://demo.dotcms.com'
|
|
139
139
|
});
|
|
140
140
|
useEffect(() => {
|
|
@@ -151,7 +151,7 @@ import { useLocation } from 'react-router-dom';
|
|
|
151
151
|
import { useContentAnalytics } from '@dotcms/analytics/react';
|
|
152
152
|
|
|
153
153
|
const { pageView } = useContentAnalytics({
|
|
154
|
-
|
|
154
|
+
siteAuth: 'SITE_AUTH',
|
|
155
155
|
server: 'https://demo.dotcms.com'
|
|
156
156
|
});
|
|
157
157
|
const location = useLocation();
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { Analytics as s } from "analytics";
|
|
2
2
|
import { dotAnalytics as l } from "./plugin/dot-analytics.plugin.js";
|
|
3
|
-
import { dotAnalyticsEnricherPlugin as
|
|
4
|
-
import { dotAnalyticsIdentityPlugin as
|
|
3
|
+
import { dotAnalyticsEnricherPlugin as u } from "./plugin/enricher/dot-analytics.enricher.plugin.js";
|
|
4
|
+
import { dotAnalyticsIdentityPlugin as a } from "./plugin/identity/dot-analytics.identity.plugin.js";
|
|
5
5
|
import { cleanupActivityTracking as c, updateSessionActivity as o } from "./shared/dot-content-analytics.activity-tracker.js";
|
|
6
6
|
const f = (n) => {
|
|
7
|
-
if (!n.
|
|
8
|
-
return console.error('DotContentAnalytics: Missing "
|
|
7
|
+
if (!n.siteAuth)
|
|
8
|
+
return console.error('DotContentAnalytics: Missing "siteAuth" in configuration'), null;
|
|
9
9
|
if (!n.server)
|
|
10
10
|
return console.error('DotContentAnalytics: Missing "server" in configuration'), null;
|
|
11
11
|
const t = s({
|
|
12
12
|
app: "dotAnalytics",
|
|
13
13
|
debug: n.debug,
|
|
14
14
|
plugins: [
|
|
15
|
-
|
|
15
|
+
a(n),
|
|
16
16
|
// Inject identity context (user_id, session_id, local_tz)
|
|
17
|
-
|
|
17
|
+
u(),
|
|
18
18
|
// Enrich with page, device, utm data
|
|
19
19
|
l(n)
|
|
20
20
|
// Send events to server
|
|
@@ -2,7 +2,7 @@ import { DotCMSAnalyticsPayload } from '../../shared/dot-content-analytics.model
|
|
|
2
2
|
/**
|
|
3
3
|
* Plugin that enriches the analytics payload data based on the event type.
|
|
4
4
|
* Uses Analytics.js lifecycle events to inject context before processing.
|
|
5
|
-
* The identity plugin runs FIRST to inject context: { session_id,
|
|
5
|
+
* The identity plugin runs FIRST to inject context: { session_id, site_auth, user_id }
|
|
6
6
|
* This enricher plugin runs SECOND to add page/device/utm data.
|
|
7
7
|
*
|
|
8
8
|
* OPTIMIZED: Uses existing payload.properties data to avoid duplication
|
|
@@ -22,9 +22,9 @@ export interface DotCMSAnalyticsConfig {
|
|
|
22
22
|
*/
|
|
23
23
|
autoPageView?: boolean;
|
|
24
24
|
/**
|
|
25
|
-
* The site
|
|
25
|
+
* The site auth for authenticating with the Analytics service.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
siteAuth: string;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Supported event types in DotCMS Analytics.
|
|
@@ -198,8 +198,8 @@ export interface DotCMSAnalytics {
|
|
|
198
198
|
* continuity across multiple analytics events.
|
|
199
199
|
*/
|
|
200
200
|
export interface DotCMSAnalyticsContext {
|
|
201
|
-
/** The site
|
|
202
|
-
|
|
201
|
+
/** The site auth for the DotCMS instance */
|
|
202
|
+
site_auth: string;
|
|
203
203
|
/** Unique session identifier */
|
|
204
204
|
session_id: string;
|
|
205
205
|
/** Unique user identifier */
|
|
@@ -55,13 +55,13 @@ const u = (t) => {
|
|
|
55
55
|
} catch {
|
|
56
56
|
return u("session_fallback");
|
|
57
57
|
}
|
|
58
|
-
},
|
|
58
|
+
}, y = (t) => {
|
|
59
59
|
const e = p(), n = f();
|
|
60
60
|
return t.debug && console.warn("DotAnalytics Identity Context:", {
|
|
61
61
|
sessionId: e,
|
|
62
62
|
userId: n
|
|
63
63
|
}), {
|
|
64
|
-
|
|
64
|
+
site_auth: t.siteAuth,
|
|
65
65
|
session_id: e,
|
|
66
66
|
user_id: n
|
|
67
67
|
};
|
|
@@ -116,7 +116,7 @@ const u = (t) => {
|
|
|
116
116
|
export {
|
|
117
117
|
$ as enrichPagePayloadOptimized,
|
|
118
118
|
u as generateSecureId,
|
|
119
|
-
|
|
119
|
+
y as getAnalyticsContext,
|
|
120
120
|
D as getLocalTime,
|
|
121
121
|
p as getSessionId,
|
|
122
122
|
f as getUserId
|
|
@@ -9,7 +9,7 @@ import { DotCMSAnalytics, DotCMSAnalyticsConfig } from '../../core/shared/dot-co
|
|
|
9
9
|
* function Button({ title, urlTitle }) {
|
|
10
10
|
* const { track } = useContentAnalytics({
|
|
11
11
|
* server: 'https://demo.dotcms.com',
|
|
12
|
-
*
|
|
12
|
+
* siteAuth: 'my-site-auth',
|
|
13
13
|
* debug: false
|
|
14
14
|
* });
|
|
15
15
|
*
|
|
@@ -2,11 +2,11 @@ import { useRef as l, useCallback as n } from "react";
|
|
|
2
2
|
import { getUVEState as r } from "../../../uve/src/lib/core/core.utils.js";
|
|
3
3
|
import "../../../uve/src/internal/constants.js";
|
|
4
4
|
import { initializeAnalytics as f } from "../internal/utils.js";
|
|
5
|
-
const
|
|
5
|
+
const h = (o) => {
|
|
6
6
|
const t = f(o), i = l(null);
|
|
7
7
|
if (!t)
|
|
8
8
|
throw new Error(
|
|
9
|
-
"Failed to initialize DotContentAnalytics. Please verify the required configuration (server and
|
|
9
|
+
"Failed to initialize DotContentAnalytics. Please verify the required configuration (server and siteAuth)."
|
|
10
10
|
);
|
|
11
11
|
const a = n(
|
|
12
12
|
(e, s = {}) => {
|
|
@@ -28,5 +28,5 @@ const g = (o) => {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
export {
|
|
31
|
-
|
|
31
|
+
h as useContentAnalytics
|
|
32
32
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { initializeContentAnalytics as r } from "../../core/dot-content-analytics.js";
|
|
2
|
-
let
|
|
3
|
-
const s = (
|
|
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
|
};
|