Last active
March 19, 2018 15:05
-
-
Save SudoPlz/62f172292c7c6fb9b47e5f7dd2cd735b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Client, Configuration } from 'bugsnag-react-native'; | |
module.exports = { // cached singleton instance | |
instance: null, | |
create(key, store, codeBundleId) { | |
if (this.instance === null) { | |
if (key == null) { | |
throw new Error(`Crash Reporter should be created with a | |
key as the first param. i.e .create(key, reduxStore)`); | |
} | |
const bugsnagConfig = new Configuration(key); | |
bugsnagConfig.shouldNotify = () => !__DEV__; | |
// code bundle id | |
if (codeBundleId) { | |
bugsnagConfig.codeBundleId = codeBundleId; | |
} | |
bugsnagConfig.notifyReleaseStages = ['production', 'staging', 'testflight']; | |
bugsnagConfig.registerBeforeSendCallback((report) => { | |
const state = JSON.parse(JSON.stringify(store.getState())); | |
const metadata = report.metadata || {}; | |
// add our calendar state as metadata | |
metadata.calendar = state.calendar; | |
if (metadata.app == null) { | |
metadata.app = {}; | |
} | |
// if the codebundleid is null, add it to the metadata | |
if (metadata.app.codeBundleId == null) { | |
metadata.app.codeBundleId = codeBundleId; | |
} | |
report.metadata = metadata; | |
}); | |
this.instance = new Client(bugsnagConfig); | |
} | |
return this.instance; | |
}, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CrashReporter.create(CONFIG.BUGSNAG_KEY, store, curAppVersion); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment