Coder Social home page Coder Social logo

getsentry / sentry-webpack-plugin Goto Github PK

View Code? Open in Web Editor NEW
663.0 56.0 116.0 1.15 MB

Repo moved to https://github.com/getsentry/sentry-javascript-bundler-plugins. Please open any issues/PRs there.

License: MIT License

JavaScript 99.55% Shell 0.45%
tag-archived

sentry-webpack-plugin's Introduction

Sentry

Moved!

โš ๏ธ Notice: The repository for the @sentry/webpack-plugin package moved to https://github.com/getsentry/sentry-javascript-bundler-plugins.

Please open any issues and PRs over there, as this repository is no longer maintained!

Sentry Webpack Plugin

A webpack plugin acting as an interface to Sentry CLI.

Installation

@sentry/webpack-plugin requires at least [email protected] or any webpack@5 version to be installed.

Using npm:

$ npm install @sentry/webpack-plugin --save-dev

Using yarn:

$ yarn add @sentry/webpack-plugin --dev

CLI Configuration

You can use either .sentryclirc file or ENV variables described here https://docs.sentry.io/cli/configuration.

Usage

const SentryWebpackPlugin = require('@sentry/webpack-plugin');

const config = {
  plugins: [
    new SentryWebpackPlugin({
      include: '.',
      ignoreFile: '.sentrycliignore',
      ignore: ['node_modules', 'webpack.config.js'],
      configFile: 'sentry.properties',
    }),
  ],
};

Also, check the example directory.

Options

Option Type Required Description
include string/array/object required One or more paths that Sentry CLI should scan recursively for sources. It will upload all .map files and match associated .js files. Each path can be given as an object with path-specific options. See table below for details.
org string optional The slug of the Sentry organization associated with the app. Can also be specified via process.env.SENTRY_ORG.
project string optional The slug of the Sentry project associated with the app. Can also be specified via process.env.SENTRY_PROJECT.
authToken string optional The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes: project:releases (and org:read if setCommits option is used).
url string optional The base URL of your Sentry instance. Defaults to https://sentry.io/, which is the correct value for SAAS customers.
customHeader string optional A header added to all outgoing requests. A string in the format header-key: header-value
vcsRemote string optional The name of the remote in the version control system. Defaults to origin.
release string optional Unique identifier for the release. Can also be specified via process.env.SENTRY_RELEASE. Defaults to the output of the sentry-cli releases propose-version command, which automatically detects values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses HEAD's commit SHA. (For HEAD option, requires access to git CLI and for the root directory to be a valid repository).
dist string optional Unique identifier for the distribution, used to further segment your release. Usually your build number.
entries array/RegExp/function(key: string): bool optional Filter for entry points that should be processed. By default, the release will be injected into all entry points.
ignoreFile string optional Path to a file containing list of files/directories to ignore. Can point to .gitignore or anything with the same format.
ignore string/array optional One or more paths to ignore during upload. Overrides entries in ignoreFile file. If neither ignoreFile nor ignore is present, defaults to ['node_modules'].
configFile string optional Path to Sentry CLI config properties, as described in https://docs.sentry.io/product/cli/configuration/#configuration-file. By default, the config file is looked for upwards from the current path, and defaults from ~/.sentryclirc are always loaded
ext array optional The file extensions to be considered. By default the following file extensions are processed: js, map, jsbundle, and bundle.
urlPrefix string optional URL prefix to add to the beginning of all filenames. Defaults to ~/ but you might want to set this to the full URL. This is also useful if your files are stored in a sub folder. eg: url-prefix '~/static/js'.
urlSuffix string optional URL suffix to add to the end of all filenames. Useful for appending query parameters.
validate boolean optional When true, attempts source map validation before upload if rewriting is not enabled. It will spot a variety of issues with source maps and cancel the upload if any are found. Defaults to false to prevent false positives canceling upload.
stripPrefix array optional When paired with rewrite, will remove a prefix from filename references inside of sourcemaps. Useful for removing a path that is build-machine-specific. Note that this will NOT change the names of uploaded files.
stripCommonPrefix boolean optional When paired with rewrite, will add ~ to the stripPrefix array. Defaults to false.
sourceMapReference boolean optional Determines whether sentry-cli should attempt to link minified files with their corresponding maps. By default, it will match files and maps based on name, and add a Sourcemap header to each minified file for which it finds a map. Can be disabled if all minified files contain sourceMappingURL. Defaults to true.
rewrite boolean optional Enables rewriting of matching source maps so that indexed maps are flattened and missing sources are inlined if possible. Defaults to true
finalize boolean optional Determines whether Sentry release record should be automatically finalized (date_released timestamp added) after artifact upload. Defaults to true
dryRun boolean optional Attempts a dry run (useful for dev environments). Defaults to false, but may be automatically set to true in development environments by some framework integrations (Next.JS, possibly others).
debug boolean optional Print useful debug information. Defaults to false.
silent boolean optional Suppresses all logs (useful for --json option). Defaults to false.
cleanArtifacts boolean optional Remove all the artifacts in the release before the upload. Defaults to false.
errorHandler function(err: Error, invokeErr: function(): void, compilation: Compilation): void optional Function to call a when CLI error occurs. Webpack compilation failure can be triggered by calling invokeErr callback. Can emit a warning rather than an error (allowing compilation to continue) by setting this to (err, invokeErr, compilation) => { compilation.warnings.push('Sentry CLI Plugin: ' + err.message) }. Defaults to (err, invokeErr) => { invokeErr() }.
setCommits Object optional Adds commits to Sentry. See table below for details.
deploy Object optional Creates a new release deployment in Sentry. See table below for details.

options.include:

Option Type Required Description
paths array required One or more paths to scan for files to upload.
ignoreFile string optional See above.
ignore string/array optional See above.
ext array optional See above.
urlPrefix string optional See above.
urlSuffix string optional See above.
stripPrefix array optional See above.
stripCommonPrefix boolean optional See above.
sourceMapReference boolean optional See above.
rewrite boolean optional See above.

Example:

const SentryWebpackPlugin = require('@sentry/webpack-plugin');

const config = {
  plugins: [
    new SentryWebpackPlugin({
      include: [
        {
          paths: ['./packages'],
          urlPrefix: '~/path/to/packages',
        },
        {
          paths: ['./client'],
          urlPrefix: '~/path/to/client',
        },
      ],
      ignoreFile: '.sentrycliignore',
      ignore: ['node_modules', 'webpack.config.js'],
      configFile: 'sentry.properties',
    }),
  ],
};

options.setCommits:

Option Type Required Description
repo string see notes The full git repo name as defined in Sentry. Required if auto option is not true, otherwise optional.
commit string see notes The current (most recent) commit in the release. Required if auto option is not true, otherwise optional.
previousCommit string optional The last commit of the previous release. Defaults to the most recent commit of the previous release in Sentry, or if no previous release is found, 10 commits back from commit.
auto boolean optional Automatically set commit and previousCommit. Defaults commit to HEAD and previousCommit as described above. Overrides other options
ignoreMissing boolean optional When the flag is set and the previous release commit was not found in the repository, will create a release with the default commits count (or the one specified with --initial-depth) instead of failing the command.

options.deploy:

Option Type Required Description
env string required Environment value for the release, for example production or staging.
started number optional UNIX timestamp for deployment start.
finished number optional UNIX timestamp for deployment finish.
time number optional Deployment duration in seconds. Can be used instead of started and finished.
name string optional Human-readable name for this deployment.
url string optional URL that points to the deployment.

You can find more information about these options in our official docs: https://docs.sentry.io/product/cli/releases/#sentry-cli-sourcemaps.

sentry-webpack-plugin's People

Contributors

asottile-sentry avatar daidi avatar dcramer avatar dependabot[bot] avatar fadomire avatar getsentry-bot avatar hazat avatar jan-auer avatar janicduplessis avatar kamerat avatar kamilogorek avatar lforst avatar lms24 avatar lobsterkatie avatar mesaugat avatar montogeek avatar palindrom615 avatar rchl avatar rhcarvalho avatar roelvanhintum avatar sawilde avatar scefali avatar seb-l avatar semoal avatar shyela avatar simon-rad avatar snyk-bot avatar tannerhallman avatar timfish avatar valerybugakov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentry-webpack-plugin's Issues

Does not work with Typescript

When attempting use use with Webpack I get the following:

Error: ./src/app/app.module.ts
Module parse failed: Unexpected character '@' (27:0)
You may need an appropriate loader to handle this file type.
| import { Services } from '../services';
|
| @NgModule({
|   declarations: [MyApp],
|   imports: [
 @ ./src/app/main.ts 16:0-41
 @ multi ./node_modules/@sentry/webpack-plugin/src/sentry-webpack.module.js ./src/app/main.ts
    at new BuildError (/path-to-project/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at callback (/path-to-project/node_modules/@ionic/app-scripts/dist/webpack.js:121:28)
    at emitRecords.err (/path-to-project/node_modules/webpack/lib/Compiler.js:269:13)
    at Compiler.emitRecords (/path-to-project/node_modules/webpack/lib/Compiler.js:375:38)
    at emitAssets.err (/path-to-project/node_modules/webpack/lib/Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (/path-to-project/node_modules/webpack/lib/Compiler.js:368:12)
    at next (/path-to-project/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/path-to-project/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at next (/path-to-project/node_modules/tapable/lib/Tapable.js:220:14)
    at versionPromise.then.then.then.then (/path-to-project/node_modules/@sentry/webpack-plugin/src/index.js:92:21)

ERROR in Sentry CLI Plugin: Cannot read property 'execute' of undefined

Hello,

I'm trying to run webpack using following plugin configuration and .sentryclirc file;

    plugins: [
        new SentryCliPlugin({
            release: function (hash) {
                return hash.slice(0, 5)
            },
            include: '.',
            ignore: ['node_modules', 'webpack.config.js'],
            configFile: 'sentry.properties'
        })
    ],
[defaults]
url=https://sentry.io/
org=xxx-llc
project=react

[auth]
token=asdfdsa9a3asdfadsfasdfasdfsdafdasdsfasadff17c721asdfdsafasdfdsaf

And I'm getting this error;
ERROR in Sentry CLI Plugin: Cannot read property 'execute' of undefined

error: An organization slug is required (provide with --org)

Hi, trying to upload sourcemap to sentry, but catch this error:

    ERROR in Sentry CLI Plugin: Command failed: /node_modules/@sentry/cli/sentry-cli releases new <version>
    error: An organization slug is required (provide with --org)

There is how i use plugin:

new SentryCliPlugin({
  release: require(root('package.json')).version,
  include: '.',
  ignoreFile: root('.gitignore'),
  configFile: root('src/site/sentry.properties'),
  ignore: ['node_modules', 'webpack.config.js'],
}),

And there is sentry.properties file:

defaults.url = https://sentry.io/
defaults.org = <org slug>
defaults.project = <project>

auth.token = <token>

Tryed to set env variable directly (export SENTRY_ORG= <org slug>) and run webpack again, but catch new error:

    ERROR in Sentry CLI Plugin: Command failed: /node_modules/@sentry/cli/sentry-cli releases new <version>
    error: project not found

Version:
"@sentry/webpack-plugin": "^1.5.2",

Adding "ext: '.css' " or "ext: 'css'" excludes .js and .map.* from upload

The following config uploads the bundle.js, bundle.map.js and bundle.css.map effectively:

    new SentryCliPlugin({
      release: (hash) => hash,
      include: buildPath,
      ignore: ['.'],
      configFile: 'sentry.properties',
    }),

But adding either ext: '.css' or ext: 'css' excludes those files from being uploaded, and bundle.css is uploaded.
Am I doing something wrong?

sentry-cli 504 preventing Webpack build from completing

ERROR in Sentry CLI Plugin: Command failed: /home/website/node_modules/@sentry/cli/sentry-cli releases files 074f833a9ebd25066afc2cad5863fac252b9b4ca upload-sourcemaps ./build/ --ignore node_modules --rewrite
error: API request failed
  caused by: sentry reported an error: unknown error (http status: 504)

Are there any ongoing issues? This was working without any problems yesterday.

Could not automatically determine release name

image

webpack config:

const path = require('path');
const SentryCliPlugin = require('@sentry/webpack-plugin');
module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist')
  },
  devtool: 'sourcemap',
  plugins: [
  	new SentryCliPlugin({
  		include: './dist',
  		configFile: `${__dirname}/sentry.properties`
  	})
  ]
};
defaults.url=http://sentry.zhuanzhuan.com/
defaults.org=zhuanzhuan
defaults.project=sentry-test

auth.token=53a6a4e8b6e0400393c9358768e338cac90f9715686546fe89042dcabfa955e0

If I set the release name manually, it all works well.

I'm just wondering, how is release name automatically generated? And why did it fail?

Sentry Webpack Plugin runs for a long time

We are using this plugin and for us it significantly increases the build time so our automated builds are timing out. This is the output for our build measured with the Speed Measure Plugin

With Sentry Webpack Plugin

 SMP  โฑ  
General output time took 13 mins, 14.095 secs

 SMP  โฑ  Plugins
SentryCliPlugin took 11 mins, 15.85 secs
HtmlWebpackPlugin took 1.78 secs
GitRevisionPlugin took 0.423 secs
NamedModulesPlugin took 0.042 secs
Object took 0.031 secs
ContextReplacementPlugin took 0.001 secs
DefinePlugin took 0 secs

 SMP  โฑ  Loaders
modules with no loaders took 34.51 secs
  module count = 2896
babel-loader took 34.16 secs
  module count = 627
css-loader, and 
postcss-loader, and 
sass-loader took 33.14 secs
  module count = 106
css-loader, and 
postcss-loader, and 
less-loader took 15.19 secs
  module count = 34
url-loader took 7.43 secs
  module count = 576
css-loader, and 
postcss-loader took 2.88 secs
  module count = 18
file-loader took 0.404 secs
  module count = 2
style-loader, and 
css-loader, and 
postcss-loader, and 
sass-loader took 0.097 secs
  module count = 106
style-loader, and 
css-loader, and 
postcss-loader, and 
less-loader took 0.031 secs
  module count = 34
html-webpack-plugin took 0.024 secs
  module count = 1
@sentry took 0.021 secs
  module count = 1
style-loader, and 
css-loader, and 
postcss-loader took 0.013 secs
  module count = 18





 SMP  โฑ  
General output time took 13 mins, 48.71 secs

 SMP  โฑ  Plugins
SentryCliPlugin took 11 mins, 55.69 secs
HtmlWebpackPlugin took 2.3 secs
GitRevisionPlugin took 0.413 secs
NamedModulesPlugin took 0.046 secs
Object took 0.028 secs
ContextReplacementPlugin took 0.001 secs
DefinePlugin took 0 secs

 SMP  โฑ  Loaders
modules with no loaders took 31.97 secs
  module count = 2896
css-loader, and 
postcss-loader, and 
sass-loader took 31.41 secs
  module count = 106
babel-loader took 31.061 secs
  module count = 627
css-loader, and 
postcss-loader, and 
less-loader took 14.65 secs
  module count = 34
url-loader took 8.11 secs
  module count = 576
css-loader, and 
postcss-loader took 3.17 secs
  module count = 18
@sentry took 0.129 secs
  module count = 1
html-webpack-plugin took 0.128 secs
  module count = 1
file-loader took 0.114 secs
  module count = 2
style-loader, and 
css-loader, and 
postcss-loader, and 
sass-loader took 0.093 secs
  module count = 106
style-loader, and 
css-loader, and 
postcss-loader, and 
less-loader took 0.036 secs
  module count = 34
style-loader, and 
css-loader, and 
postcss-loader took 0.016 secs
  module count = 18

Without Sentry Webpack Plugin

 SMP  โฑ  
General output time took 4 mins, 40.91 secs

 SMP  โฑ  Plugins
HtmlWebpackPlugin took 1.72 secs
GitRevisionPlugin took 0.553 secs
NamedModulesPlugin took 0.049 secs
Object took 0.039 secs
ContextReplacementPlugin took 0.001 secs
DefinePlugin took 0 secs

 SMP  โฑ  Loaders
modules with no loaders took 39.24 secs
  module count = 2896
babel-loader took 38.82 secs
  module count = 627
css-loader, and 
postcss-loader, and 
sass-loader took 38.44 secs
  module count = 106
css-loader, and 
postcss-loader, and 
less-loader took 17.6 secs
  module count = 34
url-loader took 5.72 secs
  module count = 576
css-loader, and 
postcss-loader took 4.33 secs
  module count = 18
style-loader, and 
css-loader, and 
postcss-loader, and 
sass-loader took 0.123 secs
  module count = 106
file-loader took 0.102 secs
  module count = 2
style-loader, and 
css-loader, and 
postcss-loader, and 
less-loader took 0.037 secs
  module count = 34
html-webpack-plugin took 0.026 secs
  module count = 1
style-loader, and 
css-loader, and 
postcss-loader took 0.014 secs
  module count = 18

How to get release hash from Raven.config๏ผŸ

What this plugin actually do? Auto releasing & uploading source map? Do I still need to set the release field in my Raven.config like I used to in my own shell script? If so, how do I get the release hash, from environment variables?

throw callback error in Promise

Hi. Now I need to throw the error, which sometimes occurs in webpack compiler's callback, to terminate the node process.

webpack(webpackConfig, (err, stats) => {
  if (err) throw err
  // ...
})

But UnhandledPromiseRejectionWarning was received, indicating the error thrown from callback was wrapped in promise chain and the node process was not terminated as expected. After debugging, I found the following code triggered the warning.

attachAfterEmitHook(compiler, (compilation, cb) => {
  this.finalizeRelease(compilation).then(() => cb())
});

Error thrown in cb was wrapped in this.finalizeRelease promise chain. Would you mind calling the cb in setTimeout method to throw out the possible error from promise chain, like:

this.finalizeRelease(compilation).then(() => {
  setTimeout(function(){
    cb()
  })
})

many thanks

Build takes a long time, then "Command failed" "sentry-cli releases files"

With the plugin configured, the build takes a lot longer, but then it fails with the following error:

ERROR in Sentry CLI Plugin: Command failed: /Users/alexkinnee/repos/Notion/desktop/node_modules/@sentry/cli/sentry-cli releases files connect-2.24.2-252cbe4ed7e90e59a750d016750055c463f629e4 upload-sourcemaps . --ignore node_modules --ignore /webpack/ --rewrite

But then I see the release in Sentry:
screen shot 2018-06-21 at 10 21 47 am

How can I debug/fix whatever is going on?

Thanks!

Upload files created in current build only

Current behavior in this plugin is to upload all .js and .map files present in include option and omit the ones specified in ignore.
Once the compilation is done webpack will call the plugins with the list of files it created, is there any specific reason we are not using this list of files to upload to sentry.

Currently we are having a build system where the output folder will have js files of previous build and every time sentry will upload all the files, including the ones from previous build.

ReferenceError: global is not defined

Hi.
It seems like the plugin, tries to inject some code in the bundle which sets SENTRY_RELEASE on global object, which causes an error. Because global var is not defined in the browser.
How can I solve the issue?

ext option ignored

    new SentryCliPlugin({
      release: hash => hash,
      include: `${paths.build}`,
      ext: 'css',
      ignore: ['.'],
      configFile: 'sentry.properties',
    }),

Does not upload my .css bundle, same happens with ext:'.css'

Am I doing anything wrong?

I can confirm that the .css file is there, same directory as the rest of bundles.

Reference git commit for a release

Continued from #55 as that was closed early.

If we're using a different release, is there no way to pass options to the set-commits command in sentry-cli? Even when not setting a release, I do not see releases tagged with specific git commits in Sentry.


The top 2 releases are once switching to this plugin - note there not being any git commits registered.

As per the docs, something like this would be great:

"refs": [{
    "repository":"owner-name/repo-name",
    "commit":"2da95dfb052f477380608d59d32b4ab9",
    "previousCommit":"1e6223108647a7bfc040ef0ca5c92f68ff0dd993" // optional
}],

Map Chunks to Sentry Projects

Thanks for the awesome plugin!

I'd love to have the ability to map webpack generated chunks to separate sentry projects.

My application is split into multiple chunks that are asynchronously loaded and some their own own instance of Raven (see getsentry/sentry-javascript#1272). This is really helpful for a complex application as we can chunk each section of the webapp and load dependencies / pages gradually.

Right now I have to have multiple configFiles for each project just to pass in a different project name. I'd rather be able to share 1 config file for things like auth & organization and pass in the project name as an option.

Proposed interface:

 new SentryCliPlugin({
            include: 'dist',
            configFile: '.sentryclirc',
            ignoreFile: '.gitignore',
            configOptions: { project: 'some-project' },
            ignore: ['node_modules', 'webpack.config.js'],
}),

or

 new SentryCliPlugin({
            include: 'dist',
            ignoreFile: '.gitignore',
            configOptions: { project: 'some-project', organization: 'organization-value-here' },
            ignore: ['node_modules', 'webpack.config.js'],
}),

what I currently do:

[
 new SentryCliPlugin({
            include: 'dist',
            configFile: '.sentryclirc.project_1',
            ignoreFile: '.gitignore',
            ignore: ['node_modules', 'webpack.config.js'],
}),
 new SentryCliPlugin({
            include: 'dist',
            configFile: '.sentryclirc.project_2,
            ignoreFile: '.gitignore',
            ignore: ['node_modules', 'webpack.config.js'],
}),
 new SentryCliPlugin({
            include: 'dist',
            configFile: '.sentryclirc.project_3',
            ignoreFile: '.gitignore',
            ignore: ['node_modules', 'webpack.config.js'],
}),
]

Webpack compatibility

Hi!

Is this plugin compatible with webpack 1.14.0?
It is throwing this error: ERROR in Sentry CLI Plugin: Cannot read property 'include' of undefined.

When logging this.options just before calling SentryCLI I got my webpack configuration instead of just the options in the plugin, I guess in webpack 1.14 options it is a reserved key.

My only option would be upgrade webpack, right?

Unable to install via npm

What ?

Unable to install this plugin via npm(version: 3.10.3).

Getting error of type:
Error: Command failed: /Users/anand/Desktop/practo/partner-ui/purchase-flow/node_modules/@sentry/cli/sentry-cli --version error: 1:0 Expecting "[Some('='), Some(':')]" but found EOF.

Tried installing @sentry/cli also. But it didn't worked

Delete SourceMaps after upload

Does this support deleting sourcemaps from the local filesystem after they've been successfully uploaded to sentry? I can't seem to find any documentation for how to do this.

Deprecation Warning webpack 4

I have this warning when i build on webpack 4 :
DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

Move @sentry/cli to peer dependencies?

At the time I'm writing this I can't install @sentry/cli@1.30.3 on Windows since the install script searches for an executable which is currently unavailable. That renders @sentry/webpack-plugin unavailable for installation on Windows. Do you guys mind specifying @sentry/cli as a peer dependency? Something like this could happen in the future.

Overwrite existing release artifacts when restarted

Our deployment script for a specific git tag sometimes fails in our CI because of a service provider quota restrictions. We must restart our Travis build to restart the deployment.

But the webpack bundling fails because of Sentry which fails to upload the artifacts because a release already exist for this tag (conflicts with existing artifacts).

Is it possible to add an option to overwrite these artifacts ?

How to make sure source maps were actually uploaded?

Hello! I've added sentry-webpack-plugin to the production build config and the build goes fine without errors. However, on the sentry.io dashboard, I still see there is no checkmark against the "Upload sourcemaps" item. The error traces are minified as well.
How can I check the plugin works correctly?
Maybe I missed something -- do I have to configure webpack to create sourcemaps (i.e. with the devtool option)? There is nothing like that in the description or in the examples, so I assume this plugin should take care of everything. Is that so?

Webpack 3.10.0 incompatibility

Hello again!
Webpack 3.10.0 allows you to pass an array of rules using the rules or loaders key:

module: {
	loaders: [
	  {
	    test: /\.handlebars$/,
	    exclude: /(node_modules|bower_components|public\/)/,
	    use: [
	      {
	        loader: 'handlebars-loader',
	        options: { inlineRequires: 'static/icons' }
	      }
	    ]
	  },
	]
}

But this plugin only checks for the rules key, since it is undefined, it would reset the rules, deleting the user loaders configuration:

if (typeof changedCompiler.options.module.rules === 'undefined') {
changedCompiler.options.module.rules = [];
}

I guess webpack supports this for historical reasons, I am not sure if the plugin should handle this case or the user should be more careful with its webpack configuration or webpack should no support it.

More info in the webpack migration guide: https://webpack.js.org/guides/migrating/#module-loaders-is-now-module-rules
Source code on webpack side: https://github.com/webpack/webpack/blob/f352436a0fd6491b8cc1aadeddfbe02c878686ff/lib/NormalModuleFactory.js#L49

As you can see rules is used if defined.

This bug was introduced in #20

Since it is supported by webpack I think the plugin should support it.

The solution should be adding an additional check for loaders key.

sentryCli.createRelease is not a function

Version: @sentry/[email protected]

Error:

/workdir/node_modules/@sentry/webpack-plugin/src/index.js:34
      .createRelease(release)
       ^

TypeError: sentryCli.createRelease is not a function
    at Compiler.<anonymous> (/home/eb/Share/front/front.2407/node_modules/@sentry/webpack-plugin/src/index.js:34:8)
    at next (/home/eb/Share/front/front.2407/node_modules/tapable/lib/Tapable.js:220:14)
    at callback (/home/eb/Share/front/front.2407/node_modules/copy-webpack-plugin/dist/index.js:129:17)
    at Compiler.<anonymous> (/home/eb/Share/front/front.2407/node_modules/copy-webpack-plugin/dist/index.js:155:13)
    at Compiler.applyPluginsAsyncSeries1 (/home/eb/Share/front/front.2407/node_modules/tapable/lib/Tapable.js:222:13)
    at Compiler.afterEmit (/home/eb/Share/front/front.2407/node_modules/webpack/lib/Compiler.js:361:9)
    at require.forEach.err (/home/eb/Share/front/front.2407/node_modules/webpack/lib/Compiler.js:350:15)
    at /home/eb/Share/front/front.2407/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/home/eb/Share/front/front.2407/node_modules/async/dist/async.js:1050:13)
    at /home/eb/Share/front/front.2407/node_modules/async/dist/async.js:958:16
    at /home/eb/Share/front/front.2407/node_modules/temp-write/node_modules/graceful-fs/graceful-fs.js:104:5
    at /home/eb/Share/front/front.2407/node_modules/gulp-cssmin/node_modules/graceful-fs/graceful-fs.js:104:5
    at /home/eb/Share/front/front.2407/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)

Webpack config:

new SentryCliPlugin({
     release: function(hash) {
       return hash.slice(0, 5);
     },
     include: '.',
     ignoreFile: '.sentrycliignore',
     ignore: ['node_modules', 'webpack.config.js'],
     configFile: 'sentry.properties'
   })

Lastly, my .sentryclirc:

[defaults]
project=projectname
org=myorgname

Adding this plugin to config causes data to be omitted from my webpack-stats output

This is a super bizarre bug, but I've investigated for hours and can't seem to find how the cause and effect here are related.

Steps that result in the problem

  1. My webpack setup uses webpack's CommonChunkPlugin twice, and the plugin section looks something like this:
plugins: [...,
new webpack.optimize.CommonsChunkPlugin({
      chunks: [ENTRY_MAIN_LOGGEDIN, ...Object.keys(ENTRY_PAGES_LOGGEDIN)],
      name: ENTRY_VENDOR_LOGGEDIN,
      minChunks: isNodeModule,
    }),
    new webpack.optimize.CommonsChunkPlugin({
      chunks: [ENTRY_MAIN, ...Object.keys(ENTRY_PAGES)],
      name: ENTRY_VENDOR,
      minChunks: isNodeModule,
    }), ...]
  1. I install sentry-webpack-plugin directly as specified in the documentation. This includes adding to the plugins array:
new SentryCliPlugin({
      include: '.',
      ignoreFile: '.sentrycliignore',
      ignore: ['node_modules', 'webpack.config.js'],
      configFile: 'sentry.properties'
    })
  1. I run cross-env NODE_ENV='production' webpack --config webpack.config.js to build my files.

What happens

My output for webpack stats (webpack-stats.json) is drastically smaller than it should be. Specifically, it only contains two chunks (specifically with the names from constants ENTRY_VENDOR and ENTRY_MAIN). All of the other chunk locations (and all of the rest of my static files) are not included in webpack-stats.json.

The crazy part of this is that if I remove the new SentryCliPlugin() block from my plugins array, my webpack stats file generates normally, with 20 chunks and a file about 6x longer. The problem is directly reproducible by simply adding the SentryCliPlugin.

What I've tried

  • Checking for webpack errors in output (there were none)
  • Reinstalling sentry-webpack-plugin into my project
  • Checking github issues for both webpack and sentry-webpack-plugin for similar problems

Let me know if there is any more information I can provide here to get to the root of the problem! Thanks for the work on sentry-webpack-plugin.

Passing release option won't upload source files

I'm getting started with this plugin

First, I tried pass include option only, and it works fine.
webpack.config.js:

  new SentryCliPlugin({
      include: paths.appBuild,
  }),

upload artifacts:
fireshot capture 1 - release 6e50f97cdeaf50416ed380de4f19c3_ - https___sentry szzbmy com_sentry_ap

all my source file were uploaded.


but after I pass release option

webpack.config.js

    new SentryCliPlugin({
      release: 'prod_1_0_0',
      include: paths.appBuild,
    }),

upload artifacts:
fireshot capture 2 - release prod_1_0_0 i gz-niubility _ ap_ - https___sentry szzbmy com_sentry_ap

only some of my source files were uploaded.

Unable to install in CI

I'm trying to enable Sentry in CI but on yarn install I get :

[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /builds/project_name/node_modules/@sentry/cli: Command failed.
Exit code: 1
Command: node scripts/install.js
Arguments: 
Directory: /builds/project_name/node_modules/@sentry/cli
Output:
fetching sentry-cli-Linux-x86_64 1%
fetching sentry-cli-Linux-x86_64 2%
fetching sentry-cli-Linux-x86_64 3%
...
fetching sentry-cli-Linux-x86_64 99%
fetching sentry-cli-Linux-x86_64 100%
Error: spawn /builds/project_name/node_modules/@sentry/cli/sentry-cli ENOENT
ERROR: Job failed: exit code 1

I was using version 1.3.2 but I just tried with 1.5.0 and have the same error ...

Any idea why ?

Error in sentry-webpack-plugin when uploading source-maps.

WebPack Sentry Cli Plugin Configuration.

new SentryCliPlugin({ release: commitId, include: '.', ignoreFile: '.sentrycliignore', ignore: ['node_modules', 'webpack', 'server', 'internals'], }),
StackTrace

ERROR in Sentry CLI Plugin: Command failed: .../node_modules/@sentry/cli/sentry-cli releases files 0a7f3e642bd63455b43bfa6d4dfe588704335bd8 upload-sourcemaps . --ignore node_modules --ignore webpack --ignore-file .sentrycliignore --rewrite

Child __offline_serviceworker:
1 asset
Child html-webpack-plugin for "index.html":
1 asset
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress --hide-modules --display-optimization-bailout
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/.npm/_logs/2018-02-27T07_08_00_943Z-debug.log

Version Used : 1.3.3

Invalid release version

Hi and thanks for the lib!

I'm getting an error when the plugin tries to create a release:

ERROR in Sentry CLI Plugin: Command failed: [my project path]/node_modules/@sentry/cli/sentry-cli releases new c38d[...]f04

error: Invalid value for '<VERSION>': Invalid release version. Releases must not contain leading or trailing spaces.

although running this command by hand works:

> [my project path]/node_modules/@sentry/cli/sentry-cli releases new c38d[...]f04
Created release c38d[...]f04

Could it be an error in the plugin or a wrong configuration on my side?

My config:

    new SentryCliPlugin({
      include: './public',
      ignore: ['node_modules', 'webpack.common.js'],
    }),

Sourcemaps not being applied.

Upon build we can see that the files are being uploaded to sentry successfully as in the image:

screen shot 2018-06-19 at 08 33 43

We can see issues coming in under the new release and when browsing to the files with their hashes they are definitely available at those paths:

screen shot 2018-06-19 at 08 34 26

However the code is still minified on the details/dashboard screen:

screen shot 2018-06-19 at 08 35 51

our webpack config (the relevant parts):

const RELEASE_HASH = Math.round((new Date()).getTime() / 1000)

devtool: isProd
    ? '#hidden-source-map'
    : '#cheap-module-source-map',
output: {
    path: path.resolve(__dirname, '../dist'),
    publicPath: '/dist/',
    filename: '[name].[chunkhash].js'
},
plugins: [
    new webpack.DefinePlugin({
        'process.env.RELEASE_HASH': JSON.stringify(RELEASE_HASH || '')
    }),
    new SentryPlugin({
        release: RELEASE_HASH,
        include: './dist',
        ignore: [
            'node_modules',
            'webpack.base.config.js'
        ],
    })
]

Any assistance would be appreciated thank you.

ENV variables probably are not passed at all

I am trying to use this plugin. I set all the env variables needed before running the webpack:

export SENTRY_AUTH_TOKEN=
export SENTRY_URL=
export SENTRY_ORG=
export SENTRY_PROJECT=

And still was getting:

ERROR in Sentry CLI Plugin: Command failed: /.../node_modules/@sentry/cli/sentry-cli releases new e7007
error: An organization slug is required (provide with --org)

After investigating whats going on, I think most likely the issue is that the JS wrapper for sentry does not actually pass the env variables with exception of setting (SENTRY_PROPERTIES).

https://github.com/getsentry/sentry-cli/blob/master/js/index.js#L62

So it seems that only way to pass actual settings are via config file.. which is undesirable as don't want to have auth token in file.

Sourcemaps parsed incorrectly

It seems like source maps aren't parsed correctly when viewing issues in Sentry's UI.

Source code was not found for webpack:///webpack/bootstrap 642dd076bbe473e6
Source code was not found for webpack:///../node_modules/core-js/modules/_set-proto.js
Source code was not found for webpack:///./apps/instances/instance.js

is what Sentry is reporting, for example.

A link to the specific issue can be found at https://sentry.io/share/issue/46e2657a83244cc9acba898659521bdb/. As per the file listed here (/assets/js/bundles/instances-fc59da29737ba10d-eaed66e.js), you can see from our release artifcacts, it exists:

This release ID is eaed66e3724291efc081574d7ff54e180f9f8d02, and as you can see below, the issue itself is tagged correctly with this release ID.

Looking at the "original" trace via the link above does seem to report valid line numbers, but not any actual code.

Let me know if we can provide any further information.

ignoreFile option is not respected

This plugin, by default, injects release id in all the files under the include path.

Need to ignore a file from the above process, because it adds unnecessary reference of global in the file.

Hence included .sentrycliignore file and added a entry of the file name to be ignored in it.

But it doesn't work. Please suggest how to make this work

Getting access to contenthash and hash in plugin

I was wondering if there is a way to do something like this in the sentry webpack plugin.

new SentryPlugin({
        release: '[hash]-[contenthash]',
        include: './dist',
        ignore: ['node_modules', 'webpack.config.js'],
})

I'm also using the mini-css-extract plugin that exposes a [contenthash]. I was wondering if there was a way to get access to the hashes as part of the plugin initialization.

Thanks!

Question: Env vars

Hello,

First, thank you very much for maintaining this repository and Sentry, my best companion for years ;)

I don't understand how to configure the plugin. I mean, I have a standard docker deployment and try to abide by 12factor. So, I have an environment variable with the sentry URL including credentials.

If I understand how to use this plugin correctly, I should write a file with my env var in the docker container with the credentials again so that I can link to it with sentry.properties file ? Note that our container is public, so that means I should write this file from runtime, maybe in django settings or something ...

Is there any way it could just configure itself on runtime using env vars instead of configuration file ?

Thanks

Option to add a suffix

From Sentry's support team asked me to upload the artifacts matching the URL of my JS bundle including the query param with the version number that I'm using for cache busting on each release.

~/assets/app.bundle.js?v=5.0.10 (notice the part ?v=5.0.10).

Is there any option to add a suffix?

If there is not done yet I'll try to add a PR. Should be simple because we already have an option to add a prefix.

Build failed in 1.3.0 release

Hi! I got the next error when updated plugin to 1.3.0 version:

ERROR in ./node_modules/@sentry/webpack-plugin/src/sentry-webpack.module.js
Module parse failed: Unterminated string constant (2:25)
You may need an appropriate loader to handle this file type.
| global.SENTRY_RELEASE={};
| global.SENTRY_RELEASE.id="function release(hash) {
| return 'FE_' + hash.slice(0, 8);
| }";

Why does this happen?

Sentry CLI usage

Hello!

Thanks for this webpack plugin, really useful.
I have a question regarding Sentry CLI usage, Why it was considered instead of using the API?
My concern is that downloading sentry-cli-binary takes a lot of time, increasing yarn or npm installs time significantly.

Thanks!

Node 4 support

hey guys, I'm aware node 4 is a legacy version but i have a pretty large codebase on AWS Lambda/ Serverless framework 0.5.6 that im integrating Sentry into and wondering what the effort is like to get the module working for node >= 4.3.x. <= 6.x.x At the moment i get syntax errors, but hoping i can convert these easily. I'll dig into the codebase when i get a moment, but wanted to get initial thoughts.

[SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode]

thanks

Uploading sourcemaps issue: An organization slug is required (provide with --org)

Hi,

I'm using these versions of sentry webpack plugin and cli

"@sentry/cli@^1.28.1":
  version "1.30.2"
  resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.30.2.tgz#ead724c661920acda9b37779613dab7b0be9d828"
  dependencies:
    https-proxy-agent "^2.1.1"
    node-fetch "^1.7.3"
    progress "2.0.0"
    proxy-from-env "^1.0.0"

"@sentry/webpack-plugin@^1.3.3":
  version "1.3.3"
  resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.3.3.tgz#017bd7a89c8c9277d79c6c5feb51c1e6c6832b1b"
  dependencies:
    "@sentry/cli" "^1.28.1"

My sentry.properties file looks like this

[defaults]
url=https://sentry.io/
org=<YourOrgShortname>
project=<YourProjectShortname>

[auth]
token=<YourToken>

In webpack.config I've added plugin, where configFile is path to sentry.properties file

      new SentryCliPlugin({
        release: process.env.LAST_BUILD_TIME,
        configFile: process.env.SENTRY_PROPERTIES_FILE,
        include: './app/dist'
      }),

However, I always get this error below, but as you can see above I've added all required properties to sentry.properties file. Obviously sentry.properties file is correct because if I remove all lines I get different message error: http error: Authentication credentials were not provided. (401)

./node_modules/@sentry/cli/sentry-cli releases new 1520006165 error: An organization slug is required (provide with --org)

I've opened stackoverflow question earlier just in case I'm doing something wrong...
https://stackoverflow.com/questions/49073088/issue-with-uploading-sourcemaps-with-sentry-webpack-plugin

Thanks for help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.