-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Error reporting in Cloudflare functions with Sentry #3068
Conversation
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
66f845d
to
f6d827e
Compare
f6d827e
to
5fd4123
Compare
Hm. I don't love adding another service to our stack just for this. It's a bit annoying that neither bugsnag nor slack have CF compatible client libraries yet, but I think a bare-bones slack integration really doesn't need the client api as they have a pretty well designed http api. E.g. so send a message to slack channel is as simple as POST https://slack.com/api/chat.postMessage
Content-type: application/json
Authorization: Bearer xoxb-your-token
{
"channel": "YOUR_CHANNEL_ID",
"text": "Hello world :tada:"
} I'm kind of leaning towards a preference for a barebones slack message - but I'm happy to discuss the pros and cons of it in the site meeting later today if you like! |
sure, we can try this too if it is indeed very straightforward. My only concern would be around reporting unhandled errors, but this is less of a concern here, since most of the functions bodies are wrapped in try {}. I would be tempted to run them in parallel for a month or so, just to make sure we're not missing anything. If we end up with perfect symmetry, then yes, by all means, let's strip it down. |
6442ee7
to
7ed4c7e
Compare
5fd4123
to
7df1fcd
Compare
7ed4c7e
to
2a45f8c
Compare
7df1fcd
to
5c3b993
Compare
see follow up in #3086 |
2a45f8c
to
aabb029
Compare
5c3b993
to
4a7c954
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aabb029
to
1bdb023
Compare
4a7c954
to
2de67c3
Compare
…tion 1) (#2998) This is part of the migration of the donor flow from Netlify to Cloudflare, tracked in #2947. This PR deals specifically with the migration of the `donate` function, which handles the creation of a Stripe checkout session upon clicking on "Donate" on /donate. See [README.md](https://github.com/owid/owid-grapher/blob/donate-cloudflare/functions/README.md) for a complete sequence diagram. Additionally, it tackles: - upgrading the Stripe API version from 2020-08-27 to 2023-10-16 - switching to [inline pricing](https://stripe.com/docs/products-prices/pricing-models#inline-pricing) for code-driven pricing (vs configuration in the Stripe dashboard) - fixes reCAPTCHA validation - a more isomorphic take on errors reported to the donor. Donation payloads are statically typed on the client and the server, and checked for proper type at runtime when received over the wire - all using a single type (thanks to Typebox). There is however no particular reporting of more general errors at this stage, beyond what might be surfaced in the Cloudflare panel. This needs to be addressed. This PR also brings some reader-facing improvements: - #2916 - a more customized checkout page (see [notion](https://www.notion.so/owid/2023-12-06-Donor-flow-repay-tech-debt-v2-option-1-2ef260e93f9a42f9a4aa2ad418831c60)) - [x] custom text next to the submit button - [x] add a product image - removal of confusing “£0.01 mention” for monthly donations - “Donate £50” instead of “Pay” for one-time donations Non-code actions: - [x] add env variables to [Cloudflare dashboard](https://dash.cloudflare.com/078fcdfed9955087315dd86792e71a7e/pages/view/owid/settings/environment-variables) (production and preview environments) - [x] (when deploying live) remove STRIPE_PUBLIC_KEY from .env (it is not used anymore) - [x] (when deploying live) update DONATE_API_URL env var (`/donation/donate`) - [ ] (when deploying live) update API version on stripe dashboard - [ ] (when deploying live) merge owid/owid-donors#1 Still unclear: - [x] reporting errors happening in functions. EDIT: see #3068 - [x] testing on staging server ~~(where to set env vars? Configure preview environment on Cloudflare dashboard?)~~ - http://staging-site-donate-cloudflare/donate doesn't get past the form. I suspect this is because Stripe requires https when not running on localhost. I might either revive hans or install ngrok on staging-site-donate-cloudflare. EDIT: testing functions is better dealt with Cloudflare previews (see #3055) Reference: - see #2947 - see [notion](https://www.notion.so/owid/2023-12-06-Donor-flow-repay-tech-debt-v2-option-1-2ef260e93f9a42f9a4aa2ad418831c60)
1bdb023
to
a0a3c63
Compare
2de67c3
to
7b34197
Compare
Follow up to #3068. We decided to replace Sentry with barebones Slack error logging in donation/* Cloudflare pages functions. We'll keep Sentry around for about a month until we have confidence in our Slack setup. For simplicity's sake, this PR also now reports the misconfiguration of env variables to the client (this particular error was previously hidden). This isn't an error that is likely to show up once the initial configuration is done, so it'll make our life easier at no real cost (the cost here being the possibility of sending an unhelpful "env variable missing" message to the client) - donate.owid.pages.dev updated with this branch. - cloudflare live and preview env vars added on CF dashboard, resp. posting to developers-errors-server and bot-testing For testing, POST an empty JSON to https://donate.owid.pages.dev/donation/thank-you or https://donate.owid.pages.dev/donation/donate
Add Sentry logging for /donation/* Cloudflare Pages functions routes.
At the time of writing, neither bugsnag nor slack have official Cloudflare worker integrations.
Given the criticality of these routes, I favoured reliability and introduced a new logging app which has official Cloudflare support: https://developers.cloudflare.com/pages/functions/plugins/sentry/
We should switch to bugsnag whenever official support is available.
Testing:
temp
-> an error is logged in sentry and an alert email is sent to [TBD]@ourworldindata.org (this will be configured when the use of Sentry is confirmed). Slack integration is only available on paid plans.