You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Learn more about further configuration of the plugin using our [Sentry Webpack Plugin documentation](https://github.com/getsentry/sentry-webpack-plugin).
26
50
27
51
Additionally, you’ll need to configure the client to send the `release`:
Copy file name to clipboardExpand all lines: src/platforms/javascript/guides/gatsby/index.mdx
+56-17Lines changed: 56 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,47 +24,86 @@ yarn add @sentry/gatsby
24
24
25
25
## Connecting the SDK to Sentry
26
26
27
-
Register the plugin in your Gatsby configuration file (typically `gatsby-config.js`).
27
+
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.
28
+
29
+
### Sentry Configuration File
30
+
31
+
<Note>
32
+
33
+
The minimum version supporting the Sentry configuration file is `6.14.0`.
34
+
35
+
</Note>
36
+
37
+
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.
28
38
29
39
```javascript {filename:gatsby-config.js}
30
40
module.exports= {
31
-
// ...
32
41
plugins: [
33
42
{
34
43
resolve:"@sentry/gatsby",
35
-
options: {
36
-
dsn:"___PUBLIC_DSN___",
37
-
},
38
44
},
39
-
// ...
40
-
],
45
+
]
41
46
};
42
47
```
43
48
44
-
## Options
49
+
Configure your `Sentry.init`:
50
+
51
+
```javascript {filename:sentry.config.js}
52
+
import*asSentryfrom'@sentry/gatsby';
53
+
54
+
Sentry.init({
55
+
dsn:"___PUBLIC_DSN___",
56
+
sampleRate:1.0, // Adjust this value in production
57
+
beforeSend(event) {
58
+
// Modify the event here
59
+
if (event.user) {
60
+
// Don't send user's email address
61
+
deleteevent.user.email;
62
+
}
63
+
returnevent;
64
+
},
65
+
// ...
66
+
});
67
+
```
68
+
69
+
```typescript {filename:sentry.config.ts}
70
+
import*asSentryfrom'@sentry/gatsby';
71
+
72
+
Sentry.init({
73
+
dsn: "___PUBLIC_DSN___",
74
+
sampleRate: 1.0, // Adjust this value in production
75
+
beforeSend(event) {
76
+
// Modify the event here
77
+
if (event.user) {
78
+
// Don't send user's email address
79
+
deleteevent.user.email;
80
+
}
81
+
returnevent;
82
+
},
83
+
// ...
84
+
});
85
+
```
45
86
46
-
The options field in the plugin configuration is passed directly to `Sentry.init`. Check our configuration docs for a [full list of the available options](configuration/options/).
87
+
### Gatsby Plugin Configuration
47
88
48
-
For example, the configuration below adjusts the `sampleRate` and `maxBreadcrumbs` options.
89
+
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.
49
90
50
91
```javascript {filename:gatsby-config.js}
51
92
module.exports= {
52
-
// ...
53
-
plugins: [
54
93
{
55
94
resolve:"@sentry/gatsby",
56
95
options: {
57
96
dsn:"___PUBLIC_DSN___",
58
-
maxBreadcrumbs:80,
59
-
sampleRate:0.7,
97
+
sampleRate:1.0, // Adjust this value in production
98
+
// Cannot set `beforeSend`
60
99
},
61
100
},
62
-
// ...
63
-
],
101
+
102
+
]
64
103
};
65
104
```
66
105
67
-
The Gatsby SDK will set certain options automatically based on environmental variables, but these can be overridden by setting custom options in the plugin configuration.
106
+
With this approach, the SDK sets some options automatically based on environmental variables, but these can be overridden by setting custom options.
0 commit comments