我已经将Firebase添加到了我作为颤振腹板工程开发的游戏中,可以在过去30分钟内看到为用户提供的实时数据条,但无法看到任何历史用户或事件数据。昨天,我将Firebase添加到我的项目中,并让许多用户访问了它,但是今天看不到这些事件的任何记录。
我再次经历了设置过程,以检查所有设置是否正确,而且我相信是正确的。
今天早上,我访问了这个网站,看到了我访问这个应用程序的实时记录如下:

然而,历史用户活动随时间变化的图表没有显示任何信息:

我创建了一个Singleton来访问分析实例,如下所示:
// 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();
}"logLevelEnd是一个默认的事件类型,所以我假设它应该只出现在Firebase中。我是否需要配置任何东西以便它能够主动捕获和保留它?“
对于该项目,我使用以下依赖项:
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最后,我有一个为web配置的firebase_options.dart文件。
为了完整起见,以下是颤振医生-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!按照这个职位的说法,我已经等了24小时才能看到数据(自从我开始在“最后30分钟内获得用户”面板上的酒吧后),现在已经是26个小时了。
有人知道为什么我在中没有看到历史用户或事件数据吗?
发布于 2022-12-03 10:52:55
这个问题的解决办法是“等待”。在第一次活动发布到Firebase后30到42小时之间,数据出现了一些时间。第二天的事件也会出现(仅延迟18个小时),所以当您首次使用该服务时,可能会出现初始的、较长的延迟。我在Firebase文档中唯一能找到的更新引用是,数据是“定期更新”的,所以我不确定数据将多久更新一次。
https://stackoverflow.com/questions/74656063
复制相似问题