Skip to content

Commit b598e54

Browse files
authored
docs(replay): Update setup docs for replay (#6795)
1 parent 7f22f5d commit b598e54

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

packages/replay/README.md

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,14 @@
1414

1515
## Pre-requisites
1616

17-
For the sentry-replay integration to work, you must have the [Sentry browser SDK package](https://www.npmjs.com/package/@sentry/browser), or an equivalent framework SDK (e.g. [@sentry/react](https://www.npmjs.com/package/@sentry/react)) installed. The minimum version required for the SDK is `7.24.0`.
18-
19-
Make sure to use the exact same version of `@sentry/replay` as your other Sentry package(s), e.g. `@sentry/browser` or `@sentry/react`.
20-
2117
`@sentry/replay` requires Node 12+, and browsers newer than IE11.
2218

2319
## Installation
2420

25-
Install the Replay package with NPM or your favourite package manager. Alternatively, you can load the Replay integration via a [CDN bundle](#loading-replay-as-a-cdn-bundle).
26-
27-
with npm:
28-
29-
```shell
30-
npm install --save @sentry/browser @sentry/replay
31-
```
32-
33-
with yarn:
21+
Replay can be imported from `@sentry/browser`, or a respective SDK package like `@sentry/react` or `@sentry/vue`.
22+
You don't need to install anything in order to use Session Replay. The minimum version that includes Replay is 7.27.0.
3423

35-
```shell
36-
yarn add @sentry/browser @sentry/replay
37-
```
24+
For details on using Replay when using Sentry via the CDN bundles, see [CDN bundle](#loading-replay-as-a-cdn-bundle).
3825

3926
## Setup
4027

@@ -43,7 +30,7 @@ See the [configuration section](#configuration) below for more details.
4330

4431
```javascript
4532
import * as Sentry from '@sentry/browser';
46-
import { Replay } from '@sentry/replay';
33+
// or e.g. import * as Sentry from '@sentry/react';
4734

4835
Sentry.init({
4936
dsn: '__DSN__',
@@ -57,7 +44,7 @@ Sentry.init({
5744
replaysOnErrorSampleRate: 1.0,
5845

5946
integrations: [
60-
new Replay({
47+
new Sentry.Replay({
6148
// Additional SDK configuration goes in here, for example:
6249
maskAllText: true,
6350
blockAllMedia: true
@@ -68,6 +55,23 @@ Sentry.init({
6855
});
6956
```
7057

58+
### Lazy loading Replay
59+
60+
Replay will start automatically when you add the integration.
61+
If you do not want to start Replay immediately (e.g. if you want to lazy-load it),
62+
you can also use `addIntegration` to load it later:
63+
64+
```js
65+
Sentry.init({
66+
// Do not load it initially
67+
integrations: []
68+
});
69+
70+
// Sometime later
71+
const { Replay } = await import('@sentry/browser');
72+
getCurrentHub().getClient().addIntegration(new Replay());
73+
```
74+
7175
### Identifying Users
7276

7377
If you have only followed the above instructions to setup session replays, you will only see IP addresses in Sentry's UI. In order to associate a user identity to a session replay, use [`setUser`](https://docs.sentry.io/platforms/javascript/enriching-events/identify-user/).
@@ -77,16 +81,19 @@ import * as Sentry from "@sentry/browser";
7781
Sentry.setUser({ email: "[email protected]" });
7882
```
7983

80-
### Start and Stop Recording
84+
### Stopping & re-starting replays
8185

82-
Replay recording only starts automatically when it is included in the `integrations` key when calling `Sentry.init`. Otherwise you can initialize the plugin and manually call the `start()` method on the integration instance. To stop recording you can call the `stop()`.
86+
You can manually stop/re-start Replay capture via `.stop()` & `.start()`:
8387

84-
```javascript
85-
const replay = new Replay(); // This will *NOT* begin recording replays
86-
87-
replay.start(); // Start recording
88+
```js
89+
const replay = new Replay();
90+
Sentry.init({
91+
integrations: [replay]
92+
});
8893

89-
replay.stop(); // Stop recording
94+
// sometime later
95+
replay.stop();
96+
replay.start();
9097
```
9198

9299
## Loading Replay as a CDN Bundle

0 commit comments

Comments
 (0)