[as] Sentry Replay integration에 네트워크 상세 로깅 필터 및 헤더 설정 추가
This commit is contained in:
@@ -7,6 +7,18 @@ const isSentryEnabled =
|
||||
process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT !== "dev" &&
|
||||
process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT !== "prd";
|
||||
|
||||
const getSentryHost = (dsn?: string) => {
|
||||
if (!dsn) return null;
|
||||
try {
|
||||
const url = new URL(dsn);
|
||||
return url.host;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const sentryHost = getSentryHost(process.env.NEXT_PUBLIC_SENTRY_DSN);
|
||||
|
||||
Sentry.init({
|
||||
enabled: isSentryEnabled,
|
||||
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
||||
@@ -14,6 +26,18 @@ Sentry.init({
|
||||
tracesSampleRate: 1.0,
|
||||
replaysSessionSampleRate: 1.0,
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
integrations: [Sentry.replayIntegration()],
|
||||
integrations: [
|
||||
Sentry.replayIntegration({
|
||||
networkDetailAllowUrls: sentryHost
|
||||
? [
|
||||
new RegExp(
|
||||
`^(?!.*${sentryHost.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}).*(?:/api/|/server/).*$`,
|
||||
),
|
||||
]
|
||||
: [/\/(?:api|server)\//],
|
||||
networkRequestHeaders: ["X-Custom-Header"],
|
||||
networkResponseHeaders: ["X-Custom-Header"],
|
||||
}),
|
||||
],
|
||||
debug: process.env.NEXT_PUBLIC_SENTRY_DEBUG === "true",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user