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

Flutter Web项目无法在Firebase Analytics查看历史活动数据

Firebase Analytics无法显示历史用户/事件数据(仅能看到实时数据)

我开发的Flutter Web游戏项目已集成Firebase Analytics,能看到过去30分钟的实时用户数据,但完全看不到任何历史用户或事件数据。昨天刚给项目添加Firebase时就有不少用户访问,但今天查不到这些事件记录。

我反复检查过设置流程,确认配置没有问题。

今早访问网站时,实时记录里能看到自己的访问数据:
实时用户数据

但历史用户活动时间线图表完全没有数据:
历史数据为空


单例Analytics类代码

// Singleton class to hold the Analytics for for Firebase
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:septuple/firebase_options.dart';

class Analytics {
  Analytics._();

  // Generate an instance of the firebase analytics class
  final FirebaseAnalytics analytics = FirebaseAnalytics.instance;

  // Create an instance of this class as a singleton
  static final Analytics _instance = Analytics._();

  // Initialise firebase for the app
  static Future<void> init() async {
    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );
    getData().setAnalyticsCollectionEnabled(true);
  }

  //Get the FirebaseAnalystics object to do event logging
  static FirebaseAnalytics getData() {
    return _instance.analytics;
  }
}

main方法初始化代码

void main() async {
  //
  // Initialise the Hive database
  await Hive.initFlutter();
  await Hive.openBox('septupleBox');
  //
  // Initialise firebase in the Analytics singleton to enable event logging
  //
  await Analytics.init();
  //
  // Run the app
  runApp(Game());
}

事件记录代码(以用户猜对单词为例)

void setWin(int attempts) {
    // Log end of game and that the user guessed correctly
    Analytics.getData().logLevelEnd(
      levelName: 'septuple',
      success: attempts,
    );
    gameState = GameState.win;
    _box.put(_gameStateName, gameState.toString());
    _game.gameTimer.startCountdown();
    notifyListeners();
  }

项目依赖

dependencies:
  flutter:
    sdk: flutter
  hive: ^2.2.3
  hive_flutter: ^1.1.0
  responsive_sizer: ^3.1.1
  #flutter_launcher_icons: ^0.10.0
  toggle_switch: ^2.0.1

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  firebase_core: ^2.3.0
  firebase_analytics: ^10.0.6

flutter doctor -v 输出

flutter doctor -v
[√] Flutter (Channel stable, 3.3.9, on Microsoft Windows [Version 10.0.22621.819], locale en-GB)
    • Flutter version 3.3.9 on channel stable at D:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (10 days ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)
    • Android SDK at C:\Users\LaptopBob\AppData\Local\Android\Sdk
    • Platform android-33, build-tools 32.0.0-rc1
    • ANDROID_HOME = C:\Users\LaptopBob\AppData\Local\Android\Sdk
    • ANDROID_SDK_ROOT = D:\Users\LaptopBob\Android_SDK\avd
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.20)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.32929.386
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.73.1)
    • VS Code at C:\Users\LaptopBob\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.54.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.819]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 108.0.5359.71
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 107.0.1418.56

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

logLevelEnd是默认事件类型,我以为它会直接显示在Firebase Analytics中,是不是需要额外配置才能捕获并保留该事件?

另外我已经参考相关帖子等待了26小时(从看到实时数据开始算),但历史数据还是为空。

请问为什么Firebase Analytics里看不到历史用户或事件数据?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 16:46:17