@@ -15,16 +15,10 @@ export function buildClientSnippet(options: SentryOptions): string {
15
15
return `import * as Sentry from "@sentry/astro";
16
16
17
17
Sentry.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 ) }
22
19
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
23
- tracesSampleRate: ${ options . tracesSampleRate ?? 1.0 } ,
24
20
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 } ,
28
22
});` ;
29
23
}
30
24
@@ -36,12 +30,16 @@ export function buildServerSnippet(options: SentryOptions): string {
36
30
return `import * as Sentry from "@sentry/astro";
37
31
38
32
Sentry.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
+ } ,
40
40
debug: ${ options . debug ? true : false } ,
41
41
environment: ${ options . environment ? JSON . stringify ( options . environment ) : 'import.meta.env.PUBLIC_VERCEL_ENV' } ,
42
42
release: ${ options . release ? JSON . stringify ( options . release ) : 'import.meta.env.PUBLIC_VERCEL_GIT_COMMIT_SHA' } ,
43
43
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