[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M795PYQBPVMPJW68GJKY752W":3,"skill-same:01M795PYQBPVMPJW68GJKY752W":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":40,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M795PYQBPVMPJW68GJKY752W","sentry-multi-env-setup",null,"Configure Sentry across development, staging, and production environments\nwith separate DSNs, environment-specific sample rates, per-environment\nalert rules, and dashboard filtering.\nUse when setting up Sentry for dev\u002Fstaging\u002Fproduction, managing\nenvironment-specific configurations, isolating data between environments,\nor configuring .env files for per-environment DSNs.\nTrigger: \"sentry environments\", \"sentry staging setup\",\n\"multi-environment sentry\", \"sentry dev vs prod\", \"sentry DSN per env\".","jukeyman\u002Fjukeyman-skills","jukeyman","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142960420?v=4","01M78FR4Y3DHMMCBCC0GXXNB3F","RICK JEFFERSON","01M78FR4Z8RVQRAD31Y5J7V6EB",1,"MIT","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--sentry-pack--sentry-multi-env-setup\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: sentry-multi-env-setup\ndescription: |\n  Configure Sentry across development, staging, and production environments\n  with separate DSNs, environment-specific sample rates, per-environment\n  alert rules, and dashboard filtering.\n  Use when setting up Sentry for dev\u002Fstaging\u002Fproduction, managing\n  environment-specific configurations, isolating data between environments,\n  or configuring .env files for per-environment DSNs.\n  Trigger: \"sentry environments\", \"sentry staging setup\",\n  \"multi-environment sentry\", \"sentry dev vs prod\", \"sentry DSN per env\".\nallowed-tools: Read, Write, Edit, Grep, Glob, Bash(npm:*), Bash(npx:*), Bash(node:*), Bash(sentry-cli:*)\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ncompatible-with: claude-code, codex, openclaw\ntags: [saas, sentry, environments, configuration, multi-env, dsn, alerts]\n---\n\n# Sentry Multi-Environment Setup\n\n## Overview\n\nConfigure Sentry to run across development, staging, and production with isolated DSNs, tuned sample rates, environment-aware alert routing, and dashboard filtering. Covers `@sentry\u002Fnode` v8+ (TypeScript) and `sentry-sdk` v2+ (Python), targeting `sentry.io` or self-hosted Sentry 24.1+. The goal is to capture everything in dev, validate in staging, and protect production with tight sampling and PII scrubbing.\n\n## Prerequisites\n\n- Sentry organization at [sentry.io](https:\u002F\u002Fsentry.io) with at least one project created\n- `@sentry\u002Fnode` v8+ installed (`npm install @sentry\u002Fnode`) or `sentry-sdk` v2+ (`pip install sentry-sdk`)\n- Environment naming convention agreed upon (this guide uses `development`, `staging`, `production`)\n- DSN strategy decided: single project with environment tags or separate projects per environment (see [project-structure-options.md](references\u002Fproject-structure-options.md))\n- `.env` file management tooling (dotenv, direnv, or platform-native env config)\n\n## Instructions\n\n### Step 1 — Create Environment-Aware SDK Configuration with Separate DSNs\n\nEach environment gets its own DSN pointing to a dedicated Sentry project. This prevents dev noise from inflating production quotas and allows independent rate limits per environment.\n\n**Set up `.env` files per environment:**\n\n```bash\n# .env.development\nSENTRY_DSN=https:\u002F\u002Fdev-key@o0.ingest.sentry.io\u002F111\nSENTRY_ENVIRONMENT=development\nSENTRY_RELEASE=local-dev\n\n# .env.staging\nSENTRY_DSN=https:\u002F\u002Fstaging-key@o0.ingest.sentry.io\u002F222\nSENTRY_ENVIRONMENT=staging\n\n# .env.production\nSENTRY_DSN=https:\u002F\u002Fprod-key@o0.ingest.sentry.io\u002F333\nSENTRY_ENVIRONMENT=production\n```\n\n**TypeScript — environment-aware init with typed config:**\n\n```typescript\n\u002F\u002F config\u002Fsentry.ts\nimport * as Sentry from '@sentry\u002Fnode';\n\ntype Environment = 'development' | 'staging' | 'production';\n\ninterface EnvSentryConfig {\n  tracesSampleRate: number;\n  sampleRate: number;\n  debug: boolean;\n  sendDefaultPii: boolean;\n  maxBreadcrumbs: number;\n  enabled: boolean;\n}\n\nconst ENV_CONFIG: Record\u003CEnvironment, EnvSentryConfig> = {\n  development: {\n    tracesSampleRate: 1.0,   \u002F\u002F Capture every transaction for local debugging\n    sampleRate: 1.0,         \u002F\u002F Every error\n    debug: true,             \u002F\u002F Verbose console output for SDK troubleshooting\n    sendDefaultPii: true,    \u002F\u002F Include PII for local debugging only\n    maxBreadcrumbs: 100,     \u002F\u002F Full breadcrumb trail\n    enabled: true,           \u002F\u002F Set to false to fully disable in dev\n  },\n  staging: {\n    tracesSampleRate: 0.5,   \u002F\u002F 50% of transactions — enough to catch regressions\n    sampleRate: 1.0,         \u002F\u002F All errors — staging validates error handling\n    debug: false,\n    sendDefaultPii: false,   \u002F\u002F Staging mirrors prod PII policy\n    maxBreadcrumbs: 50,\n    enabled: true,\n  },\n  production: {\n    tracesSampleRate: 0.1,   \u002F\u002F 10% — balances visibility with quota budget\n    sampleRate: 1.0,         \u002F\u002F All errors — never drop production errors\n    debug: false,\n    sendDefaultPii: false,   \u002F\u002F Never send PII in production\n    maxBreadcrumbs: 50,\n    enabled: true,\n  },\n};\n\nexport function initSentry(env?: Environment): void {\n  const environment = env\n    || (process.env.SENTRY_ENVIRONMENT as Environment)\n    || (process.env.NODE_ENV as Environment)\n    || 'development';\n\n  const config = ENV_CONFIG[environment] || ENV_CONFIG.development;\n\n  Sentry.init({\n    dsn: process.env.SENTRY_DSN,\n    environment,\n    release: process.env.SENTRY_RELEASE || `app@${process.env.npm_package_version || 'unknown'}`,\n    ...config,\n\n    \u002F\u002F Environment-specific event filtering\n    beforeSend(event) {\n      \u002F\u002F Dev: capture everything for debugging\n      if (environment === 'development') return event;\n\n      \u002F\u002F Staging: drop debug-level events to reduce noise\n      if (environment === 'staging' && event.level === 'debug') return null;\n\n      \u002F\u002F Production: aggressive filtering\n      if (environment === 'production') {\n        \u002F\u002F Drop known non-actionable browser errors\n        if (event.exception?.values?.some(e =>\n          e.value?.match(\u002FResizeObserver|Loading chunk|AbortError\u002F)\n        )) return null;\n\n        \u002F\u002F Scrub sensitive headers\n        if (event.request?.headers) {\n          delete event.request.headers['Authorization'];\n          delete event.request.headers['Cookie'];\n          delete event.request.headers['X-API-Key'];\n        }\n      }\n\n      return event;\n    },\n  });\n}\n```\n\n**Python — equivalent multi-environment init:**\n\n```python\n# config\u002Fsentry_config.py\nimport os\nimport sentry_sdk\n\nENV_CONFIG = {\n    \"development\": {\n        \"traces_sample_rate\": 1.0,\n        \"sample_rate\": 1.0,\n        \"debug\": True,\n        \"send_default_pii\": True,\n        \"max_breadcrumbs\": 100,\n    },\n    \"staging\": {\n        \"traces_sample_rate\": 0.5,\n        \"sample_rate\": 1.0,\n        \"debug\": False,\n        \"send_default_pii\": False,\n        \"max_breadcrumbs\": 50,\n    },\n    \"production\": {\n        \"traces_sample_rate\": 0.1,\n        \"sample_rate\": 1.0,\n        \"debug\": False,\n        \"send_default_pii\": False,\n        \"max_breadcrumbs\": 50,\n    },\n}\n\n\ndef init_sentry() -> None:\n    environment = os.environ.get(\n        \"SENTRY_ENVIRONMENT\",\n        os.environ.get(\"PYTHON_ENV\", \"development\"),\n    )\n    config = ENV_CONFIG.get(environment, ENV_CONFIG[\"development\"])\n\n    def before_send(event, hint):\n        if environment == \"production\":\n            exc_info = hint.get(\"exc_info\")\n            if exc_info:\n                exc_type = exc_info[0]\n                # Drop expected exceptions in production\n                if exc_type in (KeyboardInterrupt, SystemExit):\n                    return None\n            # Scrub PII from headers\n            request = event.get(\"request\", {})\n            headers = request.get(\"headers\", {})\n            for key in (\"Authorization\", \"Cookie\", \"X-API-Key\"):\n                headers.pop(key, None)\n        return event\n\n    sentry_sdk.init(\n        dsn=os.environ.get(\"SENTRY_DSN\", \"\"),\n        environment=environment,\n        release=os.environ.get(\"SENTRY_RELEASE\", \"unknown\"),\n        before_send=before_send,\n        **config,\n    )\n```\n\n### Step 2 — Configure Per-Environment Alert Rules and Dashboard Filtering\n\nAlert routing prevents dev noise from waking on-call engineers. Each environment gets alert rules matching its severity tier.\n\n**Production alert rules (Sentry dashboard > Alerts > Create Rule):**\n\n| Alert Type | Condition | Filter | Action |\n|-----------|-----------|--------|--------|\n| Issue alert | New issue | `environment:production` | PagerDuty on-call |\n| Metric alert | Error rate > 50\u002Fmin for 5 min | `environment:production` | Slack `#alerts-critical` |\n| Metric alert | P95 latency > 2s for 10 min | `environment:production` | Slack `#alerts-performance` |\n\n**Staging alert rules:**\n\n| Alert Type | Condition | Filter | Action |\n|-----------|-----------|--------|--------|\n| Issue alert | New issue (first seen) | `environment:staging` | Slack `#alerts-staging` |\n| Metric alert | Error rate > 100\u002Fmin for 5 min | `environment:staging` | Slack `#alerts-staging` |\n\n**Development:** No alerts configured. Developers check the dashboard manually or use `debug: true` for console output.\n\n**Add environment context tags for richer filtering:**\n\n```typescript\n\u002F\u002F Add to Sentry.init() for dashboard filtering\nSentry.init({\n  \u002F\u002F ...base config from Step 1\n  initialScope: {\n    tags: {\n      environment: process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV,\n      region: process.env.AWS_REGION || process.env.GCP_REGION || 'us-east-1',\n      service: process.env.SERVICE_NAME || 'app',\n      deployment: process.env.DEPLOYMENT_ID || 'unknown',\n    },\n  },\n});\n\n\u002F\u002F Dashboard filter queries:\n\u002F\u002F   Issues > environment:production is:unresolved\n\u002F\u002F   Performance > environment:staging service:api-gateway\n\u002F\u002F   Discover > environment:production region:us-east-1\n```\n\n**Disable Sentry in test and CI environments:**\n\n```typescript\n\u002F\u002F test\u002Fsetup.ts — prevent test runs from sending events\nconst isTestEnv = process.env.NODE_ENV === 'test' || process.env.CI === 'true';\n\nif (!isTestEnv) {\n  initSentry();\n} else {\n  \u002F\u002F Initialize with empty DSN — SDK loads but sends nothing\n  \u002F\u002F All Sentry.captureException() calls become safe no-ops\n  Sentry.init({ dsn: '' });\n}\n```\n\n### Step 3 — Wire CI\u002FCD Releases to the Correct Environment\n\nTag Sentry releases with the deploy target so the Releases dashboard shows which commit is running where. Each `sentry-cli releases deploys` call records a deployment event on the timeline.\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\n# scripts\u002Fsentry-release.sh — call from CI after deploy\nset -euo pipefail\n\nVERSION=\"${SENTRY_RELEASE:-$(git rev-parse --short HEAD)}\"\nENVIRONMENT=\"${1:?Usage: sentry-release.sh \u003Cenvironment>}\"\nORG=\"${SENTRY_ORG:-my-org}\"\nPROJECT=\"${SENTRY_PROJECT:-my-app}\"\n\necho \"Creating Sentry release ${VERSION} for ${ENVIRONMENT}...\"\n\n# Create release and associate commits\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" new \"$VERSION\"\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" set-commits \"$VERSION\" --auto\n\n# Upload source maps (if applicable)\nif [ -d \".\u002Fdist\" ]; then\n  sentry-cli sourcemaps --org \"$ORG\" --project \"$PROJECT\" \\\n    upload --release=\"$VERSION\" .\u002Fdist\nfi\n\n# Finalize and record deployment\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" finalize \"$VERSION\"\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" \\\n  deploys \"$VERSION\" new --env \"$ENVIRONMENT\"\n\necho \"Release ${VERSION} deployed to ${ENVIRONMENT}\"\n\n# Usage in CI:\n#   .\u002Fscripts\u002Fsentry-release.sh staging     # after staging deploy\n#   .\u002Fscripts\u002Fsentry-release.sh production  # after production deploy\n```\n\n**GitHub Actions integration:**\n\n```yaml\n# .github\u002Fworkflows\u002Fdeploy.yml (snippet)\n- name: Create Sentry release\n  env:\n    SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}\n    SENTRY_ORG: my-org\n    SENTRY_PROJECT: my-app\n  run: |\n    npm install -g @sentry\u002Fcli\n    .\u002Fscripts\u002Fsentry-release.sh ${{ github.event.inputs.environment || 'staging' }}\n```\n\n## Output\n\nAfter completing all three steps you will have:\n\n- **Per-environment `.env` files** with isolated DSNs pointing to separate Sentry projects\n- **Typed SDK init module** (`config\u002Fsentry.ts` or `config\u002Fsentry_config.py`) that reads `SENTRY_ENVIRONMENT` and applies the correct sample rates, PII policy, and filtering\n- **Alert rules** routed by environment: PagerDuty for production, Slack for staging, none for dev\n- **Dashboard filter tags** (`environment`, `region`, `service`) for scoped queries\n- **CI\u002FCD release script** that tags deploys with the correct environment in Sentry's timeline\n- **Test\u002FCI guard** that disables Sentry during automated test runs\n\n## Error Handling\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| Dev events appearing in production dashboard | Wrong DSN loaded at runtime | Verify `SENTRY_DSN` points to the correct project; use `dotenv` with `--env-file .env.production` |\n| `environment: undefined` in Sentry events | `SENTRY_ENVIRONMENT` and `NODE_ENV` both unset | Set `SENTRY_ENVIRONMENT` explicitly in deployment config |\n| Staging alerts routing to PagerDuty | Alert rule missing environment filter | Add `environment:production` condition to PagerDuty alert rules |\n| Quota exhausted by dev\u002Fstaging events | All environments share one Sentry project | Use separate projects per environment for independent quotas |\n| Source maps not resolving in staging | Release version mismatch | Ensure `SENTRY_RELEASE` matches between `Sentry.init()` and `sentry-cli` upload |\n| `beforeSend` dropping wanted events | Filter regex too broad | Test filters in staging first; log dropped events with `console.warn` during rollout |\n| Python `sentry_sdk.init()` silently fails | DSN env var empty string | Check `os.environ.get(\"SENTRY_DSN\")` is set; empty string disables the SDK |\n\n## Examples\n\n**TypeScript — Express app with multi-environment Sentry:**\n\n```typescript\n\u002F\u002F app.ts\nimport express from 'express';\nimport * as Sentry from '@sentry\u002Fnode';\nimport { initSentry } from '.\u002Fconfig\u002Fsentry';\n\n\u002F\u002F Initialize before any other imports that need instrumentation\ninitSentry();\n\nconst app = express();\n\n\u002F\u002F Sentry request handler — must be first middleware\nSentry.setupExpressErrorHandler(app);\n\napp.get('\u002Fhealth', (_req, res) => res.json({ status: 'ok' }));\n\napp.get('\u002Fapi\u002Fdata', async (_req, res) => {\n  const span = Sentry.startSpan({ name: 'fetch-data', op: 'db.query' }, () => {\n    \u002F\u002F Your database call here\n    return { items: [] };\n  });\n  res.json(span);\n});\n\n\u002F\u002F Error handler — Sentry captures unhandled errors automatically\napp.use((err: Error, _req: express.Request, res: express.Response, _next: express.NextFunction) => {\n  Sentry.captureException(err);\n  res.status(500).json({ error: 'Internal server error' });\n});\n\napp.listen(3000, () => {\n  console.log(`Server running in ${process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV} mode`);\n});\n```\n\n**Python — FastAPI with multi-environment Sentry:**\n\n```python\n# main.py\nimport os\nfrom fastapi import FastAPI, Request\nfrom fastapi.responses import JSONResponse\nimport sentry_sdk\nfrom config.sentry_config import init_sentry\n\n# Initialize before app creation\ninit_sentry()\n\napp = FastAPI()\n\n\n@app.get(\"\u002Fhealth\")\nasync def health():\n    return {\"status\": \"ok\"}\n\n\n@app.get(\"\u002Fapi\u002Fdata\")\nasync def get_data():\n    with sentry_sdk.start_span(op=\"db.query\", name=\"fetch-data\"):\n        # Your database call here\n        return {\"items\": []}\n\n\n@app.exception_handler(Exception)\nasync def global_exception_handler(request: Request, exc: Exception):\n    sentry_sdk.capture_exception(exc)\n    return JSONResponse(status_code=500, content={\"error\": \"Internal server error\"})\n\n\nif __name__ == \"__main__\":\n    import uvicorn\n    env = os.environ.get(\"SENTRY_ENVIRONMENT\", \"development\")\n    print(f\"Server running in {env} mode\")\n    uvicorn.run(app, host=\"0.0.0.0\", port=8000)\n```\n\n## Resources\n\n- [Sentry Environments](https:\u002F\u002Fdocs.sentry.io\u002Fproduct\u002Fsentry-basics\u002Fenvironments\u002F) — official environment concepts\n- [Filtering Events](https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Ffiltering\u002F) — `beforeSend`, `ignoreErrors`, deny lists\n- [Alert Configuration](https:\u002F\u002Fdocs.sentry.io\u002Fproduct\u002Falerts\u002Fcreate-alerts\u002F) — issue and metric alert rules\n- [Releases & Deploys](https:\u002F\u002Fdocs.sentry.io\u002Fproduct\u002Freleases\u002F) — commit tracking, deploy markers, suspect commits\n- [sentry-cli Reference](https:\u002F\u002Fdocs.sentry.io\u002Fcli\u002F) — release creation, source map upload, deploy recording\n- [Python SDK Configuration](https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fpython\u002Fconfiguration\u002Foptions\u002F) — `sentry_sdk.init()` options reference\n- [Additional examples](references\u002Fexamples.md) — end-to-end environment setup scenarios\n\n## Next Steps\n\n- **Per-route sampling**: Replace flat `tracesSampleRate` with `tracesSampler` for route-level control (see `sentry-performance-tuning` skill)\n- **Feature flag integration**: Use Sentry's feature flag support to tie errors to specific flag variants\n- **Environment promotion workflow**: Automate staging-to-production promotion with `sentry-cli releases deploys`\n- **Cost monitoring**: Set per-project rate limits and budget alerts to catch runaway staging costs (see `sentry-cost-tuning` skill)\n- **Distributed tracing**: Connect traces across services with `tracePropagationTargets` (see `sentry-reference-architecture` skill)\n","# Sentry Multi-Environment Setup\n\n## Overview\n\nConfigure Sentry to run across development, staging, and production with isolated DSNs, tuned sample rates, environment-aware alert routing, and dashboard filtering. Covers `@sentry\u002Fnode` v8+ (TypeScript) and `sentry-sdk` v2+ (Python), targeting `sentry.io` or self-hosted Sentry 24.1+. The goal is to capture everything in dev, validate in staging, and protect production with tight sampling and PII scrubbing.\n\n## Prerequisites\n\n- Sentry organization at [sentry.io](https:\u002F\u002Fsentry.io) with at least one project created\n- `@sentry\u002Fnode` v8+ installed (`npm install @sentry\u002Fnode`) or `sentry-sdk` v2+ (`pip install sentry-sdk`)\n- Environment naming convention agreed upon (this guide uses `development`, `staging`, `production`)\n- DSN strategy decided: single project with environment tags or separate projects per environment (see [project-structure-options.md](references\u002Fproject-structure-options.md))\n- `.env` file management tooling (dotenv, direnv, or platform-native env config)\n\n## Instructions\n\n### Step 1 — Create Environment-Aware SDK Configuration with Separate DSNs\n\nEach environment gets its own DSN pointing to a dedicated Sentry project. This prevents dev noise from inflating production quotas and allows independent rate limits per environment.\n\n**Set up `.env` files per environment:**\n\n```bash\n# .env.development\nSENTRY_DSN=https:\u002F\u002Fdev-key@o0.ingest.sentry.io\u002F111\nSENTRY_ENVIRONMENT=development\nSENTRY_RELEASE=local-dev\n\n# .env.staging\nSENTRY_DSN=https:\u002F\u002Fstaging-key@o0.ingest.sentry.io\u002F222\nSENTRY_ENVIRONMENT=staging\n\n# .env.production\nSENTRY_DSN=https:\u002F\u002Fprod-key@o0.ingest.sentry.io\u002F333\nSENTRY_ENVIRONMENT=production\n```\n\n**TypeScript — environment-aware init with typed config:**\n\n```typescript\n\u002F\u002F config\u002Fsentry.ts\nimport * as Sentry from '@sentry\u002Fnode';\n\ntype Environment = 'development' | 'staging' | 'production';\n\ninterface EnvSentryConfig {\n  tracesSampleRate: number;\n  sampleRate: number;\n  debug: boolean;\n  sendDefaultPii: boolean;\n  maxBreadcrumbs: number;\n  enabled: boolean;\n}\n\nconst ENV_CONFIG: Record\u003CEnvironment, EnvSentryConfig> = {\n  development: {\n    tracesSampleRate: 1.0,   \u002F\u002F Capture every transaction for local debugging\n    sampleRate: 1.0,         \u002F\u002F Every error\n    debug: true,             \u002F\u002F Verbose console output for SDK troubleshooting\n    sendDefaultPii: true,    \u002F\u002F Include PII for local debugging only\n    maxBreadcrumbs: 100,     \u002F\u002F Full breadcrumb trail\n    enabled: true,           \u002F\u002F Set to false to fully disable in dev\n  },\n  staging: {\n    tracesSampleRate: 0.5,   \u002F\u002F 50% of transactions — enough to catch regressions\n    sampleRate: 1.0,         \u002F\u002F All errors — staging validates error handling\n    debug: false,\n    sendDefaultPii: false,   \u002F\u002F Staging mirrors prod PII policy\n    maxBreadcrumbs: 50,\n    enabled: true,\n  },\n  production: {\n    tracesSampleRate: 0.1,   \u002F\u002F 10% — balances visibility with quota budget\n    sampleRate: 1.0,         \u002F\u002F All errors — never drop production errors\n    debug: false,\n    sendDefaultPii: false,   \u002F\u002F Never send PII in production\n    maxBreadcrumbs: 50,\n    enabled: true,\n  },\n};\n\nexport function initSentry(env?: Environment): void {\n  const environment = env\n    || (process.env.SENTRY_ENVIRONMENT as Environment)\n    || (process.env.NODE_ENV as Environment)\n    || 'development';\n\n  const config = ENV_CONFIG[environment] || ENV_CONFIG.development;\n\n  Sentry.init({\n    dsn: process.env.SENTRY_DSN,\n    environment,\n    release: process.env.SENTRY_RELEASE || `app@${process.env.npm_package_version || 'unknown'}`,\n    ...config,\n\n    \u002F\u002F Environment-specific event filtering\n    beforeSend(event) {\n      \u002F\u002F Dev: capture everything for debugging\n      if (environment === 'development') return event;\n\n      \u002F\u002F Staging: drop debug-level events to reduce noise\n      if (environment === 'staging' && event.level === 'debug') return null;\n\n      \u002F\u002F Production: aggressive filtering\n      if (environment === 'production') {\n        \u002F\u002F Drop known non-actionable browser errors\n        if (event.exception?.values?.some(e =>\n          e.value?.match(\u002FResizeObserver|Loading chunk|AbortError\u002F)\n        )) return null;\n\n        \u002F\u002F Scrub sensitive headers\n        if (event.request?.headers) {\n          delete event.request.headers['Authorization'];\n          delete event.request.headers['Cookie'];\n          delete event.request.headers['X-API-Key'];\n        }\n      }\n\n      return event;\n    },\n  });\n}\n```\n\n**Python — equivalent multi-environment init:**\n\n```python\n# config\u002Fsentry_config.py\nimport os\nimport sentry_sdk\n\nENV_CONFIG = {\n    \"development\": {\n        \"traces_sample_rate\": 1.0,\n        \"sample_rate\": 1.0,\n        \"debug\": True,\n        \"send_default_pii\": True,\n        \"max_breadcrumbs\": 100,\n    },\n    \"staging\": {\n        \"traces_sample_rate\": 0.5,\n        \"sample_rate\": 1.0,\n        \"debug\": False,\n        \"send_default_pii\": False,\n        \"max_breadcrumbs\": 50,\n    },\n    \"production\": {\n        \"traces_sample_rate\": 0.1,\n        \"sample_rate\": 1.0,\n        \"debug\": False,\n        \"send_default_pii\": False,\n        \"max_breadcrumbs\": 50,\n    },\n}\n\n\ndef init_sentry() -> None:\n    environment = os.environ.get(\n        \"SENTRY_ENVIRONMENT\",\n        os.environ.get(\"PYTHON_ENV\", \"development\"),\n    )\n    config = ENV_CONFIG.get(environment, ENV_CONFIG[\"development\"])\n\n    def before_send(event, hint):\n        if environment == \"production\":\n            exc_info = hint.get(\"exc_info\")\n            if exc_info:\n                exc_type = exc_info[0]\n                # Drop expected exceptions in production\n                if exc_type in (KeyboardInterrupt, SystemExit):\n                    return None\n            # Scrub PII from headers\n            request = event.get(\"request\", {})\n            headers = request.get(\"headers\", {})\n            for key in (\"Authorization\", \"Cookie\", \"X-API-Key\"):\n                headers.pop(key, None)\n        return event\n\n    sentry_sdk.init(\n        dsn=os.environ.get(\"SENTRY_DSN\", \"\"),\n        environment=environment,\n        release=os.environ.get(\"SENTRY_RELEASE\", \"unknown\"),\n        before_send=before_send,\n        **config,\n    )\n```\n\n### Step 2 — Configure Per-Environment Alert Rules and Dashboard Filtering\n\nAlert routing prevents dev noise from waking on-call engineers. Each environment gets alert rules matching its severity tier.\n\n**Production alert rules (Sentry dashboard > Alerts > Create Rule):**\n\n| Alert Type | Condition | Filter | Action |\n|-----------|-----------|--------|--------|\n| Issue alert | New issue | `environment:production` | PagerDuty on-call |\n| Metric alert | Error rate > 50\u002Fmin for 5 min | `environment:production` | Slack `#alerts-critical` |\n| Metric alert | P95 latency > 2s for 10 min | `environment:production` | Slack `#alerts-performance` |\n\n**Staging alert rules:**\n\n| Alert Type | Condition | Filter | Action |\n|-----------|-----------|--------|--------|\n| Issue alert | New issue (first seen) | `environment:staging` | Slack `#alerts-staging` |\n| Metric alert | Error rate > 100\u002Fmin for 5 min | `environment:staging` | Slack `#alerts-staging` |\n\n**Development:** No alerts configured. Developers check the dashboard manually or use `debug: true` for console output.\n\n**Add environment context tags for richer filtering:**\n\n```typescript\n\u002F\u002F Add to Sentry.init() for dashboard filtering\nSentry.init({\n  \u002F\u002F ...base config from Step 1\n  initialScope: {\n    tags: {\n      environment: process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV,\n      region: process.env.AWS_REGION || process.env.GCP_REGION || 'us-east-1',\n      service: process.env.SERVICE_NAME || 'app',\n      deployment: process.env.DEPLOYMENT_ID || 'unknown',\n    },\n  },\n});\n\n\u002F\u002F Dashboard filter queries:\n\u002F\u002F   Issues > environment:production is:unresolved\n\u002F\u002F   Performance > environment:staging service:api-gateway\n\u002F\u002F   Discover > environment:production region:us-east-1\n```\n\n**Disable Sentry in test and CI environments:**\n\n```typescript\n\u002F\u002F test\u002Fsetup.ts — prevent test runs from sending events\nconst isTestEnv = process.env.NODE_ENV === 'test' || process.env.CI === 'true';\n\nif (!isTestEnv) {\n  initSentry();\n} else {\n  \u002F\u002F Initialize with empty DSN — SDK loads but sends nothing\n  \u002F\u002F All Sentry.captureException() calls become safe no-ops\n  Sentry.init({ dsn: '' });\n}\n```\n\n### Step 3 — Wire CI\u002FCD Releases to the Correct Environment\n\nTag Sentry releases with the deploy target so the Releases dashboard shows which commit is running where. Each `sentry-cli releases deploys` call records a deployment event on the timeline.\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\n# scripts\u002Fsentry-release.sh — call from CI after deploy\nset -euo pipefail\n\nVERSION=\"${SENTRY_RELEASE:-$(git rev-parse --short HEAD)}\"\nENVIRONMENT=\"${1:?Usage: sentry-release.sh \u003Cenvironment>}\"\nORG=\"${SENTRY_ORG:-my-org}\"\nPROJECT=\"${SENTRY_PROJECT:-my-app}\"\n\necho \"Creating Sentry release ${VERSION} for ${ENVIRONMENT}...\"\n\n# Create release and associate commits\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" new \"$VERSION\"\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" set-commits \"$VERSION\" --auto\n\n# Upload source maps (if applicable)\nif [ -d \".\u002Fdist\" ]; then\n  sentry-cli sourcemaps --org \"$ORG\" --project \"$PROJECT\" \\\n    upload --release=\"$VERSION\" .\u002Fdist\nfi\n\n# Finalize and record deployment\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" finalize \"$VERSION\"\nsentry-cli releases --org \"$ORG\" --project \"$PROJECT\" \\\n  deploys \"$VERSION\" new --env \"$ENVIRONMENT\"\n\necho \"Release ${VERSION} deployed to ${ENVIRONMENT}\"\n\n# Usage in CI:\n#   .\u002Fscripts\u002Fsentry-release.sh staging     # after staging deploy\n#   .\u002Fscripts\u002Fsentry-release.sh production  # after production deploy\n```\n\n**GitHub Actions integration:**\n\n```yaml\n# .github\u002Fworkflows\u002Fdeploy.yml (snippet)\n- name: Create Sentry release\n  env:\n    SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}\n    SENTRY_ORG: my-org\n    SENTRY_PROJECT: my-app\n  run: |\n    npm install -g @sentry\u002Fcli\n    .\u002Fscripts\u002Fsentry-release.sh ${{ github.event.inputs.environment || 'staging' }}\n```\n\n## Output\n\nAfter completing all three steps you will have:\n\n- **Per-environment `.env` files** with isolated DSNs pointing to separate Sentry projects\n- **Typed SDK init module** (`config\u002Fsentry.ts` or `config\u002Fsentry_config.py`) that reads `SENTRY_ENVIRONMENT` and applies the correct sample rates, PII policy, and filtering\n- **Alert rules** routed by environment: PagerDuty for production, Slack for staging, none for dev\n- **Dashboard filter tags** (`environment`, `region`, `service`) for scoped queries\n- **CI\u002FCD release script** that tags deploys with the correct environment in Sentry's timeline\n- **Test\u002FCI guard** that disables Sentry during automated test runs\n\n## Error Handling\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| Dev events appearing in production dashboard | Wrong DSN loaded at runtime | Verify `SENTRY_DSN` points to the correct project; use `dotenv` with `--env-file .env.production` |\n| `environment: undefined` in Sentry events | `SENTRY_ENVIRONMENT` and `NODE_ENV` both unset | Set `SENTRY_ENVIRONMENT` explicitly in deployment config |\n| Staging alerts routing to PagerDuty | Alert rule missing environment filter | Add `environment:production` condition to PagerDuty alert rules |\n| Quota exhausted by dev\u002Fstaging events | All environments share one Sentry project | Use separate projects per environment for independent quotas |\n| Source maps not resolving in staging | Release version mismatch | Ensure `SENTRY_RELEASE` matches between `Sentry.init()` and `sentry-cli` upload |\n| `beforeSend` dropping wanted events | Filter regex too broad | Test filters in staging first; log dropped events with `console.warn` during rollout |\n| Python `sentry_sdk.init()` silently fails | DSN env var empty string | Check `os.environ.get(\"SENTRY_DSN\")` is set; empty string disables the SDK |\n\n## Examples\n\n**TypeScript — Express app with multi-environment Sentry:**\n\n```typescript\n\u002F\u002F app.ts\nimport express from 'express';\nimport * as Sentry from '@sentry\u002Fnode';\nimport { initSentry } from '.\u002Fconfig\u002Fsentry';\n\n\u002F\u002F Initialize before any other imports that need instrumentation\ninitSentry();\n\nconst app = express();\n\n\u002F\u002F Sentry request handler — must be first middleware\nSentry.setupExpressErrorHandler(app);\n\napp.get('\u002Fhealth', (_req, res) => res.json({ status: 'ok' }));\n\napp.get('\u002Fapi\u002Fdata', async (_req, res) => {\n  const span = Sentry.startSpan({ name: 'fetch-data', op: 'db.query' }, () => {\n    \u002F\u002F Your database call here\n    return { items: [] };\n  });\n  res.json(span);\n});\n\n\u002F\u002F Error handler — Sentry captures unhandled errors automatically\napp.use((err: Error, _req: express.Request, res: express.Response, _next: express.NextFunction) => {\n  Sentry.captureException(err);\n  res.status(500).json({ error: 'Internal server error' });\n});\n\napp.listen(3000, () => {\n  console.log(`Server running in ${process.env.SENTRY_ENVIRONMENT || process.env.NODE_ENV} mode`);\n});\n```\n\n**Python — FastAPI with multi-environment Sentry:**\n\n```python\n# main.py\nimport os\nfrom fastapi import FastAPI, Request\nfrom fastapi.responses import JSONResponse\nimport sentry_sdk\nfrom config.sentry_config import init_sentry\n\n# Initialize before app creation\ninit_sentry()\n\napp = FastAPI()\n\n\n@app.get(\"\u002Fhealth\")\nasync def health():\n    return {\"status\": \"ok\"}\n\n\n@app.get(\"\u002Fapi\u002Fdata\")\nasync def get_data():\n    with sentry_sdk.start_span(op=\"db.query\", name=\"fetch-data\"):\n        # Your database call here\n        return {\"items\": []}\n\n\n@app.exception_handler(Exception)\nasync def global_exception_handler(request: Request, exc: Exception):\n    sentry_sdk.capture_exception(exc)\n    return JSONResponse(status_code=500, content={\"error\": \"Internal server error\"})\n\n\nif __name__ == \"__main__\":\n    import uvicorn\n    env = os.environ.get(\"SENTRY_ENVIRONMENT\", \"development\")\n    print(f\"Server running in {env} mode\")\n    uvicorn.run(app, host=\"0.0.0.0\", port=8000)\n```\n\n## Resources\n\n- [Sentry Environments](https:\u002F\u002Fdocs.sentry.io\u002Fproduct\u002Fsentry-basics\u002Fenvironments\u002F) — official environment concepts\n- [Filtering Events](https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fjavascript\u002Fconfiguration\u002Ffiltering\u002F) — `beforeSend`, `ignoreErrors`, deny lists\n- [Alert Configuration](https:\u002F\u002Fdocs.sentry.io\u002Fproduct\u002Falerts\u002Fcreate-alerts\u002F) — issue and metric alert rules\n- [Releases & Deploys](https:\u002F\u002Fdocs.sentry.io\u002Fproduct\u002Freleases\u002F) — commit tracking, deploy markers, suspect commits\n- [sentry-cli Reference](https:\u002F\u002Fdocs.sentry.io\u002Fcli\u002F) — release creation, source map upload, deploy recording\n- [Python SDK Configuration](https:\u002F\u002Fdocs.sentry.io\u002Fplatforms\u002Fpython\u002Fconfiguration\u002Foptions\u002F) — `sentry_sdk.init()` options reference\n- [Additional examples](references\u002Fexamples.md) — end-to-end environment setup scenarios\n\n## Next Steps\n\n- **Per-route sampling**: Replace flat `tracesSampleRate` with `tracesSampler` for route-level control (see `sentry-performance-tuning` skill)\n- **Feature flag integration**: Use Sentry's feature flag support to tie errors to specific flag variants\n- **Environment promotion workflow**: Automate staging-to-production promotion with `sentry-cli releases deploys`\n- **Cost monitoring**: Set per-project rate limits and budget alerts to catch runaway staging costs (see `sentry-cost-tuning` skill)\n- **Distributed tracing**: Connect traces across services with `tracePropagationTargets` (see `sentry-reference-architecture` skill)\n",{"name":5,"tags":24,"author":32,"license":15,"version":33,"description":34,"allowed-tools":35,"compatible-with":36},[25,26,27,28,29,30,31],"saas","sentry","environments","configuration","multi-env","dsn","alerts","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Configure Sentry across development, staging, and production environments\nwith separate DSNs, environment-specific sample rates, per-environment\nalert rules, and dashboard filtering.\nUse when setting up Sentry for dev\u002Fstaging\u002Fproduction, managing\nenvironment-specific configurations, isolating data between environments,\nor configuring .env files for per-environment DSNs.\nTrigger: \"sentry environments\", \"sentry staging setup\",\n\"multi-environment sentry\", \"sentry dev vs prod\", \"sentry DSN per env\".\n","Read, Write, Edit, Grep, Glob, Bash(npm:*), Bash(npx:*), Bash(node:*), Bash(sentry-cli:*)","claude-code, codex, openclaw","main","99825ad3f3bcc6597ddcc7294a14e6e922f2b67b","skills\u002Fsaas-packs--sentry-pack--sentry-multi-env-setup",0,"https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills","https:\u002F\u002Fgithub.com\u002Fjukeyman","https:\u002F\u002FRJBUSINESSSOLUTIONS.ORG","Credit and Finance Expert | Developer\r\n\r\nI'm Rick Jefferson, a seasoned credit and finance expert with over a decade of experience in financial literacy,","2026-07-13 07:03:29",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add jukeyman\u002Fjukeyman-skills --skill sentry-multi-env-setup",{"tool":52,"command":53},"bunx","bunx skills add jukeyman\u002Fjukeyman-skills --skill sentry-multi-env-setup",{"tool":55,"command":56},"pnpm","pnpm dlx skills add jukeyman\u002Fjukeyman-skills --skill sentry-multi-env-setup","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fsaas-packs--sentry-pack--sentry-multi-env-setup\u002FSKILL.md",true,[],[61,68,75,82,89,97],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M79ANS2SM329NEP5ZCX106RR","zustand-store-creator","Create zustand store creator operations. Auto-activating skill for Frontend Development.\nTriggers on: zustand store creator, zustand store creator\nPart of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like \"zustand store creator\", \"zustand creator\", \"zustand\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzustand-store-creator\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M79AMZKP4YDEZ7EHG1Y7PP74","zero-trust-config-helper","Configure with zero trust config helper operations. Auto-activating skill for Security Advanced.\nTriggers on: zero trust config helper, zero trust config helper\nPart of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like \"zero trust config helper\", \"zero helper\", \"zero\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-config-helper\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M79AMJSBCEJQNBTYNAHYN5HM","zapier-integration-helper","Assist with zapier integration helper operations. Auto-activating skill for Business Automation.\nTriggers on: zapier integration helper, zapier integration helper\nPart of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like \"zapier integration helper\", \"zapier helper\", \"zapier\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzapier-integration-helper\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M79AHJZGVMARS13VFQYRR1MP","yaml-config-validator","Validate yaml config validator operations. Auto-activating skill for DevOps Basics.\nTriggers on: yaml config validator, yaml config validator\nPart of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like \"yaml config validator\", \"yaml validator\", \"yaml\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fyaml-config-validator\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":93,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M79AHGDZRN0020RDQSQDPAM8","xvary-stock-research","Thesis-driven equity analysis from public SEC EDGAR and market data; \u002Fanalyze, \u002Fscore, \u002Fcompare workflows with bundled Python tools (Claude Code, Cursor, Codex).","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxvary-stock-research\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M79AHCYJ9FV9RMHQ24HDRN33","xss-vulnerability-scanner","Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals.\nTriggers on: xss vulnerability scanner, xss vulnerability scanner\nPart of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like \"xss vulnerability scanner\", \"xss scanner\", \"xss\".","https:\u002F\u002Fgithub.com\u002Fjukeyman\u002Fjukeyman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fxss-vulnerability-scanner\u002FSKILL.md",[],[]]