@tracelog/capture-web 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 ADDED
@@ -0,0 +1,51 @@
1
+ # Changelog
2
+
3
+ Every published version of `@tracelog/capture-web`, and what changed for the
4
+ site that embeds it.
5
+
6
+ This file exists because nothing here is an alias. There is no `latest` on npm
7
+ and no `v/latest/` on the CDN — every integration names a version, so every
8
+ integration needs somewhere to read what moving costs. Entries are written for
9
+ whoever has to decide whether to change the version in their script tag, not
10
+ for whoever wrote the commit.
11
+
12
+ **What the numbers mean** — the major changes when working code stops
13
+ working: a removed or renamed method on the `TraceLog` object, a changed
14
+ meaning for an argument, a new required option, or a wire format the ingestion
15
+ endpoint of the same release no longer accepts. Everything else is a minor or a
16
+ patch, and neither requires reading your code.
17
+
18
+ Entries after 1.0.0 are drafted from the commits that touched this package and
19
+ edited before release.
20
+
21
+ ## 1.0.0
22
+
23
+ The first published runtime.
24
+
25
+ **The surface.** `TraceLog.init(options)`, `TraceLog.consent.grant()`,
26
+ `.deny()`, `.state()`, `TraceLog.step(name, context?)` and
27
+ `TraceLog.conversion(name, options)`. That is all of it, and it is what the
28
+ major number protects.
29
+
30
+ **Consent comes first, and it is not a setting.** Before consent is granted the
31
+ runtime creates no identifier, writes no storage, and sends no request — none,
32
+ not a reduced set. A site that never calls `consent.grant()` captures nothing
33
+ and costs its visitors nothing.
34
+
35
+ **What it captures** is the declared conversion path: the conversions you
36
+ declare and the steps preceding them, with their context. Not page views, not
37
+ clicks, not scroll, not keystrokes.
38
+
39
+ **Where it runs.** The browsers named in
40
+ [`tools/sdk-browser-targets.mjs`](../../tools/sdk-browser-targets.mjs), which
41
+ the reference application's end-to-end suite runs against on Chromium, WebKit
42
+ and Firefox before any release.
43
+
44
+ **How to pin it.**
45
+
46
+ ```html
47
+ <script src="https://cdn.tracelog.io/v/1.0.0/tracelog.js"></script>
48
+ ```
49
+
50
+ or `npm install @tracelog/capture-web@1.0.0`. Both are immutable: the version
51
+ you pin is the bytes you get, for as long as they are served.
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,117 @@
1
+ # @tracelog/capture-web
2
+
3
+ The TraceLog browser capture runtime. It captures the conversion path a project
4
+ declares — each conversion and the steps preceding it — and nothing else.
5
+
6
+ TraceLog is Trustworthy Conversion Intelligence — conversion intelligence you
7
+ can verify: it verifies the conversion path a project declares against the
8
+ events TraceLog receives, watches every declared step every day, alerts when
9
+ events for one stop arriving and names the TraceLog figures that are
10
+ incomplete, and never makes up a number.
11
+ <https://tracelog.io>
12
+
13
+ ## Install
14
+
15
+ **Every integration names a version.** There is no `latest` on npm and no
16
+ `v/latest/` on the CDN, so the version you pin is the bytes you get, for as long
17
+ as they are served.
18
+
19
+ <!-- x-release-please-start-version -->
20
+
21
+ ```bash
22
+ npm install @tracelog/capture-web@1.0.0
23
+ ```
24
+
25
+ Without a build step, the same runtime as a script tag:
26
+
27
+ ```html
28
+ <script src="https://cdn.tracelog.io/v/1.0.0/tracelog.js"></script>
29
+ ```
30
+
31
+ <!-- x-release-please-end -->
32
+
33
+ One runtime, two forms: ESM with types for npm, and an IIFE on
34
+ `globalThis.TraceLog` for the script tag. Both are exercised on every browser of
35
+ the floor before a release.
36
+
37
+ ## Consent first
38
+
39
+ Before consent is granted the runtime creates no identifiers, writes no storage,
40
+ and sends no network traffic — none, not a reduced set. Consent is a state
41
+ machine you drive; until it reaches `granted`, capture is inert. Denying keeps it
42
+ inert without breaking the page.
43
+
44
+ ```js
45
+ import TraceLog from "@tracelog/capture-web";
46
+
47
+ TraceLog.init({
48
+ key: "tl_pk_…",
49
+ endpoint: "https://api.tracelog.io/v1/events",
50
+ });
51
+
52
+ // Only once your consent surface says yes:
53
+ TraceLog.consent.grant();
54
+ ```
55
+
56
+ A site that never calls `consent.grant()` captures nothing and costs its
57
+ visitors nothing.
58
+
59
+ ## The surface
60
+
61
+ That is all of it, and it is what the major version protects.
62
+
63
+ | Call | Does |
64
+ | --------------------------------- | ------------------------------------------------------------------ |
65
+ | `TraceLog.init(options)` | Configures the runtime. `key` is the project's public key. |
66
+ | `TraceLog.consent.grant()` | Allows capture. Queued delivery begins. |
67
+ | `TraceLog.consent.deny()` | Keeps the runtime inert. |
68
+ | `TraceLog.consent.state()` | `"unknown" \| "granted" \| "denied"`. |
69
+ | `TraceLog.step(name, context?)` | A declared step of the conversion path. |
70
+ | `TraceLog.conversion(name, opts)` | A declared conversion. `opts.identifier` is its stable identifier. |
71
+
72
+ `init` also accepts `mode: "verification"`, which a distributed platform artifact
73
+ declares for its platform's own test order. A site's own snippet never sets it —
74
+ the runtime derives verification mode from the window that opened the page.
75
+
76
+ Call `init` once per page load. The runtime is built on the first call and
77
+ kept; a later call re-reads the key and the endpoint and rebuilds nothing else,
78
+ so a mode or an acquisition the first call decided stands for the page.
79
+
80
+ The application generates the exact calls your declared plan needs, so you never
81
+ type a name TraceLog already knows.
82
+
83
+ ## What it captures
84
+
85
+ The events your tracking plan declares, with their context. Not page views, not
86
+ clicks, not scroll, not keystrokes. Errors are captured only when they occur
87
+ inside the conversion path, attached to the step where they happened.
88
+
89
+ Identity is first-party and per site: no cross-site tracking, no fingerprinting.
90
+ An IP address is read once when the event arrives to derive a two-letter country
91
+ code, then discarded.
92
+
93
+ Events queue locally once consent allows, batch, and deliver with retry, backoff
94
+ and circuit breaking. Delivery failure surfaces as a diagnosable condition,
95
+ never as silent loss.
96
+
97
+ ## Where it runs
98
+
99
+ Chrome ≥ 100, Edge ≥ 100, Firefox ≥ 100, Safari ≥ 15.4. A browser leaving that
100
+ floor is a major version, because a site that worked stops working for its
101
+ visitors.
102
+
103
+ ## Versions
104
+
105
+ The **major** changes when working code stops working: a method removed or
106
+ renamed on the `TraceLog` object, an argument that means something else, a new
107
+ required option, or an envelope the same release's ingestion no longer accepts.
108
+ A **minor** adds surface without moving what is there. A **patch** changes
109
+ behavior nobody wrote code against.
110
+
111
+ Pinning is only reasonable if moving is legible, so every version is in
112
+ [`CHANGELOG.md`](./CHANGELOG.md), which ships inside this package.
113
+
114
+ ## Licence
115
+
116
+ MIT. The bundle is self-contained — it resolves no `@tracelog/*` package at
117
+ runtime — so a GPL-licensed plugin may carry it.
@@ -0,0 +1,24 @@
1
+ export type ConsentState = "unknown" | "granted" | "denied";
2
+
3
+ export interface InitOptions {
4
+ key: string;
5
+ endpoint?: string;
6
+ /** Declared by a platform artifact for its platform's test order. */
7
+ mode?: "verification";
8
+ }
9
+
10
+ export interface ConversionOptions {
11
+ identifier: string;
12
+ value?: number;
13
+ currency?: string;
14
+ context?: object;
15
+ }
16
+
17
+ declare const TraceLog: {
18
+ init(options: InitOptions): void;
19
+ consent: { grant(): void; deny(): void; state(): ConsentState };
20
+ step(name: string, context?: object): void;
21
+ conversion(name: string, options: ConversionOptions): void;
22
+ };
23
+
24
+ export default TraceLog;