@@ -42,8 +42,12 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
42
42
} ) ;
43
43
}
44
44
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' ) ;
47
51
48
52
if ( pathToClientInit ) {
49
53
options . debug && console . log ( `[sentry-astro] Using ${ pathToClientInit } for client init.` ) ;
@@ -55,8 +59,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
55
59
56
60
if ( pathToServerInit ) {
57
61
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 ) ) ;
60
63
options . debug && console . log ( '[sentry-astro] Using default server init.' ) ;
61
64
injectScript ( 'page-ssr' , buildServerSnippet ( options || { } ) ) ;
62
65
}
@@ -65,9 +68,9 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
65
68
} ;
66
69
} ;
67
70
68
- function findSdkInitFile ( type : 'server' | 'client' ) : string | undefined {
71
+ function findDefaultSdkInitFile ( type : 'server' | 'client' ) : string | undefined {
69
72
const fileExtensions = [ 'ts' , 'js' , 'tsx' , 'jsx' , 'mjs' , 'cjs' , 'mts' ] ;
70
73
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 } ` ) ) )
72
75
. find ( filename => fs . existsSync ( filename ) ) ;
73
76
}
0 commit comments