diff --git a/sample/src/App.tsx b/sample/src/App.tsx index b156e8b0f..05660e592 100644 --- a/sample/src/App.tsx +++ b/sample/src/App.tsx @@ -8,6 +8,7 @@ import {createStackNavigator} from '@react-navigation/stack'; // Import the Sentry React Native SDK import * as Sentry from '@sentry/react-native'; +import * as Integrations from '@sentry/integrations'; import HomeScreen from './screens/HomeScreen'; import TrackerScreen from './screens/TrackerScreen'; @@ -51,6 +52,15 @@ Sentry.init({ return context; }, }), + new Integrations.HttpClient({ + // This array can contain tuples of `[begin, end]` (both inclusive), + // Single status codes, or a combinations of both. + // default: [[500, 599]] + failedRequestStatusCodes: [[400, 599]], + // This array can contain Regexes or strings, or combinations of both. + // default: [/.*/] + failedRequestTargets: [/.*/], + }), ], enableAutoSessionTracking: true, // For testing, session close when 5 seconds (instead of the default 30) in the background. diff --git a/sample/src/screens/HomeScreen.tsx b/sample/src/screens/HomeScreen.tsx index 309f33360..2d328ad25 100644 --- a/sample/src/screens/HomeScreen.tsx +++ b/sample/src/screens/HomeScreen.tsx @@ -260,7 +260,18 @@ const HomeScreen = (props: Props) => { Get attachment - + + + { + try { + fetch('http://localhost:8081/not-found'); + } catch (error) { + //ignore the error, it will be send to Sentry + } + }}> + Capture HTTP Client Error +