Skip to content

Commit 299f3de

Browse files
authored
Enable Sentry browser profiling (#1543)
feat: enable Sentry browser profiling
1 parent 3599a0e commit 299f3de

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/router.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { routeTree } from './routeTree.gen'
44
import { DefaultCatchBoundary } from './components/DefaultCatchBoundary'
55
import { NotFound } from './components/NotFound'
66
import { QueryClient } from '@tanstack/react-query'
7+
import { browserProfilingIntegration } from '@sentry/browser'
78
import * as Sentry from '@sentry/tanstackstart-react'
89
import {
910
installStaleAppReloadHandlers,
@@ -20,8 +21,11 @@ if (typeof document !== 'undefined') {
2021
dsn: 'https://ac4bfc43ff4a892f8dc7053c4a50d92f@o4507236158537728.ingest.us.sentry.io/4507236163649536',
2122
enabled: import.meta.env.PROD && import.meta.env.MODE !== 'staging',
2223
sendDefaultPii: true,
24+
integrations: [browserProfilingIntegration()],
2325
// Performance Monitoring
2426
tracesSampleRate: 1.0, // Capture 100% of the transactions
27+
profileSessionSampleRate: 1.0,
28+
profileLifecycle: 'trace',
2529
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
2630
tracePropagationTargets: ['localhost', /^https:\/\/tanstack\.com\//],
2731
beforeSend(event, hint) {

‎src/server.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ function applyHostingHeaders(response: Response, url: URL) {
9393
headers.set(key, value)
9494
}
9595

96+
const contentType = headers.get('content-type')?.split(';')[0].trim()
97+
if (contentType === 'text/html') {
98+
headers.set('Document-Policy', 'js-profiling')
99+
}
100+
96101
if (isFrameEmbeddingAllowed(url.pathname)) {
97102
headers.delete('X-Frame-Options')
98103
}

0 commit comments

Comments
 (0)