0

I am using firebase analytics in my flutter app . In debug mode the screen views and events are visible within few seconds in realtime overview but in release build I get the screen views and events after about 1 hour in the realtime overview of google analytics.

For the debug mode i had to run the command :

adb shell setprop debug.firebase.analytics.app PACKAGE_NAME

after that only I was able to see the events and screen views in debug mode. I disabled it later . Now while checking for release build I am getting the views and events after about one hour.
Here is my main function:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform
    );
    await FirebaseAnalytics.instance.setAnalyticsCollectionEnabled(true);
    
      runApp(MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (context) => AuthState()),
          ChangeNotifierProvider(create: (context) => ConnectivityProvider()),
          ChangeNotifierProvider(create: (context) => UnitProvider()),
        ],
        child: MyApp(),
      ));
}

Here is code of my home screen where I am trying to log screen view and an event:

class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMixin {


  late final AnimationController _controller = AnimationController(vsync: this, duration: Duration(seconds: 2))..repeat();



  @override
  void initState() {
    FirebaseAnalytics.instance.logScreenView(screenName: "home_screen");
    super.initState();
  }
....
 return Stack(
            children: [
              Offstage(
                offstage: !value.isConnected,
                child: Scaffold(
                  key: _scaffoldKey,
                  drawer: const Menu(),
                  appBar: AppBar(
                    actions: [
                      Container(
                        height: 64,
                        padding: EdgeInsets.all(4),
                        child: Row(
                          mainAxisSize: MainAxisSize.max,
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Container(
                              alignment: Alignment.centerRight,
                              padding: EdgeInsets.only(right: 16),
                              child: InkWell(
                                onTap: () async {
                                 
                                   await FirebaseAnalytics.instance.logEvent(name: "button_pressed", parameters: {"button_name": "scan"});
                                    await state.scanDevice(context);
                                  }
                                },
.........
1
  • It sounds like the Analytics SDK may be batching events to save the device's battery. If that's indeed the case, that's working as intended. Only conversion events may trigger a premature sending of events in that case. Commented Feb 20 at 15:31

1 Answer 1

0

Are you asking why it takes so long?

Sorry but I don't see a specific question here.

Firebase Analytics is expected to have a delay of 1 hour.

https://firebase.blog/posts/2016/11/how-long-does-it-take-for-my-firebase-analytics-data-to-show-up/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.