mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-19 20:38:53 +01:00
Log when SIA integration is enabled
This commit is contained in:
@@ -18,14 +18,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.moez.QKSMS.manager
|
package com.moez.QKSMS.manager
|
||||||
|
|
||||||
|
import org.json.JSONObject
|
||||||
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class AnalyticsManagerImpl @Inject constructor() : AnalyticsManager {
|
class AnalyticsManagerImpl @Inject constructor() : AnalyticsManager {
|
||||||
|
|
||||||
override fun track(event: String, vararg properties: Pair<String, String>) {
|
override fun track(event: String, vararg properties: Pair<String, Any>) {
|
||||||
// Do nothing
|
|
||||||
|
// Log the event, but don't do anything else
|
||||||
|
JSONObject(properties
|
||||||
|
.associateBy { pair -> pair.first }
|
||||||
|
.mapValues { pair -> pair.value.second })
|
||||||
|
.also { Timber.v("$event: $it") }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setUserProperty(key: String, value: Any) {
|
override fun setUserProperty(key: String, value: Any) {
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ class AnalyticsManagerImpl @Inject constructor(context: Context) : AnalyticsMana
|
|||||||
amplitude.trackSessionEvents(true)
|
amplitude.trackSessionEvents(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun track(event: String, vararg properties: Pair<String, String>) {
|
override fun track(event: String, vararg properties: Pair<String, Any>) {
|
||||||
val propertiesJson = JSONObject(properties
|
val propertiesJson = JSONObject(properties
|
||||||
.associateBy { pair -> pair.first }
|
.associateBy { pair -> pair.first }
|
||||||
.mapValues { pair -> pair.value.second })
|
.mapValues { pair -> pair.value.second })
|
||||||
|
.also { Timber.v("$event: $it") }
|
||||||
|
|
||||||
amplitude.logEvent(event, propertiesJson)
|
amplitude.logEvent(event, propertiesJson)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package com.moez.QKSMS.manager
|
|||||||
|
|
||||||
interface AnalyticsManager {
|
interface AnalyticsManager {
|
||||||
|
|
||||||
fun track(event: String, vararg properties: Pair<String, String>)
|
fun track(event: String, vararg properties: Pair<String, Any>)
|
||||||
|
|
||||||
fun setUserProperty(key: String, value: Any)
|
fun setUserProperty(key: String, value: Any)
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.moez.QKSMS.common.Navigator
|
|||||||
import com.moez.QKSMS.common.androidxcompat.scope
|
import com.moez.QKSMS.common.androidxcompat.scope
|
||||||
import com.moez.QKSMS.common.base.QkViewModel
|
import com.moez.QKSMS.common.base.QkViewModel
|
||||||
import com.moez.QKSMS.interactor.MarkUnblocked
|
import com.moez.QKSMS.interactor.MarkUnblocked
|
||||||
|
import com.moez.QKSMS.manager.AnalyticsManager
|
||||||
import com.moez.QKSMS.repository.ConversationRepository
|
import com.moez.QKSMS.repository.ConversationRepository
|
||||||
import com.moez.QKSMS.util.Preferences
|
import com.moez.QKSMS.util.Preferences
|
||||||
import com.moez.QKSMS.util.tryOrNull
|
import com.moez.QKSMS.util.tryOrNull
|
||||||
@@ -33,6 +34,7 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
class BlockedViewModel @Inject constructor(
|
class BlockedViewModel @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
|
private val analytics: AnalyticsManager,
|
||||||
private val conversationRepo: ConversationRepository,
|
private val conversationRepo: ConversationRepository,
|
||||||
private val markUnblocked: MarkUnblocked,
|
private val markUnblocked: MarkUnblocked,
|
||||||
private val navigator: Navigator,
|
private val navigator: Navigator,
|
||||||
@@ -56,7 +58,10 @@ class BlockedViewModel @Inject constructor(
|
|||||||
?: false
|
?: false
|
||||||
}
|
}
|
||||||
.doOnNext { installed -> if (!installed) navigator.showSia() }
|
.doOnNext { installed -> if (!installed) navigator.showSia() }
|
||||||
.withLatestFrom(prefs.sia.asObservable()) { installed, enabled -> installed && !enabled }
|
.withLatestFrom(prefs.sia.asObservable()) { installed, enabled ->
|
||||||
|
analytics.track("Clicked SIA", Pair("enable", !enabled), Pair("installed", installed))
|
||||||
|
installed && !enabled
|
||||||
|
}
|
||||||
.autoDisposable(view.scope())
|
.autoDisposable(view.scope())
|
||||||
.subscribe { shouldEnable -> prefs.sia.set(shouldEnable) }
|
.subscribe { shouldEnable -> prefs.sia.set(shouldEnable) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user