Skip to content

Sentry Client config#1628

Merged
prxt6529 merged 2 commits intomainfrom
sentry-client
Dec 3, 2025
Merged

Sentry Client config#1628
prxt6529 merged 2 commits intomainfrom
sentry-client

Conversation

@prxt6529
Copy link
Copy Markdown
Collaborator

@prxt6529 prxt6529 commented Dec 3, 2025

Summary by CodeRabbit

  • Refactor
    • Consolidated error-tracking setup: removed duplicated browser config and unified client-side instrumentation.
    • Preserved and centralised filtering of common noisy error patterns (e.g., resize/empty-range and non-Error promise rejections) to reduce alert noise.
    • Maintained existing IndexedDB error handling and global error listeners with no behavioral changes.

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

Signed-off-by: prxt6529 <prxt@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 3, 2025

Walkthrough

Client-side Sentry initialization and noise-filtering were consolidated into instrumentation-client.ts; sentry.client.config.ts was removed. A beforeSend hook now derives a candidate message from event exception values or hint.originalException and drops events matching specific noisy patterns.

Changes

Cohort / File(s) Summary
Sentry instrumentation (client)
instrumentation-client.ts
Adds/retains client-side Sentry init and enhances beforeSend: derives candidate message from event.exception?.values?.[0] or hint.originalException (string or Error) and returns null for noisy patterns (EmptyRanges, ResizeObserver loop limit exceeded, Non-Error promise rejection captured); preserves IndexedDB error handling and global listeners.
Removed config
sentry.client.config.ts
Deleted browser Sentry config that previously called Sentry.init (DSN, tracing, PII) and contained the prior beforeSend noise-filtering logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Areas to check:
    • Correct prioritization and null-safety when extracting the candidate message from event.exception?.values?.[0] vs hint.originalException
    • Exact noisy-pattern matching (strings) matches previous behavior
    • IndexedDB-specific tagging/level/fingerprinting remains unchanged
    • No remaining imports/initialization references to the deleted sentry.client.config.ts

Possibly related PRs

  • Added Sentry to FE #1622 — Introduced the Sentry client instrumentation files and initial client setup; closely related to moving/refining beforeSend behavior.

Suggested reviewers

  • ragnep

Poem

🐇
I hopped through logs both day and night,
Tidied noise and kept the light,
Errors trimmed with careful art,
Instrumentation plays its part,
Happy hops — the traces bright! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Sentry Client config' is vague and generic, failing to clearly convey the specific nature of the changes (moving instrumentation configuration and updating beforeSend logic). Use a more descriptive title that captures the main change, such as 'Migrate Sentry client instrumentation to next/instrumentation' or 'Update Sentry client initialization for Next.js 15.3+'
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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-client

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.

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (2)
instrumentation-client.ts (2)

1-4: Remove header comments to comply with TS/JS “no comments” guideline.

Repo guidelines say TS/JS code should be self-explanatory and not include comments; the filename and Sentry config are already clear enough. Suggest removing these four comment lines and, if needed, moving this context into docs or PR description.


17-31: Align tracesSampleRate and enableLogs with production flag to follow Sentry best practices.

The current configuration applies tracesSampleRate: 0.1 and enableLogs: true whenever a DSN is set, creating inconsistency with the already env-gated replay settings. Sentry's official guidance recommends environment-specific tuning: development should use higher sampling (tracesSampleRate: 1) for full visibility, while production should use lower sampling (0.1–0.25) to control costs. Similarly, enableLogs should typically be enabled only in production or when debugging is needed.

Suggested refactor:

-  tracesSampleRate: 0.1,
-  enableLogs: true,
+  tracesSampleRate: isProduction ? 0.1 : 1,
+  enableLogs: isProduction,
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f51d9c and c0dcc3e.

📒 Files selected for processing (2)
  • instrumentation-client.ts (2 hunks)
  • sentry.client.config.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • sentry.client.config.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Do not include any comments in the code; it should be self-explanatory
Write correct, up-to-date, bug-free, fully componentized, secure, and efficient code
Include all required imports and ensure proper naming of key components
Use NextJS features that match the current version

**/*.{ts,tsx,js,jsx}: Enforce ≥ 80% line coverage for files changed since main via npm run test
All code must pass ESLint (Next's Core Web Vitals + React Hooks rules) via npm run lint
Use <Link> from Next.js for internal navigation instead of <a> tags or HTML anchors
Use <Image> from next/image instead of HTML <img> elements

Files:

  • instrumentation-client.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: All code must pass TypeScript type checking via npm run type-check (tsc --noEmit)
Use 'use cache' directive at the top of Server Components or functions to explicitly opt-in to caching in Next.js 16

Files:

  • instrumentation-client.ts
🧬 Code graph analysis (1)
instrumentation-client.ts (1)
next.config.mjs (1)
  • sentryEnabled (12-12)
⏰ 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: Analyze (javascript-typescript)
🔇 Additional comments (1)
instrumentation-client.ts (1)

33-70: beforeSend noisy‑error filtering is correct and well‑scoped.

The logic to derive a message from event.exception.values[0] or hint.originalException, then drop only specific noisy patterns (EmptyRanges, ResizeObserver loop limit, Non‑Error promise rejection) by returning null, is a safe and recommended way to reduce Sentry noise without affecting other events. The IndexedDB handling still runs for remaining events and is guarded by an error && isIndexedDBError(error) check, which is appropriate.

You could optionally hoist noisyPatterns to module scope to avoid reallocating the array on every event, but that's a micro‑optimization and not required.

Signed-off-by: prxt6529 <prxt@6529.io>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Dec 3, 2025

Copy link
Copy Markdown

@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: 0

🧹 Nitpick comments (2)
instrumentation-client.ts (2)

1-3: Header comments conflict with repo guideline and reference older Next version

The TS/JS guideline here is “no comments in the code”; these header comments also hard‑code “Next.js 15.3+” while the repo is standardizing on Next 16. Consider removing them entirely or moving this explanation to documentation instead of inline comments. Based on learnings, the project is aligning with Next.js 16 conventions.


32-55: beforeSend noise filtering is correct; consider minor cleanups and future‑proofing

The message derivation and noise filtering look logically correct and preserve existing IndexedDB handling, but there are a couple of small tweaks you might consider:

  • const message = value?.value ?? fallbackMessage; always yields a string, so the typeof message === "string" check is redundant.
  • noisyPatterns is recreated on every event; extracting it to a module‑level const would slightly reduce per‑event allocations and make it easier to keep this list in sync with any future Sentry SDK changes.

Since the filters rely on specific substrings from Sentry’s own messages (e.g., "Non-Error promise rejection captured"), it’s also worth re‑verifying them whenever @sentry/nextjs is upgraded.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0dcc3e and a507598.

📒 Files selected for processing (1)
  • instrumentation-client.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Do not include any comments in the code; it should be self-explanatory
Write correct, up-to-date, bug-free, fully componentized, secure, and efficient code
Include all required imports and ensure proper naming of key components
Use NextJS features that match the current version

**/*.{ts,tsx,js,jsx}: Enforce ≥ 80% line coverage for files changed since main via npm run test
All code must pass ESLint (Next's Core Web Vitals + React Hooks rules) via npm run lint
Use <Link> from Next.js for internal navigation instead of <a> tags or HTML anchors
Use <Image> from next/image instead of HTML <img> elements

Files:

  • instrumentation-client.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: All code must pass TypeScript type checking via npm run type-check (tsc --noEmit)
Use 'use cache' directive at the top of Server Components or functions to explicitly opt-in to caching in Next.js 16

Files:

  • instrumentation-client.ts
🧠 Learnings (1)
📚 Learning: 2025-11-25T08:37:14.950Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T08:37:14.950Z
Learning: Fix issues with modernization aligned to React 19.2, React Compiler, and Next.js 16 conventions; do not add `// eslint-disable` comments unless explicitly instructed

Applied to files:

  • instrumentation-client.ts
🧬 Code graph analysis (1)
instrumentation-client.ts (1)
next.config.mjs (1)
  • sentryEnabled (12-12)
⏰ 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: Analyze (javascript-typescript)
🔇 Additional comments (1)
instrumentation-client.ts (1)

22-24: Tracing sample rate looks reasonable; confirm it matches your observability goals

Using tracesSampleRate: 0.1 is a sensible default for client traces, but it’s worth double‑checking that this aligns with how server‑side Sentry is configured (and with your cost/error‑budget expectations) now that the browser config has been consolidated here.

@prxt6529 prxt6529 merged commit ba9f239 into main Dec 3, 2025
9 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Dec 3, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 17, 2025
This was referenced Mar 12, 2026
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.

2 participants