Remove all mentions of analytics

The analytics build configuration has not been used or updated for a while. This removes some dependencies, and some deprecated code sections.
This commit is contained in:
Inhishonor
2025-06-13 10:21:16 -07:00
parent 0eeb643e6f
commit f3b178e182
27 changed files with 49 additions and 681 deletions
-7
View File
@@ -23,7 +23,6 @@ apply plugin: 'kotlin-kapt'
android {
compileSdk 34
publishNonDefault true
flavorDimensions "analytics"
compileOptions {
sourceCompatibility 1.8
@@ -38,10 +37,6 @@ android {
buildConfigField "String", "AMPLITUDE_API_KEY", "\"${System.getenv("AMPLITUDE_API_KEY")}\""
}
productFlavors {
withAnalytics { dimension "analytics" }
noAnalytics { dimension "analytics" }
}
namespace 'dev.octoshrimpy.quik.data'
}
@@ -103,8 +98,6 @@ dependencies {
implementation project(':common')
implementation project(':domain')
withAnalyticsImplementation 'com.android.installreferrer:installreferrer:1.1'
withAnalyticsImplementation "com.amplitude:android-sdk:2.16.0"
}
repositories {
@@ -0,0 +1,10 @@
package dev.octoshrimpy.quik.manager
import javax.inject.Inject
class ReferralManagerImpl @Inject constructor() : ReferralManager {
override suspend fun trackReferrer() {
}
}
@@ -19,14 +19,12 @@
package dev.octoshrimpy.quik.mapper
import com.f2prateek.rx.preferences2.RxSharedPreferences
import dev.octoshrimpy.quik.manager.AnalyticsManager
import dev.octoshrimpy.quik.manager.RatingManager
import io.reactivex.rxkotlin.Observables
import javax.inject.Inject
class RatingManagerImpl @Inject constructor(
rxPrefs: RxSharedPreferences,
private val analyticsManager: AnalyticsManager
) : RatingManager {
companion object {
@@ -50,12 +48,10 @@ class RatingManagerImpl @Inject constructor(
}
override fun rate() {
// analyticsManager.track("Clicked Rate")
rated.set(true)
}
override fun dismiss() {
// analyticsManager.track("Clicked Rate (Dismiss)")
dismissed.set(true)
}
@@ -1,42 +0,0 @@
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.manager
import org.json.JSONObject
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class AnalyticsManagerImpl @Inject constructor() : AnalyticsManager {
override fun track(event: String, vararg properties: Pair<String, Any>) {
// 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) {
Timber.v("$key: $value")
}
}
@@ -1,29 +0,0 @@
/*
* Copyright (C) 2020 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.manager
import javax.inject.Inject
class ReferralManagerImpl @Inject constructor() : ReferralManager {
override suspend fun trackReferrer() {
}
}
@@ -1,74 +0,0 @@
/*
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.manager
import android.content.Context
import com.amplitude.api.Amplitude
import com.amplitude.api.AmplitudeClient
import com.amplitude.api.Identify
import dev.octoshrimpy.quik.data.BuildConfig
import org.json.JSONArray
import org.json.JSONObject
import timber.log.Timber
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class AnalyticsManagerImpl @Inject constructor(context: Context) : AnalyticsManager {
private val amplitude: AmplitudeClient = Amplitude.getInstance().initialize(context, BuildConfig.AMPLITUDE_API_KEY)
init {
amplitude.trackSessionEvents(true)
}
override fun track(event: String, vararg properties: Pair<String, Any>) {
val propertiesJson = JSONObject(properties
.associateBy { pair -> pair.first }
.mapValues { pair -> pair.value.second })
.also { Timber.v("$event: $it") }
amplitude.logEvent(event, propertiesJson)
}
override fun setUserProperty(key: String, value: Any) {
Timber.v("$key: $value")
// Set the value in Amplitude
val identify = Identify()
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")
}
amplitude.identify(identify)
}
}
@@ -1,76 +0,0 @@
/*
* Copyright (C) 2020 Moez Bhatti <moez.bhatti@gmail.com>
*
* This file is part of QKSMS.
*
* QKSMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QKSMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
*/
package dev.octoshrimpy.quik.manager
import android.content.Context
import com.android.installreferrer.api.InstallReferrerClient
import com.android.installreferrer.api.InstallReferrerStateListener
import dev.octoshrimpy.quik.util.Preferences
import kotlinx.coroutines.suspendCancellableCoroutine
import javax.inject.Inject
import kotlin.coroutines.resume
class ReferralManagerImpl @Inject constructor(
private val analytics: AnalyticsManager,
private val context: Context,
private val prefs: Preferences
) : ReferralManager {
override suspend fun trackReferrer() {
if (prefs.didSetReferrer.get()) {
return
}
context.packageManager.getInstallerPackageName(context.packageName)?.let { installer ->
analytics.setUserProperty("Installer", installer)
}
val referrerClient = InstallReferrerClient.newBuilder(context).build()
val responseCode = suspendCancellableCoroutine<Int> { cont ->
referrerClient.startConnection(object : InstallReferrerStateListener {
override fun onInstallReferrerSetupFinished(responseCode: Int) {
cont.resume(responseCode)
}
override fun onInstallReferrerServiceDisconnected() {
cont.resume(InstallReferrerClient.InstallReferrerResponse.SERVICE_DISCONNECTED)
}
})
cont.invokeOnCancellation {
referrerClient.endConnection()
}
}
when (responseCode) {
InstallReferrerClient.InstallReferrerResponse.OK -> {
analytics.setUserProperty("Referrer", referrerClient.installReferrer.installReferrer)
prefs.didSetReferrer.set(true)
}
InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> {
prefs.didSetReferrer.set(true)
}
}
referrerClient.endConnection()
}
}