Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sentry/esbuild-plugin

Package Overview
Dependencies
Maintainers
12
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/esbuild-plugin

Official Sentry esbuild plugin

  • 0.2.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
92K
decreased by-0.8%
Maintainers
12
Weekly downloads
 
Created
Source

Sentry

Sentry Esbuild Plugin

A esbuild plugin that provides release management features for Sentry:

  • Sourcemap upload
  • Release creation
  • Automatic release name discovery (based on CI environment - Vercel, AWS, Heroku, CircleCI, or current Git SHA)
  • Automatically association of errors with releases (Release injection)

Installation

Using npm:

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

Using yarn:

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

Usage

// esbuild.config.js
const sentryEsbuildPlugin = require("@sentry/esbuild-plugin");

require("esbuild").build({
  plugins: [
    sentryEsbuildPlugin({
      include: ".",
      ignore: ["node_modules", "esbuild.config.js"],
      org: process.env.SENTRY_ORG,
      project: process.env.SENTRY_PROJECT,
      authToken: process.env.SENTRY_AUTH_TOKEN,
    }),
  ],
});

As an alternative to passing options explicitly, you can also use a .sentryclirc file or environment variables as described in https://docs.sentry.io/product/cli/configuration/.

Configuration

The Sentry Esbuild Plugin takes an options argument with the following properties:

OptionTypeRequiredDescription
includestring/array/objectrequiredOne or more paths that the plugin should scan recursively for sources. It will upload all .map files and match associated .js files. Other file types can be uploaded by using the ext option. Each path can be given as a string or an object with path-specific options. See table below for details.
orgstringoptionalThe slug of the Sentry organization associated with the app. Can also be specified via the SENTRY_ORG environment variable.
projectstringoptionalThe slug of the Sentry project associated with the app. Can also be specified via the SENTRY_PROJECT environment variable.
authTokenstringoptionalThe 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). Can also be specified via the SENTRY_AUTH_TOKEN env variable.
urlstringoptionalThe base URL of your Sentry instance. Use this if you are using a self-hosted or Sentry instance other than sentry.io. This value can also be set via the SENTRY_URL environment variable. Defaults to https://sentry.io/, which is the correct value for SaaS customers.
customHeaderstringoptionalA header added to every outgoing network request. The format should be header-key: header-value. This value can also be specified via the CUSTOM_HEADER environment variable.
vcsRemotestringoptionalVersion control system remote name. This value can also be specified via the SENTRY_VSC_REMOTE environment variable. Defaults to 'origin'.
releasestringoptionalUnique identifier for the release. This value can also be specified via the SENTRY_RELEASE environment variable. 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 the git HEAD's commit SHA. (the latter requires access to git CLI and for the root directory to be a valid repository).
diststringoptionalUnique identifier for the distribution, used to further segment your release. Usually your build number.
releaseInjectionTargetsarray/RegExp/(string | RegExp)[]/function(filePath: string): booloptionalFilter for modules that the release should be injected in. This option takes a string, a regular expression, or an array containing strings, regular expressions, or both. It's also possible to provide a filter function that takes the absolute path of a processed module. It should return true if the release should be injected into the module and false otherwise. String values of this option require a full match with the absolute path of the module. By default, the release will be injected into all modules - however, bundlers will include the injected release code only once per entrypoint. If release injection should be disabled, provide an empty array here.
ignoreFilestringoptionalPath to a file containing list of files/directories to ignore. Can point to .gitignore or anything with the same format.
ignorestring/arrayoptionalOne or more paths to ignore during upload. Overrides entries in ignoreFile file. Defaults to ['node_modules'] if neither ignoreFile nor ignore is set.
configFilestringoptionalPath 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.
extarrayoptionalArray of file extensions of files to be collected for the file upload. By default the following file extensions are processed: js, map, jsbundle and bundle.
urlPrefixstringoptionalURL 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'.
urlSuffixstringoptionalURL suffix to add to the end of all filenames. Useful for appending query parameters.
validatebooleanoptionalWhen 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 as this can cause false positives.
stripPrefixarrayoptionalWhen paired with the rewrite option, this will remove a prefix from filename references inside of sourcemaps. For instance you can use this to remove a path that is build machine specific. Note that this will NOT change the names of uploaded files.
stripCommonPrefixbooleanoptionalWhen paired with the rewrite option, this will add ~ to the stripPrefix array.
sourceMapReferencebooleanoptionalDetermines 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 a sourceMappingURL. Defaults to true.
rewritebooleanoptionalEnables rewriting of matching source maps so that indexed maps are flattened and missing sources are inlined if possible. Defaults to true
finalizebooleanoptionalDetermines if the Sentry release record should be automatically finalized (meaning a date_released timestamp is added) after artifact upload. Defaults to true.
dryRunbooleanoptionalAttempts a dry run (useful for dev environments), making release creation a no-op. Defaults to false.
debugbooleanoptionalPrint useful debug information. Defaults to false.
silentbooleanoptionalSuppresses all logs. Defaults to false.
cleanArtifactsbooleanoptionalRemove all the artifacts in the release before the upload. Defaults to false.
errorHandlerfunction(err: Error): voidoptionalWhen an error occurs during rlease creation or sourcemaps upload, the plugin will call this function. By default, the plugin will simply throw an error, thereby stopping the bundling process. If an errorHandler callback is provided, compilation will continue, unless an error is thrown in the provided callback.
setCommitsObjectoptionalAssociates the release with its commits in Sentry. See table below for details.
deployObjectoptionalAdds deployment information to the release in Sentry. See table below for details.
injectReleasesMapbooleanoptionalIf set to true, the plugin will inject an additional SENTRY_RELEASES variable that maps from {org}@{project} to the release value. This might be helpful for webpack module federation or micro frontend setups. Defaults to false.
telemetrybooleanoptionalIf set to true, internal plugin errors and performance data will be sent to Sentry. At Sentry we like to use Sentry ourselves to deliver faster and more stable products. We're very careful of what we're sending. We won't collect anything other than error and high-level performance data. We will never collect your code or any details of the projects in which you're using this plugin. Defaults to true.
options.include:
OptionTypeRequiredDescription
pathsstring[]requiredOne or more paths to scan for files to upload.
ignoreFilestringoptionalSee above.
ignorestring/string[]optionalSee above.
extarrayoptionalSee above.
urlPrefixstringoptionalSee above.
urlSuffixstringoptionalSee above.
stripPrefixarrayoptionalSee above.
stripCommonPrefixbooleanoptionalSee above.
sourceMapReferencebooleanoptionalSee above.
rewritebooleanoptionalSee above.

Example:

// esbuild.config.js
const sentryEsbuildPlugin = require("@sentry/esbuild-plugin");

require("esbuild").build({
  plugins: [
    sentryEsbuildPlugin({
      // ...
      include: [
        {
          paths: ["./packages"],
          urlPrefix: "~/path/to/packages",
        },
        {
          paths: ["./client"],
          urlPrefix: "~/path/to/client",
        },
      ],
    }),
  ],
});
options.setCommits:
OptionTypeRequiredDescription
repostringsee notesThe full git repo name as defined in Sentry. Required if the auto option is not true, otherwise optional.
commitstringsee notesThe current (most recent) commit in the release. Required if the auto option is not true, otherwise optional.
previousCommitstringoptionalThe commit before the beginning of this release (in other words, the last commit of the previous release). Defaults to the last commit of the previous release in Sentry. If there was no previous release, the last 10 commits will be used.
autobooleanoptionalAutomatically sets commit and previousCommit. Sets commit to HEAD and previousCommit as described in the option's documentation. If you set this to true, manually specified commit and previousCommit options will be overridden. It is best to not specify them at all if you set this option to true.
ignoreMissingbooleanoptionalIf the flag is to true and the previous release commit was not found in the repository, the plugin creates a release with the default commits count instead of failing the command. Defaults to false.
options.deploy:
OptionTypeRequiredDescription
envstringrequiredEnvironment value for the release, for example production or staging.
startednumberoptionalDeployment start time in Unix timestamp (in seconds) or ISO 8601 format.
finishednumberoptionalDeployment finish time in Unix timestamp (in seconds) or ISO 8601 format.
timenumberoptionalDeployment duration in seconds. Can be used instead of started and finished.
namestringoptionalHuman-readable name for this deployment.
urlstringoptionalURL 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.

More information

Keywords

FAQs

Package last updated on 07 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc