You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo Go使用expo-firebase-analytics无法上报事件如何排查

遗漏的配置点

  1. Firebase配置仅放在web节点下,iOS/Android端运行时无法读取配置,需要补充根级expo.firebaseConfig配置项
  2. 未开启Analytics调试模式,无法确认上报请求是否正常触发
  3. 未验证Firebase项目的Analytics数据收集开关是否开启

排查解决步骤

  • 修正app.json配置,将通用Firebase配置放到根级字段,web端配置保留做覆盖:
{
  "expo": {
    "firebaseConfig": {
      "apiKey": "AIxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "authDomain": "my-app.firebaseapp.com",
      "projectId": "my-app",
      "storageBucket": "my-app.appspot.com",
      "messagingSenderId": "mySenderId",
      "appId": "1:myApp:web:myAppId",
      "measurementId": "G-MYMEASUREMENTID"
    },
    "web": {
      "config": {
        "firebase": {
          "apiKey": "AIxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
          "authDomain": "my-app.firebaseapp.com",
          "projectId": "my-app",
          "storageBucket": "my-app.appspot.com",
          "messagingSenderId": "mySenderId",
          "appId": "1:myApp:web:myAppId",
          "measurementId": "G-MYMEASUREMENTID"
        }
      }
    }
  }
}
  • 开启调试模式实时验证上报,修改App.js中的调用逻辑:
useEffect(() => {
  (async() => {
    console.log("App.js useEffect");
    // 开启调试模式,事件会实时同步到Firebase控制台的DebugView
    await Analytics.setDebugModeEnabled(true);
    await Analytics.logEvent('ScreenLoaded');
  })();
}, []);
  • 确认Firebase项目配置:检查Google Analytics数据流创建成功,measurementId填写正确,数据收集开关处于开启状态;如果你给Firebase的API密钥设置了访问限制,需要将Expo Go的包名host.exp.exponent添加到允许访问的应用列表中
  • 测试时确保设备网络可以正常访问谷歌服务,无代理拦截相关请求
  • 如果Expo Go内测试仍无数据,可以先打包成独立开发版客户端测试,Expo Go部分原生模块权限存在限制,开发版环境更接近正式运行环境
  • 注意Firebase控制台默认有2-4小时的事件上报延迟,开启调试模式后可以在DebugView中实时查看数据,不需要等待延迟

内容的提问来源于stack exchange,提问作者Scott

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.10 20:06:03