@aranova/tracking-next 0.5.1 → 0.6.1
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 +150 -0
- package/dist/index.d.mts +383 -48
- package/dist/index.d.ts +383 -48
- package/dist/index.js +26 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -16
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.d.mts +7 -0
- package/dist/middleware.d.ts +7 -0
- package/dist/middleware.js +25 -15
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +25 -15
- package/dist/middleware.mjs.map +1 -1
- package/dist/server.d.mts +8 -1
- package/dist/server.d.ts +8 -1
- package/dist/server.js +25 -15
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +25 -15
- package/dist/server.mjs.map +1 -1
- package/dist/types-B4VZHWnc.d.mts +127 -0
- package/dist/types-B4VZHWnc.d.ts +127 -0
- package/package.json +3 -2
- package/dist/types-Gp0ioRiQ.d.mts +0 -67
- package/dist/types-Gp0ioRiQ.d.ts +0 -67
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visitor consent state stored by the SDK.
|
|
3
|
+
*
|
|
4
|
+
* - `pending`: the visitor has not accepted or declined yet.
|
|
5
|
+
* - `granted`: consent was accepted and Google Consent Mode is updated to granted.
|
|
6
|
+
* - `denied`: consent was declined and Google Consent Mode is updated to denied.
|
|
7
|
+
*/
|
|
8
|
+
type ConsentState = 'granted' | 'denied' | 'pending';
|
|
9
|
+
/**
|
|
10
|
+
* Attribution parameters captured from the landing URL and persisted in cookies.
|
|
11
|
+
*
|
|
12
|
+
* Missing params are represented as `null` so payloads can be serialized
|
|
13
|
+
* directly without checking for `undefined`.
|
|
14
|
+
*/
|
|
15
|
+
interface TrackingParams {
|
|
16
|
+
/** Google Ads click id. */
|
|
17
|
+
gclid: string | null;
|
|
18
|
+
/** Meta/Facebook click id. */
|
|
19
|
+
fbclid: string | null;
|
|
20
|
+
/** UTM source, for example `google` or `newsletter`. */
|
|
21
|
+
utm_source: string | null;
|
|
22
|
+
/** UTM medium, for example `cpc` or `email`. */
|
|
23
|
+
utm_medium: string | null;
|
|
24
|
+
/** UTM campaign name. */
|
|
25
|
+
utm_campaign: string | null;
|
|
26
|
+
/** UTM paid-search term. */
|
|
27
|
+
utm_term: string | null;
|
|
28
|
+
/** UTM content/ad creative label. */
|
|
29
|
+
utm_content: string | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Runtime surface that installed the tracking SDK.
|
|
33
|
+
*
|
|
34
|
+
* Included in ingest payloads and heartbeat events so the dashboard can tell
|
|
35
|
+
* whether a site uses the Next, React, or script-tag integration.
|
|
36
|
+
*/
|
|
37
|
+
type TrackingInstallSurface = 'next' | 'react' | 'script';
|
|
38
|
+
/**
|
|
39
|
+
* Runtime context attached to tracking sessions and events.
|
|
40
|
+
*/
|
|
41
|
+
interface TrackingClientContext {
|
|
42
|
+
/** Install surface that created the client. */
|
|
43
|
+
surface: TrackingInstallSurface;
|
|
44
|
+
/** Package version, when available. */
|
|
45
|
+
sdk_version: string | null;
|
|
46
|
+
/** Package name, for example `@aranova/tracking-react`. */
|
|
47
|
+
package_name: string | null;
|
|
48
|
+
/** Browser origin of the tracked site. */
|
|
49
|
+
site_origin: string | null;
|
|
50
|
+
/** Current document title at client creation time. */
|
|
51
|
+
page_title: string | null;
|
|
52
|
+
/** Browser document referrer at client creation time. */
|
|
53
|
+
referrer: string | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Session payload sent to `POST /tracking/events`.
|
|
57
|
+
*
|
|
58
|
+
* The backend upserts this by `(business_id, session_id)` before inserting
|
|
59
|
+
* individual events.
|
|
60
|
+
*/
|
|
61
|
+
interface TrackingSessionUpsertPayload {
|
|
62
|
+
/** Rolling 30-minute client-side session id. */
|
|
63
|
+
session_id: string;
|
|
64
|
+
/** Persistent client-side visitor id. */
|
|
65
|
+
visitor_id: string | null;
|
|
66
|
+
gclid: string | null;
|
|
67
|
+
fbclid: string | null;
|
|
68
|
+
utm_source: string | null;
|
|
69
|
+
utm_medium: string | null;
|
|
70
|
+
utm_campaign: string | null;
|
|
71
|
+
utm_term: string | null;
|
|
72
|
+
utm_content: string | null;
|
|
73
|
+
first_page: string | null;
|
|
74
|
+
consent_state: Record<string, unknown> | null;
|
|
75
|
+
context: TrackingClientContext;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Event payload shape before batching into the ingest request.
|
|
79
|
+
*/
|
|
80
|
+
interface TrackingEventCreatePayload {
|
|
81
|
+
/** Session id that logically owns the event. */
|
|
82
|
+
session_id: string;
|
|
83
|
+
/** Registered event name, for example `page_view` or `form_submit`. */
|
|
84
|
+
event_type: string;
|
|
85
|
+
gclid: string | null;
|
|
86
|
+
fbclid: string | null;
|
|
87
|
+
/** Full page URL associated with the event, if known. */
|
|
88
|
+
page_url: string | null;
|
|
89
|
+
/** Event-specific metadata. Runtime shape depends on `event_type`. */
|
|
90
|
+
metadata: Record<string, unknown> | null;
|
|
91
|
+
context: TrackingClientContext;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Browser-script initialization config passed to `window.AranovaTracking.init()`.
|
|
95
|
+
*/
|
|
96
|
+
interface TrackingInitConfig {
|
|
97
|
+
/** Public tracking API key issued from the Aranova dashboard. */
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
/** Tracking endpoint base URL, usually ending in `/tracking`. */
|
|
100
|
+
endpoint?: string;
|
|
101
|
+
/** Optional Google Ads tag id, for example `AW-123456789`. */
|
|
102
|
+
gtagId?: string;
|
|
103
|
+
/** Whether to capture attribution params from `window.location`. Defaults to true. */
|
|
104
|
+
autoCaptureTrackingParams?: boolean;
|
|
105
|
+
/** Whether the browser script should inject the default consent banner. */
|
|
106
|
+
renderConsentBanner?: boolean;
|
|
107
|
+
/** Attribution cookie max age in seconds. Defaults to 90 days. */
|
|
108
|
+
cookieMaxAgeSeconds?: number;
|
|
109
|
+
/** Override the install surface reported in payload context. */
|
|
110
|
+
surface?: TrackingInstallSurface;
|
|
111
|
+
}
|
|
112
|
+
declare global {
|
|
113
|
+
interface Window {
|
|
114
|
+
gtag?: (...args: unknown[]) => void;
|
|
115
|
+
dataLayer?: unknown[];
|
|
116
|
+
AranovaTracking?: {
|
|
117
|
+
init: (config: TrackingInitConfig) => void;
|
|
118
|
+
captureTrackingParams: () => TrackingParams;
|
|
119
|
+
getTrackingParams: () => TrackingParams;
|
|
120
|
+
getConsentState: () => ConsentState;
|
|
121
|
+
setConsentState: (state: 'granted' | 'denied') => void;
|
|
122
|
+
trackEvent: (eventType: string, metadata: Record<string, unknown>) => void;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type { ConsentState as C, TrackingInstallSurface as T, TrackingClientContext as a, TrackingParams as b, TrackingEventCreatePayload as c, TrackingSessionUpsertPayload as d, TrackingInitConfig as e };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visitor consent state stored by the SDK.
|
|
3
|
+
*
|
|
4
|
+
* - `pending`: the visitor has not accepted or declined yet.
|
|
5
|
+
* - `granted`: consent was accepted and Google Consent Mode is updated to granted.
|
|
6
|
+
* - `denied`: consent was declined and Google Consent Mode is updated to denied.
|
|
7
|
+
*/
|
|
8
|
+
type ConsentState = 'granted' | 'denied' | 'pending';
|
|
9
|
+
/**
|
|
10
|
+
* Attribution parameters captured from the landing URL and persisted in cookies.
|
|
11
|
+
*
|
|
12
|
+
* Missing params are represented as `null` so payloads can be serialized
|
|
13
|
+
* directly without checking for `undefined`.
|
|
14
|
+
*/
|
|
15
|
+
interface TrackingParams {
|
|
16
|
+
/** Google Ads click id. */
|
|
17
|
+
gclid: string | null;
|
|
18
|
+
/** Meta/Facebook click id. */
|
|
19
|
+
fbclid: string | null;
|
|
20
|
+
/** UTM source, for example `google` or `newsletter`. */
|
|
21
|
+
utm_source: string | null;
|
|
22
|
+
/** UTM medium, for example `cpc` or `email`. */
|
|
23
|
+
utm_medium: string | null;
|
|
24
|
+
/** UTM campaign name. */
|
|
25
|
+
utm_campaign: string | null;
|
|
26
|
+
/** UTM paid-search term. */
|
|
27
|
+
utm_term: string | null;
|
|
28
|
+
/** UTM content/ad creative label. */
|
|
29
|
+
utm_content: string | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Runtime surface that installed the tracking SDK.
|
|
33
|
+
*
|
|
34
|
+
* Included in ingest payloads and heartbeat events so the dashboard can tell
|
|
35
|
+
* whether a site uses the Next, React, or script-tag integration.
|
|
36
|
+
*/
|
|
37
|
+
type TrackingInstallSurface = 'next' | 'react' | 'script';
|
|
38
|
+
/**
|
|
39
|
+
* Runtime context attached to tracking sessions and events.
|
|
40
|
+
*/
|
|
41
|
+
interface TrackingClientContext {
|
|
42
|
+
/** Install surface that created the client. */
|
|
43
|
+
surface: TrackingInstallSurface;
|
|
44
|
+
/** Package version, when available. */
|
|
45
|
+
sdk_version: string | null;
|
|
46
|
+
/** Package name, for example `@aranova/tracking-react`. */
|
|
47
|
+
package_name: string | null;
|
|
48
|
+
/** Browser origin of the tracked site. */
|
|
49
|
+
site_origin: string | null;
|
|
50
|
+
/** Current document title at client creation time. */
|
|
51
|
+
page_title: string | null;
|
|
52
|
+
/** Browser document referrer at client creation time. */
|
|
53
|
+
referrer: string | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Session payload sent to `POST /tracking/events`.
|
|
57
|
+
*
|
|
58
|
+
* The backend upserts this by `(business_id, session_id)` before inserting
|
|
59
|
+
* individual events.
|
|
60
|
+
*/
|
|
61
|
+
interface TrackingSessionUpsertPayload {
|
|
62
|
+
/** Rolling 30-minute client-side session id. */
|
|
63
|
+
session_id: string;
|
|
64
|
+
/** Persistent client-side visitor id. */
|
|
65
|
+
visitor_id: string | null;
|
|
66
|
+
gclid: string | null;
|
|
67
|
+
fbclid: string | null;
|
|
68
|
+
utm_source: string | null;
|
|
69
|
+
utm_medium: string | null;
|
|
70
|
+
utm_campaign: string | null;
|
|
71
|
+
utm_term: string | null;
|
|
72
|
+
utm_content: string | null;
|
|
73
|
+
first_page: string | null;
|
|
74
|
+
consent_state: Record<string, unknown> | null;
|
|
75
|
+
context: TrackingClientContext;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Event payload shape before batching into the ingest request.
|
|
79
|
+
*/
|
|
80
|
+
interface TrackingEventCreatePayload {
|
|
81
|
+
/** Session id that logically owns the event. */
|
|
82
|
+
session_id: string;
|
|
83
|
+
/** Registered event name, for example `page_view` or `form_submit`. */
|
|
84
|
+
event_type: string;
|
|
85
|
+
gclid: string | null;
|
|
86
|
+
fbclid: string | null;
|
|
87
|
+
/** Full page URL associated with the event, if known. */
|
|
88
|
+
page_url: string | null;
|
|
89
|
+
/** Event-specific metadata. Runtime shape depends on `event_type`. */
|
|
90
|
+
metadata: Record<string, unknown> | null;
|
|
91
|
+
context: TrackingClientContext;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Browser-script initialization config passed to `window.AranovaTracking.init()`.
|
|
95
|
+
*/
|
|
96
|
+
interface TrackingInitConfig {
|
|
97
|
+
/** Public tracking API key issued from the Aranova dashboard. */
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
/** Tracking endpoint base URL, usually ending in `/tracking`. */
|
|
100
|
+
endpoint?: string;
|
|
101
|
+
/** Optional Google Ads tag id, for example `AW-123456789`. */
|
|
102
|
+
gtagId?: string;
|
|
103
|
+
/** Whether to capture attribution params from `window.location`. Defaults to true. */
|
|
104
|
+
autoCaptureTrackingParams?: boolean;
|
|
105
|
+
/** Whether the browser script should inject the default consent banner. */
|
|
106
|
+
renderConsentBanner?: boolean;
|
|
107
|
+
/** Attribution cookie max age in seconds. Defaults to 90 days. */
|
|
108
|
+
cookieMaxAgeSeconds?: number;
|
|
109
|
+
/** Override the install surface reported in payload context. */
|
|
110
|
+
surface?: TrackingInstallSurface;
|
|
111
|
+
}
|
|
112
|
+
declare global {
|
|
113
|
+
interface Window {
|
|
114
|
+
gtag?: (...args: unknown[]) => void;
|
|
115
|
+
dataLayer?: unknown[];
|
|
116
|
+
AranovaTracking?: {
|
|
117
|
+
init: (config: TrackingInitConfig) => void;
|
|
118
|
+
captureTrackingParams: () => TrackingParams;
|
|
119
|
+
getTrackingParams: () => TrackingParams;
|
|
120
|
+
getConsentState: () => ConsentState;
|
|
121
|
+
setConsentState: (state: 'granted' | 'denied') => void;
|
|
122
|
+
trackEvent: (eventType: string, metadata: Record<string, unknown>) => void;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type { ConsentState as C, TrackingInstallSurface as T, TrackingClientContext as a, TrackingParams as b, TrackingEventCreatePayload as c, TrackingSessionUpsertPayload as d, TrackingInitConfig as e };
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aranova/tracking-next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Next.js tracking utilities for Aranova client sites",
|
|
6
6
|
"files": [
|
|
7
|
-
"dist"
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md"
|
|
8
9
|
],
|
|
9
10
|
"main": "./dist/index.js",
|
|
10
11
|
"module": "./dist/index.mjs",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
type ConsentState = 'granted' | 'denied' | 'pending';
|
|
2
|
-
interface TrackingParams {
|
|
3
|
-
gclid: string | null;
|
|
4
|
-
fbclid: string | null;
|
|
5
|
-
utm_source: string | null;
|
|
6
|
-
utm_medium: string | null;
|
|
7
|
-
utm_campaign: string | null;
|
|
8
|
-
utm_term: string | null;
|
|
9
|
-
utm_content: string | null;
|
|
10
|
-
}
|
|
11
|
-
type TrackingInstallSurface = 'next' | 'react' | 'script';
|
|
12
|
-
interface TrackingClientContext {
|
|
13
|
-
surface: TrackingInstallSurface;
|
|
14
|
-
sdk_version: string | null;
|
|
15
|
-
package_name: string | null;
|
|
16
|
-
site_origin: string | null;
|
|
17
|
-
page_title: string | null;
|
|
18
|
-
referrer: string | null;
|
|
19
|
-
}
|
|
20
|
-
interface TrackingSessionUpsertPayload {
|
|
21
|
-
session_id: string;
|
|
22
|
-
visitor_id: string | null;
|
|
23
|
-
gclid: string | null;
|
|
24
|
-
fbclid: string | null;
|
|
25
|
-
utm_source: string | null;
|
|
26
|
-
utm_medium: string | null;
|
|
27
|
-
utm_campaign: string | null;
|
|
28
|
-
utm_term: string | null;
|
|
29
|
-
utm_content: string | null;
|
|
30
|
-
first_page: string | null;
|
|
31
|
-
consent_state: Record<string, unknown> | null;
|
|
32
|
-
context: TrackingClientContext;
|
|
33
|
-
}
|
|
34
|
-
interface TrackingEventCreatePayload {
|
|
35
|
-
session_id: string;
|
|
36
|
-
event_type: string;
|
|
37
|
-
gclid: string | null;
|
|
38
|
-
fbclid: string | null;
|
|
39
|
-
page_url: string | null;
|
|
40
|
-
metadata: Record<string, unknown> | null;
|
|
41
|
-
context: TrackingClientContext;
|
|
42
|
-
}
|
|
43
|
-
interface TrackingInitConfig {
|
|
44
|
-
apiKey?: string;
|
|
45
|
-
endpoint?: string;
|
|
46
|
-
gtagId?: string;
|
|
47
|
-
autoCaptureTrackingParams?: boolean;
|
|
48
|
-
renderConsentBanner?: boolean;
|
|
49
|
-
cookieMaxAgeSeconds?: number;
|
|
50
|
-
surface?: TrackingInstallSurface;
|
|
51
|
-
}
|
|
52
|
-
declare global {
|
|
53
|
-
interface Window {
|
|
54
|
-
gtag?: (...args: unknown[]) => void;
|
|
55
|
-
dataLayer?: unknown[];
|
|
56
|
-
AranovaTracking?: {
|
|
57
|
-
init: (config: TrackingInitConfig) => void;
|
|
58
|
-
captureTrackingParams: () => TrackingParams;
|
|
59
|
-
getTrackingParams: () => TrackingParams;
|
|
60
|
-
getConsentState: () => ConsentState;
|
|
61
|
-
setConsentState: (state: 'granted' | 'denied') => void;
|
|
62
|
-
trackEvent: (eventType: string, metadata: Record<string, unknown>) => void;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type { ConsentState as C, TrackingInstallSurface as T, TrackingClientContext as a, TrackingParams as b, TrackingEventCreatePayload as c, TrackingSessionUpsertPayload as d, TrackingInitConfig as e };
|
package/dist/types-Gp0ioRiQ.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
type ConsentState = 'granted' | 'denied' | 'pending';
|
|
2
|
-
interface TrackingParams {
|
|
3
|
-
gclid: string | null;
|
|
4
|
-
fbclid: string | null;
|
|
5
|
-
utm_source: string | null;
|
|
6
|
-
utm_medium: string | null;
|
|
7
|
-
utm_campaign: string | null;
|
|
8
|
-
utm_term: string | null;
|
|
9
|
-
utm_content: string | null;
|
|
10
|
-
}
|
|
11
|
-
type TrackingInstallSurface = 'next' | 'react' | 'script';
|
|
12
|
-
interface TrackingClientContext {
|
|
13
|
-
surface: TrackingInstallSurface;
|
|
14
|
-
sdk_version: string | null;
|
|
15
|
-
package_name: string | null;
|
|
16
|
-
site_origin: string | null;
|
|
17
|
-
page_title: string | null;
|
|
18
|
-
referrer: string | null;
|
|
19
|
-
}
|
|
20
|
-
interface TrackingSessionUpsertPayload {
|
|
21
|
-
session_id: string;
|
|
22
|
-
visitor_id: string | null;
|
|
23
|
-
gclid: string | null;
|
|
24
|
-
fbclid: string | null;
|
|
25
|
-
utm_source: string | null;
|
|
26
|
-
utm_medium: string | null;
|
|
27
|
-
utm_campaign: string | null;
|
|
28
|
-
utm_term: string | null;
|
|
29
|
-
utm_content: string | null;
|
|
30
|
-
first_page: string | null;
|
|
31
|
-
consent_state: Record<string, unknown> | null;
|
|
32
|
-
context: TrackingClientContext;
|
|
33
|
-
}
|
|
34
|
-
interface TrackingEventCreatePayload {
|
|
35
|
-
session_id: string;
|
|
36
|
-
event_type: string;
|
|
37
|
-
gclid: string | null;
|
|
38
|
-
fbclid: string | null;
|
|
39
|
-
page_url: string | null;
|
|
40
|
-
metadata: Record<string, unknown> | null;
|
|
41
|
-
context: TrackingClientContext;
|
|
42
|
-
}
|
|
43
|
-
interface TrackingInitConfig {
|
|
44
|
-
apiKey?: string;
|
|
45
|
-
endpoint?: string;
|
|
46
|
-
gtagId?: string;
|
|
47
|
-
autoCaptureTrackingParams?: boolean;
|
|
48
|
-
renderConsentBanner?: boolean;
|
|
49
|
-
cookieMaxAgeSeconds?: number;
|
|
50
|
-
surface?: TrackingInstallSurface;
|
|
51
|
-
}
|
|
52
|
-
declare global {
|
|
53
|
-
interface Window {
|
|
54
|
-
gtag?: (...args: unknown[]) => void;
|
|
55
|
-
dataLayer?: unknown[];
|
|
56
|
-
AranovaTracking?: {
|
|
57
|
-
init: (config: TrackingInitConfig) => void;
|
|
58
|
-
captureTrackingParams: () => TrackingParams;
|
|
59
|
-
getTrackingParams: () => TrackingParams;
|
|
60
|
-
getConsentState: () => ConsentState;
|
|
61
|
-
setConsentState: (state: 'granted' | 'denied') => void;
|
|
62
|
-
trackEvent: (eventType: string, metadata: Record<string, unknown>) => void;
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type { ConsentState as C, TrackingInstallSurface as T, TrackingClientContext as a, TrackingParams as b, TrackingEventCreatePayload as c, TrackingSessionUpsertPayload as d, TrackingInitConfig as e };
|