@reopt-ai/data-sdk-client 0.1.4 → 0.1.6
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 +2 -1
- package/dist/{chunk-SRHWNG2G.js → chunk-SYCBGBTH.js} +42 -2
- package/dist/chunk-SYCBGBTH.js.map +1 -0
- package/dist/{chunk-JNIOYR44.js → chunk-YRP3I3OD.js} +2 -2
- package/dist/chunk-YRP3I3OD.js.map +1 -0
- package/dist/{client-CW9DfTlm.d.ts → client-BCd2fgmx.d.ts} +123 -113
- package/dist/index.cjs +40 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/next.cjs +40 -1
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +2 -2
- package/dist/react.cjs +40 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +4 -4
- package/dist/react.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-JNIOYR44.js.map +0 -1
- package/dist/chunk-SRHWNG2G.js.map +0 -1
|
@@ -9,11 +9,11 @@ import { ReoptBootstrap, DeviceCookieState, ConsentCookieState } from '@reopt-ai
|
|
|
9
9
|
type ConsentCategory = "analytics" | "marketing" | "functional" | "performance";
|
|
10
10
|
interface ConsentConfig {
|
|
11
11
|
/** Default decision for every configured category. Default: `true` (opt-out model). */
|
|
12
|
-
defaultConsent?: boolean;
|
|
12
|
+
defaultConsent?: boolean | undefined;
|
|
13
13
|
/** Categories the integration recognises. Default: `["analytics"]`. */
|
|
14
|
-
categories?: ConsentCategory[];
|
|
14
|
+
categories?: ConsentCategory[] | undefined;
|
|
15
15
|
/** Persist decisions through the runtime's storage. Default: `true`. */
|
|
16
|
-
persist?: boolean;
|
|
16
|
+
persist?: boolean | undefined;
|
|
17
17
|
}
|
|
18
18
|
/** Minimal synchronous key/value store — `localStorage`-shaped on purpose. */
|
|
19
19
|
interface StorageBackend {
|
|
@@ -23,31 +23,31 @@ interface StorageBackend {
|
|
|
23
23
|
}
|
|
24
24
|
interface RetryConfig {
|
|
25
25
|
/** Attempts after the first. Default: 3. */
|
|
26
|
-
maxRetries?: number;
|
|
26
|
+
maxRetries?: number | undefined;
|
|
27
27
|
/** First back-off, milliseconds. Default: 1000. */
|
|
28
|
-
baseDelay?: number;
|
|
28
|
+
baseDelay?: number | undefined;
|
|
29
29
|
/** Back-off ceiling, milliseconds. Default: 30000. */
|
|
30
|
-
maxDelay?: number;
|
|
30
|
+
maxDelay?: number | undefined;
|
|
31
31
|
/** ± fraction of the delay. Default: 0.1. */
|
|
32
|
-
jitter?: number;
|
|
32
|
+
jitter?: number | undefined;
|
|
33
33
|
}
|
|
34
34
|
interface CircuitBreakerConfig {
|
|
35
35
|
/** Consecutive transient failures before the circuit opens. Default: 5. */
|
|
36
|
-
failureThreshold?: number;
|
|
36
|
+
failureThreshold?: number | undefined;
|
|
37
37
|
/** How long the circuit stays open before one probe is allowed. Default: 60000. */
|
|
38
|
-
recoveryTimeout?: number;
|
|
38
|
+
recoveryTimeout?: number | undefined;
|
|
39
39
|
}
|
|
40
40
|
interface BatchConfig {
|
|
41
41
|
/** Events per request. Default: 100. */
|
|
42
|
-
size?: number;
|
|
42
|
+
size?: number | undefined;
|
|
43
43
|
/** Milliseconds to wait for a batch to fill before sending. Default: 1000. */
|
|
44
|
-
intervalMs?: number;
|
|
44
|
+
intervalMs?: number | undefined;
|
|
45
45
|
/**
|
|
46
46
|
* Serialized bytes per request. Default: 400 000, under the server's
|
|
47
47
|
* 512 000 hard cap with room for the JSON envelope. A 413 is a 4xx, and 4xx
|
|
48
48
|
* drops the batch — so overshooting the cap loses every event in it.
|
|
49
49
|
*/
|
|
50
|
-
maxBytes?: number;
|
|
50
|
+
maxBytes?: number | undefined;
|
|
51
51
|
}
|
|
52
52
|
/** Browser credentials — public, ships in the page. */
|
|
53
53
|
interface WriteKeyAuth {
|
|
@@ -64,7 +64,7 @@ interface FetchInit {
|
|
|
64
64
|
method: string;
|
|
65
65
|
headers: Record<string, string>;
|
|
66
66
|
body: string;
|
|
67
|
-
keepalive?: boolean;
|
|
67
|
+
keepalive?: boolean | undefined;
|
|
68
68
|
}
|
|
69
69
|
interface FetchResponseLike {
|
|
70
70
|
ok: boolean;
|
|
@@ -76,13 +76,13 @@ interface FetchResponseLike {
|
|
|
76
76
|
}
|
|
77
77
|
/** Context the runtime fills in for a `$pageview` when the caller does not. */
|
|
78
78
|
interface PageContext {
|
|
79
|
-
path?: string;
|
|
80
|
-
origin?: string;
|
|
81
|
-
title?: string;
|
|
82
|
-
referrer?: string;
|
|
83
|
-
utm?: UTMParams;
|
|
79
|
+
path?: string | undefined;
|
|
80
|
+
origin?: string | undefined;
|
|
81
|
+
title?: string | undefined;
|
|
82
|
+
referrer?: string | undefined;
|
|
83
|
+
utm?: UTMParams | undefined;
|
|
84
84
|
/** Extra properties the runtime derived from the page, e.g. a `normalizePath` hook's output. */
|
|
85
|
-
properties?: Record<string, unknown
|
|
85
|
+
properties?: Record<string, unknown> | undefined;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Everything the engine needs from the world around it. The browser package
|
|
@@ -97,58 +97,58 @@ interface ReoptRuntime {
|
|
|
97
97
|
* ingest handed back, if the runtime kept it. Unsigned values are ignored
|
|
98
98
|
* by ingest, so only send what came from `onSession`.
|
|
99
99
|
*/
|
|
100
|
-
getSessionId?: () => string | null | undefined;
|
|
100
|
+
getSessionId?: (() => string | null | undefined) | undefined;
|
|
101
101
|
/** Ingest assigned (or confirmed) a session for this batch. The runtime persists it. */
|
|
102
|
-
onSession?: (credential: {
|
|
102
|
+
onSession?: ((credential: {
|
|
103
103
|
id: string;
|
|
104
104
|
token: string;
|
|
105
|
-
}) => void;
|
|
105
|
+
}) => void) | undefined | undefined;
|
|
106
106
|
/** Durable store for the offline queue and consent. Absent = memory only. */
|
|
107
|
-
storage?: StorageBackend;
|
|
107
|
+
storage?: StorageBackend | undefined;
|
|
108
108
|
/** Clock. Defaults to `Date.now`; the browser package corrects for server skew. */
|
|
109
|
-
now?: () => number;
|
|
109
|
+
now?: (() => number) | undefined | undefined;
|
|
110
110
|
/** Id generator. Defaults to monotonic UUIDv7. */
|
|
111
|
-
createId?: () => string;
|
|
111
|
+
createId?: (() => string) | undefined | undefined;
|
|
112
112
|
/** `fetch` implementation. Defaults to `globalThis.fetch`. */
|
|
113
|
-
fetch?: FetchLike;
|
|
113
|
+
fetch?: FetchLike | undefined;
|
|
114
114
|
/**
|
|
115
115
|
* Subscribe to "the process is about to go away" signals (pagehide,
|
|
116
116
|
* visibilitychange, SIGTERM). The engine flushes on each signal. Returns
|
|
117
117
|
* the unsubscribe function.
|
|
118
118
|
*/
|
|
119
|
-
onFlushSignal?: (flush: () => void) => () => void;
|
|
119
|
+
onFlushSignal?: (flush: () => void) => () => void | undefined | undefined;
|
|
120
120
|
/**
|
|
121
121
|
* Last-chance delivery used when a flush signal fires, e.g. `sendBeacon`.
|
|
122
122
|
* Return `true` if the runtime accepted the payload; `false` falls back to
|
|
123
123
|
* keepalive fetch.
|
|
124
124
|
*/
|
|
125
|
-
sendLastChance?: (url: string, body: string, headers: Record<string, string>) => boolean;
|
|
125
|
+
sendLastChance?: ((url: string, body: string, headers: Record<string, string>) => boolean) | undefined | undefined;
|
|
126
126
|
/** Defaults for `$pageview` properties. */
|
|
127
|
-
getPageContext?: () => PageContext;
|
|
127
|
+
getPageContext?: (() => PageContext) | undefined | undefined;
|
|
128
128
|
/**
|
|
129
129
|
* Mint and persist a fresh device id. Called by `reset()`; without it a
|
|
130
130
|
* reset keeps the old device, which is wrong on a shared machine.
|
|
131
131
|
*/
|
|
132
|
-
regenerateDeviceId?: () => string;
|
|
132
|
+
regenerateDeviceId?: (() => string) | undefined | undefined;
|
|
133
133
|
}
|
|
134
134
|
interface ReoptCoreConfig {
|
|
135
135
|
auth: ReoptAuth;
|
|
136
136
|
/** Origin of the reopt-data deployment, or a same-origin proxy prefix like `/ingest`. */
|
|
137
137
|
baseUrl: string;
|
|
138
138
|
runtime: ReoptRuntime;
|
|
139
|
-
debug?: boolean;
|
|
140
|
-
batch?: BatchConfig;
|
|
139
|
+
debug?: boolean | undefined;
|
|
140
|
+
batch?: BatchConfig | undefined;
|
|
141
141
|
/** Upper bound on queued events; the oldest are dropped past it. Default: 10000. */
|
|
142
|
-
maxQueueSize?: number;
|
|
143
|
-
retry?: RetryConfig;
|
|
144
|
-
circuitBreaker?: CircuitBreakerConfig;
|
|
145
|
-
consent?: ConsentConfig;
|
|
142
|
+
maxQueueSize?: number | undefined;
|
|
143
|
+
retry?: RetryConfig | undefined;
|
|
144
|
+
circuitBreaker?: CircuitBreakerConfig | undefined;
|
|
145
|
+
consent?: ConsentConfig | undefined;
|
|
146
146
|
/** Prefix for storage keys. Default: `reopt_`. */
|
|
147
|
-
storagePrefix?: string;
|
|
147
|
+
storagePrefix?: string | undefined;
|
|
148
148
|
/** Persist the queue through `runtime.storage`. Default: `true` when storage exists. */
|
|
149
|
-
enableOfflineBuffer?: boolean;
|
|
149
|
+
enableOfflineBuffer?: boolean | undefined;
|
|
150
150
|
/** Flush on runtime flush signals. Default: `true` when the runtime provides them. */
|
|
151
|
-
autoFlushOnUnload?: boolean;
|
|
151
|
+
autoFlushOnUnload?: boolean | undefined;
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Identity a single event was recorded under, when it differs from the
|
|
@@ -157,63 +157,63 @@ interface ReoptCoreConfig {
|
|
|
157
157
|
* becomes that batch's `reopt-device-id`.
|
|
158
158
|
*/
|
|
159
159
|
interface EventIdentity {
|
|
160
|
-
deviceId?: string;
|
|
161
|
-
sessionId?: string | null;
|
|
160
|
+
deviceId?: string | undefined;
|
|
161
|
+
sessionId?: string | null | undefined;
|
|
162
162
|
}
|
|
163
163
|
interface TrackEventOptions {
|
|
164
164
|
/** File this event under another visitor than the runtime's. Server SDK use. */
|
|
165
|
-
identity?: EventIdentity;
|
|
165
|
+
identity?: EventIdentity | undefined;
|
|
166
166
|
name: string;
|
|
167
|
-
properties?: Record<string, unknown
|
|
168
|
-
profileId?: string | number;
|
|
167
|
+
properties?: Record<string, unknown> | undefined;
|
|
168
|
+
profileId?: string | number | undefined;
|
|
169
169
|
/** Consent category this event belongs to. Default: `analytics`. */
|
|
170
|
-
consentCategory?: ConsentCategory;
|
|
170
|
+
consentCategory?: ConsentCategory | undefined;
|
|
171
171
|
}
|
|
172
172
|
interface IdentifyOptions {
|
|
173
173
|
/** File this event under another visitor than the runtime's. Server SDK use. */
|
|
174
|
-
identity?: EventIdentity;
|
|
174
|
+
identity?: EventIdentity | undefined;
|
|
175
175
|
profileId: string | number;
|
|
176
|
-
firstName?: string;
|
|
177
|
-
lastName?: string;
|
|
178
|
-
email?: string;
|
|
179
|
-
avatar?: string;
|
|
180
|
-
properties?: Record<string, unknown
|
|
181
|
-
consentCategory?: ConsentCategory;
|
|
176
|
+
firstName?: string | undefined;
|
|
177
|
+
lastName?: string | undefined;
|
|
178
|
+
email?: string | undefined;
|
|
179
|
+
avatar?: string | undefined;
|
|
180
|
+
properties?: Record<string, unknown> | undefined;
|
|
181
|
+
consentCategory?: ConsentCategory | undefined;
|
|
182
182
|
}
|
|
183
183
|
interface IncrementOptions {
|
|
184
184
|
/** File this event under another visitor than the runtime's. Server SDK use. */
|
|
185
|
-
identity?: EventIdentity;
|
|
185
|
+
identity?: EventIdentity | undefined;
|
|
186
186
|
profileId: string | number;
|
|
187
187
|
property: string;
|
|
188
|
-
value?: number;
|
|
189
|
-
consentCategory?: ConsentCategory;
|
|
188
|
+
value?: number | undefined;
|
|
189
|
+
consentCategory?: ConsentCategory | undefined;
|
|
190
190
|
}
|
|
191
191
|
interface DecrementOptions {
|
|
192
192
|
/** File this event under another visitor than the runtime's. Server SDK use. */
|
|
193
|
-
identity?: EventIdentity;
|
|
193
|
+
identity?: EventIdentity | undefined;
|
|
194
194
|
profileId: string | number;
|
|
195
195
|
property: string;
|
|
196
|
-
value?: number;
|
|
197
|
-
consentCategory?: ConsentCategory;
|
|
196
|
+
value?: number | undefined;
|
|
197
|
+
consentCategory?: ConsentCategory | undefined;
|
|
198
198
|
}
|
|
199
199
|
interface UTMParams {
|
|
200
|
-
utm_source?: string;
|
|
201
|
-
utm_medium?: string;
|
|
202
|
-
utm_campaign?: string;
|
|
203
|
-
utm_term?: string;
|
|
204
|
-
utm_content?: string;
|
|
200
|
+
utm_source?: string | undefined;
|
|
201
|
+
utm_medium?: string | undefined;
|
|
202
|
+
utm_campaign?: string | undefined;
|
|
203
|
+
utm_term?: string | undefined;
|
|
204
|
+
utm_content?: string | undefined;
|
|
205
205
|
}
|
|
206
206
|
interface PageViewOptions {
|
|
207
207
|
/** File this event under another visitor than the runtime's. Server SDK use. */
|
|
208
|
-
identity?: EventIdentity;
|
|
209
|
-
path?: string;
|
|
208
|
+
identity?: EventIdentity | undefined;
|
|
209
|
+
path?: string | undefined;
|
|
210
210
|
/** Scheme + host. */
|
|
211
|
-
origin?: string;
|
|
212
|
-
title?: string;
|
|
213
|
-
referrer?: string;
|
|
214
|
-
properties?: Record<string, unknown
|
|
215
|
-
utm?: UTMParams;
|
|
216
|
-
consentCategory?: ConsentCategory;
|
|
211
|
+
origin?: string | undefined;
|
|
212
|
+
title?: string | undefined;
|
|
213
|
+
referrer?: string | undefined;
|
|
214
|
+
properties?: Record<string, unknown> | undefined;
|
|
215
|
+
utm?: UTMParams | undefined;
|
|
216
|
+
consentCategory?: ConsentCategory | undefined;
|
|
217
217
|
}
|
|
218
218
|
type EventPayload = {
|
|
219
219
|
type: "track";
|
|
@@ -221,8 +221,8 @@ type EventPayload = {
|
|
|
221
221
|
timestamp: number;
|
|
222
222
|
payload: {
|
|
223
223
|
name: string;
|
|
224
|
-
properties?: Record<string, unknown
|
|
225
|
-
profileId?: string | number;
|
|
224
|
+
properties?: Record<string, unknown> | undefined;
|
|
225
|
+
profileId?: string | number | undefined;
|
|
226
226
|
};
|
|
227
227
|
} | {
|
|
228
228
|
type: "identify";
|
|
@@ -230,11 +230,11 @@ type EventPayload = {
|
|
|
230
230
|
timestamp: number;
|
|
231
231
|
payload: {
|
|
232
232
|
profileId: string | number;
|
|
233
|
-
firstName?: string;
|
|
234
|
-
lastName?: string;
|
|
235
|
-
email?: string;
|
|
236
|
-
avatar?: string;
|
|
237
|
-
properties?: Record<string, unknown
|
|
233
|
+
firstName?: string | undefined;
|
|
234
|
+
lastName?: string | undefined;
|
|
235
|
+
email?: string | undefined;
|
|
236
|
+
avatar?: string | undefined;
|
|
237
|
+
properties?: Record<string, unknown> | undefined;
|
|
238
238
|
};
|
|
239
239
|
} | {
|
|
240
240
|
type: "increment";
|
|
@@ -259,11 +259,11 @@ type QueueDropReason = "tracking_paused" | "consent_denied" | "validation_failed
|
|
|
259
259
|
interface QueueResult {
|
|
260
260
|
eventId: string;
|
|
261
261
|
queued: boolean;
|
|
262
|
-
reason?: QueueDropReason;
|
|
262
|
+
reason?: QueueDropReason | undefined;
|
|
263
263
|
errors?: Array<{
|
|
264
264
|
field: string;
|
|
265
265
|
message: string;
|
|
266
|
-
}
|
|
266
|
+
}> | undefined;
|
|
267
267
|
}
|
|
268
268
|
interface FlushResult {
|
|
269
269
|
status: "idle" | "success" | "failed" | "skipped";
|
|
@@ -273,9 +273,9 @@ interface FlushResult {
|
|
|
273
273
|
}
|
|
274
274
|
interface FlushOptions {
|
|
275
275
|
/** Ask the transport to outlive the page (keepalive fetch / beacon). */
|
|
276
|
-
keepalive?: boolean;
|
|
276
|
+
keepalive?: boolean | undefined;
|
|
277
277
|
/** Keep sending until the queue is empty or no progress is made. */
|
|
278
|
-
drain?: boolean;
|
|
278
|
+
drain?: boolean | undefined;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
type ConsentState = Record<string, boolean>;
|
|
@@ -287,12 +287,12 @@ interface BatchDelivery {
|
|
|
287
287
|
session?: {
|
|
288
288
|
id: string;
|
|
289
289
|
token: string;
|
|
290
|
-
};
|
|
290
|
+
} | undefined;
|
|
291
291
|
}
|
|
292
292
|
interface SendOptions {
|
|
293
|
-
keepalive?: boolean;
|
|
293
|
+
keepalive?: boolean | undefined;
|
|
294
294
|
/** Overrides the runtime's device/session for this request only. */
|
|
295
|
-
identity?: EventIdentity;
|
|
295
|
+
identity?: EventIdentity | undefined;
|
|
296
296
|
}
|
|
297
297
|
interface Transport {
|
|
298
298
|
readonly url: string;
|
|
@@ -400,17 +400,17 @@ interface WebVitalMetric {
|
|
|
400
400
|
id: string;
|
|
401
401
|
name: string;
|
|
402
402
|
value: number;
|
|
403
|
-
delta?: number;
|
|
404
|
-
rating?: "good" | "needs-improvement" | "poor";
|
|
405
|
-
navigationType?: string;
|
|
403
|
+
delta?: number | undefined;
|
|
404
|
+
rating?: "good" | "needs-improvement" | "poor" | undefined;
|
|
405
|
+
navigationType?: string | undefined;
|
|
406
406
|
}
|
|
407
407
|
type WebVitalProperties = {
|
|
408
408
|
metric_name: string;
|
|
409
409
|
metric_id: string;
|
|
410
410
|
value: number;
|
|
411
|
-
delta?: number;
|
|
412
|
-
rating?: string;
|
|
413
|
-
navigation_type?: string;
|
|
411
|
+
delta?: number | undefined;
|
|
412
|
+
rating?: string | undefined;
|
|
413
|
+
navigation_type?: string | undefined;
|
|
414
414
|
path: string;
|
|
415
415
|
};
|
|
416
416
|
|
|
@@ -440,11 +440,11 @@ interface IdentityConfig {
|
|
|
440
440
|
* server also reads survives that, and lets server-side events join the
|
|
441
441
|
* same device.
|
|
442
442
|
*/
|
|
443
|
-
storage?: IdentityStorageKind;
|
|
443
|
+
storage?: IdentityStorageKind | undefined;
|
|
444
444
|
/** Cookie `Domain`; omit for host-only. Set to share across subdomains. */
|
|
445
|
-
cookieDomain?: string;
|
|
445
|
+
cookieDomain?: string | undefined;
|
|
446
446
|
/** Cookie lifetime. Default 400 days (the longest Chrome honours). */
|
|
447
|
-
cookieMaxAgeSeconds?: number;
|
|
447
|
+
cookieMaxAgeSeconds?: number | undefined;
|
|
448
448
|
}
|
|
449
449
|
interface CaptureConfig {
|
|
450
450
|
/**
|
|
@@ -452,22 +452,22 @@ interface CaptureConfig {
|
|
|
452
452
|
* The Next entry sets it to `false` because `<ReoptPageView />` owns page
|
|
453
453
|
* views there — including the first one.
|
|
454
454
|
*/
|
|
455
|
-
pageview?: boolean;
|
|
455
|
+
pageview?: boolean | undefined;
|
|
456
456
|
/** Send `$pageleave` with time-on-page when the page is hidden or the route changes. Default `true`. */
|
|
457
|
-
pageleave?: boolean;
|
|
457
|
+
pageleave?: boolean | undefined;
|
|
458
458
|
/** Attach max scroll depth to `$pageleave`. Default `true`. */
|
|
459
|
-
scrollDepth?: boolean;
|
|
459
|
+
scrollDepth?: boolean | undefined;
|
|
460
460
|
/** Send `$exception` for uncaught errors and unhandled rejections. Default `false`. */
|
|
461
|
-
exceptions?: boolean;
|
|
461
|
+
exceptions?: boolean | undefined;
|
|
462
462
|
}
|
|
463
463
|
interface ReoptClientConfig {
|
|
464
464
|
writeKey: string;
|
|
465
465
|
/** reopt-data origin, or the same-origin proxy prefix (e.g. `/ingest`) the Next.js proxy rewrites. */
|
|
466
466
|
baseUrl: string;
|
|
467
467
|
/** What the server already knows about this visitor. `null` = nothing. */
|
|
468
|
-
bootstrap?: ReoptBootstrap | null;
|
|
469
|
-
identity?: IdentityConfig;
|
|
470
|
-
capture?: CaptureConfig;
|
|
468
|
+
bootstrap?: ReoptBootstrap | null | undefined;
|
|
469
|
+
identity?: IdentityConfig | undefined;
|
|
470
|
+
capture?: CaptureConfig | undefined;
|
|
471
471
|
/**
|
|
472
472
|
* Hosts that receive the `reopt-device-id` header on outgoing `fetch`/XHR,
|
|
473
473
|
* so a server-side `track()` lands on the same device. `true` = the page's
|
|
@@ -475,9 +475,9 @@ interface ReoptClientConfig {
|
|
|
475
475
|
* `getDeviceId()` to your server call explicitly; this patches `fetch`
|
|
476
476
|
* and loads as a separate chunk only when enabled.
|
|
477
477
|
*/
|
|
478
|
-
tracingHeaders?: boolean | string[];
|
|
478
|
+
tracingHeaders?: boolean | string[] | undefined;
|
|
479
479
|
/** See {@link NormalizePath}. */
|
|
480
|
-
normalizePath?: NormalizePath;
|
|
480
|
+
normalizePath?: NormalizePath | undefined;
|
|
481
481
|
/**
|
|
482
482
|
* Properties attached to every event from the very first one. Same as
|
|
483
483
|
* calling `register()` right after `init()`, except that nothing can
|
|
@@ -486,25 +486,25 @@ interface ReoptClientConfig {
|
|
|
486
486
|
* Pass the page context the server already knows here; update it on
|
|
487
487
|
* client-side navigation with `register()`.
|
|
488
488
|
*/
|
|
489
|
-
properties?: Record<string, unknown
|
|
490
|
-
consent?: ConsentConfig;
|
|
491
|
-
batch?: BatchConfig;
|
|
492
|
-
retry?: RetryConfig;
|
|
493
|
-
circuitBreaker?: CircuitBreakerConfig;
|
|
489
|
+
properties?: Record<string, unknown> | undefined;
|
|
490
|
+
consent?: ConsentConfig | undefined;
|
|
491
|
+
batch?: BatchConfig | undefined;
|
|
492
|
+
retry?: RetryConfig | undefined;
|
|
493
|
+
circuitBreaker?: CircuitBreakerConfig | undefined;
|
|
494
494
|
/** Upper bound on queued events. Default 10 000. */
|
|
495
|
-
maxQueueSize?: number;
|
|
495
|
+
maxQueueSize?: number | undefined;
|
|
496
496
|
/** Overrides the store for the offline queue. Default `localStorage`. */
|
|
497
|
-
queueStorage?: StorageBackend;
|
|
497
|
+
queueStorage?: StorageBackend | undefined;
|
|
498
498
|
/** Prefix for storage keys. Default `reopt_`. */
|
|
499
|
-
storagePrefix?: string;
|
|
499
|
+
storagePrefix?: string | undefined;
|
|
500
500
|
/**
|
|
501
501
|
* Transport override. Tests hand in a recording function so a Playwright
|
|
502
502
|
* spec can assert on the exact payload the SDK built, without intercepting
|
|
503
503
|
* the network. Defaults to the page's `fetch` (captured at init, before the
|
|
504
504
|
* tracing patch, so the SDK's own requests are never tagged twice).
|
|
505
505
|
*/
|
|
506
|
-
fetch?: FetchLike;
|
|
507
|
-
debug?: boolean;
|
|
506
|
+
fetch?: FetchLike | undefined;
|
|
507
|
+
debug?: boolean | undefined;
|
|
508
508
|
}
|
|
509
509
|
interface ResolvedCaptureConfig {
|
|
510
510
|
pageview: boolean;
|
|
@@ -543,6 +543,7 @@ declare class ReoptClient extends ReoptCore {
|
|
|
543
543
|
private readonly uninstallers;
|
|
544
544
|
private torndown;
|
|
545
545
|
private readonly session;
|
|
546
|
+
private readonly optedOut;
|
|
546
547
|
private readonly normalize;
|
|
547
548
|
/** True when `writeKey` or `baseUrl` was missing: every call is a silent no-op. */
|
|
548
549
|
readonly disabled: boolean;
|
|
@@ -550,6 +551,15 @@ declare class ReoptClient extends ReoptCore {
|
|
|
550
551
|
/** Which store identity ended up in — `cookie`, `localStorage` or `memory`. */
|
|
551
552
|
get identityStorage(): IdentityStore["kind"];
|
|
552
553
|
pageView(options?: PageViewOptions): QueueResult;
|
|
554
|
+
setConsent(category: ConsentCategory, allowed: boolean): void;
|
|
555
|
+
setAllConsent(allowed: boolean): void;
|
|
556
|
+
replaceConsentState(state: Record<string, boolean>): void;
|
|
557
|
+
/**
|
|
558
|
+
* Refusing `analytics` removes the stored identity (the proxy does the
|
|
559
|
+
* same on its side); granting it again writes the current device through
|
|
560
|
+
* so the visit is attributable from that point on.
|
|
561
|
+
*/
|
|
562
|
+
private syncOptOut;
|
|
553
563
|
identify(options: IdentifyOptions): QueueResult;
|
|
554
564
|
/** Feed a Web Vitals metric (from `next/web-vitals` or the `web-vitals` package). */
|
|
555
565
|
captureWebVital(metric: WebVitalMetric): QueueResult;
|
package/dist/index.cjs
CHANGED
|
@@ -1564,6 +1564,7 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1564
1564
|
uninstallers = [];
|
|
1565
1565
|
torndown = false;
|
|
1566
1566
|
session;
|
|
1567
|
+
optedOut;
|
|
1567
1568
|
normalize;
|
|
1568
1569
|
/** True when `writeKey` or `baseUrl` was missing: every call is a silent no-op. */
|
|
1569
1570
|
disabled;
|
|
@@ -1574,7 +1575,16 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1574
1575
|
}
|
|
1575
1576
|
const writeKey = config.writeKey || "disabled";
|
|
1576
1577
|
const storagePrefix = config.storagePrefix ?? DEFAULT_STORAGE_PREFIX;
|
|
1577
|
-
const
|
|
1578
|
+
const rawStore = createIdentityStore(writeKey, { ...config.identity, ...disabled ? { storage: "memory" } : {} });
|
|
1579
|
+
const optedOut = {
|
|
1580
|
+
value: (0, import_identity5.isOptedOut)(rawStore.readConsent() ?? config.bootstrap?.consent ?? null) || config.consent?.defaultConsent === false
|
|
1581
|
+
};
|
|
1582
|
+
const store = {
|
|
1583
|
+
...rawStore,
|
|
1584
|
+
writeDevice: (state) => {
|
|
1585
|
+
if (!optedOut.value) rawStore.writeDevice(state);
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1578
1588
|
const identity = resolveDeviceId(store, config.bootstrap?.deviceId, storagePrefix);
|
|
1579
1589
|
const now = correctedClock(config.bootstrap);
|
|
1580
1590
|
const queueStorage = disabled ? memoryStorage() : config.queueStorage ?? localStorageBackend() ?? memoryStorage();
|
|
@@ -1627,6 +1637,7 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1627
1637
|
this.writeKey = config.writeKey;
|
|
1628
1638
|
this.disabled = disabled;
|
|
1629
1639
|
this.session = session;
|
|
1640
|
+
this.optedOut = optedOut;
|
|
1630
1641
|
this.normalize = config.normalizePath;
|
|
1631
1642
|
this.store = store;
|
|
1632
1643
|
this.capture = resolveCapture(config.capture, defaults.pageview);
|
|
@@ -1685,6 +1696,34 @@ var ReoptClient = class extends ReoptCore {
|
|
|
1685
1696
|
this.scroll?.reset();
|
|
1686
1697
|
return super.pageView(options);
|
|
1687
1698
|
}
|
|
1699
|
+
setConsent(category, allowed) {
|
|
1700
|
+
super.setConsent(category, allowed);
|
|
1701
|
+
this.syncOptOut();
|
|
1702
|
+
}
|
|
1703
|
+
setAllConsent(allowed) {
|
|
1704
|
+
super.setAllConsent(allowed);
|
|
1705
|
+
this.syncOptOut();
|
|
1706
|
+
}
|
|
1707
|
+
replaceConsentState(state) {
|
|
1708
|
+
super.replaceConsentState(state);
|
|
1709
|
+
this.syncOptOut();
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Refusing `analytics` removes the stored identity (the proxy does the
|
|
1713
|
+
* same on its side); granting it again writes the current device through
|
|
1714
|
+
* so the visit is attributable from that point on.
|
|
1715
|
+
*/
|
|
1716
|
+
syncOptOut() {
|
|
1717
|
+
const now = (0, import_identity5.isOptedOut)(this.getConsentState());
|
|
1718
|
+
if (now === this.optedOut.value) return;
|
|
1719
|
+
this.optedOut.value = now;
|
|
1720
|
+
if (now) {
|
|
1721
|
+
this.store.clearDevice();
|
|
1722
|
+
this.session.header = null;
|
|
1723
|
+
} else {
|
|
1724
|
+
this.store.writeDevice({ deviceId: this.getDeviceId() });
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1688
1727
|
identify(options) {
|
|
1689
1728
|
const result = super.identify(options);
|
|
1690
1729
|
if (!options.identity && result.queued) {
|