Skip to content

Commit 746a793

Browse files
remove sendDefaultPii and use setTags
1 parent af80823 commit 746a793

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

apps/site/cloudflare/worker-entrypoint.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
// - the official open-next docs: https://opennext.js.org/cloudflare/howtos/custom-worker
44
// - the official sentry docs: https://docs.sentry.io/platforms/javascript/guides/cloudflare
55

6-
import { withSentry } from '@sentry/cloudflare';
6+
import { setTags, withSentry } from '@sentry/cloudflare';
77

8-
import type { ExecutionContext } from '@cloudflare/workers-types';
8+
import type {
9+
ExecutionContext,
10+
Iso3166Alpha2Code,
11+
Request,
12+
} from '@cloudflare/workers-types';
913

1014
import { default as handler } from '../.open-next/worker.js';
1115

@@ -18,9 +22,6 @@ export default withSentry(
1822
SENTRY_DSN?: string;
1923
}) => ({
2024
dsn: env.SENTRY_DSN,
21-
// Adds request headers and IP for users, for more info visit:
22-
// https://docs.sentry.io/platforms/javascript/guides/cloudflare/configuration/options/#sendDefaultPii
23-
sendDefaultPii: true,
2425
// Enable logs to be sent to Sentry
2526
enableLogs: true,
2627
// Set tracesSampleRate to 0.05 to capture 5% of spans for tracing.
@@ -34,6 +35,16 @@ export default withSentry(
3435
env: Record<string, unknown>,
3536
ctx: ExecutionContext
3637
) {
38+
setTags({
39+
request_id: crypto.randomUUID(),
40+
user_agent: request.headers.get('user-agent'),
41+
ray_id: request.headers.get('cf-ray'),
42+
43+
// Type casts needed to keep lsp happy
44+
ip_country: request.cf?.country as Iso3166Alpha2Code | undefined,
45+
colo: request.cf?.colo as string | undefined,
46+
});
47+
3748
return handler.fetch(request, env, ctx);
3849
},
3950
}

0 commit comments

Comments
 (0)