@spotify-confidence/session-recording 0.0.0 → 0.17.2

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,36 @@
1
+ # Changelog
2
+
3
+ ## [0.17.2](https://github.com/spotify/confidence-sdk-js/compare/session-recording-v0.17.1...session-recording-v0.17.2) (2026-06-15)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * improve csr package READMEs ([#367](https://github.com/spotify/confidence-sdk-js/issues/367)) ([3c5a254](https://github.com/spotify/confidence-sdk-js/commit/3c5a254b6b7bd23142ffe7ce6d99f327e67ff478))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @spotify-confidence/csr-common bumped to 0.17.2
16
+ * @spotify-confidence/csr-recorder bumped to 0.17.2
17
+
18
+ ## [0.17.1](https://github.com/spotify/confidence-sdk-js/compare/session-recording-v0.17.0...session-recording-v0.17.1) (2026-06-15)
19
+
20
+
21
+ ### 🐛 Bug Fixes
22
+
23
+ * add csr packages to release-please ([#363](https://github.com/spotify/confidence-sdk-js/issues/363)) ([f868e03](https://github.com/spotify/confidence-sdk-js/commit/f868e036ee27fcdd26ee26c8a47d2466a47e2a60))
24
+
25
+
26
+ ### ✨ New Features
27
+
28
+ * add session recording packages ([#360](https://github.com/spotify/confidence-sdk-js/issues/360)) ([4584f50](https://github.com/spotify/confidence-sdk-js/commit/4584f502f17d01a15390789519c99308797a513d))
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * The following workspace dependencies were updated
34
+ * dependencies
35
+ * @spotify-confidence/csr-common bumped to 0.17.1
36
+ * @spotify-confidence/csr-recorder bumped to 0.17.1
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # @spotify-confidence/session-recording
2
+
3
+ ![](https://img.shields.io/badge/lifecycle-beta-a0c3d2.svg)
4
+
5
+ Browser SDK for recording user sessions with [Confidence](https://confidence.spotify.com). Captures DOM events in real time and streams them to the Confidence backend for analysis.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @spotify-confidence/session-recording
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```typescript
16
+ import { initSessionRecorder } from '@spotify-confidence/session-recording';
17
+
18
+ const recorder = initSessionRecorder({
19
+ clientSecret: '<your-client-secret>',
20
+ });
21
+ ```
22
+
23
+ That's it. In `automatic` mode (the default), recording begins as soon as a session is established with the backend. The SDK handles sampling, transport, and reconnection automatically.
24
+
25
+ ## Privacy: masking and blocking
26
+
27
+ The SDK provides two mechanisms to prevent sensitive content from being captured:
28
+
29
+ **Masking** replaces text content with `•` characters while preserving the layout. The element is still visible in the replay, but the actual text is never sent to the backend.
30
+
31
+ ```typescript
32
+ const recorder = initSessionRecorder({
33
+ clientSecret: '<your-client-secret>',
34
+ maskSelectors: ['.pii', '[data-sensitive]'],
35
+ maskInputs: true, // mask all <input>, <textarea>, and contenteditable values (default: true)
36
+ });
37
+ ```
38
+
39
+ **Blocking** replaces entire subtrees with an empty placeholder. The blocked element's dimensions are preserved, but nothing inside it — text, images, child nodes — is serialized or sent.
40
+
41
+ ```typescript
42
+ const recorder = initSessionRecorder({
43
+ clientSecret: '<your-client-secret>',
44
+ blockSelectors: ['video', '.third-party-widget', '[data-block]'],
45
+ });
46
+ ```
47
+
48
+ `maskInputs` defaults to `true` — all input values are masked unless you explicitly opt out.
49
+
50
+ ## Context
51
+
52
+ Context lets you attach custom dimensions to the recording session. These are sent alongside the auto-collected browser metadata (user agent, OS, viewport, language, timezone) in the session init request. Context serves two purposes: it helps you find and filter recordings later, and the backend uses it to target recordings to specific cohorts of your user population (e.g. only record premium users, or users on a specific build version).
53
+
54
+ ```typescript
55
+ const recorder = initSessionRecorder({
56
+ clientSecret: '<your-client-secret>',
57
+ targetingKey: 'user-42',
58
+ context: {
59
+ buildVersion: '2.3.1',
60
+ environment: 'production',
61
+ plan: 'premium',
62
+ featureFlags: 'new-checkout-enabled',
63
+ },
64
+ });
65
+ ```
66
+
67
+ `targetingKey` is the end-user identifier (visitor ID, device ID, etc.). The backend uses it for sampling and targeting decisions — it determines whether this user should be recorded.
68
+
69
+ ## Configuration
70
+
71
+ ```typescript
72
+ const recorder = initSessionRecorder({
73
+ // Required
74
+ clientSecret: '<your-client-secret>',
75
+
76
+ // Identity and context
77
+ targetingKey: 'user-42',
78
+ context: { buildVersion: '2.3.1' },
79
+
80
+ // Privacy
81
+ maskSelectors: ['.pii'],
82
+ blockSelectors: ['video'],
83
+ maskInputs: true, // default: true
84
+
85
+ // Capture options
86
+ captureConsoleLogs: true, // capture browser console output (default: false)
87
+ captureNetworkRequests: false, // capture fetch/XHR metadata (default: false)
88
+ captureRouteChanges: true, // capture client-side route changes (default: true)
89
+
90
+ // Recording mode
91
+ mode: 'automatic', // 'automatic' (default) or 'manual'
92
+ });
93
+ ```
94
+
95
+ ## Manual mode
96
+
97
+ Use `manual` mode to control when recording starts — useful for gating on user consent or feature flags.
98
+
99
+ ```typescript
100
+ const recorder = initSessionRecorder({
101
+ clientSecret: '<your-client-secret>',
102
+ mode: 'manual',
103
+ });
104
+
105
+ // Later, when ready:
106
+ recorder.start();
107
+ ```
108
+
109
+ ## Custom tags and measurements
110
+
111
+ Attach metadata to a recording for filtering and analysis.
112
+
113
+ ```typescript
114
+ recorder.tag('plan', 'premium');
115
+ recorder.measure('checkout_items', 3);
116
+ ```
117
+
118
+ ## API
119
+
120
+ ### `initSessionRecorder(options): SessionRecorder`
121
+
122
+ Creates a session recorder. Always returns a `SessionRecorder` — safe to call, never throws.
123
+
124
+ ### `SessionRecorder`
125
+
126
+ | Method | Description |
127
+ | ---------------------- | -------------------------------------------------------------- |
128
+ | `start()` | Start recording. No-op in automatic mode. |
129
+ | `stop()` | Stop recording permanently. Idempotent. |
130
+ | `tag(key, value?)` | Attach a string tag. Tags with the same key accumulate values. |
131
+ | `measure(key, value?)` | Record a numeric measurement. Same key = summed. |
132
+ | `isRecording` | Whether the recorder is actively capturing events. |
133
+
134
+ ## License
135
+
136
+ Apache 2.0 — see [LICENSE](../../LICENSE).