|
| 1 | +--- |
| 2 | +title: Spotlight |
| 3 | +description: "Learn how to use Sentry Spotlight for local development observability on Android." |
| 4 | +--- |
| 5 | + |
| 6 | +[Sentry Spotlight](https://spotlightjs.com/) is a local development tool that provides real-time observability for errors, traces, logs, and performance data during development. It allows you to see Sentry events in real-time without sending them to Sentry's servers, making it ideal for local debugging. |
| 7 | + |
| 8 | +The `sentry-spotlight` module provides a `SpotlightIntegration` that sends a copy of all Sentry events to your local Spotlight instance. By using `debugImplementation`, you can ensure Spotlight is excluded from release builds, preventing insecure HTTP URLs from leaking into production APKs. |
| 9 | + |
| 10 | +## Install |
| 11 | + |
| 12 | +We recommend using `debugImplementation` so the Spotlight dependency is excluded from release builds: |
| 13 | + |
| 14 | +```groovy {filename:app/build.gradle} |
| 15 | +debugImplementation 'io.sentry:sentry-spotlight:{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}' |
| 16 | +``` |
| 17 | + |
| 18 | +```kotlin {filename:app/build.gradle.kts} |
| 19 | +debugImplementation("io.sentry:sentry-spotlight:{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}") |
| 20 | +``` |
| 21 | + |
| 22 | +If you need Spotlight in all build types, use `implementation` instead of `debugImplementation`. |
| 23 | + |
| 24 | +## Configure |
| 25 | + |
| 26 | +```xml {tabTitle:XML} |
| 27 | +<application> |
| 28 | + <!-- Enable Spotlight --> |
| 29 | + <meta-data android:name="io.sentry.spotlight.enable" android:value="true" /> |
| 30 | + <!-- Optional: override the default Spotlight URL --> |
| 31 | + <meta-data android:name="io.sentry.spotlight.url" android:value="http://10.0.2.2:8969/stream" /> |
| 32 | +</application> |
| 33 | +``` |
| 34 | + |
| 35 | +```java {tabTitle:Java} |
| 36 | +import io.sentry.android.core.SentryAndroid; |
| 37 | + |
| 38 | +SentryAndroid.init(this, options -> { |
| 39 | + options.setDsn("___PUBLIC_DSN___"); |
| 40 | + options.setEnableSpotlight(true); |
| 41 | + // Optional: override the default Spotlight URL |
| 42 | + options.setSpotlightConnectionUrl("http://10.0.2.2:8969/stream"); |
| 43 | +}); |
| 44 | +``` |
| 45 | + |
| 46 | +```kotlin {tabTitle:Kotlin} |
| 47 | +import io.sentry.android.core.SentryAndroid |
| 48 | + |
| 49 | +SentryAndroid.init(this) { options -> |
| 50 | + options.dsn = "___PUBLIC_DSN___" |
| 51 | + options.isEnableSpotlight = true |
| 52 | + // Optional: override the default Spotlight URL |
| 53 | + options.spotlightConnectionUrl = "http://10.0.2.2:8969/stream" |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +<Alert level="info"> |
| 58 | + |
| 59 | +The default Spotlight URL is `http://10.0.2.2:8969/stream`. The `10.0.2.2` address is the Android emulator's bridge to the host machine's `localhost`. If you're running on a physical device, replace this with your machine's local IP address. |
| 60 | + |
| 61 | +</Alert> |
| 62 | + |
| 63 | +## Verify |
| 64 | + |
| 65 | +To verify the integration is working, capture a test exception and check the Spotlight UI: |
| 66 | + |
| 67 | +```java |
| 68 | +import io.sentry.Sentry; |
| 69 | + |
| 70 | +Sentry.captureException(new Exception("Spotlight test from Android!")); |
| 71 | +``` |
| 72 | + |
| 73 | +```kotlin |
| 74 | +import io.sentry.Sentry |
| 75 | + |
| 76 | +Sentry.captureException(Exception("Spotlight test from Android!")) |
| 77 | +``` |
| 78 | + |
| 79 | +Open the Spotlight UI and confirm that the error event appears. |
0 commit comments