Skip to content
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

Sentry cloudflare #4487

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions functions/_common/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface Env {
CLOUDFLARE_IMAGES_API_KEY: string
CLOUDFLARE_IMAGES_URL: string
ENV: string
SENTRY_DSN: string
}
// We collect the possible extensions here so we can easily take them into account
// when handling redirects
Expand Down
11 changes: 11 additions & 0 deletions functions/_middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as Sentry from "@sentry/cloudflare"
import { Env } from "./_common/env.js"

export const onRequest = [
// Make sure Sentry is the first middleware.
Sentry.sentryPagesPlugin<Env>((context) => ({
dsn: context.env.SENTRY_DSN,
environment: context.env.ENV,
tracesSampleRate: 0.01,
})),
]
1 change: 1 addition & 0 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"@ourworldindata/grapher": "workspace:^",
"@ourworldindata/types": "workspace:^",
"@ourworldindata/utils": "workspace:^",
"@sentry/cloudflare": "^8.51.0",
"itty-router": "^5.0.17",
"littlezipper": "^0.1.4",
"stripe": "^14.20.0",
Expand Down
8 changes: 7 additions & 1 deletion wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Generated by Wrangler on Mon Aug 05 2024 16:52:18 GMT+0000 (GMT)
name = "owid"
compatibility_date = "2024-11-11"
# Sentry client needs the `nodejs_als` (AsyncLocalStorage) API.
# https://docs.sentry.io/platforms/javascript/guides/cloudflare/#configure
compatibility_flags = ["nodejs_als"]
# NOTE (Martin): As of 2025-01-24, the bundle exceeded the uncompressed size
# limit of 25 MiB if we include the source maps, so we disable them for now.
# upload_source_maps = true # To get source maps in Sentry.
pages_build_output_dir = "./localBake"

# Vars that should be available in all envs, including local dev
Expand All @@ -15,7 +21,7 @@ GRAPHER_CONFIG_R2_BUCKET_FALLBACK_PATH = "v1"
[env.preview.vars]
MAILGUN_DOMAIN = "mg.ourworldindata.org"
SLACK_ERROR_CHANNEL_ID = "C016H0BNNB1"
ENV = "preview"
ENV = "staging"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with other ENV settings.

GRAPHER_CONFIG_R2_BUCKET_URL = "https://grapher-configs-staging.owid.io"
GRAPHER_CONFIG_R2_BUCKET_FALLBACK_URL = "https://grapher-configs.owid.io"
GRAPHER_CONFIG_R2_BUCKET_FALLBACK_PATH = "v1"
Expand Down
28 changes: 28 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,13 @@ __metadata:
languageName: node
linkType: hard

"@cloudflare/workers-types@npm:^4.x":
version: 4.20250121.0
resolution: "@cloudflare/workers-types@npm:4.20250121.0"
checksum: 10/4f7800e8f82b91f93745c2ad9f1223173dc7584d9efa1c28185bb6a64daf4ba2cd693aee2be94cb800441fd06b75f08be2ea5afbce3eb39b9b76a9794e8a24a2
languageName: node
linkType: hard

"@colors/colors@npm:1.5.0":
version: 1.5.0
resolution: "@colors/colors@npm:1.5.0"
Expand Down Expand Up @@ -4515,13 +4522,33 @@ __metadata:
languageName: node
linkType: hard

"@sentry/cloudflare@npm:^8.51.0":
version: 8.51.0
resolution: "@sentry/cloudflare@npm:8.51.0"
dependencies:
"@cloudflare/workers-types": "npm:^4.x"
"@sentry/core": "npm:8.51.0"
dependenciesMeta:
"@cloudflare/workers-types":
optional: true
checksum: 10/e3713886e07ebb65da6612fe288899e4473e760577953f338d404a9d4c1b15d30b65b5c3cb1b7209861cca8aee71850745b198f3dc71fac9899a51f2a64c640e
languageName: node
linkType: hard

"@sentry/core@npm:8.48.0":
version: 8.48.0
resolution: "@sentry/core@npm:8.48.0"
checksum: 10/1fff8fc1e0681459240ceda5a3b2a7402f7ac73da9fa72e3d6e57e8f994ac246b240739ee0f224d48646bf410980aac4213c3e334e1dcbbd806ed5f496c7bb3c
languageName: node
linkType: hard

"@sentry/core@npm:8.51.0":
version: 8.51.0
resolution: "@sentry/core@npm:8.51.0"
checksum: 10/02d98706e9639f97f9044d49798d64565b9fe856c1df51f4e2171a6865b221e72116a594985156eb871ec9e70494073cf1c218fac63d62a33592acd14fd13ec9
languageName: node
linkType: hard

"@sentry/node@npm:8.48.0, @sentry/node@npm:^8.48.0":
version: 8.48.0
resolution: "@sentry/node@npm:8.48.0"
Expand Down Expand Up @@ -16170,6 +16197,7 @@ __metadata:
"@ourworldindata/grapher": "workspace:^"
"@ourworldindata/types": "workspace:^"
"@ourworldindata/utils": "workspace:^"
"@sentry/cloudflare": "npm:^8.51.0"
itty-router: "npm:^5.0.17"
littlezipper: "npm:^0.1.4"
stripe: "npm:^14.20.0"
Expand Down
Loading