@tracelog/capture-core 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/CHANGELOG.md +40 -0
- package/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +470 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Every published version of `@tracelog/capture-core`, and what changed for the
|
|
4
|
+
artifact that binds it.
|
|
5
|
+
|
|
6
|
+
Nothing here is an alias: there is no `latest`, so every integration names a
|
|
7
|
+
version and needs somewhere to read what moving costs. Entries are written for
|
|
8
|
+
whoever decides whether to change that version, not for whoever wrote the
|
|
9
|
+
commit.
|
|
10
|
+
|
|
11
|
+
**What the numbers mean.** The major changes when working code stops working: a
|
|
12
|
+
removed or renamed export, a changed meaning for an argument, a new required
|
|
13
|
+
option on what the host supplies, or a wire format the ingestion endpoint of
|
|
14
|
+
the same release no longer accepts. Everything else is a minor or a patch.
|
|
15
|
+
|
|
16
|
+
This package, `@tracelog/capture-web` and `@tracelog/event-contract` carry one
|
|
17
|
+
number between them: the browser runtime's published bytes are this engine's
|
|
18
|
+
bytes, so no version of one is not also a version of the others.
|
|
19
|
+
|
|
20
|
+
## 1.0.0
|
|
21
|
+
|
|
22
|
+
The first published engine, extracted from the monorepo TraceLog was built in
|
|
23
|
+
and unchanged in behaviour by the extraction.
|
|
24
|
+
|
|
25
|
+
**The surface.** `createCaptureEngine(ports, acquisition)`, which returns a
|
|
26
|
+
`CaptureRuntime` whose `engine` takes `init`, the consent calls, `step` and
|
|
27
|
+
`conversion`; `PRE_CONSENT_CAP`, how many events wait in memory before
|
|
28
|
+
consent; the `Clock` port; and the types that describe the rest —
|
|
29
|
+
`CapturePorts`, `CaptureStorage`, `CaptureTransport`, `TransportRequest`,
|
|
30
|
+
`TransportResponse`, `AcquisitionContext`, `InitOptions`, `ConversionOptions`,
|
|
31
|
+
`ConsentState`, `CaptureEngine`, `DropCount`, `CircuitState`, and the
|
|
32
|
+
envelope's `Event` and `EventBatch`. That is all of it, and it is what the
|
|
33
|
+
major number protects.
|
|
34
|
+
|
|
35
|
+
**No DOM and no browser global.** The package compiles without the DOM library
|
|
36
|
+
and lint refuses `window` and `document` inside it, because it is what runs in
|
|
37
|
+
sandboxes that have neither. That is the property the major number protects.
|
|
38
|
+
|
|
39
|
+
**It reads no clock.** The host supplies one. A sandbox may not have a
|
|
40
|
+
`Date` worth reading, and a test must be able to hand over a fixed instant.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TraceLog
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @tracelog/capture-core
|
|
2
|
+
|
|
3
|
+
The TraceLog capture engine, with no DOM and no browser global. It is what a
|
|
4
|
+
platform artifact binds inside a sandbox that has neither — TraceLog's Shopify
|
|
5
|
+
web pixel is one — and what
|
|
6
|
+
[`@tracelog/capture-web`](https://www.npmjs.com/package/@tracelog/capture-web)
|
|
7
|
+
is built from.
|
|
8
|
+
|
|
9
|
+
**Most sites do not want this package.** A site you add a script to, or one
|
|
10
|
+
with its own build, installs `@tracelog/capture-web`, which carries this engine
|
|
11
|
+
inside it and adds the browser: its storage, its network, the page's errors and
|
|
12
|
+
lifecycle, the verification handshake and the clock. Reach for `capture-core`
|
|
13
|
+
only where there is no browser to assume.
|
|
14
|
+
|
|
15
|
+
TraceLog is conversion intelligence you can verify: it checks the conversion
|
|
16
|
+
path a project declares against the events TraceLog receives, watches every
|
|
17
|
+
declared step every day, alerts when events for one stop arriving and names the
|
|
18
|
+
TraceLog figures that are incomplete. <https://tracelog.io>
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
**Every integration names a version.** There is no `latest` on npm, so the
|
|
23
|
+
version you pin is the code you get.
|
|
24
|
+
|
|
25
|
+
<!-- x-release-please-start-version -->
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @tracelog/capture-core@1.0.0
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
<!-- x-release-please-end -->
|
|
32
|
+
|
|
33
|
+
## What it expects you to supply
|
|
34
|
+
|
|
35
|
+
The engine assumes nothing about its host, so the host supplies four things:
|
|
36
|
+
|
|
37
|
+
- **storage** — `getItem`, `setItem`, `removeItem`. A sandbox with no storage
|
|
38
|
+
supplies an in-memory one; a denial is one remembered key.
|
|
39
|
+
- **a transport** — one `send`, returning the status the endpoint answered.
|
|
40
|
+
- **a clock** — `now(): Date`. This package never reads the machine's, because
|
|
41
|
+
in a sandbox there may not be one to read.
|
|
42
|
+
- **the acquisition context** — referrer, campaign, landing page, device.
|
|
43
|
+
|
|
44
|
+
Consent comes first: before a consent decision the engine creates no
|
|
45
|
+
identifier, no storage and no traffic.
|
|
46
|
+
|
|
47
|
+
## The wire format
|
|
48
|
+
|
|
49
|
+
Events leave in the envelope
|
|
50
|
+
[`@tracelog/event-contract`](https://www.npmjs.com/package/@tracelog/event-contract)
|
|
51
|
+
defines, at the version this package was built against — one definition, shared
|
|
52
|
+
by the runtime that sends and the endpoint that receives.
|
|
53
|
+
|
|
54
|
+
## Licence
|
|
55
|
+
|
|
56
|
+
MIT. See [LICENSE](./LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type EventBatch } from "@tracelog/event-contract";
|
|
2
|
+
export type { Event, EventBatch } from "@tracelog/event-contract";
|
|
3
|
+
/**
|
|
4
|
+
* Time is injected, and this package never reads it: it runs inside sandboxes
|
|
5
|
+
* with no ambient clock, so it declares the port and the caller supplies one.
|
|
6
|
+
* `capture-web` supplies the browser's; a platform artifact supplies its
|
|
7
|
+
* host's.
|
|
8
|
+
*/
|
|
9
|
+
export interface Clock {
|
|
10
|
+
now(): Date;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* How many events wait in memory before consent. A platform artifact that
|
|
14
|
+
* buffers its own platform's events ahead of this engine holds the same line,
|
|
15
|
+
* so the number is exported rather than mirrored.
|
|
16
|
+
*/
|
|
17
|
+
export declare const PRE_CONSENT_CAP = 100;
|
|
18
|
+
export type ConsentState = "unknown" | "granted" | "denied";
|
|
19
|
+
export interface InitOptions {
|
|
20
|
+
key: string;
|
|
21
|
+
endpoint?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ConversionOptions {
|
|
24
|
+
identifier: string;
|
|
25
|
+
value?: number;
|
|
26
|
+
currency?: string;
|
|
27
|
+
context?: object;
|
|
28
|
+
}
|
|
29
|
+
export interface CaptureEngine {
|
|
30
|
+
init(options: InitOptions): void;
|
|
31
|
+
consent: {
|
|
32
|
+
grant(): void;
|
|
33
|
+
deny(): void;
|
|
34
|
+
state(): ConsentState;
|
|
35
|
+
};
|
|
36
|
+
step(name: string, context?: object): void;
|
|
37
|
+
conversion(name: string, options: ConversionOptions): void;
|
|
38
|
+
}
|
|
39
|
+
export interface CaptureStorage {
|
|
40
|
+
getItem(key: string): string | null;
|
|
41
|
+
setItem(key: string, value: string): void;
|
|
42
|
+
removeItem(key: string): void;
|
|
43
|
+
}
|
|
44
|
+
export interface TransportRequest {
|
|
45
|
+
endpoint: string;
|
|
46
|
+
key: string;
|
|
47
|
+
batch: EventBatch;
|
|
48
|
+
keepalive: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface TransportResponse {
|
|
51
|
+
status: number;
|
|
52
|
+
rejected?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface CaptureTransport {
|
|
55
|
+
send(request: TransportRequest): Promise<TransportResponse>;
|
|
56
|
+
}
|
|
57
|
+
export interface AcquisitionContext {
|
|
58
|
+
referrer?: string;
|
|
59
|
+
utm: {
|
|
60
|
+
source?: string;
|
|
61
|
+
medium?: string;
|
|
62
|
+
campaign?: string;
|
|
63
|
+
term?: string;
|
|
64
|
+
content?: string;
|
|
65
|
+
};
|
|
66
|
+
landingPage: string;
|
|
67
|
+
device: "desktop" | "mobile" | "tablet";
|
|
68
|
+
mode?: "verification";
|
|
69
|
+
}
|
|
70
|
+
export interface CapturePorts {
|
|
71
|
+
transport: CaptureTransport;
|
|
72
|
+
storage: CaptureStorage;
|
|
73
|
+
clock: Clock;
|
|
74
|
+
}
|
|
75
|
+
export interface DropCount {
|
|
76
|
+
reason: "queue_overflow" | "server_rejected" | "invalid_event";
|
|
77
|
+
count: number;
|
|
78
|
+
}
|
|
79
|
+
export type CircuitState = "closed" | "open" | "half_open";
|
|
80
|
+
export interface CaptureRuntime {
|
|
81
|
+
engine: CaptureEngine;
|
|
82
|
+
flush(keepalive?: boolean): Promise<void>;
|
|
83
|
+
captureError(message: string): void;
|
|
84
|
+
drops(): DropCount[];
|
|
85
|
+
circuitState(): CircuitState;
|
|
86
|
+
}
|
|
87
|
+
export declare function createCaptureEngine(ports: CapturePorts, acquisition: AcquisitionContext): CaptureRuntime;
|
|
88
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,UAAU,EAEhB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,KAAK;IACpB,GAAG,IAAI,IAAI,CAAC;CACb;AAMD;;;;GAIG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC;AAmBnC,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE;QACP,KAAK,IAAI,IAAI,CAAC;QACd,IAAI,IAAI,IAAI,CAAC;QACb,KAAK,IAAI,YAAY,CAAC;KACvB,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C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,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,eAAe,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE3D,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,KAAK,IAAI,SAAS,EAAE,CAAC;IACrB,YAAY,IAAI,YAAY,CAAC;CAC9B;AAoLD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,kBAAkB,GAC9B,cAAc,CAwUhB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { EVENT_ENVELOPE_VERSION, MAX_BATCH_BYTES, MAX_BATCH_EVENTS, MAX_CONTEXT_BYTES, MAX_ERROR_MESSAGE_BYTES, } from "@tracelog/event-contract";
|
|
2
|
+
const CONSENT_KEY = "__tl.c";
|
|
3
|
+
const SESSION_KEY = "__tl.s";
|
|
4
|
+
const ACTIVITY_KEY = "__tl.a";
|
|
5
|
+
const QUEUE_KEY = "__tl.q";
|
|
6
|
+
/**
|
|
7
|
+
* How many events wait in memory before consent. A platform artifact that
|
|
8
|
+
* buffers its own platform's events ahead of this engine holds the same line,
|
|
9
|
+
* so the number is exported rather than mirrored.
|
|
10
|
+
*/
|
|
11
|
+
export const PRE_CONSENT_CAP = 100;
|
|
12
|
+
const QUEUE_CAP = 200;
|
|
13
|
+
const SESSION_INACTIVITY_MS = 30 * 60 * 1000;
|
|
14
|
+
const FLUSH_INTERVAL_MS = 5 * 1000;
|
|
15
|
+
const RETRY_BASE_MS = 1000;
|
|
16
|
+
const RETRY_CAP_MS = 60 * 1000;
|
|
17
|
+
const CIRCUIT_FAILURE_THRESHOLD = 5;
|
|
18
|
+
const CIRCUIT_PROBE_MS = 60 * 1000;
|
|
19
|
+
const EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
20
|
+
const PUBLIC_KEY_PATTERN = /^tl_pk_[a-z2-7]{26}$/;
|
|
21
|
+
/**
|
|
22
|
+
* The contract states these inside its schemas (`conversionEventSchema`,
|
|
23
|
+
* `currencySchema`) and exports no constant for them; the schemas themselves
|
|
24
|
+
* are not imported because zod is not part of the runtime a visitor loads.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_IDENTIFIER_LENGTH = 256;
|
|
27
|
+
const CURRENCY_PATTERN = /^[A-Z]{3}$/;
|
|
28
|
+
const textEncoder = new TextEncoder();
|
|
29
|
+
function safeGet(storage, key) {
|
|
30
|
+
try {
|
|
31
|
+
return storage.getItem(key);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function safeSet(storage, key, value) {
|
|
38
|
+
try {
|
|
39
|
+
storage.setItem(key, value);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Capture must never break the host page when storage is unavailable.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function safeRemove(storage, key) {
|
|
46
|
+
try {
|
|
47
|
+
storage.removeItem(key);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Capture must never break the host page when storage is unavailable.
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function emptyQueue() {
|
|
54
|
+
return { events: [], drops: {} };
|
|
55
|
+
}
|
|
56
|
+
function readQueue(storage) {
|
|
57
|
+
const serialized = safeGet(storage, QUEUE_KEY);
|
|
58
|
+
if (serialized === null)
|
|
59
|
+
return emptyQueue();
|
|
60
|
+
try {
|
|
61
|
+
const value = JSON.parse(serialized);
|
|
62
|
+
if (typeof value !== "object" || value === null)
|
|
63
|
+
return emptyQueue();
|
|
64
|
+
const candidate = value;
|
|
65
|
+
if (!Array.isArray(candidate.events))
|
|
66
|
+
return emptyQueue();
|
|
67
|
+
return {
|
|
68
|
+
events: candidate.events,
|
|
69
|
+
drops: typeof candidate.drops === "object" && candidate.drops !== null
|
|
70
|
+
? candidate.drops
|
|
71
|
+
: {},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return emptyQueue();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function writeQueue(storage, queue) {
|
|
79
|
+
safeSet(storage, QUEUE_KEY, JSON.stringify(queue));
|
|
80
|
+
}
|
|
81
|
+
function addDrop(queue, reason, count = 1) {
|
|
82
|
+
queue.drops[reason] = (queue.drops[reason] ?? 0) + count;
|
|
83
|
+
}
|
|
84
|
+
function randomBytes(length) {
|
|
85
|
+
const bytes = new Uint8Array(length);
|
|
86
|
+
const cryptoSource = globalThis.crypto;
|
|
87
|
+
if (cryptoSource !== undefined)
|
|
88
|
+
return cryptoSource.getRandomValues(bytes);
|
|
89
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
90
|
+
bytes[index] = Math.floor(Math.random() * 256);
|
|
91
|
+
}
|
|
92
|
+
return bytes;
|
|
93
|
+
}
|
|
94
|
+
function uuidv7(at) {
|
|
95
|
+
const bytes = randomBytes(16);
|
|
96
|
+
let timestamp = at.getTime();
|
|
97
|
+
for (let index = 5; index >= 0; index -= 1) {
|
|
98
|
+
bytes[index] = timestamp % 256;
|
|
99
|
+
timestamp = Math.floor(timestamp / 256);
|
|
100
|
+
}
|
|
101
|
+
bytes[6] = 0x70 | (bytes[6] & 0x0f);
|
|
102
|
+
bytes[8] = 0x80 | (bytes[8] & 0x3f);
|
|
103
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0"));
|
|
104
|
+
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(6, 8).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
105
|
+
}
|
|
106
|
+
function jsonContext(value) {
|
|
107
|
+
if (value === undefined)
|
|
108
|
+
return undefined;
|
|
109
|
+
try {
|
|
110
|
+
const serialized = JSON.stringify(value);
|
|
111
|
+
if (textEncoder.encode(serialized).byteLength > MAX_CONTEXT_BYTES)
|
|
112
|
+
return undefined;
|
|
113
|
+
const parsed = JSON.parse(serialized);
|
|
114
|
+
if (typeof parsed !== "object" ||
|
|
115
|
+
parsed === null ||
|
|
116
|
+
Array.isArray(parsed)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return parsed;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function truncateUtf8(value, maxBytes) {
|
|
126
|
+
if (textEncoder.encode(value).byteLength <= maxBytes)
|
|
127
|
+
return value;
|
|
128
|
+
let low = 0;
|
|
129
|
+
let high = value.length;
|
|
130
|
+
while (low < high) {
|
|
131
|
+
const middle = Math.ceil((low + high) / 2);
|
|
132
|
+
if (textEncoder.encode(value.slice(0, middle)).byteLength <= maxBytes) {
|
|
133
|
+
low = middle;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
high = middle - 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return value.slice(0, low);
|
|
140
|
+
}
|
|
141
|
+
function isConversionValid(options) {
|
|
142
|
+
return (options.identifier.length >= 1 &&
|
|
143
|
+
options.identifier.length <= MAX_IDENTIFIER_LENGTH &&
|
|
144
|
+
(options.value === undefined ||
|
|
145
|
+
(Number.isFinite(options.value) && options.value >= 0)) &&
|
|
146
|
+
(options.currency === undefined || CURRENCY_PATTERN.test(options.currency)));
|
|
147
|
+
}
|
|
148
|
+
function batchFrom(events) {
|
|
149
|
+
const selected = [];
|
|
150
|
+
const unsendable = [];
|
|
151
|
+
for (const event of events) {
|
|
152
|
+
if (selected.length >= MAX_BATCH_EVENTS)
|
|
153
|
+
break;
|
|
154
|
+
const candidate = {
|
|
155
|
+
v: EVENT_ENVELOPE_VERSION,
|
|
156
|
+
events: [...selected, event],
|
|
157
|
+
};
|
|
158
|
+
if (textEncoder.encode(JSON.stringify(candidate)).byteLength > MAX_BATCH_BYTES) {
|
|
159
|
+
if (selected.length === 0) {
|
|
160
|
+
unsendable.push(event);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
selected.push(event);
|
|
166
|
+
}
|
|
167
|
+
return { batch: { v: EVENT_ENVELOPE_VERSION, events: selected }, unsendable };
|
|
168
|
+
}
|
|
169
|
+
export function createCaptureEngine(ports, acquisition) {
|
|
170
|
+
let consentState = "unknown";
|
|
171
|
+
let initialized = false;
|
|
172
|
+
let config = { key: "", endpoint: "/v1/events" };
|
|
173
|
+
let pending = [];
|
|
174
|
+
let lastDeclaredName;
|
|
175
|
+
let sending = false;
|
|
176
|
+
let flushTimer;
|
|
177
|
+
let consecutiveFailures = 0;
|
|
178
|
+
let circuit = "closed";
|
|
179
|
+
let nextProbeAt = 0;
|
|
180
|
+
function scheduleFlush(delay) {
|
|
181
|
+
if (flushTimer !== undefined)
|
|
182
|
+
clearTimeout(flushTimer);
|
|
183
|
+
flushTimer = setTimeout(() => {
|
|
184
|
+
flushTimer = undefined;
|
|
185
|
+
void flush(false);
|
|
186
|
+
}, delay);
|
|
187
|
+
}
|
|
188
|
+
function persistEvent(event) {
|
|
189
|
+
const queue = readQueue(ports.storage);
|
|
190
|
+
queue.events.push(event);
|
|
191
|
+
while (queue.events.length > QUEUE_CAP) {
|
|
192
|
+
queue.events.shift();
|
|
193
|
+
addDrop(queue, "queue_overflow");
|
|
194
|
+
}
|
|
195
|
+
writeQueue(ports.storage, queue);
|
|
196
|
+
}
|
|
197
|
+
function sessionFor(now) {
|
|
198
|
+
const storedId = safeGet(ports.storage, SESSION_KEY);
|
|
199
|
+
const activityValue = safeGet(ports.storage, ACTIVITY_KEY);
|
|
200
|
+
const lastActivity = activityValue === null ? Number.NaN : Number(activityValue);
|
|
201
|
+
const rotated = storedId === null ||
|
|
202
|
+
!Number.isFinite(lastActivity) ||
|
|
203
|
+
now.getTime() - lastActivity >= SESSION_INACTIVITY_MS;
|
|
204
|
+
const id = rotated ? uuidv7(now) : storedId;
|
|
205
|
+
if (rotated)
|
|
206
|
+
safeSet(ports.storage, SESSION_KEY, id);
|
|
207
|
+
safeSet(ports.storage, ACTIVITY_KEY, String(now.getTime()));
|
|
208
|
+
return { id, started: rotated };
|
|
209
|
+
}
|
|
210
|
+
function baseEvent(now, sessionId) {
|
|
211
|
+
return {
|
|
212
|
+
eventId: uuidv7(now),
|
|
213
|
+
sessionId,
|
|
214
|
+
occurredAt: now.toISOString(),
|
|
215
|
+
...(acquisition.mode === undefined ? {} : { mode: acquisition.mode }),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function recordInvalidEvent() {
|
|
219
|
+
const queue = readQueue(ports.storage);
|
|
220
|
+
addDrop(queue, "invalid_event");
|
|
221
|
+
writeQueue(ports.storage, queue);
|
|
222
|
+
}
|
|
223
|
+
function emit(pendingEvent) {
|
|
224
|
+
if (!EVENT_NAME_PATTERN.test(pendingEvent.name)) {
|
|
225
|
+
recordInvalidEvent();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (pendingEvent.kind === "conversion" &&
|
|
229
|
+
!isConversionValid(pendingEvent.options)) {
|
|
230
|
+
recordInvalidEvent();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const now = ports.clock.now();
|
|
234
|
+
const session = sessionFor(now);
|
|
235
|
+
if (session.started) {
|
|
236
|
+
persistEvent({
|
|
237
|
+
...baseEvent(now, session.id),
|
|
238
|
+
kind: "session_start",
|
|
239
|
+
name: "session_started",
|
|
240
|
+
...(acquisition.referrer === undefined
|
|
241
|
+
? {}
|
|
242
|
+
: { referrer: acquisition.referrer }),
|
|
243
|
+
utm: acquisition.utm,
|
|
244
|
+
landingPage: acquisition.landingPage,
|
|
245
|
+
device: acquisition.device,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (pendingEvent.kind === "step") {
|
|
249
|
+
const context = jsonContext(pendingEvent.context);
|
|
250
|
+
persistEvent({
|
|
251
|
+
...baseEvent(now, session.id),
|
|
252
|
+
kind: "step",
|
|
253
|
+
name: pendingEvent.name,
|
|
254
|
+
...(context === undefined ? {} : { context }),
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
const options = pendingEvent.options;
|
|
259
|
+
const context = jsonContext(options.context);
|
|
260
|
+
persistEvent({
|
|
261
|
+
...baseEvent(now, session.id),
|
|
262
|
+
kind: "conversion",
|
|
263
|
+
name: pendingEvent.name,
|
|
264
|
+
identifier: options.identifier,
|
|
265
|
+
...(options.value === undefined ? {} : { value: options.value }),
|
|
266
|
+
...(options.currency === undefined
|
|
267
|
+
? {}
|
|
268
|
+
: { currency: options.currency }),
|
|
269
|
+
...(context === undefined ? {} : { context }),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
lastDeclaredName = pendingEvent.name;
|
|
273
|
+
}
|
|
274
|
+
function capture(pendingEvent) {
|
|
275
|
+
if (!initialized || consentState === "denied")
|
|
276
|
+
return;
|
|
277
|
+
if (consentState === "unknown") {
|
|
278
|
+
if (pending.length < PRE_CONSENT_CAP)
|
|
279
|
+
pending.push(pendingEvent);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
emit(pendingEvent);
|
|
283
|
+
}
|
|
284
|
+
async function flush(keepalive = false) {
|
|
285
|
+
if (!initialized || consentState !== "granted" || sending)
|
|
286
|
+
return;
|
|
287
|
+
const queue = readQueue(ports.storage);
|
|
288
|
+
if (queue.events.length === 0 || !PUBLIC_KEY_PATTERN.test(config.key)) {
|
|
289
|
+
scheduleFlush(FLUSH_INTERVAL_MS);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const now = ports.clock.now().getTime();
|
|
293
|
+
if (circuit === "open") {
|
|
294
|
+
if (now < nextProbeAt) {
|
|
295
|
+
scheduleFlush(nextProbeAt - now);
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
circuit = "half_open";
|
|
299
|
+
}
|
|
300
|
+
const { batch, unsendable } = batchFrom(queue.events);
|
|
301
|
+
if (unsendable.length > 0) {
|
|
302
|
+
const dropped = new Set(unsendable.map((event) => event.eventId));
|
|
303
|
+
queue.events = queue.events.filter((event) => !dropped.has(event.eventId));
|
|
304
|
+
addDrop(queue, "invalid_event", unsendable.length);
|
|
305
|
+
writeQueue(ports.storage, queue);
|
|
306
|
+
}
|
|
307
|
+
if (batch.events.length === 0) {
|
|
308
|
+
scheduleFlush(FLUSH_INTERVAL_MS);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
sending = true;
|
|
312
|
+
try {
|
|
313
|
+
const response = await ports.transport.send({
|
|
314
|
+
endpoint: config.endpoint,
|
|
315
|
+
key: config.key,
|
|
316
|
+
batch,
|
|
317
|
+
keepalive,
|
|
318
|
+
});
|
|
319
|
+
if (response.status >= 200 && response.status < 300) {
|
|
320
|
+
const currentQueue = readQueue(ports.storage);
|
|
321
|
+
const delivered = new Set(batch.events.map((event) => event.eventId));
|
|
322
|
+
currentQueue.events = currentQueue.events.filter((event) => !delivered.has(event.eventId));
|
|
323
|
+
if ((response.rejected ?? 0) > 0) {
|
|
324
|
+
addDrop(currentQueue, "server_rejected", response.rejected);
|
|
325
|
+
}
|
|
326
|
+
writeQueue(ports.storage, currentQueue);
|
|
327
|
+
consecutiveFailures = 0;
|
|
328
|
+
circuit = "closed";
|
|
329
|
+
scheduleFlush(currentQueue.events.length === 0 ? FLUSH_INTERVAL_MS : 0);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* A 4xx is the server's word that this batch will never be accepted —
|
|
334
|
+
* except a 429, which is the server's word that it will be accepted
|
|
335
|
+
* later: the ingestion limit is per public key, shared by every visitor
|
|
336
|
+
* of one site, so a busy minute answers 429 to visitors whose events
|
|
337
|
+
* are sound. Dropping those is silent loss ([spec/capture.md]
|
|
338
|
+
* § Delivery); they take the retry path with everything else transient.
|
|
339
|
+
*/
|
|
340
|
+
if (response.status >= 400 &&
|
|
341
|
+
response.status < 500 &&
|
|
342
|
+
response.status !== 429) {
|
|
343
|
+
const currentQueue = readQueue(ports.storage);
|
|
344
|
+
const rejected = new Set(batch.events.map((event) => event.eventId));
|
|
345
|
+
currentQueue.events = currentQueue.events.filter((event) => !rejected.has(event.eventId));
|
|
346
|
+
addDrop(currentQueue, "server_rejected", batch.events.length);
|
|
347
|
+
writeQueue(ports.storage, currentQueue);
|
|
348
|
+
consecutiveFailures = 0;
|
|
349
|
+
circuit = "closed";
|
|
350
|
+
scheduleFlush(currentQueue.events.length === 0 ? FLUSH_INTERVAL_MS : 0);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
throw new Error("retryable response");
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
consecutiveFailures += 1;
|
|
357
|
+
if (circuit === "half_open" ||
|
|
358
|
+
consecutiveFailures >= CIRCUIT_FAILURE_THRESHOLD) {
|
|
359
|
+
circuit = "open";
|
|
360
|
+
nextProbeAt = ports.clock.now().getTime() + CIRCUIT_PROBE_MS;
|
|
361
|
+
scheduleFlush(CIRCUIT_PROBE_MS);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
scheduleFlush(Math.min(RETRY_BASE_MS * 2 ** (consecutiveFailures - 1), RETRY_CAP_MS));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
finally {
|
|
368
|
+
sending = false;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const engine = {
|
|
372
|
+
init(options) {
|
|
373
|
+
config = {
|
|
374
|
+
key: options.key,
|
|
375
|
+
endpoint: options.endpoint ?? "/v1/events",
|
|
376
|
+
};
|
|
377
|
+
initialized = true;
|
|
378
|
+
const storedConsent = safeGet(ports.storage, CONSENT_KEY);
|
|
379
|
+
consentState =
|
|
380
|
+
storedConsent === "granted" || storedConsent === "denied"
|
|
381
|
+
? storedConsent
|
|
382
|
+
: "unknown";
|
|
383
|
+
if (consentState === "granted")
|
|
384
|
+
scheduleFlush(FLUSH_INTERVAL_MS);
|
|
385
|
+
},
|
|
386
|
+
consent: {
|
|
387
|
+
grant() {
|
|
388
|
+
if (!initialized)
|
|
389
|
+
return;
|
|
390
|
+
consentState = "granted";
|
|
391
|
+
safeSet(ports.storage, CONSENT_KEY, "granted");
|
|
392
|
+
const buffered = pending;
|
|
393
|
+
pending = [];
|
|
394
|
+
for (const pendingEvent of buffered)
|
|
395
|
+
emit(pendingEvent);
|
|
396
|
+
scheduleFlush(FLUSH_INTERVAL_MS);
|
|
397
|
+
},
|
|
398
|
+
deny() {
|
|
399
|
+
if (!initialized)
|
|
400
|
+
return;
|
|
401
|
+
consentState = "denied";
|
|
402
|
+
pending = [];
|
|
403
|
+
lastDeclaredName = undefined;
|
|
404
|
+
safeSet(ports.storage, CONSENT_KEY, "denied");
|
|
405
|
+
safeRemove(ports.storage, SESSION_KEY);
|
|
406
|
+
safeRemove(ports.storage, ACTIVITY_KEY);
|
|
407
|
+
safeRemove(ports.storage, QUEUE_KEY);
|
|
408
|
+
if (flushTimer !== undefined)
|
|
409
|
+
clearTimeout(flushTimer);
|
|
410
|
+
flushTimer = undefined;
|
|
411
|
+
},
|
|
412
|
+
state() {
|
|
413
|
+
return consentState;
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
step(name, context) {
|
|
417
|
+
capture({
|
|
418
|
+
kind: "step",
|
|
419
|
+
name,
|
|
420
|
+
...(context === undefined ? {} : { context }),
|
|
421
|
+
});
|
|
422
|
+
},
|
|
423
|
+
conversion(name, options) {
|
|
424
|
+
capture({ kind: "conversion", name, options });
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
return {
|
|
428
|
+
engine,
|
|
429
|
+
flush,
|
|
430
|
+
captureError(message) {
|
|
431
|
+
if (!initialized ||
|
|
432
|
+
consentState !== "granted" ||
|
|
433
|
+
lastDeclaredName === undefined) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const now = ports.clock.now();
|
|
437
|
+
const session = sessionFor(now);
|
|
438
|
+
if (session.started) {
|
|
439
|
+
persistEvent({
|
|
440
|
+
...baseEvent(now, session.id),
|
|
441
|
+
kind: "session_start",
|
|
442
|
+
name: "session_started",
|
|
443
|
+
...(acquisition.referrer === undefined
|
|
444
|
+
? {}
|
|
445
|
+
: { referrer: acquisition.referrer }),
|
|
446
|
+
utm: acquisition.utm,
|
|
447
|
+
landingPage: acquisition.landingPage,
|
|
448
|
+
device: acquisition.device,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
persistEvent({
|
|
452
|
+
...baseEvent(now, session.id),
|
|
453
|
+
kind: "error",
|
|
454
|
+
name: "capture_error",
|
|
455
|
+
message: truncateUtf8(message, MAX_ERROR_MESSAGE_BYTES),
|
|
456
|
+
stepName: lastDeclaredName,
|
|
457
|
+
});
|
|
458
|
+
},
|
|
459
|
+
drops() {
|
|
460
|
+
const queue = readQueue(ports.storage);
|
|
461
|
+
return ["queue_overflow", "server_rejected", "invalid_event"]
|
|
462
|
+
.map((reason) => ({ reason, count: queue.drops[reason] ?? 0 }))
|
|
463
|
+
.filter((drop) => drop.count > 0);
|
|
464
|
+
},
|
|
465
|
+
circuitState() {
|
|
466
|
+
return circuit;
|
|
467
|
+
},
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,GAIxB,MAAM,0BAA0B,CAAC;AAclC,MAAM,WAAW,GAAG,QAAQ,CAAC;AAC7B,MAAM,WAAW,GAAG,Q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AAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;iBAC9D,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACtC,CAAC;QACD,YAAY;YACV,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tracelog/capture-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The TraceLog capture engine, with no DOM and no browser global: what platform artifacts bind inside sandboxes that have neither.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"conversion",
|
|
7
|
+
"conversion-tracking",
|
|
8
|
+
"tracking-plan",
|
|
9
|
+
"consent",
|
|
10
|
+
"sandbox"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://tracelog.io",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/nacorga/tracelog-sdk.git",
|
|
16
|
+
"directory": "packages/capture-core"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/nacorga/tracelog-sdk/issues"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"CHANGELOG.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@tracelog/event-contract": "1.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.build.json",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.json"
|
|
47
|
+
}
|
|
48
|
+
}
|