|
| 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 {tabTitle:Gradle} |
| 15 | +debugImplementation 'io.sentry:sentry-spotlight:{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}' |
| 16 | +``` |
| 17 | + |
| 18 | +If you need Spotlight in all build types, use `implementation` instead: |
| 19 | + |
| 20 | +```groovy {tabTitle:Gradle} |
| 21 | +implementation 'io.sentry:sentry-spotlight:{{@inject packages.version('sentry.java.spotlight', '8.32.0') }}' |
| 22 | +``` |
| 23 | + |
| 24 | +For other dependency managers, check out the [central Maven repository](https://search.maven.org/artifact/io.sentry/sentry-spotlight). |
| 25 | + |
| 26 | +## Configure |
| 27 | + |
| 28 | +```xml {tabTitle:XML} |
| 29 | +<application> |
| 30 | + <!-- Enable Spotlight --> |
| 31 | + <meta-data android:name="io.sentry.spotlight.enable" android:value="true" /> |
| 32 | + <!-- Optional: override the default Spotlight URL --> |
| 33 | + <meta-data android:name="io.sentry.spotlight.url" android:value="http://10.0.2.2:8969/stream" /> |
| 34 | +</application> |
| 35 | +``` |
| 36 | + |
| 37 | +```java {tabTitle:Java} |
| 38 | +import io.sentry.android.core.SentryAndroid; |
| 39 | + |
| 40 | +SentryAndroid.init(this, options -> { |
| 41 | + options.setDsn("___PUBLIC_DSN___"); |
| 42 | + options.setEnableSpotlight(true); |
| 43 | + // Optional: override the default Spotlight URL |
| 44 | + options.setSpotlightConnectionUrl("http://10.0.2.2:8969/stream"); |
| 45 | +}); |
| 46 | +``` |
| 47 | + |
| 48 | +```kotlin {tabTitle:Kotlin} |
| 49 | +import io.sentry.android.core.SentryAndroid |
| 50 | + |
| 51 | +SentryAndroid.init(this) { options -> |
| 52 | + options.dsn = "___PUBLIC_DSN___" |
| 53 | + options.isEnableSpotlight = true |
| 54 | + // Optional: override the default Spotlight URL |
| 55 | + options.spotlightConnectionUrl = "http://10.0.2.2:8969/stream" |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +<Note> |
| 60 | + |
| 61 | +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. |
| 62 | + |
| 63 | +</Note> |
| 64 | + |
| 65 | +## Verify |
| 66 | + |
| 67 | +To verify the integration is working, capture a test exception and check the Spotlight UI: |
| 68 | + |
| 69 | +```java |
| 70 | +import io.sentry.Sentry; |
| 71 | + |
| 72 | +Sentry.captureException(new Exception("Spotlight test from Android!")); |
| 73 | +``` |
| 74 | + |
| 75 | +```kotlin |
| 76 | +import io.sentry.Sentry |
| 77 | + |
| 78 | +Sentry.captureException(Exception("Spotlight test from Android!")) |
| 79 | +``` |
| 80 | + |
| 81 | +Open the Spotlight UI and confirm that the error event appears. |
0 commit comments