有关安装和配置 LogRocket 以进行会话重放和错误监控的指南。
LogRocket 记录用户会话并在用户使用你的应用时识别错误。你可以通过更新 ID 过滤会话,还可以连接到 Expo 仪表板上的 LogRocket 账户以快速访问应用的会话数据。
¥LogRocket records user sessions and identifies bugs as your users use your app. You can filter sessions by update IDs and also connect to your LogRocket account on the Expo dashboard to get quick access to your app's session data.
¥Install and configure LogRocket
你可以使用以下命令安装 LogRocket SDK:
¥You can install the LogRocket SDK with the following command:
-
npx expo install @logrocket/react-native expo-build-properties
然后,在你的 应用配置 中包含 LogRocket 配置插件:
¥Then, in your app config, include the LogRocket config plugin:
{
"plugins": [
[
"expo-build-properties",
{
"android": {
"minSdkVersion": 25
}
}
],
"@logrocket/react-native"
]
}
最后,在你的应用中的顶层文件(如 app/_layout.tsx)中初始化 LogRocket:
¥Finally, initialize LogRocket in your app in a top-level file, like 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。
¥In the code above, replace <App ID>
with your LogRocket App ID.
¥Connecting LogRocket on the Expo dashboard
你可以在 Expo 的仪表板上将你的 LogRocket 账户和项目链接到你的 Expo 账户和项目,以便你可以在部署和更新仪表板中查看应用的最后几个会话。
¥You can link your LogRocket account and project to your Expo account and project on Expo's dashboard, so that you can see the last few sessions from your app in the deployments and updates dashboards.
转到你的 账户设置 并单击“连接”以使用 LogRocket 进行身份验证:
¥Go to your account settings and click Connect to authenticate with LogRocket:
然后,转到你的 项目设置 并单击“连接”以将你的 LogRocket 项目与 Expo 上的项目链接起来:
¥Then, go to your project settings and click Connect to link your LogRocket project with your project on Expo:
然后,你将开始在部署和更新仪表板中的 Expo 仪表板中看到“在 LogRocket 上查看”按钮,以及来自应用的最后几个会话。
¥Then, you'll start to see View on LogRocket buttons in the Expo dashboard in the Deployments and Updates dashboards, along with the last few sessions from your app.
¥Learn more about LogRocket
要了解有关如何将 LogRocket 与 Expo 结合使用的更多信息,请查看 LogRocket 文档。
¥To learn more about how to use LogRocket with Expo, check out the LogRocket documentation.