Skip to content

Commit

Permalink
fix(Sentry): Get sentry sampling traces rate from env
Browse files Browse the repository at this point in the history
  • Loading branch information
qgerome committed Oct 7, 2022
1 parent 6bc63d1 commit 718074d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,6 @@ The following environment variables should be provided at build time (for the `d
The following environment variables should be provided at run time:
- `FALLBACK_URL`: the URL the traffic will be redirected to if NextJS cannot answer the request
- `GRAPHQL_ENDPOINT`: the URL of the OpenHexa GraphQL API
- `SENTRY_TRACES_SAMPLE_RATE`: the [Sentry](https://sentry.io/) sampling rate of traces
- `SENTRY_DSN`: the [Sentry](https://sentry.io/) DSN
- `SENTRY_ENVIRONMENT`: the [Sentry](https://sentry.io/) environment tag
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const { i18n } = require("./next-i18next.config");
const config = {
publicRuntimeConfig: {
GRAPHQL_ENDPOINT: process.env.GRAPHQL_ENDPOINT,
SENTRY_TRACES_SAMPLE_RATE: process.env.SENTRY_TRACES_SAMPLE_RATE
? parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE)
: 1,
SENTRY_DSN: process.env.SENTRY_DSN,
SENTRY_ENVIRONMENT: process.env.SENTRY_ENVIRONMENT,
},
Expand Down
2 changes: 1 addition & 1 deletion sentry.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Sentry.init({
if (context.location?.pathname === "/ready") {
return 0;
}
return 0.005;
return publicRuntimeConfig.SENTRY_TRACES_SAMPLE_RATE;
},
// ...
// Note: if you want to override the automatic release value, do not set a
Expand Down
2 changes: 1 addition & 1 deletion sentry.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (config) {
if (context.location?.pathname === "/ready") {
return 0;
}
return 0.005;
return publicRuntimeConfig.SENTRY_TRACES_SAMPLE_RATE;
},
// ...
// Note: if you want to override the automatic release value, do not set a
Expand Down

0 comments on commit 718074d

Please sign in to comment.