1. 程式人生 > >React Native整合Sentry之CodePush

React Native整合Sentry之CodePush

如果您想與CodePush一起使用哨兵,您必須向我們傳送CodePush版本:

import codePush from "react-native-code-push";

codePush.getUpdateMetadata().then((update) => {
  if (update) {
    Sentry.setVersion(update.appVersion + '-codepush:' + update.label);
  }
});

將它放在您已使用CodePush的程式碼中。這可以確保我們可以將崩潰與正確的源圖關聯起來。 Sentry.setVersion將釋出版本設定為bundle_id-version,這適用於iOS和Android。確保您呼叫此函式,否則Sentry無法正確表示您的崩潰。 更新CodePush版本後,您必須將新資產上傳到Sentry:

$ appcenter codepush release-react YourApp --output-dir ./build
$ export SENTRY_PROPERTIES=./ios/sentry.properties
$ sentry-cli react-native appcenter YourApp ios ./build/codePush