Skip to content

Commit 3ae09f5

Browse files
Merge 5ca2230 into ac72abc
2 parents ac72abc + 5ca2230 commit 3ae09f5

18 files changed

+477
-31
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ yalc.lock
7474

7575
# E2E tests
7676
test/react-native/versions
77+
78+
# Created by Sentry Metro Plugin
79+
.sentry/

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
- Improve touch event component info if annotated with [`@sentry/babel-plugin-component-annotate`](https://www.npmjs.com/package/@sentry/babel-plugin-component-annotate) ([#3899](https://github.com/getsentry/sentry-react-native/pull/3899))
88
- Add replay breadcrumbs for touch & navigation events ([#3846](https://github.com/getsentry/sentry-react-native/pull/3846))
99
- Add network data to Session Replays ([#3912](https://github.com/getsentry/sentry-react-native/pull/3912))
10+
- Add `annotateReactComponents` option to `@sentry/react-native/metro` ([#3916](https://github.com/getsentry/sentry-react-native/pull/3916))
11+
12+
```js
13+
// For Expo
14+
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
15+
const config = getSentryExpoConfig(__dirname, { annotateReactComponents: true });
16+
17+
// For RN
18+
const { getDefaultConfig } = require('@react-native/metro-config');
19+
const { withSentryConfig } = require('@sentry/react-native/metro');
20+
module.exports = withSentryConfig(getDefaultConfig(__dirname), { annotateReactComponents: true });
21+
```
1022

1123
### Dependencies
1224

@@ -473,7 +485,7 @@ see [the Expo guide](https://docs.sentry.io/platforms/react-native/manual-setup/
473485
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
474486

475487
// const config = getDefaultConfig(__dirname);
476-
const config = getSentryExpoConfig(config, {});
488+
const config = getSentryExpoConfig(__dirname);
477489
```
478490

479491
- New `npx sentry-expo-upload-sourcemaps` for simple EAS Update (`npx expo export`) source maps upload ([#3491](https://github.com/getsentry/sentry-react-native/pull/3491), [#3510](https://github.com/getsentry/sentry-react-native/pull/3510), [#3515](https://github.com/getsentry/sentry-react-native/pull/3515), [#3507](https://github.com/getsentry/sentry-react-native/pull/3507))

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"react-native": ">=0.65.0"
6868
},
6969
"dependencies": {
70+
"@sentry/babel-plugin-component-annotate": "2.20.1",
7071
"@sentry/browser": "7.117.0",
7172
"@sentry/cli": "2.31.2",
7273
"@sentry/core": "7.117.0",

samples/expo/app/_layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import { HttpClient } from '@sentry/integrations';
99
import { SENTRY_INTERNAL_DSN } from '../utils/dsn';
1010
import * as Sentry from '@sentry/react-native';
1111
import { isExpoGo } from '../utils/isExpoGo';
12+
import { LogBox } from 'react-native';
1213

1314
export {
1415
// Catch any errors thrown by the Layout component.
1516
ErrorBoundary,
1617
} from 'expo-router';
1718

19+
LogBox.ignoreAllLogs();
20+
1821
// Prevent the splash screen from auto-hiding before asset loading is complete.
1922
SplashScreen.preventAutoHideAsync();
2023

samples/expo/babel.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const componentAnnotatePlugin = require('@sentry/babel-plugin-component-annotate');
2-
31
module.exports = function (api) {
42
api.cache(false);
53
return {
@@ -13,7 +11,6 @@ module.exports = function (api) {
1311
},
1412
},
1513
],
16-
componentAnnotatePlugin,
1714
],
1815
};
1916
};

samples/expo/metro.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = getSentryExpoConfig(__dirname, {
99
// [Web-only]: Enables CSS support in Metro.
1010
isCSSEnabled: true,
1111
getDefaultConfig,
12+
annotateReactComponents: true,
1213
});
1314

1415
config.watchFolders.push(path.resolve(__dirname, '../../node_modules/@sentry'));

samples/react-native/babel.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const componentAnnotatePlugin = require('@sentry/babel-plugin-component-annotate');
2-
31
module.exports = {
42
presets: ['module:@react-native/babel-preset'],
53
plugins: [
@@ -12,6 +10,5 @@ module.exports = {
1210
},
1311
],
1412
'react-native-reanimated/plugin',
15-
componentAnnotatePlugin,
1613
],
1714
};

samples/react-native/metro.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ const config = {
6060
};
6161

6262
const m = mergeConfig(getDefaultConfig(__dirname), config);
63-
module.exports = withSentryConfig(m);
63+
module.exports = withSentryConfig(m, {
64+
annotateReactComponents: true,
65+
});

samples/react-native/src/Screens/TrackerScreen.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ const TrackerScreen = () => {
7575
return (
7676
<View style={styles.screen}>
7777
<Sentry.TimeToInitialDisplay record />
78-
<View style={styles.titleContainer}>
79-
<Text style={styles.title}>Global COVID19 Cases</Text>
80-
</View>
78+
<TrackerTitle />
8179
<View style={styles.card}>
8280
{cases ? (
8381
<>
@@ -113,6 +111,12 @@ const TrackerScreen = () => {
113111
);
114112
};
115113

114+
const TrackerTitle = () => (
115+
<View style={styles.titleContainer}>
116+
<Text style={styles.title}>Global COVID19 Cases</Text>
117+
</View>
118+
);
119+
116120
export default Sentry.withProfiler(TrackerScreen);
117121

118122
const Statistic = (props: {

src/js/tools/enableLogger.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { logger } from '@sentry/utils';
2+
3+
/**
4+
* Enables debug logger when SENTRY_LOG_LEVEL=debug.
5+
*/
6+
export function enableLogger(): void {
7+
if (process.env.SENTRY_LOG_LEVEL === 'debug') {
8+
logger.enable();
9+
}
10+
}

0 commit comments

Comments
 (0)