@qurvo/sdk-core 0.0.10 → 0.0.11
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/dist/fetch-transport.d.ts +23 -0
- package/dist/fetch-transport.d.ts.map +1 -1
- package/dist/fetch-transport.js +23 -0
- package/dist/fetch-transport.js.map +1 -1
- package/dist/queue.d.ts +79 -0
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +79 -0
- package/dist/queue.js.map +1 -1
- package/dist/types.d.ts +53 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
import type { Transport, SendOptions, CompressFn } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default {@link Transport} implementation using the Fetch API.
|
|
4
|
+
*
|
|
5
|
+
* Sends event batches as HTTP POST requests with optional gzip
|
|
6
|
+
* compression. Compression is skipped for `keepalive` requests
|
|
7
|
+
* (browser unload) because the Compression Streams API may not
|
|
8
|
+
* complete before the page is destroyed.
|
|
9
|
+
*
|
|
10
|
+
* **Error classification**:
|
|
11
|
+
* - 2xx / 202: success.
|
|
12
|
+
* - 429 with `quota_limited` body: throws {@link QuotaExceededError}.
|
|
13
|
+
* - Other 4xx: throws {@link NonRetryableError} (batch should be dropped).
|
|
14
|
+
* - 5xx: throws a plain {@link Error} (batch should be retried by the queue).
|
|
15
|
+
*/
|
|
2
16
|
export declare class FetchTransport implements Transport {
|
|
3
17
|
private readonly compress?;
|
|
18
|
+
/** @param compress - Optional gzip function (e.g. `compressGzip` from sdk-browser). */
|
|
4
19
|
constructor(compress?: CompressFn | undefined);
|
|
20
|
+
/**
|
|
21
|
+
* Send a JSON-serialized payload to the ingest endpoint.
|
|
22
|
+
*
|
|
23
|
+
* @returns `true` on 2xx/202 (accepted).
|
|
24
|
+
* @throws {@link QuotaExceededError} on 429 + `quota_limited`.
|
|
25
|
+
* @throws {@link NonRetryableError} on 4xx client errors.
|
|
26
|
+
* @throws {@link Error} on 5xx server errors.
|
|
27
|
+
*/
|
|
5
28
|
send(endpoint: string, apiKey: string, payload: unknown, options?: SendOptions): Promise<boolean>;
|
|
6
29
|
}
|
|
7
30
|
//# sourceMappingURL=fetch-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-transport.d.ts","sourceRoot":"","sources":["../src/fetch-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGlE,qBAAa,cAAe,YAAW,SAAS;
|
|
1
|
+
{"version":3,"file":"fetch-transport.d.ts","sourceRoot":"","sources":["../src/fetch-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGlE;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAe,YAAW,SAAS;IAElC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IADtC,uFAAuF;gBAC1D,QAAQ,CAAC,EAAE,UAAU,YAAA;IAElD;;;;;;;OAOG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CA2CxG"}
|
package/dist/fetch-transport.js
CHANGED
|
@@ -2,11 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FetchTransport = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
|
+
/**
|
|
6
|
+
* Default {@link Transport} implementation using the Fetch API.
|
|
7
|
+
*
|
|
8
|
+
* Sends event batches as HTTP POST requests with optional gzip
|
|
9
|
+
* compression. Compression is skipped for `keepalive` requests
|
|
10
|
+
* (browser unload) because the Compression Streams API may not
|
|
11
|
+
* complete before the page is destroyed.
|
|
12
|
+
*
|
|
13
|
+
* **Error classification**:
|
|
14
|
+
* - 2xx / 202: success.
|
|
15
|
+
* - 429 with `quota_limited` body: throws {@link QuotaExceededError}.
|
|
16
|
+
* - Other 4xx: throws {@link NonRetryableError} (batch should be dropped).
|
|
17
|
+
* - 5xx: throws a plain {@link Error} (batch should be retried by the queue).
|
|
18
|
+
*/
|
|
5
19
|
class FetchTransport {
|
|
6
20
|
compress;
|
|
21
|
+
/** @param compress - Optional gzip function (e.g. `compressGzip` from sdk-browser). */
|
|
7
22
|
constructor(compress) {
|
|
8
23
|
this.compress = compress;
|
|
9
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Send a JSON-serialized payload to the ingest endpoint.
|
|
27
|
+
*
|
|
28
|
+
* @returns `true` on 2xx/202 (accepted).
|
|
29
|
+
* @throws {@link QuotaExceededError} on 429 + `quota_limited`.
|
|
30
|
+
* @throws {@link NonRetryableError} on 4xx client errors.
|
|
31
|
+
* @throws {@link Error} on 5xx server errors.
|
|
32
|
+
*/
|
|
10
33
|
async send(endpoint, apiKey, payload, options) {
|
|
11
34
|
const json = JSON.stringify(payload);
|
|
12
35
|
const headers = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../src/fetch-transport.ts"],"names":[],"mappings":";;;AACA,mCAAgE;AAEhE,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"fetch-transport.js","sourceRoot":"","sources":["../src/fetch-transport.ts"],"names":[],"mappings":";;;AACA,mCAAgE;AAEhE;;;;;;;;;;;;;GAaG;AACH,MAAa,cAAc;IAEI;IAD7B,uFAAuF;IACvF,YAA6B,QAAqB;QAArB,aAAQ,GAAR,QAAQ,CAAa;IAAG,CAAC;IAEtD;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,QAAgB,EAAE,MAAc,EAAE,OAAgB,EAAE,OAAqB;QAClF,MAAM,IAAI,G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AAQ,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACpD,MAAM,IAAI,yBAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,QAAQ,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC,CAAC;QAC3F,CAAC;QAED,gCAAgC;QAChC,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF;AAvDD,wCAuDC"}
|
package/dist/queue.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import type { Transport, LogFn, QueuePersistence } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Buffered event queue with automatic flushing, exponential backoff, and
|
|
4
|
+
* optional persistence.
|
|
5
|
+
*
|
|
6
|
+
* **Lifecycle**: events are added via {@link enqueue}, accumulated in an
|
|
7
|
+
* in-memory buffer, and periodically sent to the ingest API by
|
|
8
|
+
* {@link flush}. Flushing is triggered either by a timer ({@link start})
|
|
9
|
+
* or when the buffer reaches `flushSize`.
|
|
10
|
+
*
|
|
11
|
+
* **Error handling**:
|
|
12
|
+
* - 5xx / network errors: the batch is re-queued and delivery retries
|
|
13
|
+
* with exponential backoff (up to 30 s).
|
|
14
|
+
* - 4xx ({@link NonRetryableError}): the batch is dropped permanently.
|
|
15
|
+
* - 429 + quota_limited ({@link QuotaExceededError}): the entire queue
|
|
16
|
+
* is drained and the timer is stopped.
|
|
17
|
+
*
|
|
18
|
+
* **Persistence**: when a {@link QueuePersistence} implementation is
|
|
19
|
+
* provided, the queue is saved to durable storage after every mutation
|
|
20
|
+
* and restored on construction.
|
|
21
|
+
*/
|
|
2
22
|
export declare class EventQueue {
|
|
3
23
|
private readonly transport;
|
|
4
24
|
private readonly endpoint;
|
|
@@ -16,15 +36,74 @@ export declare class EventQueue {
|
|
|
16
36
|
private failureCount;
|
|
17
37
|
private retryAfter;
|
|
18
38
|
private readonly maxBackoffMs;
|
|
39
|
+
/**
|
|
40
|
+
* @param transport - Transport used to deliver batches (e.g. {@link FetchTransport}).
|
|
41
|
+
* @param endpoint - Full URL of the ingest endpoint.
|
|
42
|
+
* @param apiKey - Project API key for authentication.
|
|
43
|
+
* @param flushInterval - Milliseconds between automatic flushes. Default: `5000`.
|
|
44
|
+
* @param flushSize - Batch size that triggers an immediate flush. Default: `20`.
|
|
45
|
+
* @param maxQueueSize - Maximum events held in memory (FIFO eviction). Default: `1000`.
|
|
46
|
+
* @param sendTimeoutMs - Per-request abort timeout in milliseconds. Default: `30000`.
|
|
47
|
+
* @param logger - Optional debug logger.
|
|
48
|
+
* @param persistence - Optional durable storage backing for the queue.
|
|
49
|
+
*/
|
|
19
50
|
constructor(transport: Transport, endpoint: string, apiKey: string, flushInterval?: number, flushSize?: number, maxQueueSize?: number, sendTimeoutMs?: number, logger?: LogFn | undefined, persistence?: QueuePersistence | undefined);
|
|
51
|
+
/**
|
|
52
|
+
* Add an event to the queue.
|
|
53
|
+
*
|
|
54
|
+
* When the buffer is full (`maxQueueSize`), the **oldest** event is
|
|
55
|
+
* dropped (FIFO eviction) to make room. If the buffer reaches
|
|
56
|
+
* `flushSize` after insertion, an immediate {@link flush} is triggered.
|
|
57
|
+
*/
|
|
20
58
|
enqueue(event: unknown): void;
|
|
59
|
+
/** Start the periodic flush timer. No-op if already running. */
|
|
21
60
|
start(): void;
|
|
61
|
+
/** Stop the periodic flush timer. Safe to call when already stopped. */
|
|
22
62
|
stop(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Send the next batch of events to the ingest API.
|
|
65
|
+
*
|
|
66
|
+
* No-op when a flush is already in progress, the queue is empty,
|
|
67
|
+
* or the backoff cooldown has not elapsed.
|
|
68
|
+
*
|
|
69
|
+
* **Retry logic**:
|
|
70
|
+
* - On 5xx or network error the batch is re-queued and delivery is
|
|
71
|
+
* retried with exponential backoff (1 s, 2 s, 4 s, ... up to 30 s).
|
|
72
|
+
* - On 4xx ({@link NonRetryableError}) the batch is **dropped**.
|
|
73
|
+
* - On 429 + quota_limited ({@link QuotaExceededError}) the queue is
|
|
74
|
+
* emptied and the flush timer is stopped.
|
|
75
|
+
*/
|
|
23
76
|
flush(): Promise<void>;
|
|
24
77
|
private scheduleBackoff;
|
|
78
|
+
/**
|
|
79
|
+
* Drain the queue by flushing repeatedly until empty.
|
|
80
|
+
*
|
|
81
|
+
* Resets backoff state before starting so pending retries are not
|
|
82
|
+
* delayed. Stops early if a flush cycle makes no progress (e.g. all
|
|
83
|
+
* events are failing permanently).
|
|
84
|
+
*/
|
|
25
85
|
flushAll(): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Gracefully shut down the queue.
|
|
88
|
+
*
|
|
89
|
+
* Stops the periodic timer and attempts to deliver all remaining
|
|
90
|
+
* events via {@link flushAll}. If delivery does not complete within
|
|
91
|
+
* `timeoutMs`, the promise resolves and outstanding events are lost.
|
|
92
|
+
*
|
|
93
|
+
* @param timeoutMs - Maximum time to wait for delivery. Default: `30000`.
|
|
94
|
+
*/
|
|
26
95
|
shutdown(timeoutMs?: number): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Last-resort flush for page unload (`beforeunload` / `visibilitychange`).
|
|
98
|
+
*
|
|
99
|
+
* Sends all remaining events in a single fire-and-forget request with
|
|
100
|
+
* `keepalive: true` so the browser keeps the connection alive after the
|
|
101
|
+
* page is destroyed. If a regular {@link flush} is already in-flight,
|
|
102
|
+
* only the queued (not yet sent) events are included to avoid
|
|
103
|
+
* double-delivery.
|
|
104
|
+
*/
|
|
27
105
|
flushForUnload(): void;
|
|
106
|
+
/** Total number of events pending delivery (queued + in-flight). */
|
|
28
107
|
get size(): number;
|
|
29
108
|
private persist;
|
|
30
109
|
}
|
package/dist/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,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;;;;;;;;;;;OAYG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiD5B,OAAO,CAAC,eAAe;IAMvB;;;;;;OAMG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAU/B;;;;;;;;OAQG;IACG,QAAQ,CAAC,SAAS,GAAE,MAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IASzD;;;;;;;;OAQG;IACH,cAAc,IAAI,IAAI;IAatB,oEAAoE;IACpE,IAAI,IAAI,WAEP;IAED,OAAO,CAAC,OAAO;CAOhB"}
|
package/dist/queue.js
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EventQueue = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
|
+
/**
|
|
6
|
+
* Buffered event queue with automatic flushing, exponential backoff, and
|
|
7
|
+
* optional persistence.
|
|
8
|
+
*
|
|
9
|
+
* **Lifecycle**: events are added via {@link enqueue}, accumulated in an
|
|
10
|
+
* in-memory buffer, and periodically sent to the ingest API by
|
|
11
|
+
* {@link flush}. Flushing is triggered either by a timer ({@link start})
|
|
12
|
+
* or when the buffer reaches `flushSize`.
|
|
13
|
+
*
|
|
14
|
+
* **Error handling**:
|
|
15
|
+
* - 5xx / network errors: the batch is re-queued and delivery retries
|
|
16
|
+
* with exponential backoff (up to 30 s).
|
|
17
|
+
* - 4xx ({@link NonRetryableError}): the batch is dropped permanently.
|
|
18
|
+
* - 429 + quota_limited ({@link QuotaExceededError}): the entire queue
|
|
19
|
+
* is drained and the timer is stopped.
|
|
20
|
+
*
|
|
21
|
+
* **Persistence**: when a {@link QueuePersistence} implementation is
|
|
22
|
+
* provided, the queue is saved to durable storage after every mutation
|
|
23
|
+
* and restored on construction.
|
|
24
|
+
*/
|
|
5
25
|
class EventQueue {
|
|
6
26
|
transport;
|
|
7
27
|
endpoint;
|
|
@@ -19,6 +39,17 @@ class EventQueue {
|
|
|
19
39
|
failureCount = 0;
|
|
20
40
|
retryAfter = 0;
|
|
21
41
|
maxBackoffMs = 30_000;
|
|
42
|
+
/**
|
|
43
|
+
* @param transport - Transport used to deliver batches (e.g. {@link FetchTransport}).
|
|
44
|
+
* @param endpoint - Full URL of the ingest endpoint.
|
|
45
|
+
* @param apiKey - Project API key for authentication.
|
|
46
|
+
* @param flushInterval - Milliseconds between automatic flushes. Default: `5000`.
|
|
47
|
+
* @param flushSize - Batch size that triggers an immediate flush. Default: `20`.
|
|
48
|
+
* @param maxQueueSize - Maximum events held in memory (FIFO eviction). Default: `1000`.
|
|
49
|
+
* @param sendTimeoutMs - Per-request abort timeout in milliseconds. Default: `30000`.
|
|
50
|
+
* @param logger - Optional debug logger.
|
|
51
|
+
* @param persistence - Optional durable storage backing for the queue.
|
|
52
|
+
*/
|
|
22
53
|
constructor(transport, endpoint, apiKey, flushInterval = 5000, flushSize = 20, maxQueueSize = 1000, sendTimeoutMs = 30_000, logger, persistence) {
|
|
23
54
|
this.transport = transport;
|
|
24
55
|
this.endpoint = endpoint;
|
|
@@ -42,6 +73,13 @@ class EventQueue {
|
|
|
42
73
|
}
|
|
43
74
|
}
|
|
44
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Add an event to the queue.
|
|
78
|
+
*
|
|
79
|
+
* When the buffer is full (`maxQueueSize`), the **oldest** event is
|
|
80
|
+
* dropped (FIFO eviction) to make room. If the buffer reaches
|
|
81
|
+
* `flushSize` after insertion, an immediate {@link flush} is triggered.
|
|
82
|
+
*/
|
|
45
83
|
enqueue(event) {
|
|
46
84
|
if (this.queue.length >= this.maxQueueSize) {
|
|
47
85
|
this.queue.shift();
|
|
@@ -53,17 +91,32 @@ class EventQueue {
|
|
|
53
91
|
this.flush();
|
|
54
92
|
}
|
|
55
93
|
}
|
|
94
|
+
/** Start the periodic flush timer. No-op if already running. */
|
|
56
95
|
start() {
|
|
57
96
|
if (this.timer)
|
|
58
97
|
return;
|
|
59
98
|
this.timer = setInterval(() => this.flush(), this.flushInterval);
|
|
60
99
|
}
|
|
100
|
+
/** Stop the periodic flush timer. Safe to call when already stopped. */
|
|
61
101
|
stop() {
|
|
62
102
|
if (this.timer) {
|
|
63
103
|
clearInterval(this.timer);
|
|
64
104
|
this.timer = null;
|
|
65
105
|
}
|
|
66
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Send the next batch of events to the ingest API.
|
|
109
|
+
*
|
|
110
|
+
* No-op when a flush is already in progress, the queue is empty,
|
|
111
|
+
* or the backoff cooldown has not elapsed.
|
|
112
|
+
*
|
|
113
|
+
* **Retry logic**:
|
|
114
|
+
* - On 5xx or network error the batch is re-queued and delivery is
|
|
115
|
+
* retried with exponential backoff (1 s, 2 s, 4 s, ... up to 30 s).
|
|
116
|
+
* - On 4xx ({@link NonRetryableError}) the batch is **dropped**.
|
|
117
|
+
* - On 429 + quota_limited ({@link QuotaExceededError}) the queue is
|
|
118
|
+
* emptied and the flush timer is stopped.
|
|
119
|
+
*/
|
|
67
120
|
async flush() {
|
|
68
121
|
if (this.flushing || this.queue.length === 0)
|
|
69
122
|
return;
|
|
@@ -118,6 +171,13 @@ class EventQueue {
|
|
|
118
171
|
const backoffMs = Math.min(1000 * Math.pow(2, this.failureCount - 1), this.maxBackoffMs);
|
|
119
172
|
this.retryAfter = Date.now() + backoffMs;
|
|
120
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Drain the queue by flushing repeatedly until empty.
|
|
176
|
+
*
|
|
177
|
+
* Resets backoff state before starting so pending retries are not
|
|
178
|
+
* delayed. Stops early if a flush cycle makes no progress (e.g. all
|
|
179
|
+
* events are failing permanently).
|
|
180
|
+
*/
|
|
121
181
|
async flushAll() {
|
|
122
182
|
this.retryAfter = 0;
|
|
123
183
|
this.failureCount = 0;
|
|
@@ -128,6 +188,15 @@ class EventQueue {
|
|
|
128
188
|
break;
|
|
129
189
|
}
|
|
130
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Gracefully shut down the queue.
|
|
193
|
+
*
|
|
194
|
+
* Stops the periodic timer and attempts to deliver all remaining
|
|
195
|
+
* events via {@link flushAll}. If delivery does not complete within
|
|
196
|
+
* `timeoutMs`, the promise resolves and outstanding events are lost.
|
|
197
|
+
*
|
|
198
|
+
* @param timeoutMs - Maximum time to wait for delivery. Default: `30000`.
|
|
199
|
+
*/
|
|
131
200
|
async shutdown(timeoutMs = 30_000) {
|
|
132
201
|
this.stop();
|
|
133
202
|
if (this.size === 0)
|
|
@@ -137,6 +206,15 @@ class EventQueue {
|
|
|
137
206
|
new Promise((resolve) => setTimeout(resolve, timeoutMs)),
|
|
138
207
|
]);
|
|
139
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Last-resort flush for page unload (`beforeunload` / `visibilitychange`).
|
|
211
|
+
*
|
|
212
|
+
* Sends all remaining events in a single fire-and-forget request with
|
|
213
|
+
* `keepalive: true` so the browser keeps the connection alive after the
|
|
214
|
+
* page is destroyed. If a regular {@link flush} is already in-flight,
|
|
215
|
+
* only the queued (not yet sent) events are included to avoid
|
|
216
|
+
* double-delivery.
|
|
217
|
+
*/
|
|
140
218
|
flushForUnload() {
|
|
141
219
|
// If a flush() is already in-flight, don't re-send those events — they are
|
|
142
220
|
// being delivered by the ongoing fetch. Only grab remaining queue items.
|
|
@@ -150,6 +228,7 @@ class EventQueue {
|
|
|
150
228
|
return;
|
|
151
229
|
this.transport.send(this.endpoint, this.apiKey, { events: batch, sent_at: new Date().toISOString() }, { keepalive: true }).catch(() => { });
|
|
152
230
|
}
|
|
231
|
+
/** Total number of events pending delivery (queued + in-flight). */
|
|
153
232
|
get size() {
|
|
154
233
|
return this.queue.length + (this.inFlightBatch?.length || 0);
|
|
155
234
|
}
|
package/dist/queue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":";;;AACA,mCAAgE;AAEhE,MAAa,UAAU;
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":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E,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC7I,CAAC;IAED,oEAAoE;IACpE,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAEO,OAAO;QACb,IAAI,CAAC;YACH,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACP,6BAA6B;QAC/B,CAAC;IACH,CAAC;CACF;AAvND,gCAuNC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the Qurvo SDK.
|
|
3
|
+
*
|
|
4
|
+
* Only `apiKey` is required. All other fields have sensible defaults
|
|
5
|
+
* set by the platform-specific SDK wrapper (sdk-browser / sdk-node).
|
|
6
|
+
*/
|
|
1
7
|
export interface SdkConfig {
|
|
8
|
+
/** Project API key used to authenticate ingest requests (`x-api-key` header). */
|
|
2
9
|
apiKey: string;
|
|
10
|
+
/** Ingest endpoint URL. Defaults to `https://ingest.qurvo.pro/events/batch`. */
|
|
3
11
|
endpoint?: string;
|
|
12
|
+
/** Interval in milliseconds between automatic flushes. Default: `5000`. */
|
|
4
13
|
flushInterval?: number;
|
|
14
|
+
/** Number of events that triggers an immediate flush. Default: `20`. */
|
|
5
15
|
flushSize?: number;
|
|
16
|
+
/** Maximum number of events held in memory. When exceeded, the oldest event is dropped (FIFO). Default: `1000`. */
|
|
6
17
|
maxQueueSize?: number;
|
|
18
|
+
/** Optional logger function for debug output and error reporting. */
|
|
7
19
|
logger?: LogFn;
|
|
8
20
|
}
|
|
9
21
|
export interface EventPayload {
|
|
10
22
|
event: string;
|
|
11
23
|
distinct_id: string;
|
|
12
24
|
anonymous_id?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Event properties. The browser SDK automatically merges UTM parameters
|
|
27
|
+
* (`utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, `utm_content`)
|
|
28
|
+
* from the page URL into this object. Explicitly provided properties
|
|
29
|
+
* take priority over auto-captured UTM values.
|
|
30
|
+
*/
|
|
13
31
|
properties?: Record<string, unknown>;
|
|
14
32
|
user_properties?: Record<string, unknown>;
|
|
15
33
|
context?: EventContext;
|
|
@@ -39,14 +57,49 @@ export interface SendOptions {
|
|
|
39
57
|
signal?: AbortSignal;
|
|
40
58
|
}
|
|
41
59
|
export type LogFn = (message: string, error?: unknown) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Persistence layer for the event queue.
|
|
62
|
+
*
|
|
63
|
+
* Implementations back the in-memory queue with durable storage (e.g.
|
|
64
|
+
* `localStorage` in browsers) so events survive page reloads or crashes.
|
|
65
|
+
* Persistence is best-effort: failures are silently ignored by {@link EventQueue}.
|
|
66
|
+
*/
|
|
42
67
|
export interface QueuePersistence {
|
|
68
|
+
/** Persist the current queue snapshot. Called after every enqueue and flush. */
|
|
43
69
|
save(events: unknown[]): void;
|
|
70
|
+
/** Load previously persisted events. Called once during {@link EventQueue} construction. */
|
|
44
71
|
load(): unknown[];
|
|
45
72
|
}
|
|
46
73
|
export type CompressFn = (data: string) => Promise<Blob>;
|
|
74
|
+
/**
|
|
75
|
+
* Transport contract for sending event batches to the ingest API.
|
|
76
|
+
*
|
|
77
|
+
* The default implementation is {@link FetchTransport}. Custom transports
|
|
78
|
+
* can be provided via SDK configuration for non-standard environments.
|
|
79
|
+
*/
|
|
47
80
|
export interface Transport {
|
|
81
|
+
/**
|
|
82
|
+
* Send a batch payload to the ingest endpoint.
|
|
83
|
+
*
|
|
84
|
+
* @param endpoint - Full URL of the ingest endpoint.
|
|
85
|
+
* @param apiKey - Project API key for the `x-api-key` header.
|
|
86
|
+
* @param payload - Serializable payload (`{ events, sent_at }`).
|
|
87
|
+
* @param options - Optional send options (abort signal, keepalive).
|
|
88
|
+
* @returns `true` if the server accepted the batch (2xx/202),
|
|
89
|
+
* `false` for retryable failures (e.g. network timeout handled internally).
|
|
90
|
+
* @throws {@link QuotaExceededError} when the server responds 429 with `quota_limited`.
|
|
91
|
+
* @throws {@link NonRetryableError} on 4xx client errors (bad data, auth failure).
|
|
92
|
+
* @throws {@link Error} on 5xx server errors (retryable by the queue).
|
|
93
|
+
*/
|
|
48
94
|
send(endpoint: string, apiKey: string, payload: unknown, options?: SendOptions): Promise<boolean>;
|
|
49
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Thrown when the ingest API responds with 429 and `quota_limited: true`,
|
|
98
|
+
* indicating the project has exceeded its monthly event quota.
|
|
99
|
+
*
|
|
100
|
+
* When caught by {@link EventQueue}, the queue is drained and stopped
|
|
101
|
+
* to prevent further network requests until the billing period resets.
|
|
102
|
+
*/
|
|
50
103
|
export declare class QuotaExceededError extends Error {
|
|
51
104
|
constructor();
|
|
52
105
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,eAA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BAAa,kBAAmB,SAAQ,KAAK;;CAK5C;AAED,uEAAuE;AACvE,qBAAa,iBAAkB,SAAQ,KAAK;aACd,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAIhE"}
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NonRetryableError = exports.QuotaExceededError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Thrown when the ingest API responds with 429 and `quota_limited: true`,
|
|
6
|
+
* indicating the project has exceeded its monthly event quota.
|
|
7
|
+
*
|
|
8
|
+
* When caught by {@link EventQueue}, the queue is drained and stopped
|
|
9
|
+
* to prevent further network requests until the billing period resets.
|
|
10
|
+
*/
|
|
4
11
|
class QuotaExceededError extends Error {
|
|
5
12
|
constructor() {
|
|
6
13
|
super('Monthly event limit exceeded');
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAwGA;;;;;;GAMG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAC3C;QACE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED,uEAAuE;AACvE,MAAa,iBAAkB,SAAQ,KAAK;IACd;IAA5B,YAA4B,UAAkB,EAAE,OAAe;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,eAAU,GAAV,UAAU,CAAQ;QAE5C,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AALD,8CAKC"}
|