File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
4242                  authToken : uploadOptions . authToken  ??  env . SENTRY_AUTH_TOKEN , 
4343                  telemetry : uploadOptions . telemetry  ??  true , 
4444                  sourcemaps : { 
45-                     assets : [ getSourcemapsAssetsGlob ( config ) ] , 
45+                     assets : uploadOptions . assets   ??   [ getSourcemapsAssetsGlob ( config ) ] , 
4646                  } , 
4747                  debug : options . debug  ??  false , 
4848                } ) , 
Original file line number Diff line number Diff line change @@ -68,6 +68,18 @@ type SourceMapsOptions = {
6868     * @default  true 
6969     */ 
7070    telemetry ?: boolean ; 
71+ 
72+     /** 
73+      * A glob or an array of globs that specify the build artifacts and source maps that will uploaded to Sentry. 
74+      * 
75+      * If this option is not specified, sensible defaults based on your `outDir`, `rootDir` and `adapter` 
76+      * config will be used. Use this option to override these defaults, for instance if you have a 
77+      * customized build setup that diverges from Astro's defaults. 
78+      * 
79+      * The globbing patterns must follow the implementation of the `glob` package. 
80+      * @see  https://www.npmjs.com/package/glob#glob-primer 
81+      */ 
82+     assets ?: string  |  Array < string > ; 
7183  } ; 
7284} ; 
7385
Original file line number Diff line number Diff line change @@ -83,6 +83,38 @@ describe('sentryAstro integration', () => {
8383    } ) ; 
8484  } ) ; 
8585
86+   it ( 'prefers user-specified assets-globs over the default values' ,  async  ( )  =>  { 
87+     const  integration  =  sentryAstro ( { 
88+       sourceMapsUploadOptions : { 
89+         enabled : true , 
90+         org : 'my-org' , 
91+         project : 'my-project' , 
92+         assets : [ 'dist/server/**/*, dist/client/**/*' ] , 
93+       } , 
94+     } ) ; 
95+     // @ts -expect-error - the hook exists and we only need to pass what we actually use 
96+     await  integration . hooks [ 'astro:config:setup' ] ( { 
97+       updateConfig, 
98+       injectScript, 
99+       // @ts -expect-error - only passing in partial config 
100+       config : { 
101+         outDir : new  URL ( 'file://path/to/project/build' ) , 
102+       } , 
103+     } ) ; 
104+ 
105+     expect ( sentryVitePluginSpy ) . toHaveBeenCalledTimes ( 1 ) ; 
106+     expect ( sentryVitePluginSpy ) . toHaveBeenCalledWith ( { 
107+       authToken : 'my-token' , 
108+       org : 'my-org' , 
109+       project : 'my-project' , 
110+       telemetry : true , 
111+       debug : false , 
112+       sourcemaps : { 
113+         assets : [ 'dist/server/**/*, dist/client/**/*' ] , 
114+       } , 
115+     } ) ; 
116+   } ) ; 
117+ 
86118  it ( "doesn't enable source maps if `sourceMapsUploadOptions.enabled` is `false`" ,  async  ( )  =>  { 
87119    const  integration  =  sentryAstro ( { 
88120      sourceMapsUploadOptions : {  enabled : false  } , 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments