Expo 观察故障排除

常见 Expo Observe 问题的解决方案。


For the complete documentation index, see llms.txt. Use this file to discover all available pages.

常见问题

🌐 Common issues

指标未出现在仪表板上

🌐 Metrics not appearing in the dashboard

  1. 确保在安装 expo-observe 后创建了新构建。只有包含该库的构建才会收集指标。
  2. 检查你是否在 EAS 仪表板中查看了正确的项目。
  3. 如果在调试构建中进行测试,请确保通过 configure()dispatchInDebug 设置为 true。请参阅 在开发中启用指标

首次渲染时间未显示

🌐 Time to first render not showing

验证你的根布局是否被 AppMetricsRoot 封装:

🌐 Verify that your root layout is wrapped with AppMetricsRoot:

import { AppMetricsRoot } from 'expo-observe'; function RootLayout() { return (/* your layout */); } export default AppMetricsRoot.wrap(RootLayout);

互动时间未显示

🌐 Time to interactive not showing

此指标需要手动测量。请确认:

🌐 This metric requires manual instrumentation. Verify that:

  1. 在你的启动屏幕被隐藏后,你正在调用 AppMetrics.markInteractive()
  2. 该调用实际上正在执行(添加 console.log 以验证)。
从 expo-eas-observe 迁移

如果你曾参与私有预览并且之前使用过 expo-eas-observe,请按照以下步骤迁移到 expo-observe

🌐 If you were part of the private preview and previously used expo-eas-observe, follow these steps to migrate to expo-observe.

1

更换封装

Terminal
npx expo install expo-observe
npm uninstall expo-eas-observe

如果你之前将 expo-eas-client 作为单独的依赖安装,可以将其移除:

🌐 If you previously installed expo-eas-client as a separate dependency, you can remove it:

Terminal
npm uninstall expo-eas-client

2

更新导入

- import AppMetrics from 'expo-eas-observe'; + import { AppMetrics } from 'expo-observe';

3

将手动 markFirstRender() 替换为 AppMetricsRoot

与其手动调用 markFirstRender(),不如用 AppMetricsRoot HOC 封装你的根布局。这会自动处理测量。

🌐 Instead of calling markFirstRender() manually, wrap your root layout with the AppMetricsRoot HOC. This handles the measurement automatically.

之前:

🌐 Before:

import { useEffect } from 'react'; import AppMetrics from 'expo-eas-observe'; export default function RootLayout() { useEffect(() => { AppMetrics.markFirstRender(); }, []); return (/* your layout */); }

之后:

🌐 After:

import { AppMetricsRoot } from 'expo-observe'; function RootLayout() { return (/* your layout */); } export default AppMetricsRoot.wrap(RootLayout);

4

创建新版本

完成迁移后,创建你的应用的新版本:

🌐 After completing the migration, create a new build of your app:

Terminal
eas build