Created
May 12, 2022 19:50
-
-
Save sayurimizuguchi/dec5deb0959cfa4d51461bf5665c5157 to your computer and use it in GitHub Desktop.
Sentry - Lunch and learn - May 12, 2022
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 Dev Configs | |
import './src/config'; | |
import React from 'react' | |
import { Button } from './design'; | |
/** | |
* @author Sayuri Mizuguchi | |
* Import, Initialize and Wrap | |
*/ | |
import * as Sentry from '@sentry/react-native'; | |
import App from './App'; | |
Sentry.init({ | |
dsn: "myDSNFromConfigProject", | |
enabled: !__DEV__, | |
debug: true, | |
}); | |
Sentry.wrap(App); | |
/** | |
* @author Sayuri Mizuguchi | |
* Native Crash Example | |
*/ | |
const ButtonNativeCrash = (text: string) => { | |
return ( | |
<Button onPress={() => Sentry.nativeCrash()}> | |
{text} | |
</Button> | |
); | |
} | |
/** | |
* @author Sayuri Mizuguchi | |
* JS Error Example | |
*/ | |
const simulateError = (payload: object) => { | |
try { | |
throw Error(`Errorring with payload = ${JSON.stringify(payload)}`); | |
} catch (e) { | |
console.error(e); | |
} | |
} | |
/** | |
* @author Sayuri Mizuguchi | |
* Interceptor example | |
* ref: https://docs.sentry.io/platforms/javascript/enriching-events/breadcrumbs/ | |
*/ | |
Sentry.init({ | |
dsn: "myDSNFromConfigProject", | |
enabled: !__DEV__, | |
beforeBreadcrumb(breadcrumb, _) { | |
return breadcrumb.category === "ui.network" ? | |
null : | |
breadcrumb; | |
}, | |
}); | |
/** | |
* @author Sayuri Mizuguchi | |
* Enriching events - Add custom Tags! | |
* ref: https://docs.sentry.io/platforms/javascript/enriching-events/tags/ | |
*/ | |
interface IAddTagSentry { | |
memberId: string; | |
}; | |
const addTagsSentry = (payload: IAddTagSentry) => | |
Sentry.setTag("member_id", payload.memberId) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment