Search code examples
iosswiftfirebaseanalyticsfirebase-analytics

Disable Firebase Analytics for iOS Debug builds


  1. are events from the debug builds included in Firebase Analytics reports by default?
  2. If they're included, how can I disable Firebase Analytics for the iOS debug builds?

Currently I use the following code to configure the Firebase Analytics:

        analyticsEnabled = // Fetch whether the analytics should be enabled
        FirebaseApp.configure()
        // analyticsEnabled = false can be added here for DEBUG builds
        updateDataCollectionConfiguration()
    }

    @objc public static func updateDataCollectionConfiguration() {
        Analytics.setAnalyticsCollectionEnabled(analyticsEnabled)
    }

I've added a line, where I can force disable analytics for debug builds, but the two questions are still relevant - whether it's needed (is such analytics data even collected for debug builds) and is there any "simpler" way to achieve the same goal, e.g. filter debug-data in the Firebase Console?


Solution

  • Firebase collects data for debug mode also.

    You can check for debug mode using :

    #ifdef DEBUG
    analyticsEnabled = false
    updateDataCollectionConfiguration()