ionblink-js 0.1.2 → 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/CHANGELOG.md CHANGED
@@ -1,9 +1,84 @@
1
1
  # Changelog: ionblink-js
2
2
 
3
- ## 0.1.2 - Unreleased
3
+ ## 0.1.6 - Unreleased
4
4
 
5
- Visitors who leave in the first seconds are no longer lost. Served from `cdn.ionblink.com/sdk/0.1.2` (2026-12-02);
6
- not on npm yet. No change to the wire format or the events sent.
5
+ The first version published by CI (npm trusted publishing), with npm provenance; npm and the CDN serve the same bytes
6
+ again. No change to what the SDK sends.
7
+
8
+ - Consent, sampling and the remote config's guards come from `packages/shared` (`consent.ts`), shared with
9
+ ionblink-react-native. The core's code is the same, in a different order (same size), so it needs its own version.
10
+
11
+ ## 0.1.5 - 2026-12-02
12
+
13
+ Capture gaps from the 2026-12-02 capture audit (what PostHog records that IonBlink didn't), all in the extras chunk
14
+ (8,129 -> 8,187 bytes brotli, +58, inside its 8 KB budget with 5 to spare; the core changes only by the chunk's new
15
+ name and integrity, 11,026 -> 11,022). On the CDN only (cdn.ionblink.com/sdk/0.1.5): npm goes from 0.1.2 to 0.1.6.
16
+
17
+ - A choice made in a form sends `$field` with `action: "change"`: a select, checkbox or radio, from the `input` event
18
+ the core already forwards. It says which control (type, label, name), never what was chosen. PostHog's autocapture
19
+ records these; IonBlink saw only focus and blur.
20
+ - `$vitals` carries `lcp_el`, the largest paint's element as a short selector (the same one as a click's `sel`), so a
21
+ slow-page fix can name what was slow. It was a number only.
22
+ - `$signals` carries the page's `scroll_pct` and `engaged_ms`, as `$page_leave` has them. A page hidden for good
23
+ without a pagehide (Facebook's and Instagram's in-app browsers, a tab the phone kills) sends no `$page_leave`, so its
24
+ depth and engaged time were lost: on one site, 81 leaves for 140 pages.
25
+
26
+ ## 0.1.4 - 2026-12-02
27
+
28
+ Fixes from the 2026-12-02 audit of IonBlink against PostHog and the live page. On the CDN only
29
+ (cdn.ionblink.com/sdk/0.1.4): npm goes from 0.1.2 to 0.1.6.
30
+
31
+ - Batches cut while the page is hidden carry `hidden: true` (PROTOCOL.md): mobile Safari and Chrome often hide a tab
32
+ and then freeze or kill it without a `pagehide`, so the server can end that session minutes later instead of after
33
+ 30 idle minutes. What the page captures while hidden (such as an event from its own hide handler, which runs after
34
+ the SDK's) goes at once by beacon instead of waiting for a 5 s timer a phone may never run: one site's engagement
35
+ event was lost in 6 of 51 sessions that way.
36
+ - A report-only Content-Security-Policy violation is no longer recorded as an error or warned about as a block (only
37
+ an enforced policy blocks anything).
38
+
39
+ - PostHog's markers hide in IonBlink too: class `ph-no-capture` and `data-testid="ph-no-capture"` block an element in
40
+ replay (and `ph-no-capture` stops autocapture inside it); `data-ph-mask`, class `ph-mask` and class `ph-sensitive`
41
+ mask its text and attributes. A site with both tools used to show IonBlink controls' labels and images inside regions
42
+ it had hidden from PostHog only.
43
+ - Images whose file name carries a build's content hash load in the player again: `wave.a9a981030fa052f3d366b65f41052068.webp`
44
+ (Expo web) and `christmas-in-london-614a30287eb2.webp` kept their path, where the scrubber took the hash for a token
45
+ (or `Q12345678-7daf…` for a phone number) and redacted the segment. Tokens, UUIDs and emails in image paths are
46
+ still redacted.
47
+ - A full snapshot stays under ingest's 2 MB cap when a browser extension injects megabytes of inlined fonts and images:
48
+ in an inlined stylesheet over 1 MB, each base64 `data:` URI over 32 KB becomes `data:,`. The Readwise highlighter's
49
+ shadow root (3 MB of CSS) made every snapshot about 2.05 MB gzipped, on any site its user visited; one went past the
50
+ cap, was refused (413) and its page couldn't play. Now about 220 KB. Smaller stylesheets keep every data URI.
51
+
52
+ ## 0.1.3 - 2026-12-02
53
+
54
+ Console and network in replays, off by default. On the CDN only (cdn.ionblink.com/sdk/0.1.3): npm goes from 0.1.2 to
55
+ 0.1.6.
56
+
57
+ - When a site's owner turns them on in IonBlink (remote config `replay.console`, `replay.network`), recorded sessions
58
+ also carry the page's console lines (`log`, `info`, `warn`, `error`, uncaught errors, unhandled rejections) as
59
+ `rrweb/console@1` plugin events, and its fetch and XHR requests (method, URL without its query and fragment, status,
60
+ start, duration, transfer size, initiator type, phases from resource timing; never headers or bodies) as
61
+ `rrweb/network@1` plugin events, on the replay lane (PROTOCOL.md, "Console and network").
62
+ - Console lines are masked like page text (values under secret-named keys starred; emails, card and phone numbers,
63
+ IBANs, SSNs, JWTs, API keys and long tokens scrubbed), cut to 2,000 characters, and limited to 1,000 lines a page at
64
+ 20 a second after a burst of 100; requests to 1,000 a page. The SDK's own requests and lines are never recorded.
65
+ - `replay: { console: false }` and `replay: { network: false }` refuse either whatever the site says;
66
+ `replay: { network: { keepParams: ['page'] } }` keeps named query parameters (values scrubbed).
67
+ - The capture code is its own lazy chunk (`i-<hash>.js` on the CDN, 3.42 KB brotli; a dynamic import in the npm build),
68
+ loaded by the replay chunk only for a recording the site turned it on for; its name and integrity live in the replay
69
+ chunk. The core grows 21 bytes brotli (the two config keys; budget 10.75 -> 10.77 KB).
70
+ - From the 2026-12-01 security review of the capture: `Authorization`, `sid`, CSRF and signature keys are starred, and a
71
+ credential after `Bearer`/`Basic` in a string; every string is masked raw, before it is cut or JSON-escaped; URLs in
72
+ a line lose their query and fragment; only plain objects and arrays are opened (a React event, Location or a store is
73
+ its class name, a typed array its length); the `text` mask level stars console text; a reused XHR gets its listeners
74
+ once; the buffer of earlier requests is read only on the landing page and only when the recording didn't wait for
75
+ consent; the SDK's own batches are recognised whatever the key looks like; an unhandled fetch failure still reaches
76
+ the page's `unhandledrejection`; a later config that turns capture off stops it on the page.
77
+
78
+ ## 0.1.2 - 2026-12-02
79
+
80
+ Visitors who leave in the first seconds are no longer lost. Served from `cdn.ionblink.com/sdk/0.1.2` (2026-12-02); the
81
+ first version on npm (2026-12-02). No change to the wire format or the events sent.
7
82
 
8
83
  - The page's first batch (its `$page`) goes as soon as the SDK boots instead of after the 5 s cadence, so a visit that
9
84
  ends in a second still starts a session. A first visit's batch still waits for the config answer (the region may ask
@@ -14,10 +89,10 @@ not on npm yet. No change to the wire format or the events sent.
14
89
  - A beacon round sends the events batches before the replay chunks, so a replay chunk can't use up the browser's 64 KB
15
90
  keepalive quota first.
16
91
 
17
- ## 0.1.1 - Unreleased
92
+ ## 0.1.1 - CDN only
18
93
 
19
- First npm release. 0.1.0 was served from `cdn.ionblink.com` only (2026-12-01) and lacks `headers()` and
20
- `proxy()`'s country forwarding; its URL keeps working.
94
+ Served from `cdn.ionblink.com` only; npm starts at 0.1.2. 0.1.0 (2026-12-01) was CDN-only too and lacks `headers()`
95
+ and `proxy()`'s country forwarding; its URL keeps working.
21
96
 
22
97
  First public release.
23
98
 
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # ionblink-js
2
2
 
3
3
  IonBlink for the browser: product analytics built for agents. Page views, autocapture, agent signals, and masked
4
- session replay that loads only when a session is recorded. The core is 10.6 KB brotli, starts when the browser is
4
+ session replay that loads only when a session is recorded. The core is 10.8 KB brotli, starts when the browser is
5
5
  idle, sets no cookies and never throws into your page.
6
6
 
7
- > Not on npm yet: the first release waits for a security review. IonBlink serves this package's CDN build at
8
- > `https://cdn.ionblink.com/sdk/v1.js`.
7
+ > IonBlink serves this package's CDN build at `https://cdn.ionblink.com/sdk/v1.js`, which always loads the current
8
+ > release. npm installs update when you bump the package.
9
9
 
10
10
  ## Quickstart
11
11
 
@@ -28,27 +28,30 @@ splits out the two lazy chunks (extras, and replay with rrweb). For React and Ne
28
28
  ### Script tag (one line, no build step)
29
29
 
30
30
  ```html
31
- <script src="https://cdn.ionblink.com/sdk/v1.js" data-key="ib_pk_…" async></script>
31
+ <script src="https://cdn.ionblink.com/sdk/v1.js" crossorigin="anonymous" data-key="ib_pk_…" async></script>
32
32
  ```
33
33
 
34
34
  Attributes: `data-key` (required), `data-api-host` (a first-party proxy), `data-mode` (`basic`, `full`, `replay`),
35
35
  `data-require-consent` (treat every visitor as opt-in until `consent()`). The global is `window.ionblink`.
36
- `/sdk/v1.js` is the moving "latest 1.x" file: cached for 5 minutes, then revalidated in the background.
36
+ `/sdk/v1.js` always serves the current release, so your site gets fixes with no change: cached for 5 minutes, then
37
+ revalidated in the background. It has no `integrity` because it moves; the chunks it loads are checked against their
38
+ own integrity hashes.
37
39
  `cdn.ionblink.com` serves static files from Cloudflare's edge, brotli or gzip, and never sets or reads a cookie.
38
40
 
39
- ### Pinned version with Subresource Integrity
41
+ ### Pinned version with Subresource Integrity (the strict option)
40
42
 
41
- Each release has a URL that never changes, cached for a year. The core then loads its two chunks from the same folder,
42
- each with its own integrity hash built in:
43
+ For a Content-Security-Policy or SRI policy that wants an `integrity` hash on every script, or to hold a version. Each
44
+ release has a URL that never changes, cached for a year; it updates only when you change it. The core then loads its
45
+ lazy chunks from the same folder, each with its own integrity hash built in:
43
46
 
44
47
  ```html
45
- <script src="https://cdn.ionblink.com/sdk/0.1.2/ionblink.min.js"
48
+ <script src="https://cdn.ionblink.com/sdk/0.1.6/ionblink.min.js"
46
49
  integrity="sha384-…" crossorigin="anonymous" data-key="ib_pk_…" async></script>
47
50
  ```
48
51
 
49
52
  The `integrity` value for each release is in `dist/integrity.json` of the package (and in the release notes). Every
50
53
  npm release is also on jsDelivr and unpkg with no extra step, for example
51
- `https://cdn.jsdelivr.net/npm/ionblink-js@0.1.2/dist/v1.js` (same bytes, same integrity). Batches still go to
54
+ `https://cdn.jsdelivr.net/npm/ionblink-js@0.1.6/dist/v1.js` (same bytes, same integrity). Batches still go to
52
55
  `https://api.ionblink.com` (or your `data-api-host`).
53
56
 
54
57
  ### Inline snippet (call the API before the SDK loads)
@@ -95,8 +98,24 @@ Route changes are page views on their own. Add the `/ib` route with `ionblinkRou
95
98
 
96
99
  Options: `apiHost`, `mode` (the most this site captures, default `replay`), `requireConsent`, `mask`, `storage`
97
100
  (`local` default, `cookie` with `cookieDomain` for subdomains, `memory`), `pages`, `autocapture` (or per family:
98
- `clicks`, `forms`, `errors`, `vitals`, `signals`), `replay: { sample, maskSelectors, blockSelectors, blockPaths }`,
99
- `keepQuery`, `app: { version, build }`, `debug`, `beforeSend`. See `src/types.ts`.
101
+ `clicks`, `forms`, `errors`, `vitals`, `signals`), `replay: { sample, maskSelectors, blockSelectors, blockPaths,
102
+ console, network }`, `keepQuery`, `app: { version, build }`, `debug`, `beforeSend`. See `src/types.ts`.
103
+
104
+ **Console and network in replays.** When a site's owner turns them on in IonBlink (Settings, Sites), recorded sessions
105
+ also carry the page's console lines (`log`, `info`, `warn`, `error`, uncaught errors and unhandled rejections) and its
106
+ fetch and XHR requests (method, URL without its query and fragment, status, timings and size; never headers or bodies),
107
+ shown beside the replay. Both are off by default and load a small chunk only when on. Console lines are masked like
108
+ page text (secret-named keys and `Authorization` values starred, emails, cards and tokens scrubbed, URLs without their
109
+ query; all text starred at the `text` mask level), only plain objects and arrays are opened, and a line is cut to 2,000
110
+ characters. Your code can refuse either whatever the site says, or keep named query parameters in request URLs:
111
+
112
+ ```js
113
+ ionblink.init('ib_pk_…', { replay: { console: false, network: { keepParams: ['page'] } } })
114
+ ```
115
+
116
+ Console capture wraps `console.log`, `info`, `warn` and `error`, so DevTools shows those lines as coming from the SDK's
117
+ file; network capture wraps `fetch` (it hands back a promise that settles as fetch's did) and `XMLHttpRequest`. The
118
+ format is in [PROTOCOL.md](../../PROTOCOL.md#console-and-network).
100
119
 
101
120
  **Sent for you:** page views (SPA navigations included), page leave with engaged time and scroll depth, clicks with a
102
121
  masked target, rage clicks (3 in 1 s within 30 px), dead clicks, field focus and form submits (never values), JS
@@ -145,6 +164,9 @@ can carry out the withdrawal. The choice is kept for 6 months.
145
164
  included; `data-ib-unmask` keeps a control's label at `controls`; `data-ib-block` (or `ib-block`) replaces an
146
165
  element with a placeholder in replay and stops autocapture inside it; `data-ib-no-capture` stops autocapture only;
147
166
  `data-ib-name="checkout"` names a target.
167
+ - PostHog's markers work too, so a page moving from PostHog keeps hiding what it hid: class `ph-no-capture` (and
168
+ `data-testid="ph-no-capture"`, React Native Web's `testID`) blocks like `data-ib-block`; `data-ph-mask`, class
169
+ `ph-mask` and class `ph-sensitive` mask like `data-ib-mask`.
148
170
  - Attributes in replay: `data-*` values are masked like text (a short lowercase word such as `open` or `dark` stays,
149
171
  so styles keep working), `<meta content>` is masked (CSRF tokens, keys) except `viewport`, `theme-color` and
150
172
  `color-scheme`, a cross-origin iframe's URL is masked like a link, and inline handlers, `nonce` and `srcdoc` are
@@ -184,9 +206,10 @@ which IonBlink needs for rate limits and the consent rule.
184
206
 
185
207
  | File | brotli | gzip | Loads |
186
208
  |---|---|---|---|
187
- | `v1.js` (core) | 10.66 KB | 11.72 KB | always, `async` |
188
- | `x-<hash>.js` (signals, autocapture, vitals, offline queue, the replay controller) | 7.88 KB | 8.68 KB | when the core boots (idle) |
189
- | `r-<hash>.js` (rrweb, masking, chunking) | 22.37 KB | 25.12 KB | only when this session is recorded, after the page's `load` event, at idle |
209
+ | `v1.js` (core) | 10.76 KB | 11.82 KB | always, `async` |
210
+ | `x-<hash>.js` (signals, autocapture, vitals, offline queue, the replay controller) | 7.91 KB | 8.76 KB | when the core boots (idle) |
211
+ | `r-<hash>.js` (rrweb, masking, chunking) | 22.87 KB | 25.67 KB | only when this session is recorded, after the page's `load` event, at idle |
212
+ | `i-<hash>.js` (console and network capture) | 3.42 KB | 3.78 KB | loaded by the replay chunk, only when the site turned console or network capture on |
190
213
  | snippet | 0.28 KB | 0.34 KB | inline |
191
214
 
192
215
  CI fails when a file outgrows its budget (`scripts/size.ts`). How it stays out of your page's way:
@@ -198,8 +221,8 @@ CI fails when a file outgrows its budget (`scripts/size.ts`). How it stays out o
198
221
  handler, and nothing else reads layout while the page scrolls or the pointer moves.
199
222
  - The page view goes as soon as the SDK boots; then events go out every 5 s or at 20 events, replay every 10 s, at
200
223
  most one request in flight per lane, each request gzipped (`CompressionStream`) when over 1 KB and at most 60 KB.
201
- Requests use `fetch` with `keepalive`; when the page is hidden or left, what is left goes by `sendBeacon`. No
202
- synchronous XHR, ever.
224
+ Requests use `fetch` with `keepalive`; when the page is hidden or left, what is left goes by `sendBeacon`, and so
225
+ does anything captured while it stays hidden, without waiting for the 5 s cadence. No synchronous XHR, ever.
203
226
  - Failed requests back off exponentially (2 s to 5 min, with jitter, honouring `Retry-After`). Offline, nothing is
204
227
  tried until the browser is back online; batches wait in IndexedDB for the next page if they must.
205
228
  - Every SDK task is timed and reported in `perf` (total main-thread ms, longest task, tasks over 4 and 50 ms), so the