Skip to content

Commit 47ff386

Browse files
authored
Merge pull request #340 from backtrace-labs/aibrahim/BT-5870/addSessionReplayToBrowserSdkDocs
aibrahim/BT-5870/add-session-replay-to-browser-sdk-docs
2 parents 93a5266 + ff10944 commit 47ff386

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

packages/browser/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ easy, after which you can explore the rich set of Backtrace features.
1616
- [Attributes](#attributes)
1717
- [File Attachments](#file-attachments)
1818
- [Breadcrumbs](#breadcrumbs)
19+
- [Session Replay](#session-replay)
1920
- [Application Stability Metrics](#application-stability-metrics)
2021
- [Metrics Configuration](#metrics-configuration)
2122
- [Metrics Usage](#metrics-usage)
@@ -266,6 +267,62 @@ client.breadcrumbs?.info('This is a manual breadcrumb.', {
266267

267268
---
268269

270+
### Session Replay
271+
272+
The optional `@backtrace/session-replay` module allows you to capture and replay the user's interactions leading up to an error. This provides a video-like context for your error reports, making it much easier to reproduce and debug issues.
273+
274+
The Session Replay module is designed with privacy as a top priority. By default, it automatically masks all text and input fields to avoid capturing sensitive user data.
275+
276+
For full details on session replay configuration, sampling, and advanced privacy controls, please see the **[Session Replay Module Documentation](../session-replay/README.md)**.
277+
278+
#### 1. Install the additional package
279+
280+
In addition to `@backtrace/browser`, you will also need to install the session replay package.
281+
282+
```bash
283+
$ npm install @backtrace/session-replay
284+
```
285+
286+
#### 2. Add the module to the client
287+
288+
To enable session replay, you must use the BacktraceClient.builder() and add the BacktraceSessionReplayModule. This replaces the standard BacktraceClient.initialize().
289+
290+
```ts
291+
// Import the necessary modules
292+
import { BacktraceClient, BacktraceConfiguration } from '@backtrace/react';
293+
import { BacktraceSessionReplayModule } from '@backtrace/session-replay';
294+
295+
// Configure client options
296+
const options: BacktraceConfiguration = {
297+
name: 'MyWebPage',
298+
version: '1.2.3',
299+
url: 'https://submit.backtrace.io/<universe>/<token>/json',
300+
};
301+
302+
// Initialize the client using the builder to add the session replay module
303+
const client = BacktraceClient.builder(options)
304+
.useModule(
305+
new BacktraceSessionReplayModule({
306+
// Configuration for session replay goes here.
307+
maxEventCount: 100,
308+
privacy: {
309+
blockClass: 'do-not-send',
310+
},
311+
sampling: {
312+
input: 'last',
313+
}
314+
}),
315+
)
316+
.build();
317+
318+
// The client is now initialized with Session Replay enabled.
319+
// Any errors captured by the client or the ErrorBoundary will now include a session replay.
320+
```
321+
322+
When an error is captured, a link to the session replay will be available on the Debugger page for that specific error in the Backtrace UI.
323+
324+
---
325+
269326
### Application Stability Metrics
270327

271328
The Backtrace Browser SDK has the ability to send usage Metrics to be viewable in the Backtrace UI.

packages/react/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ after which you can explore the rich set of Backtrace features.
1717
- [Attributes](#attributes)
1818
- [File Attachments](#file-attachments)
1919
- [Breadcrumbs](#breadcrumbs)
20+
- [Session Replay](#session-replay)
2021
- [Application Stability Metrics](#application-stability-metrics)
2122
- [Metrics Configuration](#metrics-configuration)
2223
- [Metrics Usage](#metrics-usage)
@@ -295,6 +296,62 @@ client.breadcrumbs?.info('This is a manual breadcrumb.', {
295296

296297
---
297298

299+
### Session Replay
300+
301+
The optional `@backtrace/session-replay` module allows you to capture and replay the user's interactions leading up to an error. This provides a video-like context for your error reports, making it much easier to reproduce and debug issues.
302+
303+
The Session Replay module is designed with privacy as a top priority. By default, it automatically masks all text and input fields to avoid capturing sensitive user data.
304+
305+
For full details on session replay configuration, sampling, and advanced privacy controls, please see the **[Session Replay Module Documentation](../session-replay/README.md)**.
306+
307+
#### 1. Install the additional package
308+
309+
In addition to `@backtrace/react`, you will also need to install the session replay package.
310+
311+
```bash
312+
$ npm install @backtrace/session-replay
313+
```
314+
315+
#### 2. Add the module to the client
316+
317+
To enable session replay, you must use the BacktraceClient.builder() and add the BacktraceSessionReplayModule. This replaces the standard BacktraceClient.initialize().
318+
319+
```ts
320+
// Import the necessary modules
321+
import { BacktraceClient, BacktraceConfiguration } from '@backtrace/react';
322+
import { BacktraceSessionReplayModule } from '@backtrace/session-replay';
323+
324+
// Configure client options
325+
const options: BacktraceConfiguration = {
326+
name: 'MyWebPage',
327+
version: '1.2.3',
328+
url: 'https://submit.backtrace.io/<universe>/<token>/json',
329+
};
330+
331+
// Initialize the client using the builder to add the session replay module
332+
const client = BacktraceClient.builder(options)
333+
.useModule(
334+
new BacktraceSessionReplayModule({
335+
// Configuration for session replay goes here.
336+
maxEventCount: 100,
337+
privacy: {
338+
blockClass: 'do-not-send',
339+
},
340+
sampling: {
341+
input: 'last',
342+
}
343+
}),
344+
)
345+
.build();
346+
347+
// The client is now initialized with Session Replay enabled.
348+
// Any errors captured by the client or the ErrorBoundary will now include a session replay.
349+
```
350+
351+
When an error is captured, a link to the session replay will be available on the Debugger page for that specific error in the Backtrace UI.
352+
353+
---
354+
298355
### Application Stability Metrics
299356

300357
The Backtrace React SDK has the ability to send usage Metrics to be viewable in the Backtrace UI.

0 commit comments

Comments
 (0)