mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
remove unused analytics
This commit is contained in:
parent
56d28980b9
commit
f282f3f71e
5 changed files with 1 additions and 205 deletions
|
|
@ -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) }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue