function reactNativePlugin(Raven, options) {
  options = options || {};

  // react-native doesn't have a document, so can't use default Image
  // transport - use XMLHttpRequest instead
  Raven.setTransport(reactNativePlugin._transport);

  // Use data callback to strip device-specific paths from stack traces
  Raven.setDataCallback(
    wrappedCallback(function(data) {
      return reactNativePlugin._normalizeData(data, options.pathStrip);
    })
  );

  // Check for a previously persisted payload, and report it.
  reactNativePlugin
    ._restorePayload()
    .then(function(payload) {
      options.onInitialize && options.onInitialize(payload);
      if (!payload) return;
      Raven._sendProcessedPayload(payload, function(error) {
        if (error) return; // Try again next launch.
        reactNativePlugin._clearPayload();
      });
    })
    ['catch'](function() {});

  // Make sure that if multiple fatals occur, we only persist the first one.
  //
  // The first error is probably the most important/interesting error, and we
  // want to crash ASAP, rather than potentially queueing up multiple errors.
  var handlingFatal = false;

  var defaultHandler =
    (ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler()) ||
    ErrorUtils._globalHandler;

  Raven.setShouldSendCallback(function(data, originalCallback) {
    if (!(FATAL_ERROR_KEY in data)) {
      // not a fatal (will not crash runtime), continue as planned
      return originalCallback ? originalCallback.call(this, data) : true;
    }

    var origError = data[FATAL_ERROR_KEY];
    delete data[FATAL_ERROR_KEY];

    reactNativePlugin
      ._persistPayload(data)
      .then(function() {
        defaultHandler(origError, true);
        handlingFatal = false; // In case it isn't configured to crash.
        return null;
      })
      ['catch'](function() {});

    return false; // Do not continue.
  });

  ErrorUtils.setGlobalHandler(function(error, isFatal) {
    var captureOptions = {
      timestamp: new Date() / 1000
    };
    var error = arguments[0];
    // We want to handle fatals, but only in production mode.
    var shouldHandleFatal = isFatal && !global.__DEV__;
    if (shouldHandleFatal) {
      if (handlingFatal) {
        console.log('Encountered multiple fatals in a row. The latest:', error);
        return;
      }
      handlingFatal = true;
      // We need to preserve the original error so that it can be rethrown
      // after it is persisted (see our shouldSendCallback above).
      captureOptions[FATAL_ERROR_KEY] = error;
    }
    Raven.captureException(error, captureOptions);
    // Handle non-fatals regularly.
    if (!shouldHandleFatal) {
      defaultHandler(error);
    }
  });
}
function reactNativePlugin(Raven, options) {
  options = options || {};

  // react-native doesn't have a document, so can't use default Image
  // transport - use XMLHttpRequest instead
  Raven.setTransport(reactNativePlugin._transport);

  // Use data callback to strip device-specific paths from stack traces
  Raven.setDataCallback(
    wrappedCallback(function(data) {
      return reactNativePlugin._normalizeData(data, options.pathStrip);
    })
  );

  // Check for a previously persisted payload, and report it.
  reactNativePlugin
    ._restorePayload()
    .then(function(payload) {
      options.onInitialize && options.onInitialize(payload);
      if (!payload) return;
      Raven._sendProcessedPayload(payload, function(error) {
        if (error) return; // Try again next launch.
        reactNativePlugin._clearPayload();
      });
    })
    ['catch'](function() {});

  // Make sure that if multiple fatals occur, we only persist the first one.
  //
  // The first error is probably the most important/interesting error, and we
  // want to crash ASAP, rather than potentially queueing up multiple errors.
  var handlingFatal = false;

  var defaultHandler =
    (ErrorUtils.getGlobalHandler && ErrorUtils.getGlobalHandler()) ||
    ErrorUtils._globalHandler;

  Raven.setShouldSendCallback(function(data, originalCallback) {
    if (!(FATAL_ERROR_KEY in data)) {
      // not a fatal (will not crash runtime), continue as planned
      return originalCallback ? originalCallback.call(this, data) : true;
    }

    var origError = data[FATAL_ERROR_KEY];
    delete data[FATAL_ERROR_KEY];

    reactNativePlugin
      ._persistPayload(data)
      .then(function() {
        defaultHandler(origError, true);
        handlingFatal = false; // In case it isn't configured to crash.
        return null;
      })
      ['catch'](function() {});

    return false; // Do not continue.
  });

  ErrorUtils.setGlobalHandler(function(error, isFatal) {
    var captureOptions = {
      timestamp: new Date() / 1000
    };
    var error = arguments[0];
    // We want to handle fatals, but only in production mode.
    var shouldHandleFatal = isFatal && !global.__DEV__;
    if (shouldHandleFatal) {
      if (handlingFatal) {
        console.log('Encountered multiple fatals in a row. The latest:', error);
        return;
      }
      handlingFatal = true;
      // We need to preserve the original error so that it can be rethrown
      // after it is persisted (see our shouldSendCallback above).
      captureOptions[FATAL_ERROR_KEY] = error;
    }
    Raven.captureException(error, captureOptions);
    // Handle non-fatals regularly.
    if (!shouldHandleFatal) {
      defaultHandler(error);
    }
  });
}
function reactNativePlugin ( Raven , options ) { options = options || { } ; // react-native doesn't have a document, so can't use default Image // transport - use XMLHttpRequest instead Raven . setTransport ( reactNativePlugin . _transport ) ; // Use data callback to strip device-specific paths from stack traces Raven . setDataCallback ( wrappedCallback ( function ( data ) { return reactNativePlugin . _normalizeData ( data , options . pathStrip ) ; } ) ) ; // Check for a previously persisted payload, and report it. reactNativePlugin . _restorePayload ( ) . then ( function ( payload ) { options . onInitialize && options . onInitialize ( payload ) ; if ( ! payload ) return ; Raven . _sendProcessedPayload ( payload , function ( error ) { if ( error ) return ; // Try again next launch. reactNativePlugin . _clearPayload ( ) ; } ) ; } ) [ 'catch' ] ( function ( ) { } ) ; // Make sure that if multiple fatals occur, we only persist the first one. // // The first error is probably the most important/interesting error, and we // want to crash ASAP, rather than potentially queueing up multiple errors. var handlingFatal = false ; var defaultHandler = ( ErrorUtils . getGlobalHandler && ErrorUtils . getGlobalHandler ( ) ) || ErrorUtils . _globalHandler ; Raven . setShouldSendCallback ( function ( data , originalCallback ) { if ( ! ( FATAL_ERROR_KEY in data ) ) { // not a fatal (will not crash runtime), continue as planned return originalCallback ? originalCallback . call ( this , data ) : true ; } var origError = data [ FATAL_ERROR_KEY ] ; delete data [ FATAL_ERROR_KEY ] ; reactNativePlugin . _persistPayload ( data ) . then ( function ( ) { defaultHandler ( origError , true ) ; handlingFatal = false ; // In case it isn't configured to crash. return null ; } ) [ 'catch' ] ( function ( ) { } ) ; return false ; // Do not continue. } ) ; ErrorUtils . setGlobalHandler ( function ( error , isFatal ) { var captureOptions = { timestamp : new Date ( ) / 1000 } ; var error = arguments [ 0 ] ; // We want to handle fatals, but only in production mode. var shouldHandleFatal = isFatal && ! global . __DEV__ ; if ( shouldHandleFatal ) { if ( handlingFatal ) { console . log ( 'Encountered multiple fatals in a row. The latest:' , error ) ; return ; } handlingFatal = true ; // We need to preserve the original error so that it can be rethrown // after it is persisted (see our shouldSendCallback above). captureOptions [ FATAL_ERROR_KEY ] = error ; } Raven . captureException ( error , captureOptions ) ; // Handle non-fatals regularly. if ( ! shouldHandleFatal ) { defaultHandler ( error ) ; } } ) ; }
Initializes React Native plugin
Initializes React Native plugin
This is the main function that is called by the react - native plugin. It is called by the react - native plugin to send the data to the server.