diff --git a/docs/crashlytics/android.md b/docs/crashlytics/android.md new file mode 100644 index 00000000..c35ad598 --- /dev/null +++ b/docs/crashlytics/android.md @@ -0,0 +1,11 @@ +--- +title: Android Setup +description: Manually integrate Crashlytics into your Android application. +--- + +# Android Setup + +> The following steps are only required if your environment does not have access to React Native +auto-linking. + +## TODO diff --git a/docs/crashlytics/index.md b/docs/crashlytics/index.md new file mode 100644 index 00000000..739a5196 --- /dev/null +++ b/docs/crashlytics/index.md @@ -0,0 +1,53 @@ +--- +title: Crashlytics +description: Firebase Crashlytics is a lightweight, realtime crash reporter that helps you track, prioritize, and fix stability issues that erode your app quality. +--- + +# Crashlytics + +Firebase Crashlytics is a lightweight, realtime crash reporter that helps you track, prioritize, and fix stability issues that erode your app quality. +React Native Firebase provides automatic crash reporting for both native and JavaScript errors, including unhandled promise rejections. +The JavaScript API also allows for full custom crash reporting and supports sending additional attributes to help debug crashes within your +application. + + + +## Getting Started + + + + Install & start capturing any errors your application throws. + + + Ensuring crash reports contain the right information to help you debug and fix the issue is crtical to providing + a stable application. Our guides cover tips and tricks for integrating Crashlytics sucessfully. + + + The API reference covers every aspect to successfully integrate your application with + Crashlyics. + + + +## Learn more + +Our documentation is a great place to start, however if you're looking for more help or want to help others, +check out the resources below: + +- [Stack Overflow](https://stackoverflow.com/questions/tagged/react-native-firebase-crashlytics) +- [Github Issues](https://github.com/invertase/react-native-firebase/issues?utf8=%E2%9C%93&q=is%3Aissue+sort%3Aupdated-desc+label%3Acrashlytics+) +- [Firebase Documentation](https://firebase.google.com/docs/functions?utm_source=invertase&utm_medium=react-native-firebase&utm_campaign=crashlytics) diff --git a/docs/crashlytics/ios.md b/docs/crashlytics/ios.md new file mode 100644 index 00000000..e4aa34e2 --- /dev/null +++ b/docs/crashlytics/ios.md @@ -0,0 +1,11 @@ +--- +title: iOS Setup +description: Manually integrate Crashlytics into your iOS application. +--- + +# iOS Setup + +> The following steps are only required if your environment does not have access to React Native +auto-linking. + +## TODO diff --git a/docs/crashlytics/quick-start.md b/docs/crashlytics/quick-start.md new file mode 100644 index 00000000..f9c504d8 --- /dev/null +++ b/docs/crashlytics/quick-start.md @@ -0,0 +1,96 @@ +--- +title: Quick Start +description: Get to grips with the basics of Crashlytics in React Native Firebase +--- + +# Crashlytics Quick Start + +## Installation + +Install this module with Yarn: + +```bash +yarn add @react-native-firebase/crashlytics +``` + +> Integrating manually and not via React Native auto-linking? Check the setup instructions for Android & iOS. + +## Module usage + +The Crashlytics package will automatically report on any fatal application crash. Both native and JavaScript +crashes along with unhandled promise rejections are captured with full stack traces. + +The package provides a JavaScript API to create your own crash reports and/or send additional information +with crash reports to the Firebase console for a better debugging experience. + +Once installed, import the Crashlytics package into your project: + +```js +import crashlytics from '@react-native-firebase/crashlytics'; +``` + +The package also provides access to the firebase instance: + +```js +import { firebase } from '@react-native-firebase/crashlytics'; +``` + +### Testing crashes + +The Crashlytics package provides a `crash` method which is provided to ensure crash reports are correctly +being sent to the Firebase console and can be used with your own test suite. Any `log` methods called before +sending a crash report and sent with the crash report. + +```js +import crashlytics from '@react-native-firebase/crashlytics'; + +function forceCrash() { + crashlytics.log('Testing crash'); + crashlytics.crash(); +} +``` + +### Handling non-fatal crashes + +Crashlytics supports sending JavaScript stack traces to the Firebase console. This can be used in any situations +where an error occurs but is caught by your own code as a bailout method. To +send a stack trace, pass a [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) +to the `recordError` method. + + ```js + import crashlytics from '@react-native-firebase/crashlytics'; + +function sendReport() { + crashlytics().recordError( + new Error( + 'Error with a stack trace' + ) + ); +} + ``` + +### Additional crash attributes + +It is possible to provide additional attributes which are sent with crash reports. This helps with debugging and +localising the error. To set additional attributes call the `set*` methods. + +```js +import crashlytics from '@react-native-firebase/crashlytics'; + +async function onSignIn(user) { + await Promise.all([ + crashlytics().setUserId(user.uid), + crashlytics().setUserName(user.username), + crashlytics().setUserEmail(user.email), + crashlytics().setAttribute('credits', user.credits), + ]); + + crashlytics.crash(); +} +``` + +### Disabling Crashlytics + +To disable Crashlytics, set the `` to `false` in the `firebase.json` file. + +To learn more, view the App documentation.