Learn/Firebase Integration/Analytics, Crashlytics & Remote Config

Analytics, Crashlytics & Remote Config

Track user behavior, catch crashes, and control your app remotely

7 min~7 min read+35 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Google Analytics
  2. 2. Firebase Crashlytics
  3. 3. Firebase Remote Config
  4. 4. Observability Strategy
  5. 5. This Lesson In Simple Words
  6. 6. Your level focus
  7. 7. One practical habit
  8. 8. Deep Understanding Guide
  9. 9. Why this lesson matters
  10. 10. Study flow for better retention
  11. 11. Quick Glossary
  12. 12. Architecture Lens

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Analytics, Crashlytics & Remote Config

Once your app is live, you need visibility into how users interact with it, what errors they encounter, and a way to change app behavior without publishing a new update. Firebase provides three essential production services for this. Google Analytics tracks user events and screen views so you can understand usage patterns. Firebase Crashlytics automatically captures crash reports with full stack traces so you can find and fix bugs quickly. Firebase Remote Config lets you change values in your app from the Firebase console without requiring users to download an update.

Google Analytics

Google Analytics is included automatically when you add Firebase to your project. It tracks basic events like app open and screen view by default. You can also log custom events to track specific user actions such as completing a purchase, finishing a level, or sharing content. These events appear in the Firebase console where you can build audiences, create funnels, and measure retention.

dart
1// pubspec.yaml: firebase_analytics: ^11.0.0
2import 'package:firebase_analytics/firebase_analytics.dart';
3
4final analytics = FirebaseAnalytics.instance;
5
6// Log a custom event
7await analytics.logEvent(
8 name: 'level_completed',
9 parameters: {
10 'level_id': 5,
11 'score': 1200,
12 'time_seconds': 45,
13 },
14);
15
16// Log a screen view
17await analytics.logScreenView(
18 screenName: 'Dashboard',
19 screenClass: 'DashboardScreen',
20);
21
22// Log a predefined event (purchase)
23await analytics.logPurchase(
24 currency: 'USD',
25 value: 9.99,
26 items: [
27 AnalyticsEventItem(
28 itemName: 'Premium Plan',
29 itemId: 'premium_monthly',
30 price: 9.99,
31 ),
32 ],
33);
34
35// Set user properties for audience segmentation
36await analytics.setUserProperty(
37 name: 'subscription_type',
38 value: 'premium',
39);
40
41// Set user ID to link analytics across devices
42await analytics.setUserId(id: 'user_12345');
43
44// Use as NavigatorObserver for automatic screen tracking
45MaterialApp(
46 navigatorObservers: [
47 FirebaseAnalyticsObserver(analytics: analytics),
48 ],
49);

Firebase Crashlytics

Crashlytics gives you real-time crash reporting with detailed stack traces, device information, and the sequence of events leading up to a crash. It groups similar crashes together so you can prioritize the most impactful issues. Setting up Crashlytics in Flutter involves overriding the default error handlers to forward all uncaught errors to the Crashlytics service.

dart
1// pubspec.yaml: firebase_crashlytics: ^4.0.0
2import 'package:firebase_crashlytics/firebase_crashlytics.dart';
3
4// Setup in main.dart - catch ALL Flutter errors
5void main() async {
6 WidgetsFlutterBinding.ensureInitialized();
7 await Firebase.initializeApp(
8 options: DefaultFirebaseOptions.currentPlatform,
9 );
10
11 // Catch Flutter framework errors
12 FlutterError.onError =
13 FirebaseCrashlytics.instance.recordFlutterFatalError;
14
15 // Catch errors outside Flutter (async, isolates)
16 PlatformDispatcher.instance.onError = (error, stack) {
17 FirebaseCrashlytics.instance.recordError(error, stack, fatal: true);
18 return true;
19 };
20
21 // Disable in debug mode
22 if (kDebugMode) {
23 await FirebaseCrashlytics.instance
24 .setCrashlyticsCollectionEnabled(false);
25 }
26
27 runApp(const MyApp());
28}
29
30// Record a non-fatal error manually
31try {
32 await riskyOperation();
33} catch (e, stack) {
34 await FirebaseCrashlytics.instance.recordError(
35 e,
36 stack,
37 reason: 'riskyOperation failed',
38 );
39}
40
41// Add custom keys for debugging context
42FirebaseCrashlytics.instance.setCustomKey('user_level', 5);
43FirebaseCrashlytics.instance.setCustomKey('screen', 'checkout');
44
45// Add breadcrumb log messages
46FirebaseCrashlytics.instance.log('User tapped checkout button');
47
48// Set user identifier
49FirebaseCrashlytics.instance.setUserIdentifier('user_12345');

Firebase Remote Config

Remote Config lets you define key-value pairs in the Firebase console and fetch them at runtime. This is extremely useful for A/B testing, feature flags, changing UI text, toggling maintenance mode, adjusting difficulty levels, or updating promotion banners without publishing a new app version. You set default values in the app and then override them from the console whenever needed.

dart
1// pubspec.yaml: firebase_remote_config: ^5.0.0
2import 'package:firebase_remote_config/firebase_remote_config.dart';
3
4final remoteConfig = FirebaseRemoteConfig.instance;
5
6// Configure fetch settings
7await remoteConfig.setConfigSettings(RemoteConfigSettings(
8 fetchTimeout: const Duration(minutes: 1),
9 minimumFetchInterval: const Duration(hours: 1),
10));
11
12// Set default values (used before first fetch)
13await remoteConfig.setDefaults({
14 'welcome_message': 'Welcome to our app!',
15 'show_banner': true,
16 'max_free_lessons': 5,
17 'maintenance_mode': false,
18});
19
20// Fetch and activate latest values from Firebase console
21await remoteConfig.fetchAndActivate();
22
23// Read values anywhere in your app
24final welcomeMsg = remoteConfig.getString('welcome_message');
25final showBanner = remoteConfig.getBool('show_banner');
26final maxLessons = remoteConfig.getInt('max_free_lessons');
27final inMaintenance = remoteConfig.getBool('maintenance_mode');
28
29// Listen for real-time config updates
30remoteConfig.onConfigUpdated.listen((event) async {
31 await remoteConfig.activate();
32 // Update UI with new values
33 print('Config updated: ${event.updatedKeys}');
34});

Disable Crashlytics in Debug Mode

💡 Disable Crashlytics in Debug Mode

Always disable Crashlytics collection during development by checking kDebugMode and calling setCrashlyticsCollectionEnabled(false). This prevents test crashes from cluttering your production dashboard and makes debugging faster since crash reports are not uploaded.

Remote Config Fetch Interval

⚠️ Remote Config Fetch Interval

In production, set minimumFetchInterval to at least one hour. During development you can set it to Duration.zero for instant updates. Fetching too frequently in production can cause throttling and your requests will fail with a fetch error.

Observability Strategy

Analytics, Crashlytics, and Remote Config are strongest when designed as one loop:

  • Observe behavior with analytics events.
  • Detect failures with crash and non-fatal reports.
  • Roll out fixes or feature toggles with remote config.
  • Measure post-change impact through updated analytics metrics.

This closed loop shortens incident response time and improves product decisions with data.

Tracking And Monitoring Pitfalls

  • Logging too many low-value events and drowning dashboards in noise.
  • Using inconsistent event names that break funnels and comparisons.
  • Forgetting user consent or privacy requirements for analytics collection.
  • Ignoring non-fatal errors that signal upcoming crash trends.
  • Deploying remote config changes without guardrails or rollback plan.

Production Monitoring Checklist

  • Critical business events and conversion steps are tracked with stable names.
  • Crashlytics is enabled only for non-debug builds and includes useful custom keys.
  • Remote config defaults match safe fallback product behavior.
  • Feature flags have kill-switch values tested before rollout.
  • A dashboard exists for release health: crash-free users, key funnel metrics, and rollback triggers.

This Lesson In Simple Words

Track user behavior, catch crashes, and control your app remotely. This lesson adds one more building block for creating stable and user-friendly Flutter apps.

Your level focus

Think in architecture, reliability, and team-level maintainability.

One practical habit

After reading, rewrite the concept in your own words and apply it in a tiny runnable sample.

Deep Understanding Guide

Why this lesson matters

Each lesson becomes useful when you connect concept, implementation, and real-user outcome together.

Study flow for better retention

  1. Separate UI, state, and data boundaries before writing implementation details.
  2. Use a simple cycle: understand, implement, test, and explain.
  3. If another developer can read your flow quickly, your design choices are clear.

Common Mistakes To Avoid

  • Moving forward without checking whether the current concept is truly clear.
  • Copying code exactly without experimenting with small changes.
  • Skipping edge cases and only testing happy-path behavior.
  • Assuming one pattern works for every scenario without trade-off analysis.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Build one tiny example from memory after finishing this lesson.
  • Write one paragraph about where this concept fits in a real app.
  • Create one failure scenario and verify your app handles it safely.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "What does Firebase Analytics track automatically without any code?".

Quick Glossary

  • build: The method that describes UI for the current state.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Architecture Lens

Connect this lesson to separation of concerns so your codebase stays maintainable as it grows.

As your app grows, keep UI, state, and data responsibilities separate so each part stays testable and easier to modify.

Lesson Completion Checklist

  • I can explain "Analytics, Crashlytics & Remote Config" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Moving forward without checking whether the current concept is truly clear.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

What does Firebase Analytics track automatically without any code?

Firebase Analytics automatically tracks app_open, first_open, and basic screen_view events. Custom events like purchases or button taps must be logged manually.

How do you catch all Flutter framework errors and send them to Crashlytics?

Setting FlutterError.onError to FirebaseCrashlytics.instance.recordFlutterFatalError forwards all uncaught Flutter framework errors to Crashlytics automatically.

What is the purpose of Remote Config default values?

Default values ensure your app works even before the first Remote Config fetch completes or if the device is offline.

What method fetches and applies the latest Remote Config values?

fetchAndActivate() downloads the latest values from the Firebase console and immediately makes them available via getString(), getBool(), and getInt().

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue