Using Spotlight with Astro
By Adding Spotlight to your Astro application, you can get deep insights into errors and performance issues across your entire stacks. On this page you’ll learn how to install and add Spotlight to your Astro Dev Toolbar with just one command.
1. Installation
Start by adding the @sentry/astro and @spotlightjs/astro dependencies:
npx astro add @sentry/astro @spotlightjs/astropnpm astro add @sentry/astro @spotlightjs/astroyarn astro add @sentry/astro @spotlightjs/astro2. Configuration
The Astro CLI should have already added the Sentry & Spotlight integration to your astro.config.mjs file during installation.
It should look similarly to the example below. Otherwise, import and register the Sentry and Spotlight integrations:
import { defineConfig } from 'astro/config';
import sentry from "@sentry/astro";import spotlightjs from "@spotlightjs/astro";
// https://astro.build/configexport default defineConfig({ // Order matters here! `sentry()` should come before `spotlightjs()` integrations: [sentry(), spotlightjs()]});3. Configure Other Sentry SDKs
If your Astro application is interacting with other services, such as a Python API, you can also configure those SDKs to work with Spotlight. You don’t need to be using the Sentry service to take advantage of Sentry’s SDKs to power Spotlight.
Web platforms
In the Browser you don’t need to set spotlight: true, Spotlight.init() will automatically detect if Sentry is available and if so, hook into the SDK.
Sentry.init({ dsn: '___DSN___',});// In the frontend it's important that you init Spotlight after SentrySpotlight.init();Sentry.init({ dsn: '___DSN___', spotlight: process.env.NODE_ENV === "development",});sentry_sdk.init( dsn="___DSN___", # You should only load this in your development environment spotlight=bool(os.environ.get("DEV")),)\Sentry\init([ 'dsn' => '___DSN___', // You should only load this in your development environment 'spotlight' => App::environment(['local']),]);Sentry.init do |config| config.dsn = '___DSN___' # You should only load this in your development environment config.spotlight = Rails.env.development?endSentrySdk.Init(o =>{ o.Dsn = "___DSN___";#if DEBUG // You should only load this in your development environment o.EnableSpotlight = true;#endif});