Skip to content

Instantly share code, notes, and snippets.

@KryptKode
Created July 15, 2020 11:23
Show Gist options
  • Save KryptKode/1066687873e967220e425611d20b0036 to your computer and use it in GitHub Desktop.
Save KryptKode/1066687873e967220e425611d20b0036 to your computer and use it in GitHub Desktop.
class ButtonEvent : CustomEvent(){
override fun getEventName() {
return "event_tag" //event tag
}
}
class LoginEvent (private val userId:String) : CustomEvent(){
override fun getEventName() {
return "login" // the event tag
}
override fun getParameters(): MutableMap<String, Any> {
return hashMapOf("user_id" to userId) // map of parameters
}
}
//imports
class MainActivity : BaseActivity() {
@Inject
lateinit var appAnalytics: AppAnalytics
override fun onCreate(savedInstanceState:Bundle?){
super.onCreate(savedInstanceState)
myButton.setOnClickListener{
appAnalytics.log(ButtonClickEvent())
}
}
override fun onStart(){
appAnalytics.log(ViewMainScreenEvent())
}
}
class MainPresenter @Inject constructor (
private val appAnalytics: AppAnalytics,
private val loginUseCase: LoginUseCase
) : BasePresenter(){
fun login(){
loginUseCase.execute({userId->
appAnalytics.log(LoginEvent(userId))
}, {error->
//handle error
})
}
}
class ViewMainScreenEvent : ContentViewEvent(){
override fun getName(){
return "view_main_screen" //the tag of the view event
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment