Skip to content

fix(gatsby): Remove plugin configuration docs #6246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 2 additions & 47 deletions src/platforms/javascript/guides/gatsby/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,7 @@ yarn add @sentry/gatsby

</Note>

## Connecting the SDK to Sentry

You can configure the SDK in one of two ways discussed below: by creating a configuration file, or defining the options along with the Gatsby configuration. If you define options in both places, the SDK will prioritize the `init` in the configuration file and ignore the options in the Gatsby configuration.

### Sentry Configuration File

<Note>

The minimum version supporting the Sentry configuration file is `6.14.0`.

</Note>

Using a Sentry configuration file is the approach we recommend since it supports defining non-serializable options in the `init`. Note that you still need to include the plugin, even if you don't set any options.
First add `@sentry/gatsby` as a plugin to your `gatsby-config.js`.

```javascript {filename:gatsby-config.js}
module.exports = {
Expand All @@ -46,7 +34,7 @@ module.exports = {
};
```

Configure your `Sentry.init`:
Then, configure your `Sentry.init`:

```javascript {filename:sentry.config.js}
import * as Sentry from "@sentry/gatsby";
Expand Down Expand Up @@ -83,36 +71,3 @@ Sentry.init({
// ...
});
```

### Gatsby Plugin Configuration

Another alternative is to use Gatsby's [plugin configuration options](https://www.gatsbyjs.com/docs/how-to/plugins-and-themes/using-a-plugin-in-your-site/#using-plugin-configuration-options). While this keeps the SDK options with the plugin definition, it doesn't support non-serializable options like `integrations`, `transport`, `stackParser`,`beforeSend`, `beforeSendTransaction`, and `tracesSampler`.

```javascript {filename:gatsby-config.js}
module.exports = {
plugins: [
{
resolve: "@sentry/gatsby",
options: {
dsn: "___PUBLIC_DSN___",
tracesSampleRate: 1.0, // Adjust this value in production
// Cannot set any non-serializable options
},
},
],
};
```

With this approach, the SDK sets some options automatically based on environmental variables, but these can be overridden by setting custom options.

`environment` (string)

: Defaults to `process.env.NODE_ENV` or `development`

`release` (string)

: Defaults to certain environment variables based on the platform

- GitHub Actions: `process.env.GITHUB_SHA`
- Netlify: `process.env.COMMIT_REF`
- Vercel: `process.env.VERCEL_GIT_COMMIT_SHA`