在React Native项目中集成哨兵不工作丢弃错误日志

问题描述 投票:0回答:3

我想集成哨兵工具来反应本机项目崩溃报告,所以下面是我的代码

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包中定义文本组件,所以这是一个错误,但在我的哨兵仪表板中错误没有下降,所以知道我缺少什么配置吗?

react-native crash-reports
3个回答
0
投票

我目前正在使用 Sentry,但我不必安装 Raven

我发现您一直在阅读 JavaScript 部分,这就是您安装 Raven 的原因。但是,您应该查看 React Native 部分

我使用

react-native-sentry
软件包并安装它,我只需使用:

import { Sentry } from 'react-native-sentry'

Sentry.config('key').install();

0
投票

您所需要的配置就是这个

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,....
   });

-1
投票

嘿,您提供了将 Sentry 与 React 集成的正确步骤,您可以查看此博客 - React 应用程序中的 Sentry 集成和简化 CI/CD 管道

© www.soinside.com 2019 - 2024. All rights reserved.