Skip to content

Commit 0d6f5b0

Browse files
dcramerPeloWriter
authored andcommitted
feat: Add example of how to sample rrweb (#2398)
Co-authored-by: Fiona <[email protected]>
1 parent 78c2e86 commit 0d6f5b0

File tree

1 file changed

+23
-0
lines changed
  • src/platforms/javascript/common/integrations

1 file changed

+23
-0
lines changed

src/platforms/javascript/common/integrations/rrweb.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,26 @@ For more information on configuration, see the [@sentry/rrweb project on GitHub]
4848
</markdown></Note>
4949

5050
Once a replay is captured with an event, you'll find it visible within Issue Details under the Replay section of the event.
51+
52+
## Sampling
53+
54+
To suit your organization's needs, you may prefer to sample replays. The easiest way to do this is to make the sampling decision when you initialize the Sentry SDK. For example, here's how Sentry itself uses sampling to capture these for only employees:
55+
56+
```javascript
57+
const hasReplays = getCurrentUser().isStaff;
58+
59+
let integrations = [];
60+
if (hasReplays) {
61+
console.log("[sentry] Instrumenting session with rrweb");
62+
integrations.push(new SentryRRWeb());
63+
}
64+
65+
Sentry.init({
66+
dsn: "___PUBLIC_DSN___",
67+
integrations,
68+
});
69+
70+
Sentry.setTag("rrweb.active", hasReplays ? "yes" : "no");
71+
```
72+
73+
You'll note we also set the `rrweb.active` tag, which helps us identify events that have a replay attached, since otherwise we'd not be able to find them. Once configured, you'll be able simply use `rrweb.active:yes` in your search queries.

0 commit comments

Comments
 (0)