旧版上传方法
了解如何使用旧版 SDK 和 Sentry 工具上传源映射。
本页面描述了如何为旧版 React Native SDK 上传源映射。如果你使用的是最新版本的 SDK,请遵循这些说明。
你需要在构建时为应用程序的每次发布生成并上传源映射,以便发送的事件能够正确解压缩。为此,请按照以下步骤操作:
通过查看 配置指南 来配置 CLI 命令。
Hermes
如果你使用 Hermes 引擎,你需要按照此指南为 Hermes 编译源映射。
你可以使用 React Native CLI 为你的应用程序生成 JavaScript 捆绑包和源映射:
Copied
react-native bundle \
--dev false \
--platform android \
--entry-file index.android.js \
--reset-cache \
--bundle-output index.android.bundle \
--sourcemap-output index.android.bundle.map
了解更多关于 React Native CLI bundle 命令的信息。
将你的入口文件传递给 --entry-file
,分别用于 Android 或 iOS。默认情况下,此文件通常命名为 index.js
。对于 Android,它通常命名为 index.android.js
,对于 iOS,则命名为 index.ios.js
。
这些文件将输出你的捆绑包和源映射。默认情况下,这些文件对于 Android 命名为 index.android.bundle
和 index.android.bundle.map
,对于 iOS 命名为 main.jsbundle
和 main.jsbundle.map
。
源映射的名称必须是捆绑包名称加上 .map
,以便源映射能够正确被检测到。
Copied
node_modules/@sentry/cli/bin/sentry-cli sourcemaps upload \
--release <release> \
--dist <dist> \
--strip-prefix /path/to/project/root \
index.android.bundle index.android.bundle.map