@@ -15,16 +15,10 @@ export function buildClientSnippet(options: SentryOptions): string {
1515 return `import * as Sentry from "@sentry/astro";
1616
1717Sentry.init({
18- dsn: ${ options . dsn ? JSON . stringify ( options . dsn ) : 'import.meta.env.PUBLIC_SENTRY_DSN' } ,
19- debug: ${ options . debug ? true : false } ,
20- environment: ${ options . environment ? JSON . stringify ( options . environment ) : 'import.meta.env.PUBLIC_VERCEL_ENV' } ,
21- release: ${ options . release ? JSON . stringify ( options . release ) : 'import.meta.env.PUBLIC_VERCEL_GIT_COMMIT_SHA' } ,
18+ ${ buildCommonInitOptions ( options ) }
2219 integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
23- tracesSampleRate: ${ options . tracesSampleRate ?? 1.0 } ,
2420 replaysSessionSampleRate: ${ options . replaysSessionSampleRate ?? 0.1 } ,
25- replaysOnErrorSampleRate: ${ options . replaysOnErrorSampleRate ?? 1.0 } ,${
26- options . sampleRate ? `\n sampleRate: ${ options . sampleRate } ,` : ''
27- }
21+ replaysOnErrorSampleRate: ${ options . replaysOnErrorSampleRate ?? 1.0 } ,
2822});` ;
2923}
3024
@@ -36,12 +30,16 @@ export function buildServerSnippet(options: SentryOptions): string {
3630 return `import * as Sentry from "@sentry/astro";
3731
3832Sentry.init({
39- dsn: ${ options . dsn ? JSON . stringify ( options . dsn ) : 'import.meta.env.PUBLIC_SENTRY_DSN' } ,
33+ ${ buildCommonInitOptions ( options ) }
34+ });` ;
35+ }
36+
37+ const buildCommonInitOptions = ( options : SentryOptions ) : string => `dsn: ${
38+ options . dsn ? JSON . stringify ( options . dsn ) : 'import.meta.env.PUBLIC_SENTRY_DSN'
39+ } ,
4040 debug: ${ options . debug ? true : false } ,
4141 environment: ${ options . environment ? JSON . stringify ( options . environment ) : 'import.meta.env.PUBLIC_VERCEL_ENV' } ,
4242 release: ${ options . release ? JSON . stringify ( options . release ) : 'import.meta.env.PUBLIC_VERCEL_GIT_COMMIT_SHA' } ,
4343 tracesSampleRate: ${ options . tracesSampleRate ?? 1.0 } ,${
44- options . sampleRate ? `\n sampleRate: ${ options . sampleRate } ,` : ''
45- }
46- });` ;
47- }
44+ options . sampleRate ? `\n sampleRate: ${ options . sampleRate } ,` : ''
45+ } `;
0 commit comments