Official Sentry SDK for Svelte
This SDK currently only supports Svelte apps in the browser. If you're using SvelteKit, we
recommend using our dedicated
Sentry SvelteKit SDK.
General
This package is a wrapper around @sentry/browser
, providing error monitoring and basic performance monitoring features
for Svelte.
To use the SDK, initialize Sentry in your Svelte entry point main.js
before you bootstrap your Svelte app:
import App from './App.svelte';
import * as Sentry from '@sentry/svelte';
Sentry.init({
dsn: '__DSN__',
release: 'my-project-name@2.3.12',
integrations: [Sentry.browserTracingIntegration()],
tracesSampleRate: 1.0,
});
const app = new App({
target: document.getElementById('app'),
});
export default app;
The Sentry Svelte SDK supports all features from the @sentry/browser
SDK. Until it becomes more stable, please refer
to the Sentry Browser SDK documentation for more information and usage
instructions.
Sourcemaps and Releases
To generate source maps of your Svelte app bundle, check our guide
how to configure your bundler to
emit source maps.
To create releases and upload source maps to
Sentry, we recommend using sentry-cli
. You can for instance create a bash
script to take care of creating a release, uploading source maps and finalizing the release:
#!/bin/bash
VERSION=<your version>
ORG=<your org-slug>
PROJECT=<your project-slug>
SOURCEMAPS_PATH=./dist
sentry-cli releases new $VERSION --org $ORG --project $PROJECT
sentry-cli releases files $VERSION upload-sourcemaps $SOURCEMAPS_PATH --org $ORG --project $PROJECT
sentry-cli releases finalize $VERSION --org $ORG --project $PROJECT
Please note that the paths provided in this example work for a typical Svelte project that adheres to the project
structure set by create-vite with the svelte(-ts)
template. If your
project setup differs from this template, your configuration may need adjustments. Please refer to our documentation of
Advanced sentry-cli
Sourcemaps Options and to
our Sourcemaps Troubleshooting Guide.
Check out our
Svelte source maps uploading guide
for more information.
8.0.0
The Sentry JS SDK team is proud to announce the release of version 8.0.0
of Sentry's JavaScript SDKs - it's been a
long time coming! Thanks to everyone for your patience and a special shout out to the brave souls testing preview builds
and reporting issues - we appreciate your support!
How to Upgrade to Version 8:
We recommend reading the
migration guide docs to find out
how to address any breaking changes in your code for your specific platform or framework.
To automate upgrading to v8 as much as possible, use our migration codemod @sentry/migr8
:
npx @sentry/migr8@latest
All deprecations from the v7 cycle, with the exception of getCurrentHub()
, have been removed and can no longer be used
in v8. If you have an advanced Sentry SDK setup, we additionally recommend reading the
in-depth migration guide in our repo which highlights all changes with additional details and
information.
The rest of this changelog highlights the most important (breaking) changes and links to more detailed information.
Version Support
With v8, we dropped support for several old runtimes and browsers
Node SDKs: The Sentry JavaScript SDK v8 now supports Node.js 14.8.0 or higher. This applies to @sentry/node
and all of our node-based server-side sdks (@sentry/nextjs
, @sentry/remix
, etc.). Furthermore, version 8 now ships
with full support for ESM-based node apps using Node.js 18.19.0 or higher.
Browser SDKs: The browser SDKs now require
ES2018+
compatible browsers. New minimum browser versions:
- Chrome 71
- Edge 79
- Safari 12.1, iOS Safari 12.2
- Firefox 65
- Opera 58
- Samsung Internet 10
For more details, please see the
version support section in our migration guide.
Initializing Server-side SDKs (Node, Bun, Deno, Serverless):
In v8, we support a lot more node-based packages than before. In order to ensure auto-instrumentation works, the SDK now
needs to be imported and initialized before any other import in your code.
We recommend creating a new file (e.g. instrumentation.js
) to import and initialize the SDK. Then, import the file on
top of your entry file or detailed instructions, check our updated SDK setup docs
initializing the SDK in v8.
Performance Monitoring Changes
The API around performance monitoring and tracing has been streamlined, and we've added support for more integrations
out of the box.
Functional Integrations
Integrations are now simple functions instead of classes. Class-based integrations
have been removed:
// old (v7)
Sentry.init({
integrations: [new Sentry.BrowserTracing()],
});
// new (v8)
Sentry.init({
integrations: [Sentry.browserTracingIntegration()],
});
Package removal
The following packages have been removed or replaced and will no longer be published: