Skip to content

fix: init sentry earlier#764

Merged
LadyBluenotes merged 2 commits intomainfrom
feature/init-sentry-earlier
Mar 17, 2026
Merged

fix: init sentry earlier#764
LadyBluenotes merged 2 commits intomainfrom
feature/init-sentry-earlier

Conversation

@TkDodo
Copy link
Contributor

@TkDodo TkDodo commented Mar 17, 2026

and only add the tracing plugin that needs access to the router later

Summary by CodeRabbit

  • Chores
    • Reorganized error tracking initialization for improved browser-based monitoring and session replay capabilities
    • Enhanced performance monitoring with integrated router tracing
    • Updated type definitions for better TypeScript support

and only add the tracing plugin that needs access to the router later
@netlify
Copy link

netlify bot commented Mar 17, 2026

Deploy Preview for tanstack ready!

Name Link
🔨 Latest commit ec18dbf
🔍 Latest deploy log https://app.netlify.com/projects/tanstack/deploys/69b97860edc48200081bdf08
😎 Deploy Preview https://deploy-preview-764--tanstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 29 (🔴 down 5 from production)
Accessibility: 90 (no change from production)
Best Practices: 83 (🔴 down 9 from production)
SEO: 97 (no change from production)
PWA: 70 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

The router module reorganizes Sentry initialization into a browser-only block at module load and adjusts the Sentry instrumentation approach. TypeScript module augmentation declarations extend TanStack Router and React Start types with custom route properties and configuration fields.

Changes

Cohort / File(s) Summary
Sentry and Router Initialization
src/router.tsx
Moved Sentry initialization to browser-only block; replaced per-browser Sentry setup with tanstackRouterBrowserTracingIntegration; repositioned SSR query integration after browser checks; added TypeScript module augmentations for StaticDataRouteOption and Register interfaces.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit reorganized the Sentry's way,
Browser-only blocks now brighten the day,
Types augmented with a flourish so fine,
Router and queries now perfectly align,
Order restored with a quantum of care! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: init sentry earlier' accurately summarizes the main change: moving Sentry initialization earlier in the application startup sequence.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/init-sentry-earlier
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can use your project's `biome` configuration to improve the quality of JS/TS/CSS/JSON code reviews.

Add a configuration file to your project to customize how CodeRabbit runs biome.

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: 1

🧹 Nitpick comments (1)
src/router.tsx (1)

62-62: Consider using a more specific type instead of any.

Using any bypasses type checking. Since this appears to be a React component returning renderable content, consider using React.ReactNode or React.ReactElement.

♻️ Suggested type improvement
  interface StaticDataRouteOption {
    baseParent?: boolean
-   Title?: () => any
+   Title?: () => React.ReactNode
    showNavbar?: boolean
  }

You may need to add a React import at the top of the file if not already present via JSX transform:

import type { ReactNode } from 'react'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/router.tsx` at line 62, The Title prop type currently uses `any` (Title?:
() => any) which disables type checking; change it to return a React renderable
type (e.g. `Title?: () => ReactNode` or `() => ReactElement`) and add a type
import (`import type { ReactNode } from 'react'`) at the top if needed; update
any usages of the `Title` function to satisfy the new return type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/router.tsx`:
- Around line 9-22: Sentry is currently initialized with sendDefaultPii: true
which will cause automatic collection of IPs/cookies/PII; update the Sentry.init
call (the Sentry.init block / sendDefaultPii setting) to set sendDefaultPii:
false (or remove the option) and, if you still need to attach user identifiers
selectively, add explicit calls to Sentry.setUser(...) only where consented, and
ensure any server-side IP/PII forwarding is disabled or scrubbed before sending.

---

Nitpick comments:
In `@src/router.tsx`:
- Line 62: The Title prop type currently uses `any` (Title?: () => any) which
disables type checking; change it to return a React renderable type (e.g.
`Title?: () => ReactNode` or `() => ReactElement`) and add a type import
(`import type { ReactNode } from 'react'`) at the top if needed; update any
usages of the `Title` function to satisfy the new return type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ecf7976e-8596-4546-be02-736581fd404c

📥 Commits

Reviewing files that changed from the base of the PR and between 1e79903 and a1cec21.

📒 Files selected for processing (1)
  • src/router.tsx

Comment on lines +9 to +22
if (typeof document !== 'undefined') {
Sentry.init({
dsn: 'https://ac4bfc43ff4a892f8dc7053c4a50d92f@o4507236158537728.ingest.us.sentry.io/4507236163649536',
integrations: [Sentry.replayIntegration()],
sendDefaultPii: true,
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ['localhost', /^https:\/\/tanstack\.com\//],
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
})
}
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

Privacy/compliance concern with sendDefaultPii: true.

Enabling sendDefaultPii causes Sentry to automatically capture user IP addresses, cookies, and other personally identifiable information. This may conflict with GDPR, CCPA, or other privacy regulations and could require additional disclosure in your privacy policy.

Consider whether this is necessary, or if you can achieve your debugging goals without it.

🛡️ Suggested change to disable PII collection
  Sentry.init({
    dsn: 'https://ac4bfc43ff4a892f8dc7053c4a50d92f@o4507236158537728.ingest.us.sentry.io/4507236163649536',
    integrations: [Sentry.replayIntegration()],
-   sendDefaultPii: true,
+   sendDefaultPii: false,
    // Performance Monitoring
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (typeof document !== 'undefined') {
Sentry.init({
dsn: 'https://ac4bfc43ff4a892f8dc7053c4a50d92f@o4507236158537728.ingest.us.sentry.io/4507236163649536',
integrations: [Sentry.replayIntegration()],
sendDefaultPii: true,
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ['localhost', /^https:\/\/tanstack\.com\//],
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
})
}
if (typeof document !== 'undefined') {
Sentry.init({
dsn: 'https://ac4bfc43ff4a892f8dc7053c4a50d92f@o4507236158537728.ingest.us.sentry.io/4507236163649536',
integrations: [Sentry.replayIntegration()],
sendDefaultPii: false,
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ['localhost', /^https:\/\/tanstack\.com\//],
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
})
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/router.tsx` around lines 9 - 22, Sentry is currently initialized with
sendDefaultPii: true which will cause automatic collection of IPs/cookies/PII;
update the Sentry.init call (the Sentry.init block / sendDefaultPii setting) to
set sendDefaultPii: false (or remove the option) and, if you still need to
attach user identifiers selectively, add explicit calls to Sentry.setUser(...)
only where consented, and ensure any server-side IP/PII forwarding is disabled
or scrubbed before sending.

@LadyBluenotes LadyBluenotes merged commit b15d561 into main Mar 17, 2026
6 of 8 checks passed
@LadyBluenotes LadyBluenotes deleted the feature/init-sentry-earlier branch March 17, 2026 15:51
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