Skip to content

Commit

Permalink
gatsby
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia committed Sep 19, 2023
1 parent 7bfaf24 commit fce4f85
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The Replay integration is **already included** with the Gatsby SDK package.

```bash {tabTitle: npm}
npm install --save @sentry/gatsby
```

```bash {tabTitle: Yarn}
yarn add @sentry/gatsby
```
45 changes: 45 additions & 0 deletions src/platform-includes/session-replay/setup/javascript.gatsby.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
```javascript
import * as Sentry from "@sentry/gatsby";

Sentry.init({
dsn: "___PUBLIC_DSN___",

// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,

// If the entire session is not sampled, use the below sample rate to sample
// sessions when an error occurs.
replaysOnErrorSampleRate: 1.0,

integrations: [
new Sentry.Replay({
// Additional SDK configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
],
});
```

With the settings above, session replays with errors are always captured.
You can verify that with the following:

```javascript
myUndefinedFunction();
```

### Lazy-loading Replay

Once you've added the integration, Replay will start automatically. If you don't want to start it immediately (lazy-load it), you can use `addIntegration`:

```js
Sentry.init({
// Note, Replay is NOT instantiated below:
integrations: [],
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/gatsby");
getCurrentHub().getClient().addIntegration(new Replay());
```

0 comments on commit fce4f85

Please sign in to comment.