What is @sentry/vite-plugin?
@sentry/vite-plugin is a Vite plugin that integrates Sentry's error tracking and performance monitoring into Vite projects. It helps in capturing and reporting errors, performance issues, and other telemetry data from your Vite-based applications.
What are @sentry/vite-plugin's main functionalities?
Error Tracking
This feature allows you to configure Sentry for error tracking in your Vite project. By providing your Sentry organization, project, and authentication token, you can automatically capture and report errors.
import { defineConfig } from 'vite';
import { sentryVitePlugin } from '@sentry/vite-plugin';
export default defineConfig({
plugins: [
sentryVitePlugin({
org: 'your-org',
project: 'your-project',
authToken: 'your-auth-token',
release: 'your-release',
url: 'https://sentry.io/',
}),
],
});
Source Maps Upload
This feature allows you to upload source maps to Sentry, which helps in better error tracking by providing readable stack traces. You need to specify the directory containing the source maps.
import { defineConfig } from 'vite';
import { sentryVitePlugin } from '@sentry/vite-plugin';
export default defineConfig({
plugins: [
sentryVitePlugin({
org: 'your-org',
project: 'your-project',
authToken: 'your-auth-token',
release: 'your-release',
include: './dist',
url: 'https://sentry.io/',
}),
],
});
Performance Monitoring
This feature enables performance monitoring in your Vite project. By setting the `tracesSampleRate`, you can control the sampling rate for performance data collection.
import { defineConfig } from 'vite';
import { sentryVitePlugin } from '@sentry/vite-plugin';
export default defineConfig({
plugins: [
sentryVitePlugin({
org: 'your-org',
project: 'your-project',
authToken: 'your-auth-token',
release: 'your-release',
url: 'https://sentry.io/',
tracesSampleRate: 1.0,
}),
],
});
Other packages similar to @sentry/vite-plugin
rollbar
Rollbar is an error tracking and monitoring tool that provides real-time error reporting and analysis. It is similar to Sentry in terms of functionality but offers different integrations and a different user interface.
bugsnag
Bugsnag is another error monitoring tool that focuses on stability and user experience. It provides detailed error reports and supports various platforms, similar to Sentry, but with a different approach to error prioritization and user impact analysis.
logrocket
LogRocket is a front-end monitoring tool that records everything users do on your site, making it easier to reproduce and fix bugs. It offers error tracking, performance monitoring, and session replay, providing a more comprehensive view of user interactions compared to Sentry.
Sentry Vite Plugin (WIP)
WARNING: This package is work in progress! Use with caution and do not yet use it in production. We're happy to receive your feedback!
A Vite 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)
Configuration
Every plugin takes an options argument with the following properties:
Option | Type | Required | Description |
---|
include | string | required | A path that the plugin should scan recursively for source maps. It will upload all .map files and match associated .js files. |
org | string | optional | The slug of the Sentry organization associated with the app. |
project | string | optional | The slug of the Sentry project associated with the app. |
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. |
release | string | optional | Unique identifier for the release. Defaults to automatically detected values for CI environments like Vercel, AWS, Heroku, CircleCI. If no such CI environment is detected, the plugin uses the git HEAD 's commit SHA. (For HEAD option, requires access to the git CLI). |
entries | (string | RegExp)[] | RegExp | string | function(absoluteFilePath: string): boolean | optional | Filter for entry points that should be processed. By default, the release will be injected into all entry points. |
ext | array | optional | The file extensions to be considered for the sourcemaps upload. By default the following file extensions are processed: js , map , jsbundle , and bundle . |
finalize | boolean | optional | Indicates whether Sentry release record should be automatically finalized (date_released timestamp added) after artifact upload. Defaults to true |
debug | boolean | optional | Print useful debug information. Defaults to false . |
cleanArtifacts | boolean | optional | Remove all existing artifacts in the Sentry release before uploading sourcemaps. Defaults to false . |
errorHandler | function(err: Error): void | optional | Function that is called when an error occurs during rlease creation or sourcemaps upload. When this function is provided, thrown errors will not cause the process to abort. If you still want to abort the process you can throw an error in the function. |
More information