Jor*_*dan 4 sentry react-native code-push
我似乎无法弄清楚这一点。有人可以帮我解决这个问题吗?我正在使用 CodePush 上传我的应用程序,并且我希望 Sentry 处理我的错误,因为应用程序中心诊断不是很好。
我的应用程序的根组件中有这个......
if (process.env.NODE_ENV === 'production') {
Sentry.config('****',{
deactivateStacktraceMerging: false
}).install();
codePush.getUpdateMetadata().then((update) => {
if (update) {
Sentry.setVersion(update.appVersion + '-codepush:' + update.label);
}
});
}
Run Code Online (Sandbox Code Playgroud)
我有一个部署包脚本,它将部署到 codepush 并运行在其文档中找到的哨兵命令
appcenter codepush release-react -a account/project --output-dir ./build && export SENTRY_PROPERTIES=./ios/sentry.properties && sentry-cli react-native appcenter account/project ios ./build/codePush
每当我捕获到一个错误或捕获到一个错误时,我都缺乏有关哪个文件引发错误的实际信息,并且我会There was 1 error encountered while processing this event在顶部看到Source code was not found for app:///main.jsbundle当我展开它时的信息。
我觉得这一定是因为哨兵没有正确连接到 codepush 来获取我的源映射?
经过一番尝试和失败(因为 Sentry 文档具有误导性),最终通过 AppCenter codepush 使源映射适用于 iOS 和 Android,请按照 bash 脚本中的以下步骤操作:
MY_APP_NAME="e.g. Sentry account/project"
MY_BUNDLE_ID="e.g. com.company.superapp"
MY_APP_ENV="e.g. development, staging or production"
NATIVE_VERSION="e.g. 1.2.3"
PLATFORM="e.g. ios or android"
# Build and release to appcenter
appcenter codepush release-react \
-a "$MY_APP_NAME" \
-d "$MY_APP_ENV" \
-m -t "$NATIVE_VERSION" \
--sourcemap-output \
--output-dir "./build/$PLATFORM"
export SENTRY_PROPERTIES="./$PLATFORM/sentry.properties"
# Get label and name of latest release
LABEL=$(appcenter codepush deployment history $MY_APP_ENV -a $MY_APP_NAME --output json | jq '.[-1][0]' -r)
RELEASE_NAME="$MY_BUNDLE_ID@$NATIVE_VERSION+codepush:$LABEL"
# Upload sourcemap
sentry-cli react-native appcenter \
"$MY_APP_NAME" "$PLATFORM" "./build/$PLATFORM/CodePush" \
--deployment "$MY_APP_ENV" \
--release-name "$RELEASE_NAME" \
--dist "$LABEL"
Run Code Online (Sandbox Code Playgroud)
并在 app.ts (或类似的)中进行初始化:
Sentry.init({...});
codePush.getUpdateMetadata().then(update => {
if (update) {
if (MY_APP_ENV === 'production')) {
Sentry.setRelease(
`${MY_BUNDLE_ID}@${update.appVersion}+codepush:${update.label}`,
);
} else {
Sentry.setRelease(
`${MY_BUNDLE_ID}.${MY_APP_ENV}@${update.appVersion}+codepush:${update.label}`,
);
}
Sentry.setDist(update.label);
}
});
Run Code Online (Sandbox Code Playgroud)
环境:
appcenter version: 2.7.3
@sentry/react-native: 2.5.1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1891 次 |
| 最近记录: |