This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

使用 LogRocket

编辑页面

一份关于安装和配置 LogRocket 以进行会话回放和错误监控的指南。


LogRocket 会记录用户会话,并在用户使用你的应用时识别 bug。你可以按更新 ID 过滤会话,也可以在 EAS 控制台中将你的 LogRocket 账户连接起来,以便快速访问应用的会话数据。

安装并配置 LogRocket

你可以使用以下命令安装 LogRocket SDK:

Terminal
npx expo install @logrocket/react-native expo-build-properties

然后,在你的 app 配置 中包含 LogRocket 配置插件:

app.json
{ "plugins": [ [ "expo-build-properties", { "android": { "minSdkVersion": 25 } } ], "@logrocket/react-native" ] }

最后,在应用中的顶层文件里初始化 LogRocket,例如 src/app/_layout.tsx

src/app/_layout.tsx
import { useEffect } from 'react'; import * as Updates from 'expo-updates'; import LogRocket from '@logrocket/react-native'; const App = () => { useEffect(() => { LogRocket.init('<App ID>', { updateId: Updates.isEmbeddedLaunch ? null : Updates.updateId, expoChannel: Updates.channel, }); }, []); };

在上面的代码中,请将 <App ID> 替换为你的 LogRocket 应用 ID

Connect LogRocket in the EAS dashboard

You can link your LogRocket account and project to your Expo account and project so that you can view your app’s most recent sessions in the Expo dashboard, along with relevant information in the deployments and updates dashboards.

Go to Account settings > Overview > Connections, then click Connect to authenticate through LogRocket:

Then, go to your project and, under Project settings > General, click Connect to link your LogRocket project with the project on Expo:

After that, you’ll start seeing the View on LogRocket button and your app’s most recent sessions in the Native Deployments and Updates dashboards in the EAS dashboard.

了解更多关于 LogRocket 的信息

要进一步了解如何在 Expo 中使用 LogRocket,请查看 LogRocket 文档