setting-up-error-monitoring
Skill0 starsChanged 4 months agoMITView on GitHub
Sets up Sentry-style error monitoring with tested scrubbing of sensitive data - including a real scrubbing bug found and fixed during testing, not a theoretical warning. Use whenever the user wants to add error tracking/monitoring to a project, debug why errors aren't showing up in a monitoring tool, or set up alerts for production issues.
In this repository19 other files it gives its agents.
- adding-authenticationSkill
- auditing-seoSkill
- automating-git-workflowsSkill
- building-email-sequencesSkill
- building-graphql-apisSkill
- building-wordpress-pluginsSkill
- designing-carouselsSkill
- fine-tuning-ml-modelsSkill
- handling-web-formsSkill
- n8n-automationSkill
- organizing-spreadsheetsSkill
- reviewing-cloudflare-workers-codeSkill
- reviewing-code-for-securitySkill
- scaffolding-landing-pagesSkill
- setting-up-firebase-authSkill
- using-nextjs-best-practicesSkill
- working-with-postgres-databasesSkill
- writing-marketing-copySkill
- writing-terraform-codeSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 57
Add at least one alert (new error type, error rate spike) before calling setup complete - monitoring with no alerting just becomes a …
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Setting up error monitoring
Installs and configures error monitoring so production issues surface with useful context - tested against the real @sentry/node SDK, including a real data-leak bug found while testing the scrubbing hook.
Workflow
- Detect the platform/framework first - SDK setup differs significantly between a Node backend, a React SPA, and a mobile app.
- Separate environments in the SDK config from the start - confirmed below via
getOptions(). - Source maps for minified code - without uploading source maps, production stack traces are unreadable.
- Scrub sensitive data in
beforeSend, and verify the scrub actually hits the right path - see the real bug found below. Getting this wrong doesn't throw an error or fail loudly; it just silently ships secrets to your monitoring dashboard. - Always
flush()before a process exits - see below, this is a second easy silent-failure mode.
Tested, with a real bug found and fixed
Ran against the actual @sentry/node SDK (not mocked), capturing a real thrown error with request context attached.
Bug found during testing: the first version of the scrubbing hook checked event.request.data for sensitive fields. Testing showed the sensitive data was not scrubbed - password and apiKey came through in plain text:
Captured request data: {"userId":42,"password":"hunter2","apiKey":"sk_live_abc123"}
FAIL - sensitive data leaked into eventRoot cause: manually-attached context via Sentry.captureException(err, { contexts: { request: {...} } }) actually lands at event.contexts.request.data - the top-level event.request field is reserved for the SDK's own HTTP framework integrations, not manually-attached context. Checking the wrong path meant the scrub silently did nothing.
Fixed version, checking the correct path:
beforeSend(event) {
if (event.contexts?.request?.data) {
for (const field of ['password', 'token', 'apiKey', 'creditCard']) {
if (event.contexts.request.data[field] !== undefined) {
event.contexts.request.data[field] = '[Scrubbed]';
}
}
}
return event;
}Confirmed after the fix:
Captured request data: {"userId":42,"password":"[Scrubbed]","apiKey":"[Scrubbed]"}
PASS - password and apiKey scrubbedPractical takeaway for reviewing anyone's beforeSend hook: don't just check that a scrubbing function exists - check that the field path it scrubs actually matches the field path the data was attached at. These two silently drift apart whenever context is attached manually rather than through the SDK's built-in integrations, and there's no error or warning when it happens - the event just ships with the sensitive field intact.
Second finding: events need an explicit flush
The first test run showed 0 events captured immediately after captureException() - not because capture failed, but because Sentry batches and sends asynchronously, and beforeSend only fires when the batch actually flushes. Adding await Sentry.flush(2000) before checking fixed it. This matters most for short-lived processes (serverless functions, CLI scripts, CI jobs) - if the process exits before the SDK's internal flush timer fires, captured errors can be silently dropped with no indication anything went wrong. Always flush explicitly before intentional process exit in these environments.
Notes
- This was tested with a fake DSN and
beforeSendreturningnullto prevent any real network call - the scrubbing logic and event shape are real SDK behavior; actual delivery to Sentry's servers wasn't (and doesn't need to be) tested here. - Add at least one alert (new error type, error rate spike) before calling setup complete - monitoring with no alerting just becomes a dashboard nobody checks.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

