Skip to content

Commit

Permalink
fix some sentry config
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed May 22, 2024
1 parent c8369fd commit 09aa5f9
Show file tree
Hide file tree
Showing 6 changed files with 470 additions and 133 deletions.
12 changes: 4 additions & 8 deletions app/utils/monitoring.server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { nodeProfilingIntegration } from '@sentry/profiling-node'
import {
init as sentryInit,
httpIntegration,
prismaIntegration,
} from '@sentry/remix'
import Sentry from '@sentry/remix'

export function init() {
sentryInit({
Sentry.init({
dsn: ENV.SENTRY_DSN,
environment: ENV.MODE,
tracesSampleRate: ENV.MODE === 'production' ? 1 : 0,
Expand All @@ -23,8 +19,8 @@ export function init() {
/\/site\.webmanifest/,
],
integrations: [
httpIntegration(),
prismaIntegration(),
Sentry.httpIntegration(),
Sentry.prismaIntegration(),
nodeProfilingIntegration(),
],
beforeSendTransaction(event) {
Expand Down
21 changes: 20 additions & 1 deletion mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ const miscHandlers = [
http.get('https://verifier.meetchopra.com/verify/:email', () => {
return HttpResponse.json({ status: true })
}),
http.post('https://metrics.metronome.sh/telemetry/v5/metrics', () => {
return HttpResponse.json({ success: true })
}),
http.post('https://metrics.metronome.sh/telemetry/v5/spans', () => {
return HttpResponse.json({ success: true })
}),
]

const server = setupServer(
Expand All @@ -80,7 +86,20 @@ const server = setupServer(
...miscHandlers,
)

server.listen({ onUnhandledRequest: 'warn' })
server.listen({
onUnhandledRequest(request, print) {
// Do not print warnings on unhandled requests to https://<:userId>.ingest.us.sentry.io/api/
// Note: a request handler with passthrough is not suited with this type of url
// until there is a more permissible url catching system
// like requested at https://github.com/mswjs/msw/issues/1804
if (request.url.includes('.sentry.io')) {
return
}

// Print the regular MSW unhandled request warning otherwise.
print.warning()
},
})
console.info('🔶 Mock server installed')

process.once('SIGINT', () => server.close())
Expand Down
Loading

0 comments on commit 09aa5f9

Please sign in to comment.