This file contains 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
@AnalyticsEvent | |
sealed class MyEvent { | |
data class ShareImage(val imageName: String, val fullString: String) : MyEvent() | |
object ButtonTapped : MyEvent() | |
} |
This file contains 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
apply plugin: 'kotlin' | |
apply plugin: 'kotlin-kapt' | |
dependencies { | |
// Add dependency to your module that has the annotation class. | |
compileOnly project(':annotation') | |
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | |
// To easily register your custom annotation processor to the annotation process flow. | |
implementation "com.google.auto.service:auto-service:1.0-rc4" |
This file contains 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
// Set Target as class since we want this annotation to be added to a class element | |
@Target(AnnotationTarget.CLASS) | |
// Set retention as Source since we only need this annotation | |
// during annotation processing process and | |
// we don't need this class at runtime. | |
@Retention(AnnotationRetention.SOURCE) | |
annotation class AnalyticsEvent |
This file contains 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
// Dummy analytics event tracker that logs the events to Logcat | |
object EventTracker { | |
private const val TAG = "EventTracker" | |
fun logEvent(name: String, params: Bundle) { | |
Log.d(TAG, "Logging event name: $name; params: $params") | |
} | |
} |
NewerOlder