forked from upstream-mirrors/quik
Set user property for upgraded status
This commit is contained in:
@@ -22,4 +22,6 @@ interface AnalyticsManager {
|
|||||||
|
|
||||||
fun track(event: String)
|
fun track(event: String)
|
||||||
|
|
||||||
|
fun setUserProperty(key: String, value: Any)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,9 +32,13 @@ import com.android.billingclient.api.SkuDetailsParams
|
|||||||
import io.reactivex.Observable
|
import io.reactivex.Observable
|
||||||
import io.reactivex.subjects.BehaviorSubject
|
import io.reactivex.subjects.BehaviorSubject
|
||||||
import io.reactivex.subjects.Subject
|
import io.reactivex.subjects.Subject
|
||||||
|
import manager.AnalyticsManager
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class BillingManager @Inject constructor(context: Context) : PurchasesUpdatedListener {
|
class BillingManager @Inject constructor(
|
||||||
|
context: Context,
|
||||||
|
private val analyticsManager: AnalyticsManager
|
||||||
|
) : PurchasesUpdatedListener {
|
||||||
|
|
||||||
enum class UpgradeStatus { REGULAR, UPGRADED }
|
enum class UpgradeStatus { REGULAR, UPGRADED }
|
||||||
|
|
||||||
@@ -67,6 +71,7 @@ class BillingManager @Inject constructor(context: Context) : PurchasesUpdatedLis
|
|||||||
else -> UpgradeStatus.REGULAR
|
else -> UpgradeStatus.REGULAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.doOnNext { upgraded -> analyticsManager.setUserProperty("Upgraded", upgraded) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun queryPurchases() {
|
private fun queryPurchases() {
|
||||||
|
|||||||
@@ -29,4 +29,8 @@ class AnalyticsManagerImpl @Inject constructor() : AnalyticsManager {
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setUserProperty(key: String, value: Any) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,13 @@ package common.util
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.amplitude.api.Amplitude
|
import com.amplitude.api.Amplitude
|
||||||
import com.amplitude.api.AmplitudeClient
|
import com.amplitude.api.AmplitudeClient
|
||||||
|
import com.amplitude.api.Identify
|
||||||
import com.mixpanel.android.mpmetrics.MixpanelAPI
|
import com.mixpanel.android.mpmetrics.MixpanelAPI
|
||||||
import com.moez.QKSMS.BuildConfig
|
import com.moez.QKSMS.BuildConfig
|
||||||
import manager.AnalyticsManager
|
import manager.AnalyticsManager
|
||||||
|
import org.json.JSONArray
|
||||||
|
import org.json.JSONObject
|
||||||
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@@ -41,4 +45,30 @@ class AnalyticsManagerImpl @Inject constructor(context: Context): AnalyticsManag
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setUserProperty(key: String, value: Any) {
|
||||||
|
|
||||||
|
// Set the value in Mixpanel
|
||||||
|
val properties = JSONObject()
|
||||||
|
properties.put(key, value)
|
||||||
|
mixpanel.registerSuperProperties(properties)
|
||||||
|
|
||||||
|
// Set the value in Amplitude
|
||||||
|
when (value) {
|
||||||
|
is Boolean -> Identify().set(key, value)
|
||||||
|
is BooleanArray -> Identify().set(key, value)
|
||||||
|
is Double -> Identify().set(key, value)
|
||||||
|
is DoubleArray -> Identify().set(key, value)
|
||||||
|
is Float -> Identify().set(key, value)
|
||||||
|
is FloatArray -> Identify().set(key, value)
|
||||||
|
is Int -> Identify().set(key, value)
|
||||||
|
is IntArray -> Identify().set(key, value)
|
||||||
|
is Long -> Identify().set(key, value)
|
||||||
|
is LongArray -> Identify().set(key, value)
|
||||||
|
is String -> Identify().set(key, value)
|
||||||
|
is JSONArray -> Identify().set(key, value)
|
||||||
|
is JSONObject -> Identify().set(key, value)
|
||||||
|
else -> Timber.e("Value of type ${value::class.java} not supported")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user