Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fsdk-installation%2Freact-native%2Freact-native-plugin.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fsdk-installation%2Freact-native%2Freact-native-plugin.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# Official Coralogix React Native plugin

[![npm version](https://img.shields.io/npm/v/@coralogix/react-native-plugin.svg)](https://www.npmjs.com/package/@coralogix/react-native-plugin)

This package replaces the old `@coralogix/react-native-sdk` package.

## Links[​](#links "Direct link to Links")

* [Changelog](https://coralogix.github.io/cx-react-native-plugin/CHANGELOG.html)
* [Coralogix Real User Monitoring](https://coralogix.com/docs/user-guides/rum/getting-started/real-user-monitoring.md)

## Usage[​](#usage "Direct link to Usage")

To use Coralogix SDK, call `CoralogixRum.init(options)` at the soonest available moment after the app loads. This will initialize the SDK based on the options you provided. `init` is an `async` function.

```
import { CoralogixRum } from '@coralogix/react-native-plugin'



await CoralogixRum.init({

  application: 'app-name',

  environment: 'production',

  public_key: 'abc-123-456',

  coralogixDomain: 'EU2',

  version: 'v1.0.3',

  labels: {

    payment: 'visa',

  },

  ignoreErrors: ['some error message to ignore'],

  ignoreUrls: [/.*\.svg/, /.*\.ico/], // will ignore all requests to .svg and .ico files 

  sessionSampleRate: 100, // Percentage of overall sessions being tracked, Default to 100%

});
```

`sessionSampleRate` is a whole percentage in `0`-`100` and is applied **once**. A fractional value is rounded to an integer before it is forwarded (and a non-zero rate is never rounded down to `0`), because the native bridges read the value as an integer.

To provide contextual information or transmit manual logs, utilize the exported functions of `CoralogixRum`. Keep in mind that these functions will remain inactive until you've invoked `CoralogixRum.init()`.

```
import { CoralogixRum } from '@coralogix/react-native-plugin';



// Update user context dynamically

CoralogixRum.setUserContext({

  user_id: '123',

  user_name: 'name',

  user_email: 'user@email.com',

  user_metadata: {

    role: 'admin',

    // ...

  },

});



// Update custom labels dynamically

CoralogixRum.setLabels({

  ...CoralogixRum.getLabels(),

  paymentMethod: 'visa',

  userTheme: 'dark',

  // ...

});



// Update application context dynamically

CoralogixRum.setApplicationContext({

  application: 'app-name',

  version: '1.0.0',

});



CoralogixRum.log(CoralogixLogSeverity.Error, 'this is a log', { key: 'value' });

CoralogixRum.error('this is a log with error severity', { key: 'value' });
```

### Optional - Coralogix Gradle plugin (Android)[​](#optional---coralogix-gradle-plugin-android "Direct link to Optional - Coralogix Gradle plugin (Android)")

The Coralogix Gradle Plugin automatically instruments all OkHttp clients in your app (including third-party SDKs) at build time. This ensures that all network traffic is automatically traced and reported to Coralogix, with no manual setup or code changes required. This plugin is especially useful for instrumenting networking libraries that create their own OkHttpClient instances internally and would otherwise be impossible to monitor.

#### Apply the plugin[​](#apply-the-plugin "Direct link to Apply the plugin")

1. Add the plugin to your project classpath<br />In your project-level `build.gradle` file:

   ```
   buildscript {

       dependencies {

           classpath "com.coralogix.gradle.plugin:gradle-plugin:0.0.2"

       }

   }
   ```

2. Apply the plugin in your app module<br />At the top of your app-level build.gradle file:

   ```
   apply plugin: "com.coralogix.gradle.plugin"
   ```

#### Configure the plugin[​](#configure-the-plugin "Direct link to Configure the plugin")

The plugin exposes a simple Gradle extension you can use in your app module:

```
coralogix {

  // Enable or disable instrumentation (default: true)

  enabled = true



  // Print debug logs during the build process (default: false)

  log = false

}
```

If the default configuration suits your needs, you can safely omit this block — the defaults will apply automatically.

#### Note[​](#note "Direct link to Note")

This plugin is optional. Regular JavaScript `fetch` calls and standard network requests will still be instrumented without it.

However, the plugin is the only way to capture network activity from third-party libraries or SDKs that use their own `OkHttpClient` instances internally.

### Troubleshooting[​](#troubleshooting "Direct link to Troubleshooting")

#### URL.origin is not implemented[​](#urlorigin-is-not-implemented "Direct link to URL.origin is not implemented")

1. `npm install react-native-url-polyfill`
2. At the top of your entry-point file (index.js) add: `import "react-native-url-polyfill/auto"`
