Additional Configuration

These are functions you can call in your JavaScript code:

import { Sentry, SentrySeverity, SentryLog } from "react-native-sentry";

// disable stack trace merging
Sentry.config("", {
  deactivateStacktraceMerging: false, // default: true | Deactivates the stack trace merging feature
  logLevel: SentryLog.Debug, // default SentryLog.None | Possible values:  .None, .Error, .Debug, .Verbose
  disableNativeIntegration: false, // default: false | Deactivates the native integration and only uses raven-js
  handlePromiseRejection: true, // default: true | Handle unhandled promise rejections
  // sampleRate: 0.5 // default: 1.0 | Only set this if you don't want to send every event so e.g.: 0.5 will send 50% of all events
  // These two options will only be considered if stack trace merging is active
  // Here you can add modules that should be ignored or exclude modules
  // that should no longer be ignored from stack trace merging
  // ignoreModulesExclude: ["I18nManager"], // default: [] | Exclude is always stronger than include
  // ignoreModulesInclude: ["RNSentry"], // default: [] | Include modules that should be ignored too
  // ---------------------------------

// set a callback after an event was successfully sent
// its only guaranteed that this event contains `event_id` & `level`
Sentry.setEventSentSuccessfully((event) => {
  // can also be called outside this block but maybe null
  // Sentry.lastEventId(); -> returns the last event_id after the first successfully sent event
  // Sentry.lastException(); -> returns the last event after the first successfully sent event

Sentry.setShouldSendCallback((event) => {
  return true; // if return false, event will not be sent

// Sentry.lastException(); // Will return the last sent error event
// Sentry.lastEventId(); // Will return the last event id

// export an extra context
  a_thing: 3,
  some_things: { green: "red" },
  foobar: ["a", "b", "c"],
  react: true,
  float: 2.43,

// set the tag context
  environment: "production",
  react: true,

// set the user context
  email: "",
  userID: "12341",
  username: "username",
  extra: {
    is_admin: false,

// set a custom message
Sentry.captureMessage("TEST message", {
  level: SentrySeverity.Warning,
}); // Default SentrySeverity.Error

// capture an exception
Sentry.captureException(new Error("Oops!"), {
  logger: "my.module",

// capture a breadcrumb
  message: "Item added to shopping cart",
  category: "action",
  data: {
    isbn: "978-1617290541",
    cartSize: "3",

// This will trigger a crash in the native Sentry client
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").