React Native

Installation

Firstly, add the library to your project:

npm install --save raygun4js

Then in a central component (e.g index.ios.js/index.android.js), import the library:

import rg4js from 'raygun4js';

Next, configure the provider using your Raygun application’s API key. These lines should be called once only early on when your app boots, for example:

export default class YourReactNativeProject extends Component {
  constructor() {
    super()

    rg4js('enableCrashReporting', true);
    rg4js('apiKey', 'add_your_api_key_here');

    // Put any other rg4js() options you want to set here

    rg4js('boot'); // This call must be made last to start the provider
  }
}

Naturally, you can factor the above logic out into a function or separate component, which should be called early on from your main app component.

note: Real User Monitoring is not currently supported by the React Native provider.

On this page: