@@ -14,6 +14,7 @@ import { addSpanToTransaction, captureMinimalError, makeSentryClient } from "./s
1414import { Span , Transaction } from "@sentry/types" ;
1515import { createLogger } from "./sentry/logger" ;
1616import { normalizeUserOptions } from "./options-mapping" ;
17+ import { getSentryCli } from "./sentry/cli" ;
1718
1819// We prefix the polyfill id with \0 to tell other plugins not to try to load or transform it.
1920// This hack is taken straight from https://rollupjs.org/guide/en/#resolveid.
@@ -87,6 +88,8 @@ const unplugin = createUnplugin<Options>((options, unpluginMetaContext) => {
8788 silent : internalOptions . silent ,
8889 } ) ;
8990
91+ const cli = getSentryCli ( internalOptions , logger ) ;
92+
9093 if ( internalOptions . telemetry ) {
9194 logger . info ( "Sending error and performance telemetry data to Sentry." ) ;
9295 logger . info ( "To disable telemetry, set `options.telemetry` to `false`." ) ;
@@ -116,13 +119,17 @@ const unplugin = createUnplugin<Options>((options, unpluginMetaContext) => {
116119 /**
117120 * Responsible for starting the plugin execution transaction and the release injection span
118121 */
119- buildStart ( ) {
122+ async buildStart ( ) {
123+ if ( ! internalOptions . release ) {
124+ internalOptions . release = await cli . releases . proposeVersion ( ) ;
125+ }
126+
120127 transaction = sentryHub . startTransaction ( {
121128 op : "function.plugin" ,
122129 name : "Sentry Bundler Plugin execution" ,
123130 } ) ;
124131 releaseInjectionSpan = addSpanToTransaction (
125- { hub : sentryHub , parentSpan : transaction , logger } ,
132+ { hub : sentryHub , parentSpan : transaction , logger, cli } ,
126133 "function.plugin.inject_release" ,
127134 "Release injection"
128135 ) ;
@@ -259,7 +266,7 @@ const unplugin = createUnplugin<Options>((options, unpluginMetaContext) => {
259266 const releasePipelineSpan =
260267 transaction &&
261268 addSpanToTransaction (
262- { hub : sentryHub , parentSpan : transaction , logger } ,
269+ { hub : sentryHub , parentSpan : transaction , logger, cli } ,
263270 "function.plugin.release" ,
264271 "Release pipeline"
265272 ) ;
@@ -275,7 +282,7 @@ const unplugin = createUnplugin<Options>((options, unpluginMetaContext) => {
275282 // That's good for them but a hassle for us. Let's try to normalize this into one data type
276283 // (I vote IncludeEntry[]) and continue with that down the line
277284
278- const ctx : BuildContext = { hub : sentryHub , parentSpan : releasePipelineSpan , logger } ;
285+ const ctx : BuildContext = { hub : sentryHub , parentSpan : releasePipelineSpan , logger, cli } ;
279286
280287 createNewRelease ( internalOptions , ctx )
281288 . then ( ( ) => cleanArtifacts ( internalOptions , ctx ) )
0 commit comments