From a3c568d5a19446770c64e26df15c1c5e2ffd7b6b Mon Sep 17 00:00:00 2001 From: Ahmad <103906421+ahmadk953@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:38:50 -0500 Subject: [PATCH] Added JavaScript Profiling with Sentry --- next.config.ts | 13 +++++++++++++ sentry.client.config.ts | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/next.config.ts b/next.config.ts index 28e32b3..0652f90 100644 --- a/next.config.ts +++ b/next.config.ts @@ -23,6 +23,19 @@ const nextConfig: NextConfig = { }, ], }, + async headers() { + return [ + { + source: '/:path*', + headers: [ + { + key: 'Document-Policy', + value: 'js-profiling', + }, + ], + }, + ]; + }, pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'], compress: true, serverMiddleware: [compression()], diff --git a/sentry.client.config.ts b/sentry.client.config.ts index a5cbf1e..fcc19ba 100644 --- a/sentry.client.config.ts +++ b/sentry.client.config.ts @@ -19,8 +19,19 @@ Sentry.init({ }), ], - // Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. - tracesSampleRate: 1, + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for tracing. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, + // Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled + tracePropagationTargets: ['localhost', /^https:\/\/tasko\.ahmadk953\.org/], + + // Set profilesSampleRate to 1.0 to profile every transaction. + // Since profilesSampleRate is relative to tracesSampleRate, + // the final profiling rate can be computed as tracesSampleRate * profilesSampleRate + // For example, a tracesSampleRate of 0.5 and profilesSampleRate of 0.5 would + // result in 25% of transactions being profiled (0.5*0.5=0.25) + profilesSampleRate: 1.0, // Define how likely Replay events are sampled. replaysSessionSampleRate: 0.5,