I'm using Firebase Analytics in an iOS app. I've created two "environments" - one for production and one for staging. The idea of staging is to separate app data in development builds from production builds (for example, I use a different database instance in prod vs. stage).
Analytics recording in my app looks something like:
import Firebase Analytics
// do this somewhere
Analytics.logEvent(name, parameters: ["param" : value])
However, Google Analytics will aggregate events from both prod and staging environments, which can skew data based on what's happening in development builds. I want to be able to see analytics only for prod builds.
I have a mechanism to detect which environment we're in, so I could create a function
func logEvent(name: String, parameters: [String: Any]) {
if DatabaseClient.environment == .production {
Analytics.logEvent(name, parameters: ["param" : value])
}
}
However, my main concern is that this would make it difficult to verify that analytics events are being triggered while running staging builds. I currently use the -FIRAnalyticsDebugEnabled environment argument when testing out events so that I can see logged events in the console, but if we restrict event logging to just production builds, we wouldn't be able to verify this in staging builds.