6
6
7
7
# Official Sentry SDK for GatsbyJS
8
8
9
- Register the package as a plugin in ` gatsby-config.js ` :
9
+ First register the package as a plugin in ` gatsby-config.js ` :
10
10
11
11
``` javascript
12
12
module .exports = {
@@ -23,66 +23,32 @@ module.exports = {
23
23
};
24
24
```
25
25
26
- Options will be passed directly to ` Sentry.init ` . See all available options in
27
- [ our docs] ( https://docs.sentry.io/error-reporting/configuration/?platform=javascript ) . The ` environment ` value defaults
28
- to ` NODE_ENV ` (or ` 'development' ` if ` NODE_ENV ` is not set).
29
-
30
- ## GitHub Actions
31
-
32
- The ` release ` value is inferred from ` GITHUB_SHA ` .
33
-
34
- ## Netlify
35
-
36
- The ` release ` value is inferred from ` COMMIT_REF ` .
37
-
38
- ## Vercel
39
-
40
- To automatically capture the ` release ` value on Vercel you will need to register appropriate
41
- [ system environment variable] ( https://vercel.com/docs/v2/build-step#system-environment-variables ) (e.g.
42
- ` VERCEL_GITHUB_COMMIT_SHA ` ) in your project.
43
-
44
- ## Sentry Performance
45
-
46
- To enable tracing, supply either ` tracesSampleRate ` or ` tracesSampler ` to the options. This will turn on the
47
- ` BrowserTracing ` integration for automatic instrumentation of pageloads and navigations.
26
+ Then configure your ` Sentry.init ` call:
48
27
49
28
``` javascript
50
- module .exports = {
51
- // ...
52
- plugins: [
53
- {
54
- resolve: ' @sentry/gatsby' ,
55
- options: {
56
- dsn: process .env .SENTRY_DSN , // this is the default
29
+ import * as Sentry from ' @sentry/gatsby' ;
57
30
58
- // A rate of 1 means all traces will be sent, so it's good for testing.
59
- // In production, you'll likely want to either choose a lower rate or use `tracesSampler` instead (see below).
60
- tracesSampleRate : 1 ,
31
+ Sentry . init ({
32
+ dsn : ' __PUBLIC_DSN__ ' ,
33
+ integrations : [ Sentry . browserTracingIntegration (), Sentry . replayIntegration ()] ,
61
34
62
- // Alternatively:
63
- tracesSampler : samplingContext => {
64
- // Examine provided context data (along with anything in the global namespace) to decide the sample rate
65
- // for this transaction.
66
- // Can return 0 to drop the transaction entirely.
35
+ // Set tracesSampleRate to 1.0 to capture 100%
36
+ // of transactions for performance monitoring.
37
+ // We recommend adjusting this value in production
38
+ tracesSampleRate: 1.0 ,
67
39
68
- if (' ...' ) {
69
- return 0.5 ; // These are important - take a big sample
70
- } else if (' ...' ) {
71
- return 0.01 ; // These are less important or happen much more frequently - only take 1% of them
72
- } else if (' ...' ) {
73
- return 0 ; // These aren't something worth tracking - drop all transactions like this
74
- } else {
75
- return 0.1 ; // Default sample rate
76
- }
77
- },
78
- },
79
- },
80
- // ...
81
- ],
82
- };
40
+ // Capture Replay for 10% of all sessions,
41
+ // plus for 100% of sessions with an error
42
+ replaysSessionSampleRate: 0.1 ,
43
+ replaysOnErrorSampleRate: 1.0 ,
44
+
45
+ // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
46
+ tracePropagationTargets: [' localhost' , / ^ https:\/\/ yourserver\. io\/ api/ ],
47
+ });
83
48
```
84
49
85
- If you want to supply options to the ` BrowserTracing ` integration, use the ` browserTracingOptions ` parameter.
50
+ The Gatsby SDK also automatically sets up sourcemaps uploading for you. To disable this functionality, set the
51
+ ` enableClientWebpackPlugin ` option to be ` false ` .
86
52
87
53
``` javascript
88
54
module .exports = {
@@ -91,12 +57,7 @@ module.exports = {
91
57
{
92
58
resolve: ' @sentry/gatsby' ,
93
59
options: {
94
- dsn: process .env .SENTRY_DSN , // this is the default
95
- tracesSampleRate: 1 , // or tracesSampler (see above)
96
- browserTracingOptions: {
97
- // disable creating spans for XHR requests
98
- traceXHR: false ,
99
- },
60
+ enableClientWebpackPlugin: false ,
100
61
},
101
62
},
102
63
// ...
0 commit comments