React Native项目接入Sentry指南

本文主要介绍React Native项目接入Sentry流程,以及遇到的一些注意点,方便大家去解决和处理,如果在接入过程中,遇到任何问题可以在评论区留言,我将根据自己的接入经验给出一些解决方案和建议。

1, 安装sentry sdk

我们可以在项目中执行如下命令来安装sentry,命令如下:

yarn sentry-wizard -s -i reactNative
或者
npx @sentry/wizard -s -i reactNative

可以参考React Native官方接入sentry的文档:https://docs.sentry.io/platforms/react-native/。

如果顺利的话,执行完上述命令后,基本不需要怎么改动就可以直接测试异常上报等功能。首先,需要初始化。

import * as Sentry from "@sentry/react-native"; 


Sentry.init({ 
    dsn: "https://6701a142b36c4098b88385bebf702fbd@o4504790585835520.ingest.sentry.io/4504790600450048", 
    // Set tracesSampleRate to 1.0 to capture 100% 
    // of transactions for performance monitoring. 
    // We recommend adjusting this value in production 
    tracesSampleRate: 1.0, 
});

你可能感兴趣的:(React,Native,react,native,sentry,react.js)