Firebase Analytics 自定义事件参数

Firebase Analytics custom events params

我对 Firebase 分析完全陌生。我正在尝试发送一个事件,该事件显示有关我的 API 呼叫的统计信息。

endTime = System.currentTimeMillis() - startTime;

// [START event]
Bundle params = new Bundle();
params.putString(FirebaseConstants.PHONE_NUMBER, Utility.getPhone());
params.putLong(FirebaseConstants.DURATION, endTime);
FirebaseAnalytics
            .getInstance(getContext())
            .logEvent(FirebaseConstants.BALANCE_CHECK, params);
// [END event]

但是我只看到了活动名称、用户数和发生次数。 24 小时过去了,我没有看到我的自定义属性。作为参考,我想看到一个 phone 数字(Utility.getPhone())和 API 调用所花费的时间(结束时间)。也许它没有发送任何东西,因为我在我的 FirebaseConstans class

中创建了自定义参数

[更新,2017 年 5 月]

自 2017 年 5 月起,Google Analytics for Firebase 现在支持自定义参数报告。请参阅此帮助中心文章了解更多信息 details

根据文档,您必须 link 使用 BigQuery 才能查看自定义参数:

Custom parameters: Custom parameters are not represented directly in your Analytics reports, but they can be used as filters in audience definitions that can be applied to every report. Custom parameters are also included in data exported to BigQuery if your app is linked to a BigQuery project.

来源:https://firebase.google.com/docs/analytics/android/events#log_events

我已联系 firebase 支持并得到回复:

Looks like the params don't pre-populate automatically. When creating your audience, you'll have to fill them in yourself.

事实是,数据只会在创建新受众后发生的事件中填充,直到那一刻才会收集数据,这是我希望的情况...

编辑:来自 firebase 支持人员

Audiences are not retroactive, so you will indeed need to create them before data will be populated within them. Do note that existing data can still be looked at and queried if linked with BigQuery. Also keep in mind that most audiences will have a minimum threshold which needs to be met before reports are generated for them.

您的自定义数据和参数将在您的受众达到 10 人或更多时立即可用,这是隐私限制。 所以只需在 activity 中将其用作:

FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Bundle bundle = new Bundle();
bundle.putString("some_key", "some_value");
mFirebaseAnalytics.logEvent("some_name", bundle);

它将起作用(一段时间后(最多 24 小时)您可以在事件视图中看到 some_name 作为事件,但当观众人数达到或超过 10 人时 some_key 将可用)。

来自https://firebase.google.com/docs/analytics/android/events#log_events

自定义参数:自定义参数不会直接显示在您的 Analytics 报告中,但它们可以用作受众定义中的过滤器,可应用于每个报告。

https://support.google.com/firebase/answer/7397304?hl=en&ref_topic=6317489 开始,您需要先注册参数才能显示它们

When you first set up custom parameters, a data card for it will be added to your event detail report. However, it may take up to 24 hours for any data to appear.