@@ -42,8 +42,12 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
4242 } ) ;
4343 }
4444
45- const pathToClientInit = options . clientInitPath ?? findSdkInitFile ( 'client' ) ;
46- const pathToServerInit = options . serverInitPath ?? findSdkInitFile ( 'server' ) ;
45+ const pathToClientInit = options . clientInitPath
46+ ? path . resolve ( options . clientInitPath )
47+ : findDefaultSdkInitFile ( 'client' ) ;
48+ const pathToServerInit = options . serverInitPath
49+ ? path . resolve ( options . serverInitPath )
50+ : findDefaultSdkInitFile ( 'server' ) ;
4751
4852 if ( pathToClientInit ) {
4953 options . debug && console . log ( `[sentry-astro] Using ${ pathToClientInit } for client init.` ) ;
@@ -55,8 +59,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
5559
5660 if ( pathToServerInit ) {
5761 options . debug && console . log ( `[sentry-astro] Using ${ pathToServerInit } for server init.` ) ;
58- // For whatever reason, we need to move one level up to import the server file correctly
59- injectScript ( 'page-ssr' , buildSdkInitFileImportSnippet ( path . join ( '..' , pathToServerInit ) ) ) ;
62+ injectScript ( 'page-ssr' , buildSdkInitFileImportSnippet ( pathToServerInit ) ) ;
6063 options . debug && console . log ( '[sentry-astro] Using default server init.' ) ;
6164 injectScript ( 'page-ssr' , buildServerSnippet ( options || { } ) ) ;
6265 }
@@ -65,9 +68,9 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
6568 } ;
6669} ;
6770
68- function findSdkInitFile ( type : 'server' | 'client' ) : string | undefined {
71+ function findDefaultSdkInitFile ( type : 'server' | 'client' ) : string | undefined {
6972 const fileExtensions = [ 'ts' , 'js' , 'tsx' , 'jsx' , 'mjs' , 'cjs' , 'mts' ] ;
7073 return fileExtensions
71- . map ( ext => path . join ( process . cwd ( ) , `sentry.${ type } .config.${ ext } ` ) )
74+ . map ( ext => path . resolve ( path . join ( process . cwd ( ) , `sentry.${ type } .config.${ ext } ` ) ) )
7275 . find ( filename => fs . existsSync ( filename ) ) ;
7376}
0 commit comments