kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
remove unused analytics
rodzic
56d28980b9
commit
f282f3f71e
|
@ -179,7 +179,6 @@ dependencies {
|
|||
implementation 'com.google.firebase:firebase-analytics:20.1.0'
|
||||
|
||||
// geeksville-androidlib
|
||||
compileOnly 'com.mixpanel.android:mixpanel-android:5.8.7'
|
||||
// compileOnly 'com.google.android.gms:play-services-base:17.6.0'
|
||||
|
||||
// alas implementation bug deep in the bowels when I tried it for my SyncBluetoothDevice class
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
package com.geeksville.mesh.analytics
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import com.geeksville.mesh.android.AppPrefs
|
||||
import com.geeksville.mesh.android.Logging
|
||||
import com.mixpanel.android.mpmetrics.MixpanelAPI
|
||||
import org.json.JSONObject
|
||||
|
||||
|
||||
class MixpanelAnalytics(context: Context, apiToken: String, pushToken: String? = null) :
|
||||
AnalyticsProvider, Logging {
|
||||
// Initialize the library with your
|
||||
// Mixpanel project token, MIXPANEL_TOKEN, and a reference
|
||||
// to your application context.
|
||||
// See mixpanel docs at https://mixpanel.com/help/reference/android
|
||||
val mixpanel: MixpanelAPI = MixpanelAPI.getInstance(context, apiToken)
|
||||
val people = mixpanel.getPeople()!!
|
||||
|
||||
init {
|
||||
// fixupMixpanel()
|
||||
|
||||
// Assign a unique ID
|
||||
val pref = AppPrefs(context)
|
||||
val id = pref.getInstallId()
|
||||
debug("Connecting to mixpanel $id")
|
||||
mixpanel.identify(id)
|
||||
people.identify(id)
|
||||
}
|
||||
|
||||
private fun makeJSON(properties: Array<out DataPair>) =
|
||||
if (properties.isEmpty())
|
||||
null
|
||||
else {
|
||||
val r = JSONObject()
|
||||
properties.forEach { r.put(it.name, it.value) }
|
||||
r
|
||||
}
|
||||
|
||||
override fun trackLowValue(event: String, vararg properties: DataPair) {
|
||||
}
|
||||
|
||||
override fun setEnabled(on: Boolean) {
|
||||
if (on) mixpanel.optInTracking() else mixpanel.optOutTracking()
|
||||
}
|
||||
|
||||
override fun track(event: String, vararg properties: DataPair) {
|
||||
|
||||
debug("Tracking $event")
|
||||
val obj = makeJSON(properties)
|
||||
|
||||
mixpanel.track(event, obj)
|
||||
}
|
||||
|
||||
override fun endSession() {
|
||||
// track("End Session")
|
||||
mixpanel.flush()
|
||||
}
|
||||
|
||||
override fun startSession() {
|
||||
track("Start Session")
|
||||
}
|
||||
|
||||
override fun setUserInfo(vararg p: DataPair) {
|
||||
mixpanel.registerSuperProperties(makeJSON(p))
|
||||
}
|
||||
|
||||
override fun increment(name: String, amount: Double) {
|
||||
mixpanel.people.increment(name, amount)
|
||||
}
|
||||
|
||||
override fun sendScreenView(name: String) {
|
||||
// too verbose for mixpanel
|
||||
track(name)
|
||||
}
|
||||
|
||||
override fun endScreenView() {}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
package com.geeksville.mesh.analytics
|
||||
|
||||
|
||||
/**
|
||||
* Created by kevinh on 12/24/14.
|
||||
*/
|
||||
|
||||
// Mint.initAndStartSession(MyActivity.this, "01a9c628");
|
||||
|
||||
/* disable for now because something in gradle doesn't like their lib repo
|
||||
import com.splunk.mint.Mint
|
||||
|
||||
class SplunkAnalytics(val context: Context, apiToken: String) : AnalyticsProvider, Logging {
|
||||
|
||||
private var inited = false
|
||||
|
||||
init {
|
||||
try {
|
||||
Mint.initAndStartSession(context, apiToken)
|
||||
inited = true
|
||||
} catch(ex: Exception) {
|
||||
error("exception logging failed to init")
|
||||
}
|
||||
}
|
||||
|
||||
override fun endSession() {
|
||||
track("End Session")
|
||||
if (inited)
|
||||
Mint.closeSession(context)
|
||||
// Mint.flush() // Send results now
|
||||
}
|
||||
|
||||
override fun trackLowValue(event: String, vararg properties: DataPair) {
|
||||
}
|
||||
|
||||
override fun track(event: String, vararg properties: DataPair) {
|
||||
if (inited)
|
||||
Mint.logEvent(event)
|
||||
}
|
||||
|
||||
override fun startSession() {
|
||||
if (inited) {
|
||||
Mint.startSession(context)
|
||||
track("Start Session")
|
||||
}
|
||||
}
|
||||
|
||||
override fun setUserInfo(vararg p: DataPair) {
|
||||
if (inited)
|
||||
p.forEach { Mint.addExtraData(it.name, it.value.toString()) }
|
||||
}
|
||||
|
||||
override fun increment(name: String, amount: Double) {
|
||||
if (inited)
|
||||
Mint.logEvent("$name increment")
|
||||
}
|
||||
|
||||
override fun sendScreenView(name: String) {
|
||||
}
|
||||
|
||||
override fun endScreenView() {
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
|
@ -1,45 +0,0 @@
|
|||
package com.geeksville.mesh.analytics
|
||||
|
||||
/**
|
||||
* Created by kevinh on 1/12/16.
|
||||
*/
|
||||
class TeeAnalytics(vararg providersIn: AnalyticsProvider) : AnalyticsProvider {
|
||||
|
||||
val providers = providersIn
|
||||
|
||||
override fun track(event: String, vararg properties: DataPair) {
|
||||
providers.forEach { it.track(event, *properties) }
|
||||
}
|
||||
|
||||
override fun trackLowValue(event: String, vararg properties: DataPair) {
|
||||
providers.forEach { it.trackLowValue(event, *properties) }
|
||||
}
|
||||
|
||||
override fun endSession() {
|
||||
providers.forEach { it.endSession() }
|
||||
}
|
||||
|
||||
override fun increment(name: String, amount: Double) {
|
||||
providers.forEach { it.increment(name, amount) }
|
||||
}
|
||||
|
||||
override fun setUserInfo(vararg p: DataPair) {
|
||||
providers.forEach { it.setUserInfo(*p) }
|
||||
}
|
||||
|
||||
override fun startSession() {
|
||||
providers.forEach { it.startSession() }
|
||||
}
|
||||
|
||||
override fun sendScreenView(name: String) {
|
||||
providers.forEach { it.sendScreenView(name) }
|
||||
}
|
||||
|
||||
override fun endScreenView() {
|
||||
providers.forEach { it.endScreenView() }
|
||||
}
|
||||
|
||||
override fun setEnabled(on: Boolean) {
|
||||
providers.forEach { it.setEnabled(on) }
|
||||
}
|
||||
}
|
|
@ -9,8 +9,6 @@ import android.os.Bundle
|
|||
import android.provider.Settings
|
||||
import androidx.core.content.edit
|
||||
import com.geeksville.mesh.analytics.AnalyticsProvider
|
||||
import com.geeksville.mesh.analytics.MixpanelAnalytics
|
||||
import com.geeksville.mesh.analytics.TeeAnalytics
|
||||
import com.google.android.gms.common.ConnectionResult
|
||||
import com.google.android.gms.common.GoogleApiAvailability
|
||||
|
||||
|
@ -37,7 +35,6 @@ open class GeeksvilleApplication(
|
|||
}
|
||||
|
||||
var splunk: AnalyticsProvider? = null
|
||||
var mixAnalytics: MixpanelAnalytics? = null
|
||||
|
||||
private val lifecycleCallbacks = object : ActivityLifecycleCallbacks {
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
|
@ -95,19 +92,8 @@ open class GeeksvilleApplication(
|
|||
override fun onCreate() {
|
||||
super<Application>.onCreate()
|
||||
|
||||
/*
|
||||
if(splunkKey != null)
|
||||
splunk = SplunkAnalytics(this, splunkKey) // Only used for crash reports
|
||||
*/
|
||||
|
||||
val googleAnalytics = com.geeksville.mesh.analytics.GoogleAnalytics(this)
|
||||
if (mixpanelKey != null) {
|
||||
val mix = com.geeksville.mesh.analytics.MixpanelAnalytics(this, mixpanelKey, pushKey)
|
||||
mixAnalytics = mix
|
||||
|
||||
analytics = TeeAnalytics(googleAnalytics, mix)
|
||||
} else
|
||||
analytics = googleAnalytics
|
||||
analytics = googleAnalytics
|
||||
|
||||
// Set analytics per prefs
|
||||
isAnalyticsAllowed = isAnalyticsAllowed
|
||||
|
|
Ładowanie…
Reference in New Issue