我想集成哨兵工具来反应本机项目崩溃报告,所以下面是我的代码
import { AppRegistry } from 'react-native';
import App from './App';
import { Sentry,SentryLog } from 'react-native-sentry';
import Raven from 'raven-js';
Raven
.config('https://****@sentry.io/1196569', {
logLevel: SentryLog.Debug,
})
.install();
try {
//doSomething(a[0])
} catch(e) {
Raven.captureException(e)
}
AppRegistry.registerComponent('RNCrashReport', () => App);
应用程序.js
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
View
} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={styles.container}>
<Text>{Hello}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
在我的App.js中,我没有在react-native包中定义文本组件,所以这是一个错误,但在我的哨兵仪表板中错误没有下降,所以知道我缺少什么配置吗?
我目前正在使用 Sentry,但我不必安装 Raven。
我发现您一直在阅读 JavaScript 部分,这就是您安装 Raven 的原因。但是,您应该查看 React Native 部分。
我使用
react-native-sentry
软件包并安装它,我只需使用:
import { Sentry } from 'react-native-sentry'
Sentry.config('key').install();
您所需要的配置就是这个
import { Sentry } from 'react-native-sentry';
Sentry.config(SENTRY_URL).install();
然后您可以使用https://docs.sentry.io/clients/react-native/config/
中列出的方法设置您自己的键值对:
Sentry.setExtraContext({
key: value, key: value,....
});
嘿,您提供了将 Sentry 与 React 集成的正确步骤,您可以查看此博客 - React 应用程序中的 Sentry 集成和简化 CI/CD 管道