Skip to content
10 changes: 10 additions & 0 deletions sample/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 12 additions & 1 deletion sample/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,18 @@ const HomeScreen = (props: Props) => {
<Text style={styles.buttonText}>Get attachment</Text>
</TouchableOpacity>
<View style={styles.spacer} />
<UserFeedbackModal/>
<UserFeedbackModal />
<View style={styles.spacer} />
<TouchableOpacity
onPress={async () => {
try {
fetch('http://localhost:8081/not-found');
} catch (error) {
//ignore the error, it will be send to Sentry
}
}}>
<Text style={styles.buttonText}>Capture HTTP Client Error</Text>
</TouchableOpacity>
</View>
<View style={styles.buttonArea}>
<TouchableOpacity
Expand Down