File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Expand file tree Collapse file tree 3 files changed +47
-3
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
} ) ,
@@ -106,13 +106,13 @@ function getSourcemapsAssetsGlob(config: AstroConfig): string {
106
106
// only copied over to <root>/.vercel. This seems to happen too late though.
107
107
// So we glob on both of these directories.
108
108
// Another case of "it ain't pretty but it works":(
109
- if ( config . adapter && config . adapter . name ?. startsWith ( '@astrojs/vercel' ) ) {
109
+ if ( config . adapter ? .name ?. startsWith ( '@astrojs/vercel' ) ) {
110
110
return '{.vercel,dist}/**/*' ;
111
111
}
112
112
113
113
// paths are stored as "file://" URLs
114
114
const outDirPathname = config . outDir && path . resolve ( config . outDir . pathname ) ;
115
- const rootDirName = path . resolve ( ( config . root && config . root . pathname ) || process . cwd ( ) ) ;
115
+ const rootDirName = path . resolve ( config . root ?. pathname || process . cwd ( ) ) ;
116
116
117
117
if ( outDirPathname ) {
118
118
const relativePath = path . relative ( rootDirName , outDirPathname ) ;
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 @@ -110,6 +110,38 @@ describe('sentryAstro integration', () => {
110
110
} ) ;
111
111
} ) ;
112
112
113
+ it ( 'prefers user-specified assets-globs over the default values' , async ( ) => {
114
+ const integration = sentryAstro ( {
115
+ sourceMapsUploadOptions : {
116
+ enabled : true ,
117
+ org : 'my-org' ,
118
+ project : 'my-project' ,
119
+ assets : [ 'dist/server/**/*, dist/client/**/*' ] ,
120
+ } ,
121
+ } ) ;
122
+ // @ts -expect-error - the hook exists and we only need to pass what we actually use
123
+ await integration . hooks [ 'astro:config:setup' ] ( {
124
+ updateConfig,
125
+ injectScript,
126
+ // @ts -expect-error - only passing in partial config
127
+ config : {
128
+ outDir : new URL ( 'file://path/to/project/build' ) ,
129
+ } ,
130
+ } ) ;
131
+
132
+ expect ( sentryVitePluginSpy ) . toHaveBeenCalledTimes ( 1 ) ;
133
+ expect ( sentryVitePluginSpy ) . toHaveBeenCalledWith ( {
134
+ authToken : 'my-token' ,
135
+ org : 'my-org' ,
136
+ project : 'my-project' ,
137
+ telemetry : true ,
138
+ debug : false ,
139
+ sourcemaps : {
140
+ assets : [ 'dist/server/**/*, dist/client/**/*' ] ,
141
+ } ,
142
+ } ) ;
143
+ } ) ;
144
+
113
145
it ( "doesn't enable source maps if `sourceMapsUploadOptions.enabled` is `false`" , async ( ) => {
114
146
const integration = sentryAstro ( {
115
147
sourceMapsUploadOptions : { enabled : false } ,
You can’t perform that action at this time.
0 commit comments