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 => {
42
42
authToken : uploadOptions . authToken ?? env . SENTRY_AUTH_TOKEN ,
43
43
telemetry : uploadOptions . telemetry ?? true ,
44
44
sourcemaps : {
45
- assets : [ getSourcemapsAssetsGlob ( config ) ] ,
45
+ assets : uploadOptions . assets ?? [ getSourcemapsAssetsGlob ( config ) ] ,
46
46
} ,
47
47
debug : options . debug ?? false ,
48
48
} ) ,
Original file line number Diff line number Diff line change @@ -68,6 +68,18 @@ type SourceMapsOptions = {
68
68
* @default true
69
69
*/
70
70
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 > ;
71
83
} ;
72
84
} ;
73
85
Original file line number Diff line number Diff line change @@ -83,6 +83,38 @@ describe('sentryAstro integration', () => {
83
83
} ) ;
84
84
} ) ;
85
85
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
+
86
118
it ( "doesn't enable source maps if `sourceMapsUploadOptions.enabled` is `false`" , async ( ) => {
87
119
const integration = sentryAstro ( {
88
120
sourceMapsUploadOptions : { enabled : false } ,
You can’t perform that action at this time.
0 commit comments