mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-19 19:42:17 +02:00
refactor: Simplify sendAnalyticsEvent
This commit is contained in:
parent
86a0a4bc97
commit
8d52aedfba
@ -25,6 +25,7 @@
|
||||
<w>autoreport</w>
|
||||
<w>barfoo</w>
|
||||
<w>beolingus</w>
|
||||
<w>brayan</w>
|
||||
<w>canonify</w>
|
||||
<w>cardbrowser</w>
|
||||
<w>cardviewer</w>
|
||||
|
@ -205,17 +205,6 @@ object UsageAnalytics {
|
||||
sAnalytics!!.screenView().screenName(screenName).sendAsync()
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an arbitrary analytics event - these should be noun/verb pairs, e.g. "text to speech", "enabled"
|
||||
*
|
||||
* @param category the category of event, make your own but use a constant so reporting is good
|
||||
* @param action the action the user performed
|
||||
*/
|
||||
@KotlinCleanup("remove when all callers are Kotlin")
|
||||
fun sendAnalyticsEvent(category: String, action: String) {
|
||||
sendAnalyticsEvent(category, action, Integer.MIN_VALUE, null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a detailed arbitrary analytics event, with noun/verb pairs and extra data if needed
|
||||
*
|
||||
@ -224,7 +213,7 @@ object UsageAnalytics {
|
||||
* @param value A value for the event, Integer.MIN_VALUE signifies caller shouldn't send the value
|
||||
* @param label A label for the event, may be null
|
||||
*/
|
||||
fun sendAnalyticsEvent(category: String, action: String, value: Int = Int.MIN_VALUE, label: String? = null) {
|
||||
fun sendAnalyticsEvent(category: String, action: String, value: Int? = null, label: String? = null) {
|
||||
Timber.d("sendAnalyticsEvent() category/action/value/label: %s/%s/%s/%s", category, action, value, label)
|
||||
if (!optIn) {
|
||||
return
|
||||
@ -233,7 +222,7 @@ object UsageAnalytics {
|
||||
if (label != null) {
|
||||
event.eventLabel(label)
|
||||
}
|
||||
if (value > Int.MIN_VALUE) {
|
||||
if (value != null) {
|
||||
event.eventValue(value)
|
||||
}
|
||||
event.sendAsync()
|
||||
|
Loading…
Reference in New Issue
Block a user