Last active
January 18, 2021 21:08
-
-
Save amsterdatech/0fdaf3c40395478f4026b67e0d511eea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cclass AndroidLogTracker(private val context: Context) : Tracker { | |
private val TAG = this::class.java.simpleName | |
private fun tag(): String = | |
"${context.applicationInfo.name}:${context.applicationInfo.packageName}:$TAG" | |
override fun isAnalyticsEnabled(): Boolean { | |
Log.d( | |
TAG, | |
"${tag()} is enable ${BuildConfig.DEBUG}" | |
) | |
return BuildConfig.DEBUG | |
} | |
override fun enableAnalytics(enabled: Boolean) { | |
Log.d(TAG, "${tag()} enable analytics $enabled ") | |
} | |
override fun logLevel(logLevel: Int) { | |
Log.d(TAG, "${tag()} log level: $logLevel") | |
} | |
override fun start() { | |
Log.d(TAG, "${tag()} has started!!") | |
} | |
override fun apiKey(): String { | |
val apiKey = UUID.randomUUID() | |
Log.d(TAG, "${tag()} generate an random uuid as apiKey: $apiKey") | |
return apiKey.toString() | |
} | |
override fun trackEvent(eventTrack: Event) { | |
when (eventTrack) { | |
is Event.EventTrack -> { | |
Log.d(TAG, "${tag()} trackEvent ${eventTrack.eventName}") | |
} | |
else -> { | |
//TODO You can choose what kind of events you want to be aware about | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment