bugsnag / bugsnag-react-native

Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
https://docs.bugsnag.com/platforms/react-native
MIT License
369 stars 121 forks source link

Ask for user confirmation in registerBeforeSendCallback #451

Closed djschilling closed 4 years ago

djschilling commented 4 years ago

As mentioned in this issue: https://github.com/bugsnag/bugsnag-react-native/issues/422 there will be soon a new version with async options. When will it come out?

In the meantime, how can i ask for user confirmation before sending the crash report?

configuration.registerBeforeSendCallback(function(report, error) {
        Alert.alert(
            'Send crash report',
            'Can the crash report be sent?',
            [
                {
                    text: 'Cancel',
                    onPress: () => console.log('Cancel Pressed'),
                    style: 'cancel'
                },
                { text: 'OK', onPress: () => console.log('OK Pressed') }
            ],
            { cancelable: false }
        );
        return false; // no error report will be sent
    });

How can i make this work?

xljones commented 4 years ago

Hey @djschilling, we don't have a timeline for this for public release, but it's in the works and should be here soon!

You can use the before send callback to reject a report by using return false; based on whatever criteria you deem necessary as long as the function remains synchronous. This could be a really poor UX for an end-user if multiple reports are getting thrown, though.

There's more info in our docs here: https://docs.bugsnag.com/platforms/react-native/react-native/configuration-options/#beforesendcallbacks.