Skip to content

Conversation

@0xApotheosis
Copy link
Member

@0xApotheosis 0xApotheosis commented Nov 27, 2025

Adds sentry exception tracking to the agent.

Screenshot 2025-11-27 at 12 33 37 pm

Also adds tsconfig.node.tsbuildinfo to .gitignore for housekeeping.

Summary by CodeRabbit

  • New Features

    • Added Sentry error tracking and monitoring to capture production issues
    • Added KaTeX support for mathematical expressions
  • Chores

    • Enhanced build configuration to generate source maps for better debugging
    • Updated CI pipeline to automatically upload error tracking artifacts

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
shapeshift-agentic Ready Ready Preview Comment Nov 27, 2025 1:37am

@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Sentry Error Tracking Integration
apps/agentic-chat/src/main.tsx, apps/agentic-chat/package.json
Adds Sentry SDK initialization with DSN, sendDefaultPii, and enableLogs configuration. Adds @sentry/react and katex dependencies; creates sentry:sourcemaps npm script.
Build Source Map Configuration
apps/agentic-chat/vite.config.mjs, apps/agentic-chat/vite.config.mts
Enables sourcemap: true in build configurations for both Vite config files.
CI/CD Pipeline Updates
.github/workflows/ci.yml
Adds two new workflow steps for main branch pushes: upload Sentry source maps for agentic-chat app and create Sentry release with authentication via SENTRY_AUTH_TOKEN.
Build Artifact Management
.gitignore, tsconfig.node.tsbuildinfo
Adds *.tsbuildinfo to ignored files; removes TypeScript incremental build cache artifact.

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
Loading
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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Sentry configuration accuracy: Verify DSN, PII handling, and logging settings in src/main.tsx are appropriate for the environment.
  • CI workflow authentication: Confirm SENTRY_AUTH_TOKEN and Sentry org/project configuration are correctly specified in the workflow steps.
  • Source map pipeline integrity: Validate that source map generation, npm script, and CI upload steps are properly coordinated and will execute without errors.
  • Vite config consistency: Ensure both vite.config.mjs and vite.config.mts changes are intentional and consistent.

Possibly related PRs

  • feat: add mixpanel #129 — Adds Mixpanel error tracking initialization to the same src/main.tsx file, demonstrating similar analytics integration patterns.
  • feat: migrate from node to bun #112 — Modifies .github/workflows/ci.yml with Node/Bun setup changes that may interact with the new Sentry CI steps.

Suggested reviewers

  • premiumjibles

Poem

🐰 Sourcemaps dance through the ether now,

Sentry's watchful eyes catch the errors—how!

From CI pipelines to release we flow,

Bugs exposed before users can know. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add sentry' directly and concisely summarizes the main change: adding Sentry exception tracking integration to the agentic-chat application.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sentry

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@premiumjibles premiumjibles merged commit e4701d5 into main Nov 27, 2025
3 of 4 checks passed
@premiumjibles premiumjibles deleted the sentry branch November 27, 2025 01:45
Copy link

@coderabbitai coderabbitai bot left a 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 logs

The current Sentry.init() is missing critical fields that prevent sourcemaps uploaded by CI from being applied to errors:

  • No release field: CI creates releases via sentry-cli but 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 or import.meta.env.SENTRY_RELEASE).
  • No environment field: Can't distinguish production errors from staging/dev in the Sentry dashboard. Set it based on import.meta.env.PROD or a custom env var.
  • No gating: Sentry initializes unconditionally (unlike Mixpanel which checks analyticsEnabled). Consider wrapping init in a check for production or adding enabled: false in dev to avoid noisy logs from local development.
  • enableLogs: true always 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_RELEASE at build time to match what sentry:sourcemaps uploads.

🧹 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) with Sentry.ErrorBoundary will 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's errorElement to 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 includes integrations: [new BrowserTracing()] and appropriate beforeSend filtering 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 6909d11 and 7d884a3.

⛔ Files ignored due to path filters (1)
  • bun.lock is 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 artifacts

Ignoring *.tsbuildinfo is a good cleanup so incremental build metadata doesn’t end up committed, and it matches the removal of tsconfig.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/bash

First, 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/bash

Search 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/bash

Search 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/bash

Get 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 behavior
Vite build.sourcemap ESM CommonJS config entrypoints gotchas
apps/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 to true and 'inline')
  • With 'hidden', map files are generated but the sourceMappingURL comment is stripped from shipped JS, preventing casual public discovery
  • Sentry's recommended pattern is: use hidden sourcemaps + upload maps to Sentry (via @sentry/vite-plugin or sentry-cli) before shipping
  • Never publicly serve .map files
  • 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."

Comment on lines +33 to +48
- 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"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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)?

Comment on lines +11 to 13
"type-check": "tsc --noEmit",
"sentry:sourcemaps": "npx @sentry/wizard@latest -i sourcemaps --saas --org shapeshift-dao --project agent"
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

Script executed:

# Find CI workflow files that might use the sentry:sourcemaps script
fd -t f -e yml -e yaml . | head -20

Repository: 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)

  1. Build first, upload after a successful production build — upload sourcemaps/artifacts for the exact build you deploy. [2]
  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]
  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]
  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]
  5. Prevent publishing .map files publicly (serve-block or delete before deploy) if not using Sentry-only matching. [4]
  6. Make uploads idempotent and retry on transient failures; fail-safe your deploy (upload should ideally run before marking deploy complete). [2][7]
  7. Pin sentry-cli / plugin versions in CI and test uploads in a predeploy stage to catch config changes early. [2][3]
  8. 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 -20

Repository: 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 json

Repository: 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.yml

Repository: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants