Skip to content

Log your analytics

Mohamed Hamdan edited this page Nov 6, 2018 · 1 revision

@Analytics

With @Analytics annotation you be able to log your events by annotate your fields with this annotation and add one or more events to same field.

@Analytics(Event("Login"))
val age: Int

For support multiple events on same field you may add multiple @Event to same @Analytics

@Analytics(
    Event("Login"),
    Event("Register"),
    Event("Logout")
)
val age: Int

Full example

data class User(
        @Analytics(
                Event("Login"),
                Event("Logout")
        )
        val name: String,

        @Analytics(Event("Logout"))
        val email: String,

        @Analytics(Event("Login"))
        val phone: String,

        @Analytics(
                Event("Login"),
                Event("Logout")
        )
        val age: Int,

        @AnalyticsEmbedded
        val address: Address?
)

Now you able to use analytics like this

Analytics.getInstance(context).userAnalytics.loginEvent(User())

No reflection here, all code is auto generated

Clone this wiki locally