React Native崩溃报告有什么好的设置?

fac*_*com 6 sentry crashlytics hockeyapp twitter-fabric react-native

我看到getSentry现在有React Native的崩溃报告:

https://docs.getsentry.com/hosted/clients/javascript/integrations/react-native/

我喜欢他们,因为他们很好地将异常与您的源地图相关联.但我也想抓住本机崩溃.你基本上要设置getSentry和Crashlytics吗?

这是讨论各种选项的主题:

https://github.com/facebook/react-native/issues/5378

这里有一个看似很好但有点迂回的hokeyapp解决方案:http: //blog.nparashuram.com/2015/10/crash-analytics-and-feedback-for.html

我想知道人们在生产中成功使用什么来捕获原生和javascript崩溃与详细的源地图感知报告?

Sud*_*Plz 6

我是react-native-bugsnag的作者.

我不是公司的附属公司,但我喜欢他们的仪表板,以及他们的定价模型,所以我为我们创建了这个库本地程序员,以便有办法使用他们的服务.

[TL/DR]:

1)复制下面的脚本,将其添加到项目根目录,

2)更改脚本开头的版本以匹配您的react-native项目的本机部分的版本.

3)运行它:

sh crash_report.sh -i <BUGSNAG_KEY> 捆绑和上传你的ios源图,

要么

sh crash_report.sh -a <BUGSNAG_KEY> 捆绑和上传你的Android源图.

[LONGER VERSION]:

官方的反应本地bugsnag SDK现已发布.

它支持iOS/Android和Javascript处理和无法处理的崩溃报告.

让我解释一下我是怎么做到的:

我创建了一个名为的文件crash_report.sh来创建我的项目源图,并将它们上传到bugsnag以及我的所有项目文件,以便我可以看到如下所示的丰富错误报告: 在此输入图像描述

要使用它,您只需将其添加到项目根文件夹,将版本变量(appVersion)更改为您的xcode项目所具有的任何版本,或者您的android studio项目.(这是非常重要的)否则你将无法在bugnsag中看到去混淆代码然后运行它.

crash_report.sh:

#!/bin/bash

appVersion='1.0.0'  # IMPORTANT, this has to be the same as the version of your native project in xcode or android studio.

# Get shell args
aflag=''
iflag=''
platform=''
bugsnagKey=''
while getopts 'i:a:' flag; do
  case "${flag}" in
    a) 
    aflag='true'
    bugsnagKey=$OPTARG
    ;;
    i) iflag='true' 
    bugsnagKey=$OPTARG
    ;;
    *) printf "Usage: %s: [-a] [-i] args\n" $0
  esac
done

if [ -n "$aflag" ] && [ -z "$iflag" ]; then
    printf "Now bundling for android.\n"
    platform='android'
fi
if [ -n "$iflag" ] && [ -z "$aflag" ]; then
    printf "Now bundling for ios.\n"
    platform='ios'
fi

if [ -z "$platform" ]; then
    printf "\nUsage: <script> -i <BUGSNAG_KEY> OR -a <BUGSNAG_KEY>. \nTerminating...\n\n"
else
    printf "Now fetching project properties from package.json\n"

    echo 'Now creating sourcemaps\n App version: '${appVersion}' for platform: '${platform}

    # #Create iOS sourcemaps
    react-native bundle --dev false --platform ${platform} --entry-file index.${platform}.js --bundle-output main.${platform}.jsbundle --sourcemap-output main.${platform}.jsbundle.map

    echo 'Now uploading with key: '${bugsnagKey}' for version '${appVersion}

    CUR_DIRR=`pwd`  # Get current directory
    CUR_DIRR=${CUR_DIRR}'/' # Append a forward slash to it

    # Here we get ALL the project files, and form them as curl params, so that we can later on pass them to curl
    PROJECT_FILES=$(find src -name '*.js'  | while read -r i; do echo '-F '$CUR_DIRR$i'=@'$i; done) # Form the right file ending for curl
    # echo ${PROJECT_FILES}

    # #Upload iOS sourcemaps
    curl -w "\n\n%{http_code}\n" --progress-bar -F apiKey=${bugsnagKey} -F appVersion=${appVersion} -F minifiedUrl="main.jsbundle" -F sourceMap=@main.${platform}.jsbundle.map -F minifiedFile=@main.${platform}.jsbundle -F overwrite=true ${PROJECT_FILES} https://upload.bugsnag.com

    echo '\nDone.\n'

fi
Run Code Online (Sandbox Code Playgroud)

我希望这对某人有所帮助,这花了我几个小时的时间.玩得开心..!


ehf*_*eng 2

Sentry 的原生 iOS 客户端支持符号化(类似于 Crashlytics),因此您可以为 javascript 和 objc 层添加 Sentry。