Send sentry logs
maidinhkhoa92 opened this issue · 9 comments
In my project, I create a util call log. Here is content.
import { logger, sentryTransport } from "react-native-logs"
import * as Sentry from "@sentry/react-native"
/*
* Configure sentry
*/
const config = {
severity: "error",
transport: sentryTransport,
transportOptions: {
SENTRY: Sentry,
},
}
export const log = logger.createLogger(config)
In my app.tsx, I import log and try my first error log but it doesn't work:
import React, { useEffect,} from "react"
import {Text, View} from "react-native"
import { log } from "./utils/log"
function App() {
useEffect(() => {
log.error("My first Sentry error!")
}, [])
return (
<View><Text>test</Text></View>
)
}
export default App
Can anyone help me to push my first log?
have you configured Sentry correctly?
you should have something like that in your app index file before send logs:
import * as Sentry from "@sentry/react-native";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
});
import * as Sentry from "@sentry/react-native"; Sentry.init({ dsn: "https://examplePublicKey@o0.ingest.sentry.io/0", });
Thanks @alessandro-bottamedi I will try and let you know.
@alessandro-bottamedi it doesn't work. Here is my code
import { logger, sentryTransport } from "react-native-logs"
import * as Sentry from "@sentry/react-native"
util.ts
/*
* Configure sentry
*/
const config = {
severity: "error",
transport: sentryTransport,
transportOptions: {
SENTRY: Sentry,
},
}
export const log = logger.createLogger(config)
app.tsx
import React, { useEffect,} from "react"
import {Text, View} from "react-native"
import { log } from "./utils/log"
import * as Sentry from "@sentry/react-native"
Sentry.init({
dsn: "https://xxxx",
})
function App() {
useEffect(() => {
log.error("My first Sentry error!")
}, [])
return (
<View><Text>test</Text></View>
)
}
export default App
If you throw the error directly with SENTRY, does it work?
Sentry.captureException("My first Sentry error!");
@alessandro-bottamedi yes, it works with direct throwing.
I just realized that React-native-logs only works with realease build. Not for development. Did I miss any confirgurations for development ?
No, do you have the last version?
try to put this lines in the index.js
file, the first file you load:
import * as Sentry from "@sentry/react-native"
Sentry.init({
dsn: "https://xxxx",
})
@maidinhkhoa92 I don't know if this is your case, but I had the hole config right and was using it coupled with Expo. Sentry.init
needs a specific parameter to work in development enableInExpoDevelopment: true
, this was my problem.
Feel free to re-open if necessary