Skip to content

Firebase Crashlytics: Real-Time Crash Reporting & App Stability

DodaTech Updated 2026-06-28 5 min read

In this tutorial, you will learn about Firebase Crashlytics: Real. We cover key concepts, practical examples, and best practices to help you master this topic.

Firebase Crashlytics provides real-time crash reporting for mobile and web apps, automatically collecting crash stacks, device state, and user context to help you diagnose and fix issues quickly.

What You'll Learn

How to integrate Crashlytics, report crashes and non-fatal errors, add custom breadcrumbs and user context, set up alerts, and analyze crash trends to improve app stability.

Why It Matters

Undiagnosed crashes erode user trust and cause churn. DodaTech uses Crashlytics to catch every crash, group by root cause, and send alerts to the engineering team — often fixing issues before users notice.

Real-World Use

A user's app crashes during a scan. Crashlytics captures the stack trace, device model, OS version, and the exact scan configuration. The developer sees the crash dashboard, identifies the null pointer, and ships a fix within hours.

flowchart LR
    A["App Crash\nOccurs"] --> B["Crashlytics SDK"]
    B --> C["Collect Stack Trace\n+ Device Info"]
    C --> D["Upload on\nNext Launch"]
    D --> E["Crashlytics\nDashboard"]
    E --> F["Group by\nRoot Cause"]
    E --> G["Alert Team\nEmail + Slack"]
    F --> H["Developer\nFixes Issue"]
    style A fill:#fecaca,stroke:#dc2626
    style E fill:#dbeafe,stroke:#2563eb
    style H fill:#bbf7d0,stroke:#16a34a

Integrating Crashlytics

// Web: import and initialize
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { getPerformance } from "firebase/performance";
// Note: Crashlytics is primarily for mobile (Android/iOS)
// For web, use Error Reporting via Cloud Monitoring

// Mobile (React Native):
// npm install @react-native-firebase/crashlytics

import crashlytics from "@react-native-firebase/crashlytics";

async function initCrashlytics() {
  await crashlytics().setCrashlyticsCollectionEnabled(true);
  console.log("Crashlytics initialized");
}

Logging Custom Errors

// React Native / Android / iOS
import crashlytics from "@react-native-firebase/crashlytics";

function analyzeFile(filePath) {
  try {
    // Risky operation
    const result = performFileAnalysis(filePath);
    return result;
  } catch (error) {
    // Log as non-fatal (doesn't crash the app)
    crashlytics().recordError(error, {
      filePath: filePath,
      operation: "analyzeFile",
      timestamp: Date.now()
    });

    console.log("Error recorded in Crashlytics:", error.message);
    return null;
  }
}

Custom Breadcrumbs

import crashlytics from "@react-native-firebase/crashlytics";

// Add breadcrumbs to trace user actions before a crash
function scanDevice(deviceId) {
  crashlytics().log("Starting scan for device: " + deviceId);
  crashlytics().setAttribute("current_device", deviceId);

  try {
    // Scan logic
    crashlytics().log("Scan in progress: checking threats");
    const threats = performScan(deviceId);

    crashlytics().log("Scan completed: " + threats.length + " threats found");
    return threats;
  } catch (error) {
    crashlytics().log("Scan failed at: check_threats");
    crashlytics().recordError(error);
    return [];
  }
}

User Context

import crashlytics from "@react-native-firebase/crashlytics";

// Set user identifier (anonymized)
async function identifyUser(userId, subscriptionTier) {
  await crashlytics().setUserId(userId);

  // Set custom attributes for filtering
  await crashlytics().setAttributes({
    subscription_tier: subscriptionTier,
    app_version: getAppVersion(),
    device_count: getUserDeviceCount().toString()
  });

  console.log("User context set in Crashlytics");
}

// These attributes appear in crash reports,
// helping you answer: "Is this crash specific to Pro users on Android 14?"

Crash-Free Session Reporting

// Crashlytics automatically tracks crash-free sessions
// View in Firebase Console > Crashlytics > Dashboard

// Key metrics:
// - Crash-free users (last 24h / 7d / 30d)
// - Total crashes (last 24h)
// - Most common crash types
// - Affected versions
// - Affected devices

// Set a goal: maintain 99.9%+ crash-free rate
// If crashes spike, Crashlytics sends an alert

function checkCrashRate() {
  console.log("Crash-free rate target: 99.9%");
  console.log("View in Firebase Console > Crashlytics");
  console.log("Common patterns to monitor:");
  console.log("- NPE (Null Pointer Exception): check optional chaining");
  console.log("- Network errors: add retry logic");
  console.log("- Memory pressure: optimize image loading");
}

Alerts and Integration

// Configure alerts in Firebase Console:
// Crashlytics > Settings > Integration

// Supported integrations:
// - Slack: #alerts-crashlytics channel
// - Email: engineering@dodatech.com
// - PagerDuty: on-call rotation
// - Jira: auto-create bug tickets

// Alert conditions:
// - Crash-free rate drops below threshold (e.g., 99.5%)
// - New fatal crash in a specific version
// - Crash count spikes (e.g., +200% in 1 hour)

console.log("Crashlytics alert configured for spike detection");

Common Mistakes

1. Not Initializing Crashlytics Early

Initialize Crashlytics in the app's entry point before any other code runs. Late initialization can miss early crashes during startup.

2. Ignoring Non-Fatal Errors

Not all errors crash the app. Log non-fatals with recordError() to catch issues that degrade the user experience without crashing.

3. Not Adding Breadcrumbs

Crashes without breadcrumbs lack context. Add breadcrumbs for critical user actions so you can replay the steps leading to the crash.

4. Opting Out in Release Builds

Some developers disable Crashlytics in release builds. Release builds are where crashes affect real users — keep Crashlytics enabled in all builds.

5. Not Setting User Attributes

Without user attributes, you can't filter crashes by user segment. Set attributes like app version, subscription tier, and device model for better crash triage.

Practice Questions

  1. What information does Crashlytics automatically collect on a crash?
  2. What is the difference between a fatal and non-fatal error?
  3. How do breadcrumbs help with debugging?
  4. How do you set up alerts for crash spikes?

Answers:

  1. Stack trace, device model, OS version, app version, timestamp, free memory/disk, battery level, and orientation.
  2. Fatal errors crash the app. Non-fatals are caught exceptions that don't crash but indicate bugs. Both should be logged.
  3. Breadcrumbs are custom log messages that show the sequence of user actions before a crash, helping reproduce the issue.
  4. In Firebase Console > Crashlytics > Settings > Alerts, configure conditions (crash-free rate drop, new fatal crash, crash count spike) and notification channels.

Challenge: Implement Crashlytics in a React Native security app: initialize in entry point, add breadcrumbs for scan flow, log non-fatal errors from try/catch blocks, set user attributes (tier, device count), and configure Slack alerts for crash spikes.

FAQ

Is Crashlytics free?

Yes, Crashlytics is included in the Firebase free plan. There is no additional cost for crash reporting.

How long are crash reports retained?

Crash reports are retained for 90 days on the free plan. Extended retention is available with the Blaze plan.

Does Crashlytics affect app performance?

Crashlytics has minimal performance impact. The SDK is optimized for low overhead and uploads crash reports on the next app launch.

Can I use Crashlytics for web apps?

Crashlytics primarily supports Android and iOS. For web apps, use Firebase Error Reporting or Sentry for JavaScript error tracking.

How does Crashlytics handle user privacy?

Crashlytics automatically redacts user data. You can disable automatic collection and implement manual consent per GDPR requirements.

Mini Project

Implement Crashlytics for a security scanning app: initialize with user consent, add breadcrumbs for each scan step, log network errors as non-fatals, set user attributes for crash filtering, and configure alerts for crash-free rate drops.

What's Next

Firebase Test Lab — test your app on real devices in Google's cloud.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro