getsentry / sentry-javascript-bundler-plugins Goto Github PK
View Code? Open in Web Editor NEWJavaScript Bundler Plugins for Sentry
Home Page: https://sentry.io
License: BSD 3-Clause "New" or "Revised" License
JavaScript Bundler Plugins for Sentry
Home Page: https://sentry.io
License: BSD 3-Clause "New" or "Revised" License
I'm unable to build my vite + ts + vue project due to what seems to be some ESM related issue.
See reproduction and "Actual result" section below for further details.
See reproduction
Reproduction at https://stackblitz.com/edit/vitejs-vite-cupjlj?file=vite.config.ts
What you thought would happen.
Locally in my own project:
failed to load config from /workspaces/app/vite.config.ts
error during build:
TypeError: sentryVitePlugin is not a function
at file:///workspaces/way-app/vite.config.ts.timestamp-1669634829752.mjs:13:5
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
at async loadConfigFromBundledFile (file:///workspaces/way-app/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62832:21)
at async loadConfigFromFile (file:///workspaces/way-app/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62717:28)
at async resolveConfig (file:///workspaces/way-app/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:62341:28)
at async doBuild (file:///workspaces/way-app/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:45248:20)
at async build (file:///workspaces/way-app/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:45237:16)
at async CAC. (file:///workspaces/way-app/node_modules/vite/dist/node/cli.js:756:9)
In reproduction:
$ vue-tsc && vite build
failed to load config from /home/projects/vitejs-vite-cupjlj/vite.config.ts
error during build:
Error: _file_home_projects_vitejs_vite_cupjlj_node_modules_sentry_vite_plugin_dist_cjs_index_js.default is not a function
at file:///home/projects/vitejs-vite-cupjlj/vite.config.ts.timestamp-1669635121082.mjs
at async doBuild (file://file:///home/projects/vitejs-vite-cupjlj/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:45295:20)
at async build (file://file:///home/projects/vitejs-vite-cupjlj/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:45284:16)
at async CAC.eval (file://file:///home/projects/vitejs-vite-cupjlj/node_modules/vite/dist/node/cli.js:767:9)
We need examples in the READMEs of the individual bundlers/packages.
Ref: #50
Extracted from #103 (comment):
The customHeader
option can also be set via the CUSTOM_HEADER
env variable. This env variable's name is inconsistent as we don't prefix it with SENTRY_
like with all other env variables. Sentry CLI v1 expects exactly this header. Sentry CLI v2 expects the SENTRY_HEADER
env variable (see changelog) which replaces CUSTOM_HEADER
.
To already be ahead of a breaking change when upgrading to CLI v2, we can default the JSDoc of the bundler plugin to SENTRY_HEADER
and internally, when converting to internal options, set the customHeader
variable to the env variables' value:
customHeader: userOptions.customHeader ?? process.env["SENTRY_HEADER"] ?? process.env["CUSTOM_HEADER"]
Interestingly, SENTRY_HEADER
isn't documented in the CLI configuration docs.
Add the deploy
option (and the corrseponding command/step in the release pipeline).
ref #50
To go with feature parity to the webpack plugin, we should rename the option we currently call customHeaders
to customHeader
and let users pass a string in the format [header-name]: [header-value]
.
self-hosted (I don't know the version)
Which SDK and version?
Latest Javascript
Run webpack twice using setCommits.ignoreMissing to true
The setCommits.ignoreMissing parameter works as expected.
/cli/sentry-cli releases set-commits development --auto --ignore-missing
error: No commits found. Change commits range, initial depth or use --ignore-empty to allow empty patch sets.
Probably due to a CLI param rename?
We want to add a test framework to properly test artifact upload to Sentry. These tests should help us to test sourcemaps and file upload scenarios with different configurations (e.g. one inculde
path, multiple include entries, combinations of sourcemap modification options, etc.)
High level plan:
Per test scenario:
Options
object as inputOpen questions/Risks:
ref: #50
The telemetry option had some issues depending on what kind of format the users provided the URL in. Additionally, the logic for setting the telemetry option is kinda sketchy (manually overriding client options) so we need to refactor that as well.
Source and Source map files can be gzipped before our plugin gets to them. We have to decompress them to modify them correctly (if necessary)
ref #50
sync fs operations are slow
After realizing that achieving feature parity with the Sentry WebPack Plugin and at the same time replacing Sentry CLI underneath would be an enourmous amount of work, we decided to prioritize feature parity. Consequently, we're re-introducing Sentry CLI.
Tasks:
ref: #50
Currently this is blocked because we don't want to lose Node v8 and v10 support and this is why we should most likely simply adjust Sentry CLI V2 so that it supports these versions (via Babel (?) or by not using APIs that are not supported by v8 and v10)
release
value (#21, #22)entries
option (#38, ref: #28)We need to have updated option tables in the individual READMEs of the bundlers.
Our first implementation of enabling/disabling Sentry for (not) sending events to Sentry is a bit sketchy.
We should use an EventProvessor instead of setting sample rates/init options.
Add the setCommits
option (and the corrseponding command/step in the release pipeline).
ref #50
"@sentry/vite-plugin": "^0.3.0",
"vite": "^3.1.0",
"@sentry/node": "^7.27.0",
"@sentry/svelte": "^7.26.0",
"@sentry/tracing": "^7.26.0",
Sourcemaps would be uploaded and releases automatically created in Sentry, with no other side-effects.
I'm getting inconsistently failing builds in Vercel with this error:
Error: spawn /vercel/path0/node_modules/@sentry/cli/sentry-cli ENOENT
--
15:30:52.098 | at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
15:30:52.098 | at onErrorNT (node:internal/child_process:485:16)
15:30:52.098 | at processTicksAndRejections (node:internal/process/task_queues:83:21) {
15:30:52.098 | errno: -2,
15:30:52.098 | code: 'ENOENT',
15:30:52.098 | syscall: 'spawn /vercel/path0/node_modules/@sentry/cli/sentry-cli',
15:30:52.098 | path: '/vercel/path0/node_modules/@sentry/cli/sentry-cli',
15:30:52.098 | spawnargs: [ 'releases', 'propose-version' ],
15:30:52.098 | cmd: '/vercel/path0/node_modules/@sentry/cli/sentry-cli releases propose-version'
15:30:52.098 | }
This doesn't happen every time. I can redeploy the same commit in Vercel and it will work 1 out of every 3 times.
Right now it shows you your config object, but presumably you already know what's in there. What would be more helpful is if would tell you things like which files it would upload or which commits it would associate, so you can decide if you have your config set up correctly.
the Vite team with the help of our ecosystem partners, is happy to announce the release of Vite 4, powered during build time by Rollup 3
Hi!
I am using @sentry/vite-plugin
with Nuxt3.
I am generating a static file for use with CSR, but when generating, the Upload to sentry starts before the source map is created.
Is it possible to upload the source map after build?
generate log
[sentry-vite-plugin] Info: Sending error and performance telemetry data to Sentry. 16:18:08
[sentry-vite-plugin] Info: To disable telemetry, set options.telemetry to false. 16:18:08
[sentry-vite-plugin] Info: Successfully created release. 16:18:13
[sentry-vite-plugin] Info: Uploading Sourcemaps. 16:18:13
> Rewriting sources
> Rewriting completed in 0s
> Adding source map references
> Bundling files for upload...
> Bundling completed in 0.008s
> Optimizing completed in 0s
> Uploading completed in 0.227s
> Uploaded release files to Sentry
> Processing completed in 0.227s
> File upload complete (processing pending on server)
> Organization: xxxx
> Project: xxxx
> Release: xxxx
> Dist: None
Source Map Upload Report
[sentry-vite-plugin] Info: Successfully uploaded source maps. 16:18:15
[sentry-vite-plugin] Info: Successfully finalized release. 16:18:17
ℹ Client built in 8567ms 16:18:17
ℹ Building server... 16:18:17
[sentry-vite-plugin] Info: Sending error and performance telemetry data to Sentry. 16:18:17
[sentry-vite-plugin] Info: To disable telemetry, set options.telemetry to false. 16:18:17
[sentry-vite-plugin] Info: Successfully created release. 16:18:18
[sentry-vite-plugin] Info: Uploading Sourcemaps. 16:18:18
> Rewriting sources
> Rewriting completed in 0s
> Adding source map references
> Bundling files for upload...
> Bundling completed in 0s
> Optimizing completed in 0s
> Uploading completed in 0.231s
> Uploaded release files to Sentry
> Processing completed in 0.219s
> File upload complete (processing pending on server)
> Organization: xxxx
> Project: xxxx
> Release: xxxx
> Dist: None
Source Map Upload Report
[sentry-vite-plugin] Info: Successfully uploaded source maps. 16:18:21
[sentry-vite-plugin] Info: Successfully finalized release. 16:18:22
✔ Server built in 5376ms 16:18:22
✔ Generated public .output/public nitro 16:18:22
ℹ Initializing prerenderer nitro 16:18:22
ℹ Prerendering 5 initial routes with crawler nitro 16:18:23
├─ / (24ms) nitro 16:18:23
├─ /index.html (2ms) nitro 16:18:23
├─ /200.html (2ms) nitro 16:18:23
├─ /404.html (2ms) nitro 16:18:23
✔ You can now deploy .output/public to any static hosting!
It would be neat if, when specifying a path object in include
, the ignore
option could be a function to filter out files. For example:
include: {
paths: ["some/dir"],
ignore: file => file.startsWith("nope")
}
and then the function would be run against all of the filenames in some/dir
.
Example use case: I don't know ahead of time which chunks are going to contain my code and which will only contain framework or dependency code. If I could load each chunk's sourcemap and check out the sources
entry, I'd know where the code in the chunk came from and therefore whether or not I'd want to upload it to Sentry.
We should think about adding the plugin packages to the release registry. The webpack plugin was never added but it def doesn't hurt to do it. Perhaps it might even be helpful in the future.
Open question:
sdk
packages?This is low-prio. Just adding this issue so we don't forget it
Hello, I'm trying setup webpack cache in my project, and when I was added this configs
cache: {
type: 'filesystem',
cacheDirectory: process.env.CACHE_DIRECTORY
}
webpack caching works fine (first build => 146s / second build => 60s).
But when I am changing sentry release number and start build she is always takes 146s or more.
Please help me understand what I am doing wrong...
P.S. This is my SentryWebpackPlugin
configs
sentry: {
url: SENTRY_SERVICE_URL,
urlPrefix: `~/${SOURCE_DIRECTORY}`,
authToken: SENTRY_AUTH_TOKEN,
org: 'sentry',
project: SENTRY_FRONTEND_PROJECT,
release: [SENTRY_FRONTEND_PROJECT, SENTRY_RELEASE].join('-'),
include: output,
silent: true,
// Do not block deploy when sentry is not available
errorHandler: (err, invokeErr, compilation) => {
compilation.warnings.push(`Sentry CLI Plugin: ${err.message}`);
}
}
What version are you running? Etc.
yarn install
yarn build
The build succeeds.
With the @sentry/vite-plugin
in place in the vite.config.ts
the build script breaks with the message
Error: 'default' is not exported by node_modules/form-data/lib/browser.js, imported by node_modules/axios/lib/env/classes/FormData.js
Removing the plugin from the config, the build works.
SaaS (https://sentry.io/)
No response
I have Sentry connected to Vercel and GIthub and the following next.config.js:
However, the Vercel build fails at the Sentry CLI step.
// eslint-disable-next-line
const { withSentryConfig } = require('@sentry/nextjs');
// eslint-disable-next-line
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
poweredByHeader: false,
swcMinify: true,
compiler: {
removeConsole: process.env.NODE_ENV === 'production',
},
},
typescript: {
ignoreBuildErrors: true,
},
sentry: {
hideSourceMaps: true,
},
};
const sentryWebpackPluginOptions = {
silent: true, // Suppresses all logs
setCommits: {
repo: 'username/repo',
auto: true,
ignoreMissing: true,
},
};
module.exports = withSentryConfig(
withBundleAnalyzer(nextConfig),
sentryWebpackPluginOptions
);
Expect to Vercel build to pass and to deploy.
- info - Creating an optimized production build...
- Failed to compile.
- Sentry CLI Plugin: Command failed: /vercel/path0/node_modules/@sentry/cli/sentry-cli releases set-commits 9a08b86b.....364bc5fd67f --auto --ignore-missing
- error: No commits found. Change commits range, initial depth or use --ignore-empty to allow empty patch sets.
- > Build failed because of webpack errors
- error Command failed with exit code 1.
- - Error! Command "yarn run build" exited with 1
Not sure if it's failing because my config is incorrect or because Next.js using SWC as a default now instead of Webpack.
Supporting both headers
and customHeaders
options is unnecessary so we should just have headers
.
Once implemented, we shouldn't forget to add this removal/deprecation to the migration guide.
sentry-cli releases set-commits [email protected] --auto --ignore-missing --ignore-empty
New Sentry realse deployed
error: API request failed
caused by: sentry reported an error: request failure (http status: 400)
Object({"commits": Object({"patch_set": Object({"path": Array([String("Ensure this field has no more than 255 characters.")])})})})
Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.
It appears that the plugins only allow specifying a single custom header via customHeader
. I would like to add multiple headers.
We run Sentry self-hosted with Cloudflare Zero Trust. I need to be able to send Cf-Access-Client-Id
and Cf-Access-Client-Secret
headers with source-map upload request to successfully authenticate.
Provide a new option customHeaders
that accepts object of headers (Record<string, string>
). This option should be available on all plugins (webpack, vite, esbuild, rollup...).
Happy to attempt a PR if the feature request aligns with your vision and would help speed this up!
Look at isEntry
in resolveId
. If it's not an entry module, we store it in a map M
. in transform
we only inject the injector
when id
is not part of M
- that way we kinda robustly inject only in entry points. Additionally, we can also filter for things the user provides in the entries
option.
This issue serves as a roadmap to releasing Sentry bundler plugins for Vite, esbuild, Rollup. Eventually, we'll also replace our Sentry Webpack plugin with this new plugin.
For security purposes, we should not expose sourcemaps online. So a cleanSourceMaps
configuration is good to autodelete sourcemaps after artifacts has been uploaded successfully.
include
is the most important option option for the plugins and we have to support it properly.
include
can either be a simple string, an IncludeEntry
or an array with a mixture of strings and entries. Ideally, we normalize the given user option into an internal option and take it from there.
Prework:
Sub-options to support that deal with file collection:
EDIT: moved include
file modification options to separate issue (#81)
ref #50
Add writeBundle
hook support to Unplugin. This hook is invoked after the bundle was written and at this point we should be good to upload source maps (unjs/unplugin#179)
PR to use writeBundle
hook: #67
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.