Spotlight can be utilized in any stack, but in particular is well supported anywhere Sentry integration exists.
There’s a few steps to get started:
Install and initialize the Overlay .
Run the Sidecar concurrently with your development server.
Configure Sentry’s SDKs to send to Spotlight by passing spotlight=True
.
1. Installation
Start by installing the @spotlightjs/spotlight
package in your existing frontend application.
npm add @spotlightjs/spotlight
pnpm add @spotlightjs/spotlight
yarn add @spotlightjs/spotlight
Note
We’re loading Spotlight with production dependencies as the import is static, but the expectation is that it will be tree-shaken out by checking for a development environment.
If you’re using a dynamic import, its possible you can simply list this in your devDependencies
instead.
2. Configuration
Inject the Spotlight overlay into your application:
If your bundler supports it, its recommended to do a dynamic import to aid tree-shaking:
if ( process . env . NODE_ENV === " development " ) {
import ( ' @spotlightjs/spotlight ' ) . then ( ( Spotlight ) =>
Spotlight . init ({ injectImmediately: true })
import * as Spotlight from ' @spotlightjs/spotlight ' ;
// only load Spotlight in dev
if ( import. meta . env . DEV ) {
import * as Spotlight from ' @spotlightjs/spotlight ' ;
// only load Spotlight in dev
if ( process . env . NODE_ENV === " development " ) {
Upon loading your UI you should now see the Spotlight toolbar in bottom-right corner of your application.
For more options on how to configure Spotlight’s UI, see Configuration .
3. Run the Sidecar
Spotlight’s architecture requires a sidecar to be running alongside your service. This is to enable streaming data collection from your backend services into the Spotlight overlay.
Bonus: Leverage Sentry SDKs
To get the most value out of Spotlight, configure Sentry’s SDKs. You don’t have to use sentry.io but you can use the them to just power Spotlight.
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.
// In the frontend it's important that you init Spotlight after Sentry
spotlight: process . env . NODE_ENV === " development " ,
# You should only load this in your development environment
spotlight = bool ( os.environ. get ( " DEV " )) ,
// You should only load this in your development environment
' spotlight ' => App :: environment ([ ' local ' ]),
# You should only load this in your development environment
config.spotlight = Rails .env.development?
// You should only load this in your development environment
o . EnableSpotlight = true ;
SentryAndroid. init ( this , options -> {
options. setDsn ( "___DSN___" );
// You should only enable this in your development environment
options.isEnableSpotlight = BuildConfig.DEBUG;
You also need to allow cleartext traffic from your emulator to the Sidecar on your host machine by adding the following to src/debug/res/xml/network.xml
:
<? xml version = " 1.0 " encoding = " utf-8 " ?>
< network-security-config >
< domain-config cleartextTrafficPermitted = " true " >
<!-- Allow cleartext traffic from the emulator to the host machine -->
<!-- See https://developer.android.com/studio/run/emulator-networking for more details -->
< domain includeSubdomains = " true " > 10.0.2.2 </ domain >
</ network-security-config >
SentrySDK.start { options in
options. dsn = " ___DSN___ "
// You should only enable this in your development environment
options. enableSpotlight = true
enableSpotlight: __DEV__,
await SentryFlutter . init ((options) {
options.dsn = '___DSN___' ;
// You should only enable this in your development environment
options.spotlight = Spotlight (enabled : kDebugMode);