Skip to content

Kotlin Compiler Plugin for injecting function calls in the generated code using annotations.

Notifications You must be signed in to change notification settings

thermondo/funlin

Repository files navigation

Funlin


Installing

plugins {
    //...
    id("de.thermondo.funlin") version "latest_version"
}

Setup

in your module build.gradle.kts
funlin {
    enabled.set(true)
    annoatation.set("TrackIt")
    callableTargetPath.set("dev.thermondo.android.app.AnyObjectNameYouWant.anyFunctionName")
}
  • Create your own Annotation and annotate your functions with it
  • Create an Object that will be called when the function which is annotated with your Annotation is called.
Annotation
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.FUNCTION)
annotation class TrackIt
Object
package any.packagename.you.need

object AnyObjectNameYouWant {
    // parameter names are not important, but the types or the order are important.
    fun anyFunctionName(
        name: String,
        parent: String,
        body: String,
        args: Map<String, Any?>,
    ) {
        // your code here, logging/tracking events, etc.
    }
}

Warning

Parameter names are not important, but the types or the order are important.

In your code
@TrackIt
fun anyFunctionName(
    anyParameterName: Any,
) {
    // your code here
}

Important

All arguments are supported as long as they give meaningful information when .toString() is called on them. If you want to use a custom object, make sure to override the toString() method for that object.


Documentation




About

Kotlin Compiler Plugin for injecting function calls in the generated code using annotations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages