-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(astro): Align options with shared build time options type #17396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
s1gr1d
wants to merge
1
commit into
develop
Choose a base branch
from
sig/astro-build-time-options
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+394
−136
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,3 +1,4 @@ | ||||
import type { BuildTimeOptionsBase, UnstableVitePluginOptions } from '@sentry/core'; | ||||
import type { SentryVitePluginOptions } from '@sentry/vite-plugin'; | ||||
import type { RouteData } from 'astro'; | ||||
|
||||
|
@@ -23,12 +24,16 @@ type SdkInitPaths = { | |||
serverInitPath?: string; | ||||
}; | ||||
|
||||
/** | ||||
* @deprecated Move these options to the top-level of your Sentry configuration. | ||||
*/ | ||||
type SourceMapsOptions = { | ||||
/** | ||||
* If this flag is `true`, and an auth token is detected, the Sentry integration will | ||||
* automatically generate and upload source maps to Sentry during a production build. | ||||
* | ||||
* @default true | ||||
* @deprecated Use `sourcemaps.disable` instead (with inverted logic) | ||||
*/ | ||||
enabled?: boolean; | ||||
|
||||
|
@@ -39,18 +44,24 @@ type SourceMapsOptions = { | |||
* | ||||
* To create an auth token, follow this guide: | ||||
* @see https://docs.sentry.io/product/accounts/auth-tokens/#organization-auth-tokens | ||||
* | ||||
* @deprecated Use top-level `authToken` option instead | ||||
*/ | ||||
authToken?: string; | ||||
|
||||
/** | ||||
* The organization slug of your Sentry organization. | ||||
* Instead of specifying this option, you can also set the `SENTRY_ORG` environment variable. | ||||
* | ||||
* @deprecated Use top-level `org` option instead | ||||
*/ | ||||
org?: string; | ||||
|
||||
/** | ||||
* The project slug of your Sentry project. | ||||
* Instead of specifying this option, you can also set the `SENTRY_PROJECT` environment variable. | ||||
* | ||||
* @deprecated Use top-level `project` option instead | ||||
*/ | ||||
project?: string; | ||||
|
||||
|
@@ -59,6 +70,7 @@ type SourceMapsOptions = { | |||
* It will not collect any sensitive or user-specific data. | ||||
* | ||||
* @default true | ||||
* @deprecated Use top-level `telemetry` option instead | ||||
*/ | ||||
telemetry?: boolean; | ||||
|
||||
|
@@ -71,6 +83,8 @@ type SourceMapsOptions = { | |||
* | ||||
* The globbing patterns must follow the implementation of the `glob` package. | ||||
* @see https://www.npmjs.com/package/glob#glob-primer | ||||
* | ||||
* @deprecated Use `sourcemaps.assets` instead | ||||
*/ | ||||
assets?: string | Array<string>; | ||||
|
||||
|
@@ -81,6 +95,8 @@ type SourceMapsOptions = { | |||
* @default [] - By default no files are deleted. | ||||
* | ||||
* The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob) | ||||
* | ||||
* @deprecated Use `sourcemaps.filesToDeleteAfterUpload` instead | ||||
*/ | ||||
filesToDeleteAfterUpload?: string | Array<string>; | ||||
|
||||
|
@@ -95,49 +111,10 @@ type SourceMapsOptions = { | |||
* changes can occur at any time within a major SDK version. | ||||
* | ||||
* Furthermore, some options are untested with Astro specifically. Use with caution. | ||||
*/ | ||||
unstable_sentryVitePluginOptions?: Partial<SentryVitePluginOptions>; | ||||
}; | ||||
|
||||
type BundleSizeOptimizationOptions = { | ||||
/** | ||||
* If set to `true`, the plugin will attempt to tree-shake (remove) any debugging code within the Sentry SDK. | ||||
* Note that the success of this depends on tree shaking being enabled in your build tooling. | ||||
* | ||||
* Setting this option to `true` will disable features like the SDK's `debug` option. | ||||
*/ | ||||
excludeDebugStatements?: boolean; | ||||
|
||||
/** | ||||
* If set to true, the plugin will try to tree-shake performance monitoring statements out. | ||||
* Note that the success of this depends on tree shaking generally being enabled in your build. | ||||
* Attention: DO NOT enable this when you're using any performance monitoring-related SDK features (e.g. Sentry.startSpan()). | ||||
*/ | ||||
excludeTracing?: boolean; | ||||
|
||||
/** | ||||
* If set to `true`, the plugin will attempt to tree-shake (remove) code related to the Sentry SDK's Session Replay Shadow DOM recording functionality. | ||||
* Note that the success of this depends on tree shaking being enabled in your build tooling. | ||||
* | ||||
* This option is safe to be used when you do not want to capture any Shadow DOM activity via Sentry Session Replay. | ||||
* @deprecated Use top-level `unstable_sentryVitePluginOptions` instead | ||||
*/ | ||||
excludeReplayShadowDom?: boolean; | ||||
|
||||
/** | ||||
* If set to `true`, the plugin will attempt to tree-shake (remove) code related to the Sentry SDK's Session Replay `iframe` recording functionality. | ||||
* Note that the success of this depends on tree shaking being enabled in your build tooling. | ||||
* | ||||
* You can safely do this when you do not want to capture any `iframe` activity via Sentry Session Replay. | ||||
*/ | ||||
excludeReplayIframe?: boolean; | ||||
|
||||
/** | ||||
* If set to `true`, the plugin will attempt to tree-shake (remove) code related to the Sentry SDK's Session Replay's Compression Web Worker. | ||||
* Note that the success of this depends on tree shaking being enabled in your build tooling. | ||||
* | ||||
* **Notice:** You should only do use this option if you manually host a compression worker and configure it in your Sentry Session Replay integration config via the `workerUrl` option. | ||||
*/ | ||||
excludeReplayWorker?: boolean; | ||||
unstable_sentryVitePluginOptions?: Partial<SentryVitePluginOptions>; | ||||
}; | ||||
|
||||
type InstrumentationOptions = { | ||||
|
@@ -202,27 +179,23 @@ type DeprecatedRuntimeOptions = Record<string, unknown>; | |||
* | ||||
* If you specify a dedicated init file, the SDK options passed to `sentryAstro` will be ignored. | ||||
*/ | ||||
export type SentryOptions = SdkInitPaths & | ||||
export type SentryOptions = Omit<BuildTimeOptionsBase, 'release'> & | ||||
// todo(v11): `release` and `debug` need to be removed from BuildTimeOptionsBase as it is currently conflicting with `DeprecatedRuntimeOptions` | ||||
UnstableVitePluginOptions<SentryVitePluginOptions> & | ||||
SdkInitPaths & | ||||
InstrumentationOptions & | ||||
SdkEnabledOptions & { | ||||
/** | ||||
* Options for the Sentry Vite plugin to customize the source maps upload process. | ||||
* | ||||
* These options are always read from the `sentryAstro` integration. | ||||
* Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files. | ||||
*/ | ||||
sourceMapsUploadOptions?: SourceMapsOptions; | ||||
/** | ||||
* Options for the Sentry Vite plugin to customize bundle size optimizations. | ||||
* | ||||
* These options are always read from the `sentryAstro` integration. | ||||
* Do not define them in the `sentry.client.config.(js|ts)` or `sentry.server.config.(js|ts)` files. | ||||
* @deprecated This option was deprecated. Please move the options to the top-level configuration. | ||||
* See the migration guide in the SourceMapsOptions type documentation. | ||||
*/ | ||||
bundleSizeOptimizations?: BundleSizeOptimizationOptions; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Am I confused or did this disappear with the changes? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is part of the shared type so it's possible to delete it here :)
|
||||
/** | ||||
* If enabled, prints debug logs during the build process. | ||||
*/ | ||||
debug?: boolean; | ||||
// eslint-disable-next-line deprecation/deprecation | ||||
sourceMapsUploadOptions?: SourceMapsOptions; | ||||
// eslint-disable-next-line deprecation/deprecation | ||||
} & DeprecatedRuntimeOptions; | ||||
|
||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Sentry Vite Plugin Misinterprets Configuration Options
New top-level build-time options (e.g.,
org
,project
,authToken
,sentryUrl
,headers
,telemetry
,silent
,errorHandler
) are not destructured from theoptions
object. This causes them to be incorrectly included inotherOptions
, triggering a deprecation warning for 'additional options'. As a result, misleading warnings appear in production builds, despite these options being valid and used for Sentry Vite plugin configuration.