<commit_before>/*
* Automatically notifies Bugsnag when React Native's global error handler is called
*/

const createReportFromErr = require('@bugsnag/core/lib/report-from-error')

module.exports = {
  init: (client, ErrorUtils = global.ErrorUtils) => {
    if (!client.config.autoNotify) return
    if (!ErrorUtils) {
      client._logger.warn('ErrorUtils is not defined. Can’t attach a global error handler.')
      return
    }
    const prev = ErrorUtils.getGlobalHandler()

    ErrorUtils.setGlobalHandler((error, isFatal) => {
      client.notify(createReportFromErr(error, {
        severity: 'error',
        unhandled: true,
        severityReason: { type: 'unhandledException' }
      }), {}, () => {
        if (typeof prev === 'function') prev(error, isFatal)
      })
    })<commit_msg>feat(react-native-global-error-handler): Flag the report to be saved rather than sent<commit_after>/*
* Automatically notifies Bugsnag when React Native's global error handler is called
*/

const createReportFromErr = require('@bugsnag/core/lib/report-from-error')

module.exports = {
  init: (client, ErrorUtils = global.ErrorUtils) => {
    if (!client.config.autoNotify) return
    if (!ErrorUtils) {
      client._logger.warn('ErrorUtils is not defined. Can’t attach a global error handler.')
      return
    }
    const prev = ErrorUtils.getGlobalHandler()

    ErrorUtils.setGlobalHandler((error, isFatal) => {
      client.notify(createReportFromErr(error, {
        severity: 'error',
        unhandled: true,
        severityReason: { type: 'unhandledException' },
        attemptDelivery: false
      }), {}, () => {
        if (typeof prev === 'function') prev(error, isFatal)
      })
    })
{'fraction_non_alphanumeric': 0.12852112676056338, 'fraction_numerical': 0.0, 'mean_word_length': 3.2839195979899496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3522874', 'n_tokens_mistral': 500, 'n_tokens_neox': 491, 'n_words': 121}