问题
I've tried to make an audience in Firebase Analytics, with "App Version" set to "contains 'debug'". The debug version of my app appends "-debug" on the end of the Version Name string.
When I run the app, though, while Firebase records data for my sessions, it does not record any for the "debug audience."
What I ultimately hope to get to is a world where I can use Remote Config, creating config items that I can use in testing, but I wouldn't have to worry about accidentally leaving config active in some test mode when I push the app live. Right now, my solution is to wrap all calls to apply Remote Config with "if (!BuildConfig.DEBUG)", but I'm sure to forget once, and push an app live with "isPremiumUser" set to true for all users, or something dumb like that :).
Is there a way to create an audience of developer builds, whether by version name, or any other method?
Thanks!
回答1:
You could use Firebase Analytics user properties for this (Android docs, iOS docs).
Android example:
if (BuildConfig.DEBUG) {
mFirebaseAnalytics.setUserProperty("debug_build", "true");
}
You will also need to go to the Firebase console and do two things:
- Analytics -> User Properties -> New User Property ->
"debug_build"
- Analytics -> Audiences -> New Audience -> name your audience and set condition to user property where
debug_build = "true"
Now in Remote Config you can set up conditions based on the newly created audience.
A few things to note:
- Once a user is in an audience, they will forever be in that audience, so even if you stop setting that property the user will still be part of the debug audience
- There is a limit of 50 audiences and 25 user properties so you are sacrificing some of these numbers for debug builds
回答2:
One thing to keep in mind is that audience user counts are thresholded below 10 users for privacy reasons. And so if you're just testing your "debug" audience yourself, then your audience has < 10 users and "0" will be shown. This will be clarified in the future.
回答3:
If you are mostly using Analytics you can also register two independent Firebase Projects one for development and one for production. This will allow you to experiment in development w/o interfering with the production data. Just don't forget to switch the project id before releasing the app. You might be able to do this with Gradle targets as well.
来源:https://stackoverflow.com/questions/37450256/is-there-a-way-to-create-an-audience-of-developer-builds