-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add sentry #130
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
feat: add sentry #130
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe pull request integrates Sentry error tracking into the agentic-chat application. It adds Sentry SDK initialization to the app entry point, enables source map generation in build configurations, introduces an npm script for source map generation, and adds CI pipeline steps to upload source maps and create Sentry releases on pushes to main. Changes
Sequence Diagram(s)sequenceDiagram
rect rgb(240, 248, 255)
Note over Application: Initialization Phase
Application->>Sentry: Import & Initialize with DSN
Sentry-->>Application: Ready for error tracking
Application->>Mixpanel: Initialize existing analytics
end
rect rgb(255, 250, 240)
Note over Application: Runtime
Application->>Sentry: Capture errors
Application->>Mixpanel: Track events
end
sequenceDiagram
participant Git as Git Push
participant CI as CI Workflow
participant Build as Build Process
participant Sentry as Sentry API
Git->>CI: Push to main
CI->>Build: Run build with sourcemap generation
Build-->>CI: sourcemap files generated
CI->>Sentry: Upload source maps
Sentry-->>CI: Upload confirmed
CI->>Sentry: Create release
Sentry-->>CI: Release finalized
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/agentic-chat/src/main.tsx (1)
3-19: Fix Sentry initialization to match CI releases and avoid noisy dev logsThe current
Sentry.init()is missing critical fields that prevent sourcemaps uploaded by CI from being applied to errors:
- No
releasefield: CI creates releases viasentry-clibut your SDK doesn't report which release it's running, so sourcemaps won't match. Inject the release (e.g., via environment variable set by your build orimport.meta.env.SENTRY_RELEASE).- No
environmentfield: Can't distinguish production errors from staging/dev in the Sentry dashboard. Set it based onimport.meta.env.PRODor a custom env var.- No gating: Sentry initializes unconditionally (unlike Mixpanel which checks
analyticsEnabled). Consider wrapping init in a check for production or addingenabled: falsein dev to avoid noisy logs from local development.enableLogs: truealways on: This can be verbose in dev; consider making it conditional on environment.Suggested minimal fix:
Sentry.init({ dsn: '...', release: import.meta.env.SENTRY_RELEASE, environment: import.meta.env.PROD ? 'production' : 'development', sendDefaultPii: false, enableLogs: import.meta.env.PROD, tracesSampleRate: 0.1, })Ensure your vite build or CI injects
SENTRY_RELEASEat build time to match whatsentry:sourcemapsuploads.
🧹 Nitpick comments (1)
apps/agentic-chat/src/main.tsx (1)
3-7: Consider adding a Sentry error boundary at the app root to capture render errors automatically.The suggestion aligns with Sentry best practices for React 19 and React Router v7. Wrapping your app (around
<Router>at lines 36–41) withSentry.ErrorBoundarywill catch React render errors and report them automatically, preventing blank screens on failures. However, pair this with route-level error boundaries using React Router v7'serrorElementto handle loader/action errors separately—this provides better error triage since route-specific failures are caught closer to their source. Also ensure your Sentry initialization includesintegrations: [new BrowserTracing()]and appropriatebeforeSendfiltering to avoid duplicate reports with React 19's error semantics.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
.github/workflows/ci.yml(1 hunks).gitignore(1 hunks)apps/agentic-chat/package.json(3 hunks)apps/agentic-chat/src/main.tsx(2 hunks)apps/agentic-chat/vite.config.mjs(1 hunks)apps/agentic-chat/vite.config.mts(1 hunks)tsconfig.node.tsbuildinfo(0 hunks)
💤 Files with no reviewable changes (1)
- tsconfig.node.tsbuildinfo
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: main
🔇 Additional comments (4)
.gitignore (1)
11-13: LGTM: ignore TypeScript .tsbuildinfo artifactsIgnoring
*.tsbuildinfois a good cleanup so incremental build metadata doesn’t end up committed, and it matches the removal oftsconfig.node.tsbuildinfo.apps/agentic-chat/package.json (1)
29-29: I'll help you verify the Sentry and KaTeX dependencies. Let me start by examining the package.json file and checking how these dependencies are used in the codebase.
<function_calls>
#!/bin/bashFirst, examine the package.json to see the full dependency list
cd apps/agentic-chat
cat -n package.json | head -50
</function_calls>Now let me search for KaTeX and related dependencies in the codebase:
<function_calls>
#!/bin/bashSearch for KaTeX and rehype-katex references
rg -i 'katex|rehype' apps/agentic-chat/ -n -C2
</function_calls>Now let me search for Sentry initialization and configuration:
<function_calls>
#!/bin/bashSearch for Sentry usage and configuration
rg -i 'sentry|@sentry' apps/agentic-chat/ -n -C2 --type=ts --type=tsx --type=js --type=jsx
</function_calls>Let me also get the full package.json to see all dependencies:
<function_calls>
#!/bin/bashGet the full package.json
cat apps/agentic-chat/package.json
</function_calls>Now let me search the web for compatibility information:
<function_calls>
@sentry/react 10.27.0 React 19.1.1 compatibility
</function_calls><function_calls>
KaTeX react-markdown rehype-katex setup configuration
</function_calls>apps/agentic-chat/vite.config.mjs (1)
26-34: Now let me search for Vite-specific caveats about multiple config entrypoints:Vite documentation multiple config entrypoints .mjs .mts build behaviorVite build.sourcemap ESM CommonJS config entrypoints gotchasapps/agentic-chat/vite.config.mts (1)
28-36: I've gathered information about Vite's sourcemap options and Sentry integration best practices. Unfortunately, I cannot fully verify the codebase state due to a repository cloning issue. However, the web search confirms that the review comment's suggestion is valid and based on industry best practices.Key findings:
- Vite natively supports
build.sourcemap: 'hidden'(in addition totrueand'inline')- With
'hidden', map files are generated but thesourceMappingURLcomment is stripped from shipped JS, preventing casual public discovery- Sentry's recommended pattern is: use hidden sourcemaps + upload maps to Sentry (via
@sentry/vite-pluginorsentry-cli) before shipping- Never publicly serve
.mapfiles- Maps still expose original source code, so protect sensitive information
The review comment is directionally correct, though it could be more specific about recommending
'hidden'as a concrete Vite option rather than generic "env-gating or hiding."
| - name: Upload Sentry source maps | ||
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
| run: cd apps/agentic-chat && bun run sentry:sourcemaps | ||
|
|
||
| - name: Create Sentry release | ||
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
| env: | ||
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
| SENTRY_ORG: shapeshift-dao | ||
| SENTRY_PROJECT: agent | ||
| run: | | ||
| curl -sL https://sentry.io/get-cli/ | bash | ||
| VERSION=$(sentry-cli releases propose-version) | ||
| sentry-cli releases new "$VERSION" | ||
| sentry-cli releases set-commits "$VERSION" --auto | ||
| sentry-cli releases finalize "$VERSION" |
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.
Harden CI Sentry steps (wizard usage, auth, and curl | bash)
The Sentry CI steps are fragile as-is: the sourcemap upload uses the sentry:sourcemaps wizard script (likely interactive and missing SENTRY_* env), and the release step downloads an unpinned CLI via curl | bash. That combination risks CI flakiness and supply‑chain surprises. I’d strongly recommend switching to the official Sentry GitHub Action or a pinned sentry-cli binary and calling sentry-cli sourcemaps upload + sentry-cli releases ... directly with explicit SENTRY_AUTH_TOKEN/ORG/PROJECT.
What is Sentry’s current recommended way to integrate releases and sourcemap uploads in GitHub Actions CI (including example workflows using `sentry-cli` or the official Sentry Action)?
| "type-check": "tsc --noEmit", | ||
| "sentry:sourcemaps": "npx @sentry/wizard@latest -i sourcemaps --saas --org shapeshift-dao --project agent" | ||
| }, |
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.
🧩 Analysis chain
Script executed:
# Find CI workflow files that might use the sentry:sourcemaps script
fd -t f -e yml -e yaml . | head -20Repository: shapeshift/agentic-chat
<shell_result>
Repository: shapeshift/agentic-chat
Exit code: 0
</shell_result>
Sentry sourcemaps upload CI best practices @sentry/wizard vs sentry-cli
<web_search_result>
Short summary — when to use which, plus CI best practices.
Which to use
- @sentry/wizard: best for initial setup and developer onboarding — interactive, updates config/plugins (Vite/Rollup/Next/etc.) and can scaffold CI steps. Use it to pick sensible defaults quickly. [1][2]
- sentry-cli: best for CI automation and control — explicit commands to create releases, inject Debug IDs or upload artifact bundles, more flexible for complex pipelines or nonstandard builds. Required for scripted uploads in CI. [2][3]
Key differences (one-liners)
- Wizard: interactive, convenience, edits project files and recommends plugin-based uploads. Good for getting started. [1][2]
- sentry-cli: noninteractive, scriptable, supports artifact bundles, release/file APIs, and fine-grained flags (release, dist, rewrite/debug-id injection). Use in CI. [2][3]
CI best practices (apply when using sentry-cli or when the wizard generates CI snippets)
- Build first, upload after a successful production build — upload sourcemaps/artifacts for the exact build you deploy. [2]
- Use Debug IDs / artifact bundles where possible (recommended) to avoid brittle path matching. Ensure your SDK and upload tool versions support Debug IDs. [3]
- Authenticate with a token in CI (SENTRY_AUTH_TOKEN) scoped to least privilege (Project: Read & Write / Release: Admin or Organization token if needed). Never commit tokens; store in CI secrets. [1][4]
- Set consistent release (and dist if used) from CI (e.g., git SHA, semantic version) and use the same value when uploading files and when the app reports events. This ties events to uploaded sourcemaps. [2][3]
- Prevent publishing .map files publicly (serve-block or delete before deploy) if not using Sentry-only matching. [4]
- Make uploads idempotent and retry on transient failures; fail-safe your deploy (upload should ideally run before marking deploy complete). [2][7]
- Pin sentry-cli / plugin versions in CI and test uploads in a predeploy stage to catch config changes early. [2][3]
- Verify uploads programmatically (sentry-cli releases files list / Sentry API) and spot-check a bundle in Project → Source Maps. Monitor for "could not find associated source map" errors and follow Sentry troubleshooting guidance. [2][3][7]
Practical recommendation
- Run @sentry/wizard locally to set up SDK and CI snippets, then convert those snippets to a reproducible sentry-cli-based step in your CI that: sets SENTRY_AUTH_TOKEN, uses a deterministic release name (commit SHA), builds, injects Debug IDs (if applicable), uploads artifact bundles/sourcemaps, and confirms upload. Use the wizard for onboarding and sentry-cli for production CI. [1][2][3]
Sources
[1] Sentry Wizard (GitHub docs).
[2] Sentry docs — Sentry CLI sourcemaps/upload guides.
[3] Sentry blog — Debug IDs / troubleshooting sourcemap uploads.
[4] Sentry docs — bundler/plugin upload guidance (auth token & .env.sentry-build-plugin).
[7] Sentry blog post on fixing sourcemap upload errors.
</web_search_result>
Script executed:
# Search for CI workflow files that might invoke the sentry:sourcemaps script
find . -path "./.git" -prune -o -type f \( -name "*.yml" -o -name "*.yaml" \) -print | grep -E "(workflow|\.github)" | head -20Repository: shapeshift/agentic-chat
<shell_result>
Repository: shapeshift/agentic-chat
Exit code: 0
stdout:
./.github/workflows/ci.yml
</shell_result>
Script executed:
# Also search for any references to "sentry:sourcemaps" in the codebase
rg "sentry:sourcemaps" -t yaml -t jsonRepository: shapeshift/agentic-chat
<shell_result>
Repository: shapeshift/agentic-chat
Exit code: 0
stdout:
apps/agentic-chat/package.json: "sentry:sourcemaps": "npx @sentry/wizard@latest -i sourcemaps --saas --org shapeshift-dao --project agent"
</shell_result>
Script executed:
# Read the CI workflow file to see if the sentry:sourcemaps script is invoked
cat -n ./.github/workflows/ci.ymlRepository: shapeshift/agentic-chat
<shell_result>
Repository: shapeshift/agentic-chat
Exit code: 0
stdout:
1 name: CI
2
3 on:
4 push:
5 branches:
6 - main
7 pull_request:
8
9 permissions:
10 actions: read
11 contents: read
12
13 jobs:
14 main:
15 runs-on: ubuntu-latest
16 steps:
17 - uses: actions/checkout@v4
18 with:
19 fetch-depth: 0
20
21 - uses: oven-sh/setup-bun@v1
22 with:
23 bun-version: 1.3.2
24
25 - uses: actions/cache@v4
26 with:
27 path: .eslintcache
28 key: eslint-${{ hashFiles('eslint.config.ts') }}
29 restore-keys: eslint-
30
31 - run: bun install --frozen-lockfile
32 - run: bun run build
33 - name: Upload Sentry source maps
34 if: github.ref == 'refs/heads/main' && github.event_name == 'push'
35 run: cd apps/agentic-chat && bun run sentry:sourcemaps
36
37 - name: Create Sentry release
38 if: github.ref == 'refs/heads/main' && github.event_name == 'push'
39 env:
40 SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
41 SENTRY_ORG: shapeshift-dao
42 SENTRY_PROJECT: agent
43 run: |
44 curl -sL https://sentry.io/get-cli/ | bash
45 VERSION=$(sentry-cli releases propose-version)
46 sentry-cli releases new "$VERSION"
47 sentry-cli releases set-commits "$VERSION" --auto
48 sentry-cli releases finalize "$VERSION"
49
50 - run: bun run type-check
51 - run: bun run lint
52 - run: bun run test
</shell_result>
Replace @sentry/wizard@latest with sentry-cli sourcemaps upload for reproducible CI sourcemap uploads
The sentry:sourcemaps script in your CI workflow (line 35 of .github/workflows/ci.yml) runs npx @sentry/wizard@latest -i sourcemaps, which is designed for interactive one‑time developer setup, not repeatable CI automation. The script lacks a SENTRY_AUTH_TOKEN env var and will fail or hang in the non-interactive CI environment. Additionally, @latest breaks reproducibility and can cause unpredictable behavior changes.
Sentry's official guidance recommends using sentry-cli sourcemaps upload for CI (non-interactive, scriptable, pinned version). Your existing "Create Sentry release" step (lines 37–48) already demonstrates the correct pattern: pinned sentry-cli version from curl and proper auth via SENTRY_AUTH_TOKEN. Apply the same approach to sourcemap uploads:
sentry-cli sourcemaps upload --org shapeshift-dao --project agent <path-to-sourcemaps>Alternatively, use the official Sentry GitHub Action for simpler integration. See Sentry sourcemaps CLI docs for details.
🤖 Prompt for AI Agents
In apps/agentic-chat/package.json around lines 11 to 13, the "sentry:sourcemaps"
script uses `npx @sentry/wizard@latest` which is interactive and
non-reproducible for CI; replace it with a pinned `sentry-cli` invocation (or
the official Sentry GitHub Action) that runs `sentry-cli sourcemaps upload` with
the --org and --project flags and the correct path to your built sourcemaps,
ensure SENTRY_AUTH_TOKEN is provided in CI and pin the sentry-cli version the
same way your "Create Sentry release" step does (or use the released action) so
uploads are non-interactive and reproducible.
Adds sentry exception tracking to the agent.
Also adds
tsconfig.node.tsbuildinfoto.gitignorefor housekeeping.Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.