Skip to content

Commit af67055

Browse files
authored
feat(core): Track NavigationContainer adoption (#6424)
* 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 NavigationContainer adoption Register a no-op `NavigationContainer` integration when the component mounts so the name flows through to `event.sdk.integrations`. Refs: #6415
1 parent 04d85d3 commit af67055

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

packages/core/src/js/NavigationContainer.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import * as React from 'react';
33

44
import { getNavigationContainerComponent } from './reactNavigationImport';
55
import { getReactNavigationIntegration } from './tracing/reactnavigation';
6+
import { registerFeatureMarker } from './utils/featureMarkers';
7+
8+
export const NAVIGATION_CONTAINER_INTEGRATION_NAME = 'NavigationContainer';
69

710
export type FontStyle = {
811
fontFamily: string;
@@ -124,6 +127,10 @@ export const NavigationContainer = React.forwardRef<unknown, SentryNavigationCon
124127
[forwardedRef],
125128
);
126129

130+
React.useEffect(() => {
131+
registerFeatureMarker(NAVIGATION_CONTAINER_INTEGRATION_NAME);
132+
}, []);
133+
127134
const onReady = React.useCallback(() => {
128135
try {
129136
const client = getClient();

packages/core/test/NavigationContainer.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { render } from '@testing-library/react-native';
22
import * as React from 'react';
33
import { Text, View } from 'react-native';
44

5-
import { NavigationContainer } from '../src/js/NavigationContainer';
5+
import { NAVIGATION_CONTAINER_INTEGRATION_NAME, NavigationContainer } from '../src/js/NavigationContainer';
66

77
const mockRegisterNavigationContainer = jest.fn();
88
const mockGetClient = jest.fn();
9+
const mockAddIntegration = jest.fn();
10+
const mockGetIntegrationByName = jest.fn();
911
const mockDebugLog = jest.fn();
1012
const mockDebugWarn = jest.fn();
1113

@@ -47,12 +49,25 @@ jest.mock('../src/js/reactNavigationImport', () => ({
4749
describe('NavigationContainer', () => {
4850
beforeEach(() => {
4951
jest.clearAllMocks();
50-
mockGetClient.mockReturnValue({ getIntegrationByName: jest.fn() });
52+
mockGetIntegrationByName.mockReturnValue(undefined);
53+
mockGetClient.mockReturnValue({
54+
getIntegrationByName: mockGetIntegrationByName,
55+
addIntegration: mockAddIntegration,
56+
});
5157
mockGetReactNavigationIntegration.mockReturnValue({
5258
registerNavigationContainer: mockRegisterNavigationContainer,
5359
});
5460
});
5561

62+
it('registers the NavigationContainer feature marker on mount', () => {
63+
render(
64+
<NavigationContainer>
65+
<Text>App</Text>
66+
</NavigationContainer>,
67+
);
68+
expect(mockAddIntegration).toHaveBeenCalledWith({ name: NAVIGATION_CONTAINER_INTEGRATION_NAME });
69+
});
70+
5671
it('renders children through to the underlying NavigationContainer', () => {
5772
const { getByText } = render(
5873
<NavigationContainer>

0 commit comments

Comments
 (0)