@@ -20,7 +20,7 @@ import {
2020} from "./sentry/telemetry" ;
2121import { Span , Transaction } from "@sentry/types" ;
2222import { createLogger , Logger } from "./sentry/logger" ;
23- import { InternalOptions , normalizeUserOptions , validateOptions } from "./options-mapping" ;
23+ import { NormalizedOptions , normalizeUserOptions , validateOptions } from "./options-mapping" ;
2424import { getSentryCli } from "./sentry/cli" ;
2525import { makeMain } from "@sentry/node" ;
2626import os from "os" ;
@@ -70,18 +70,18 @@ const esbuildDebugIdInjectionFilePath = require.resolve(
7070 *
7171 * This release creation pipeline relies on Sentry CLI to execute the different steps.
7272 */
73- const unplugin = createUnplugin < Options , true > ( ( options , unpluginMetaContext ) => {
74- const internalOptions = normalizeUserOptions ( options ) ;
73+ const unplugin = createUnplugin < Options , true > ( ( userOptions , unpluginMetaContext ) => {
74+ const options = normalizeUserOptions ( userOptions ) ;
7575
76- const allowedToSendTelemetryPromise = shouldSendTelemetry ( internalOptions ) ;
76+ const allowedToSendTelemetryPromise = shouldSendTelemetry ( options ) ;
7777
7878 const { sentryHub, sentryClient } = makeSentryClient (
7979 "https://[email protected] /6690737" , 8080 allowedToSendTelemetryPromise ,
81- internalOptions . project
81+ options . project
8282 ) ;
8383
84- addPluginOptionInformationToHub ( internalOptions , sentryHub , unpluginMetaContext . framework ) ;
84+ addPluginOptionInformationToHub ( options , sentryHub , unpluginMetaContext . framework ) ;
8585
8686 //TODO: This call is problematic because as soon as we set our hub as the current hub
8787 // we might interfere with other plugins that use Sentry. However, for now, we'll
@@ -92,23 +92,23 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
9292
9393 const logger = createLogger ( {
9494 prefix : `[sentry-${ unpluginMetaContext . framework } -plugin]` ,
95- silent : internalOptions . silent ,
96- debug : internalOptions . debug ,
95+ silent : options . silent ,
96+ debug : options . debug ,
9797 } ) ;
9898
99- if ( ! validateOptions ( internalOptions , logger ) ) {
99+ if ( ! validateOptions ( options , logger ) ) {
100100 handleError (
101101 new Error ( "Options were not set correctly. See output above for more details." ) ,
102102 logger ,
103- internalOptions . errorHandler
103+ options . errorHandler
104104 ) ;
105105 }
106106
107- const cli = getSentryCli ( internalOptions , logger ) ;
107+ const cli = getSentryCli ( options , logger ) ;
108108
109109 const releaseNamePromise = new Promise < string > ( ( resolve ) => {
110- if ( options . release ) {
111- resolve ( options . release ) ;
110+ if ( userOptions . release ) {
111+ resolve ( userOptions . release ) ;
112112 } else {
113113 resolve ( cli . releases . proposeVersion ( ) ) ;
114114 }
@@ -156,7 +156,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
156156 "Unable to determine a release name. Make sure to set the `release` option or use an environment that supports auto-detection https://docs.sentry.io/cli/releases/#creating-releases`"
157157 ) ,
158158 logger ,
159- internalOptions . errorHandler
159+ options . errorHandler
160160 ) ;
161161 }
162162
@@ -211,13 +211,13 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
211211 // a windows style path to `releaseInjectionTargets`
212212 const normalizedId = path . normalize ( id ) ;
213213
214- if ( internalOptions . releaseInjectionTargets ) {
214+ if ( options . releaseInjectionTargets ) {
215215 // If there's an `releaseInjectionTargets` option transform (ie. inject the release varible) when the file path matches the option.
216- if ( typeof internalOptions . releaseInjectionTargets === "function" ) {
217- return internalOptions . releaseInjectionTargets ( normalizedId ) ;
216+ if ( typeof options . releaseInjectionTargets === "function" ) {
217+ return options . releaseInjectionTargets ( normalizedId ) ;
218218 }
219219
220- return internalOptions . releaseInjectionTargets . some ( ( entry ) => {
220+ return options . releaseInjectionTargets . some ( ( entry ) => {
221221 if ( entry instanceof RegExp ) {
222222 return entry . test ( normalizedId ) ;
223223 } else {
@@ -247,7 +247,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
247247 async transform ( code , id ) {
248248 logger . debug ( 'Called "transform":' , { id } ) ;
249249
250- if ( ! internalOptions . injectRelease ) {
250+ if ( ! options . injectRelease ) {
251251 return ;
252252 }
253253
@@ -259,10 +259,10 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
259259 ms . append (
260260 generateGlobalInjectorCode ( {
261261 release : await releaseNamePromise ,
262- injectReleasesMap : internalOptions . injectReleasesMap ,
263- injectBuildInformation : internalOptions . _experiments . injectBuildInformation || false ,
264- org : internalOptions . org ,
265- project : internalOptions . project ,
262+ injectReleasesMap : options . injectReleasesMap ,
263+ injectBuildInformation : options . _experiments . injectBuildInformation || false ,
264+ org : options . org ,
265+ project : options . project ,
266266 } )
267267 ) ;
268268 } else {
@@ -314,12 +314,12 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
314314
315315 try {
316316 if ( ! unpluginMetaContext . watchMode ) {
317- if ( internalOptions . _experiments . debugIdUpload ) {
317+ if ( options . sourcemaps ?. assets ) {
318318 const debugIdChunkFilePaths = (
319- await glob ( internalOptions . _experiments . debugIdUpload . include , {
319+ await glob ( options . sourcemaps . assets , {
320320 absolute : true ,
321321 nodir : true ,
322- ignore : internalOptions . _experiments . debugIdUpload . ignore ,
322+ ignore : options . sourcemaps . ignore ,
323323 } )
324324 ) . filter ( ( p ) => p . endsWith ( ".js" ) || p . endsWith ( ".mjs" ) || p . endsWith ( ".cjs" ) ) ;
325325
@@ -363,15 +363,15 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
363363 ) ;
364364
365365 tmpUploadFolder = await sourceFileUploadFolderPromise ;
366- await uploadDebugIdSourcemaps ( internalOptions , ctx , tmpUploadFolder , releaseName ) ;
366+ await uploadDebugIdSourcemaps ( options , ctx , tmpUploadFolder , releaseName ) ;
367367 }
368368
369- await createNewRelease ( internalOptions , ctx , releaseName ) ;
370- await cleanArtifacts ( internalOptions , ctx , releaseName ) ;
371- await uploadSourceMaps ( internalOptions , ctx , releaseName ) ;
372- await setCommits ( internalOptions , ctx , releaseName ) ;
373- await finalizeRelease ( internalOptions , ctx , releaseName ) ;
374- await addDeploy ( internalOptions , ctx , releaseName ) ;
369+ await createNewRelease ( options , ctx , releaseName ) ;
370+ await cleanArtifacts ( options , ctx , releaseName ) ;
371+ await uploadSourceMaps ( options , ctx , releaseName ) ;
372+ await setCommits ( options , ctx , releaseName ) ;
373+ await finalizeRelease ( options , ctx , releaseName ) ;
374+ await addDeploy ( options , ctx , releaseName ) ;
375375 }
376376 transaction ?. setStatus ( "ok" ) ;
377377 } catch ( e : unknown ) {
@@ -380,7 +380,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
380380 level : "error" ,
381381 message : "Error during writeBundle" ,
382382 } ) ;
383- handleError ( e , logger , internalOptions . errorHandler ) ;
383+ handleError ( e , logger , options . errorHandler ) ;
384384 } finally {
385385 if ( tmpUploadFolder ) {
386386 fs . rm ( tmpUploadFolder , { recursive : true , force : true } , ( ) => {
@@ -402,7 +402,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
402402 rollup : {
403403 renderChunk ( code , chunk ) {
404404 if (
405- options . _experiments ?. debugIdUpload &&
405+ options . sourcemaps ?. assets &&
406406 [ ".js" , ".mjs" , ".cjs" ] . some ( ( ending ) => chunk . fileName . endsWith ( ending ) ) // chunks could be any file (html, md, ...)
407407 ) {
408408 return injectDebugIdSnippetIntoChunk ( code ) ;
@@ -414,7 +414,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
414414 vite : {
415415 renderChunk ( code , chunk ) {
416416 if (
417- options . _experiments ?. debugIdUpload &&
417+ options . sourcemaps ?. assets &&
418418 [ ".js" , ".mjs" , ".cjs" ] . some ( ( ending ) => chunk . fileName . endsWith ( ending ) ) // chunks could be any file (html, md, ...)
419419 ) {
420420 return injectDebugIdSnippetIntoChunk ( code ) ;
@@ -424,7 +424,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
424424 } ,
425425 } ,
426426 webpack ( compiler ) {
427- if ( options . _experiments ?. debugIdUpload ) {
427+ if ( options . sourcemaps ?. assets ) {
428428 // Cache inspired by https://github.com/webpack/webpack/pull/15454
429429 const cache = new WeakMap < sources . Source , sources . Source > ( ) ;
430430
@@ -488,7 +488,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
488488 } ) ;
489489
490490 if ( unpluginMetaContext . framework === "esbuild" ) {
491- if ( internalOptions . _experiments . debugIdUpload ) {
491+ if ( options . sourcemaps ?. assets ) {
492492 plugins . push ( {
493493 name : "sentry-esbuild-debug-id-plugin" ,
494494 esbuild : {
@@ -507,7 +507,7 @@ const unplugin = createUnplugin<Options, true>((options, unpluginMetaContext) =>
507507function handleError (
508508 unknownError : unknown ,
509509 logger : Logger ,
510- errorHandler : InternalOptions [ "errorHandler" ]
510+ errorHandler : NormalizedOptions [ "errorHandler" ]
511511) {
512512 if ( unknownError instanceof Error ) {
513513 logger . error ( unknownError . message ) ;
0 commit comments