@nexly/core 0.16.2 → 1.0.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 +1 -1
- package/dist/collect.d.ts +10 -0
- package/dist/collect.d.ts.map +1 -1
- package/dist/collect.js +3 -0
- package/dist/nexly-base.d.ts +18 -11
- package/dist/nexly-base.d.ts.map +1 -1
- package/dist/nexly-base.js +14 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ import { Nexly } from '@nexly/core'
|
|
|
18
18
|
const nexly = new Nexly(options)
|
|
19
19
|
|
|
20
20
|
nexly.pageview()
|
|
21
|
-
nexly.event({ name: '
|
|
21
|
+
nexly.event({ name: 'signup_clicked', type: 'custom', cdata: { plan: 'pro' } })
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Constructor options use the `NexlyInit` type from the published typings.
|
package/dist/collect.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export type CollectCredentials = {
|
|
|
15
15
|
collectUrl: string;
|
|
16
16
|
/** Which SDK identity to report (see {@link TrackEventInput.client}). Optional. */
|
|
17
17
|
client?: NexlyClient;
|
|
18
|
+
/** Mirror of {@link TrackEventInput.privacyMode}; forwarded on the wire. */
|
|
19
|
+
privacyMode?: boolean;
|
|
18
20
|
} & IngestCredentials;
|
|
19
21
|
/**
|
|
20
22
|
* Top-level scalar payload used by the `cdata` slot. The contract is
|
|
@@ -99,6 +101,14 @@ export type TrackEventInput = {
|
|
|
99
101
|
* rejects any value outside the enum.
|
|
100
102
|
*/
|
|
101
103
|
client?: NexlyClient;
|
|
104
|
+
/**
|
|
105
|
+
* When true the SDK did not read or write any device-storage identifier
|
|
106
|
+
* for this event. Emitted as top-level `privacy_mode: true` on the wire so
|
|
107
|
+
* the collector may derive a short-lived server-side visit fingerprint when
|
|
108
|
+
* `context.visitor_id` / `context.session_id` are absent. Never set for
|
|
109
|
+
* SDKs that simply omit IDs by design (e.g. server runtimes).
|
|
110
|
+
*/
|
|
111
|
+
privacyMode?: boolean;
|
|
102
112
|
context?: Record<string, unknown>;
|
|
103
113
|
data?: Record<string, unknown>;
|
|
104
114
|
cdata?: CData;
|
package/dist/collect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../src/collect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,iDAAiD;AACjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,mFAAmF;IACnF,MAAM,CAAC,EAAE,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../src/collect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,iDAAiD;AACjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,mFAAmF;IACnF,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,GAAG,iBAAiB,CAAA;AAErB;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;AAE7D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,CAAC,EAAE,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CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACzC,CAAA;AAMD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+BnF"}
|
package/dist/collect.js
CHANGED
package/dist/nexly-base.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ export type NexlyInit = {
|
|
|
7
7
|
collectUrl?: string;
|
|
8
8
|
appId: string;
|
|
9
9
|
key: string;
|
|
10
|
+
/**
|
|
11
|
+
* Privacy mode: the SDK never reads or writes device storage
|
|
12
|
+
* (`localStorage` / `AsyncStorage`) for its visitor / session identifiers.
|
|
13
|
+
* Events are sent with `privacy_mode: true` on the wire; when no manual ID
|
|
14
|
+
* was provided the collector derives a short-lived, daily-rotating visit
|
|
15
|
+
* fingerprint server-side instead. Defaults to `false`.
|
|
16
|
+
*/
|
|
17
|
+
privacyMode?: boolean;
|
|
10
18
|
/**
|
|
11
19
|
* @internal
|
|
12
20
|
*
|
|
@@ -22,20 +30,17 @@ export type NexlyEventType = 'pageview' | 'engagement' | 'custom' | 'navigation'
|
|
|
22
30
|
export type NexlyEventInput = {
|
|
23
31
|
name: string;
|
|
24
32
|
type: NexlyEventType | string;
|
|
25
|
-
/**
|
|
26
|
-
* SDK-emitted built-in event payload. For built-in event types
|
|
27
|
-
* (`engagement`, `lifecycle`, `pageview`, `navigation`) the server
|
|
28
|
-
* validates this against a per-event-type allowlist. For
|
|
29
|
-
* `type: 'custom'` events, user-defined payload belongs in
|
|
30
|
-
* {@link cdata} instead — `data` is reserved for SDK metrics.
|
|
31
|
-
*/
|
|
32
|
-
data?: Record<string, unknown>;
|
|
33
33
|
/**
|
|
34
34
|
* User-defined custom analytics payload. Top-level scalar map
|
|
35
35
|
* (`string` / `number` / `boolean`). Server validates against the
|
|
36
36
|
* per-app `Custom data` registry; unapproved keys are discovered
|
|
37
37
|
* but not stored. Use {@link NexlyBase.customEvent} for the
|
|
38
38
|
* ergonomic per-event API.
|
|
39
|
+
*
|
|
40
|
+
* This is the only slot for application payload. The SDK-emitted
|
|
41
|
+
* built-in `data` vocabulary (engagement metrics, lifecycle pings)
|
|
42
|
+
* is populated internally by the auto-tracking listeners and is not
|
|
43
|
+
* settable from application code.
|
|
39
44
|
*/
|
|
40
45
|
cdata?: CData;
|
|
41
46
|
/** Merged on top of default platform context (see {@link NexlyBase.collectEventContext}). */
|
|
@@ -63,6 +68,7 @@ export declare abstract class NexlyBase {
|
|
|
63
68
|
readonly appId: string;
|
|
64
69
|
readonly key: string;
|
|
65
70
|
readonly client: NexlyClient | undefined;
|
|
71
|
+
readonly privacyMode: boolean;
|
|
66
72
|
/**
|
|
67
73
|
* Tracks whether `session_context` has already been emitted for the current
|
|
68
74
|
* `session_id`. `session_context` is session-stable (UA, screen, locale) —
|
|
@@ -88,9 +94,10 @@ export declare abstract class NexlyBase {
|
|
|
88
94
|
pageview(path?: string): boolean;
|
|
89
95
|
/**
|
|
90
96
|
* Sends a generic event. The unstructured `context` is merged on top
|
|
91
|
-
* of the default platform context;
|
|
92
|
-
*
|
|
93
|
-
*
|
|
97
|
+
* of the default platform context; application payload travels in
|
|
98
|
+
* `cdata`. The built-in `data` vocabulary is owned by the SDK's
|
|
99
|
+
* auto-tracking and is always sent empty from this entry point —
|
|
100
|
+
* prefer {@link customEvent} for the ergonomic custom-analytics API.
|
|
94
101
|
*/
|
|
95
102
|
event(input: NexlyEventInput): boolean;
|
|
96
103
|
/**
|
package/dist/nexly-base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nexly-base.d.ts","sourceRoot":"","sources":["../src/nexly-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC7B,MAAM,cAAc,CAAA;AAIrB,eAAO,MAAM,mBAAmB,q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eAAe,GAAG,OAAO;IAatC;;;;;;;;;;;;OAYG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO;IAapF,OAAO,CAAC,QAAQ;CAoCjB"}
|
package/dist/nexly-base.js
CHANGED
|
@@ -26,6 +26,7 @@ export class NexlyBase {
|
|
|
26
26
|
appId;
|
|
27
27
|
key;
|
|
28
28
|
client;
|
|
29
|
+
privacyMode;
|
|
29
30
|
/**
|
|
30
31
|
* Tracks whether `session_context` has already been emitted for the current
|
|
31
32
|
* `session_id`. `session_context` is session-stable (UA, screen, locale) —
|
|
@@ -39,6 +40,7 @@ export class NexlyBase {
|
|
|
39
40
|
this.appId = (init.appId ?? '').trim();
|
|
40
41
|
this.key = (init.key ?? '').trim();
|
|
41
42
|
this.client = init.client;
|
|
43
|
+
this.privacyMode = init.privacyMode === true;
|
|
42
44
|
if (!this.appId)
|
|
43
45
|
console.warn('[Nexly] Missing appId — tracking will be disabled.');
|
|
44
46
|
if (!this.key)
|
|
@@ -66,9 +68,10 @@ export class NexlyBase {
|
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* Sends a generic event. The unstructured `context` is merged on top
|
|
69
|
-
* of the default platform context;
|
|
70
|
-
*
|
|
71
|
-
*
|
|
71
|
+
* of the default platform context; application payload travels in
|
|
72
|
+
* `cdata`. The built-in `data` vocabulary is owned by the SDK's
|
|
73
|
+
* auto-tracking and is always sent empty from this entry point —
|
|
74
|
+
* prefer {@link customEvent} for the ergonomic custom-analytics API.
|
|
72
75
|
*/
|
|
73
76
|
event(input) {
|
|
74
77
|
if (this.disabled)
|
|
@@ -79,7 +82,7 @@ export class NexlyBase {
|
|
|
79
82
|
eventName: input.name,
|
|
80
83
|
eventType: input.type,
|
|
81
84
|
context,
|
|
82
|
-
data:
|
|
85
|
+
data: {},
|
|
83
86
|
cdata: input.cdata,
|
|
84
87
|
});
|
|
85
88
|
}
|
|
@@ -111,12 +114,16 @@ export class NexlyBase {
|
|
|
111
114
|
}
|
|
112
115
|
dispatch(args) {
|
|
113
116
|
const sessionId = typeof args.context.session_id === 'string' ? args.context.session_id : '';
|
|
117
|
+
// In privacy mode the session id may be derived server-side, so the SDK
|
|
118
|
+
// cannot key "session_context sent once" off it. Fall back to a sentinel:
|
|
119
|
+
// send session_context once per client instance (≈ once per page load).
|
|
120
|
+
const sessionContextKey = sessionId || (this.privacyMode ? '\u0000privacy' : '');
|
|
114
121
|
let sessionContext;
|
|
115
|
-
if (
|
|
122
|
+
if (sessionContextKey && sessionContextKey !== this.sentSessionContextFor) {
|
|
116
123
|
const collected = this.collectSessionContext();
|
|
117
124
|
if (collected && Object.keys(collected).length > 0) {
|
|
118
125
|
sessionContext = collected;
|
|
119
|
-
this.sentSessionContextFor =
|
|
126
|
+
this.sentSessionContextFor = sessionContextKey;
|
|
120
127
|
}
|
|
121
128
|
}
|
|
122
129
|
const payload = buildCollectPayload({
|
|
@@ -124,6 +131,7 @@ export class NexlyBase {
|
|
|
124
131
|
eventName: args.eventName,
|
|
125
132
|
eventType: args.eventType,
|
|
126
133
|
client: this.client,
|
|
134
|
+
privacyMode: this.privacyMode,
|
|
127
135
|
context: args.context,
|
|
128
136
|
data: args.data,
|
|
129
137
|
cdata: args.cdata,
|