Skip to content

Commit 7b891b1

Browse files
feat: Add spotlight option (#4023)
1 parent 8f05739 commit 7b891b1

File tree

6 files changed

+47
-9
lines changed

6 files changed

+47
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Add `spotlight` option ([#4023](https://github.com/getsentry/sentry-react-native/pull/4023))
6+
- Deprecating `enableSpotlight` and `spotlightSidecarUrl`
7+
38
## 5.29.0
49

510
### Features

samples/expo/app/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({
8484
// replaysOnErrorSampleRate: 1.0,
8585
replaysSessionSampleRate: 1.0,
8686
},
87-
enableSpotlight: true,
87+
spotlight: true,
8888
});
8989

9090
function RootLayout() {

samples/react-native/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Sentry.init({
123123
// replaysSessionSampleRate: 1.0,
124124
replaysOnErrorSampleRate: 1.0,
125125
},
126-
enableSpotlight: true,
126+
spotlight: true,
127127
// This should be disabled when manually initializing the native SDK
128128
// Note that options from JS are not passed to the native SDKs when initialized manually
129129
autoInitializeNativeSdk: true,

src/js/integrations/default.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,9 @@ export function getDefaultIntegrations(options: ReactNativeClientOptions): Integ
108108
integrations.push(expoContextIntegration());
109109
}
110110

111-
if (options.enableSpotlight) {
112-
integrations.push(
113-
spotlightIntegration({
114-
sidecarUrl: options.spotlightSidecarUrl,
115-
}),
116-
);
111+
if (options.spotlight || options.enableSpotlight) {
112+
const sidecarUrl = (typeof options.spotlight === 'string' && options.spotlight) || options.spotlightSidecarUrl;
113+
integrations.push(spotlightIntegration({ sidecarUrl }));
117114
}
118115

119116
if (

src/js/options.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ export interface BaseReactNativeOptions {
166166
* More details: https://spotlightjs.com/
167167
*
168168
* IMPORTANT: Only set this option to `true` while developing, not in production!
169+
*
170+
* @deprecated Use `spotlight` instead.
169171
*/
170172
enableSpotlight?: boolean;
171173

@@ -178,9 +180,23 @@ export interface BaseReactNativeOptions {
178180
* More details: https://spotlightjs.com/
179181
*
180182
* @default "http://localhost:8969/stream"
183+
*
184+
* @deprecated Use `spotlight` instead.
181185
*/
182186
spotlightSidecarUrl?: string;
183187

188+
/**
189+
* If you use Spotlight by Sentry during development, use
190+
* this option to forward captured Sentry events to Spotlight.
191+
*
192+
* Either set it to true, or provide a specific Spotlight Sidecar URL.
193+
*
194+
* More details: https://spotlightjs.com/
195+
*
196+
* IMPORTANT: Only set this option to `true` while developing, not in production!
197+
*/
198+
spotlight?: boolean | string;
199+
184200
/**
185201
* Sets a callback which is executed before capturing screenshots. Only
186202
* relevant if `attachScreenshot` is set to true. When false is returned

test/sdk.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ describe('Tests the SDK functionality', () => {
432432
expect(actualIntegrations).toEqual(expect.not.arrayContaining([expect.objectContaining({ name: 'Spotlight' })]));
433433
});
434434

435-
it('adds spotlight integration', () => {
435+
it('adds spotlight integration with enableSpotlight', () => {
436436
init({
437437
enableSpotlight: true,
438438
});
@@ -442,6 +442,26 @@ describe('Tests the SDK functionality', () => {
442442
expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'Spotlight' })]));
443443
});
444444

445+
it('adds spotlight integration with spotlight bool', () => {
446+
init({
447+
spotlight: true,
448+
});
449+
450+
const actualOptions = usedOptions();
451+
const actualIntegrations = actualOptions?.integrations;
452+
expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'Spotlight' })]));
453+
});
454+
455+
it('adds spotlight integration with direct url', () => {
456+
init({
457+
spotlight: 'http://localhost:8969/stream',
458+
});
459+
460+
const actualOptions = usedOptions();
461+
const actualIntegrations = actualOptions?.integrations;
462+
expect(actualIntegrations).toEqual(expect.arrayContaining([expect.objectContaining({ name: 'Spotlight' })]));
463+
});
464+
445465
it('no default integrations', () => {
446466
init({
447467
defaultIntegrations: false,

0 commit comments

Comments
 (0)