@spectosh/browser 0.1.3 → 0.2.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Evigasoft and Specto contributors
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 CHANGED
@@ -2,29 +2,63 @@
2
2
 
3
3
  Specto's session-replay recorder for bundler users (npm/pnpm/yarn). Same
4
4
  engine as the script-tag snippet: rrweb DOM capture, console/network/error/
5
- rage signals, SPA navigations — with inputs masked and sensitive attributes
6
- scrubbed **in the visitor's browser** before anything is uploaded.
5
+ rage signals, SPA navigations — with inputs masked, sensitive attributes and
6
+ PII-looking text scrubbed **in the visitor's browser** before anything is
7
+ uploaded.
7
8
 
8
9
  ```bash
9
10
  npm i @spectosh/browser
10
11
  ```
11
12
 
12
13
  ```js
13
- import { startRecording } from '@spectosh/browser'
14
+ import { startRecording, identify, track } from '@spectosh/browser'
14
15
 
15
16
  const rec = startRecording({
16
17
  key: 'pk_your_key',
17
- endpoint: 'https://your-specto-host/api/ingest',
18
- privacy: 'strict', // optional: mask ALL text, not just inputs
18
+ endpoint: 'https://specto.sh/api/ingest', // or your self-hosted instance
19
+ privacy: 'strict', // optional: mask ALL text, not just inputs
20
+ sampleRate: 0.5, // optional: record half of all sessions
21
+ consent: 'required', // optional: record nothing until grantConsent()
19
22
  })
20
23
 
21
- // rec.sessionId, rec.count(), rec.flushNow(), rec.stop()
24
+ identify('user_42', { email: 'jane@acme.io', plan: 'pro' }) // find this user's sessions
25
+ track('checkout_started', { items: 3 }) // custom timeline event
26
+
27
+ rec.sessionId // current session id
28
+ rec.sessionUrl() // link to this replay in Specto (handy for support tools)
29
+ rec.stop()
22
30
  ```
23
31
 
24
- Do-Not-Track and Global Privacy Control are honored automatically. Use CSS
25
- classes `specto-mask` (mask text) and `specto-block` (drop element) for
26
- per-element control. Full docs live at `/docs` on your Specto instance.
32
+ ## Sessions
33
+
34
+ A session is one visitor's continuous activity. It survives page loads (it
35
+ lives in `sessionStorage`), ends after 30 minutes without interaction and
36
+ rotates after 4 hours. Batches are numbered, so retries after a network
37
+ failure, `429` or `503` never duplicate data; `quota_exceeded` stops
38
+ recording, and a full DOM checkpoint is taken every 5 minutes so a lost batch
39
+ never ruins the rest of a replay.
40
+
41
+ ## Privacy & consent
42
+
43
+ - Inputs are always masked; `privacy: 'strict'` masks all text, drops
44
+ console text and keeps only the path of recorded URLs (requests,
45
+ navigations, the page address: no query strings, no hash-route parameters). CSS classes `specto-mask` (mask text) and `specto-block` (drop
46
+ element) give per-element control.
47
+ - Heatmap events carry a click's page position, the viewport width and a
48
+ selector built from tag, id and classes — never text — plus how far each
49
+ page view scrolled.
50
+ - `data-*`, `title`, `alt`, `placeholder`, `aria-label` and `value`
51
+ attributes are scrubbed; emails, JWTs, bearer tokens, API keys and
52
+ card-like numbers are redacted from console lines, error messages and URLs.
53
+ - Do-Not-Track and Global Privacy Control are honored automatically.
54
+ - `consent: 'required'` records and stores nothing until `grantConsent()`;
55
+ `revokeConsent()`, `optOut()` and `optIn()` are exported too.
56
+ - The project's settings in Specto (strict privacy, console, network details,
57
+ sampling, a recording kill switch) are fetched at start; the stricter of
58
+ those and your options always wins.
59
+
60
+ Full docs live at `/docs` on your Specto instance.
27
61
 
28
62
  Build from the monorepo: `pnpm run build:npm` (outputs `packages/browser/dist`,
29
63
  ESM + CJS, worker inlined). Releases go out via `pnpm run release` locally or
30
- the tag-triggered workflow (`.github/workflows/release.yml`) — both publish to npm.
64
+ the tag-triggered workflow (`.github/workflows/release.yml`).