Skip to content

Commit 0b20be6

Browse files
authored
feat(core): Track CaptureAppStartErrors adoption (#6429)
* feat(core): Track GlobalErrorBoundary adoption Register a no-op `GlobalErrorBoundary` integration when the component mounts so the name flows through to `event.sdk.integrations` — the same channel used for feature- adoption signals like `MobileFeedback` and `AppStart`. Also introduces a shared `registerFeatureMarker` helper. Subsequent markers for other opt-in features (NavigationContainer, ExpoRouter error boundary, AppLoaded, ...) will use this helper — see #6415. Refs: #6415 * feat(core): Track CaptureAppStartErrors adoption Register a no-op `CaptureAppStartErrors` integration when the JS runtime detects `sentry.options.json` is bundled (via `RN_GLOBAL_OBJ.__SENTRY_OPTIONS__`), so the name flows through to `event.sdk.integrations`. The Metro serializer already bundles `sentry.options.json` into the JS bundle as `__SENTRY_OPTIONS__` at build time — shipping the config is what opts users into the pre-JS crash capture feature. No native/bridge changes needed. Refs: #6415
1 parent 029d028 commit 0b20be6

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

packages/core/src/js/sdk.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ import {
3434
import { useEncodePolyfill } from './transports/encodePolyfill';
3535
import { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';
3636
import { getDefaultEnvironment, isExpoGo, isRunningInMetroDevServer, isWeb } from './utils/environment';
37+
import { registerFeatureMarker } from './utils/featureMarkers';
3738
import { getDefaultRelease } from './utils/release';
3839
import { safeFactory, safeTracesSampler } from './utils/safe';
3940
import { checkSentryJsSdkVersionMismatch } from './utils/sdkVersionCheck';
4041
import { RN_GLOBAL_OBJ } from './utils/worldwide';
4142
import { NATIVE } from './wrapper';
4243

44+
const CAPTURE_APP_START_ERRORS_INTEGRATION_NAME = 'CaptureAppStartErrors';
45+
4346
const DEFAULT_OPTIONS: ReactNativeOptions = {
4447
enableNativeCrashHandling: true,
4548
enableNativeNagger: true,
@@ -189,6 +192,10 @@ export function init(passedOptions: ReactNativeOptions): void {
189192

190193
if (RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {
191194
debug.log('Sentry JS initialized with options from the options file.');
195+
// Adoption marker for the "capture app-start errors" feature: shipping
196+
// `sentry.options.json` is what opts users in (the Metro serializer bundles
197+
// it into JS as `__SENTRY_OPTIONS__`, and native reads it before JS runs).
198+
registerFeatureMarker(CAPTURE_APP_START_ERRORS_INTEGRATION_NAME);
192199
}
193200
}
194201

packages/core/test/sdk.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { init, withScope } from '../src/js/sdk';
1111
import { REACT_NATIVE_TRACING_INTEGRATION_NAME, reactNativeTracingIntegration } from '../src/js/tracing';
1212
import { makeNativeTransport } from '../src/js/transports/native';
1313
import { getDefaultEnvironment, isExpoGo, notWeb } from '../src/js/utils/environment';
14+
import { registerFeatureMarker } from '../src/js/utils/featureMarkers';
1415
import { RN_GLOBAL_OBJ } from '../src/js/utils/worldwide';
1516
import { NATIVE } from './mockWrapper';
1617
import { firstArg, secondArg } from './testutils';
@@ -25,6 +26,9 @@ jest.mock('@sentry/core', () => ({
2526
jest.mock('../src/js/integrations/debugsymbolicatorutils', () => ({
2627
getDevServer: jest.fn(),
2728
}));
29+
jest.mock('../src/js/utils/featureMarkers', () => ({
30+
registerFeatureMarker: jest.fn(),
31+
}));
2832

2933
describe('Tests the SDK functionality', () => {
3034
beforeEach(() => {
@@ -189,6 +193,18 @@ describe('Tests the SDK functionality', () => {
189193
});
190194
expect(usedOptions()?.autoInitializeNativeSdk).toBe(false);
191195
});
196+
197+
it('registers the CaptureAppStartErrors marker when __SENTRY_OPTIONS__ is set', () => {
198+
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
199+
init({});
200+
expect(registerFeatureMarker).toHaveBeenCalledWith('CaptureAppStartErrors');
201+
});
202+
203+
it('does not register the CaptureAppStartErrors marker without __SENTRY_OPTIONS__', () => {
204+
delete RN_GLOBAL_OBJ.__SENTRY_OPTIONS__;
205+
init({});
206+
expect(registerFeatureMarker).not.toHaveBeenCalledWith('CaptureAppStartErrors');
207+
});
192208
});
193209

194210
describe('environment', () => {

0 commit comments

Comments
 (0)