-
Notifications
You must be signed in to change notification settings - Fork 275
feat: google analytics (APP-105) #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sergey48k
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall, but I want to see another iteration.
| @@ -0,0 +1,95 @@ | |||
| package app | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
src/main/kotlin/app/Analytics.kt
Outdated
| private val fuelManager = FuelManager() | ||
|
|
||
| var uuid: String = "" // Should be set on start of the app. | ||
| var username: String = "" // Should be set on success authorization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
successful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
src/main/kotlin/app/Analytics.kt
Outdated
| post(params + defaultParams.filter { !params.contains(it) } | ||
| + idParams).responseString() | ||
| } catch (e: Throwable) { | ||
| // Never fail from analytics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some sort of log/console output here, at least.
| try { | ||
| // Send event to GA with united params. | ||
| post(params + defaultParams.filter { !params.contains(it) } | ||
| + idParams).responseString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird line breakdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
| return fuelManager.request(Method.POST, "/collect", params) | ||
| } | ||
|
|
||
| private fun trackEvent(event: String, params: List<Param> = listOf()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment that explains how exactly this is being logged? E.g. if it's virtual urls, can you explain how it will map to virtual urls? I also suggest all virtual urls start with /virtual prefix as a convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
src/main/kotlin/app/Analytics.kt
Outdated
|
|
||
| fun trackError() { | ||
| // TODO(anatoly): Send message with exd, consider limit 150 bytes. | ||
| trackEvent("/error", listOf("t" to HIT_EXCEPTION)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be some sort sort of error code as an argument for trackError, e.g.
/virtual/app/error/out-of-disk-space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo is about it.
src/main/kotlin/app/Analytics.kt
Outdated
| } | ||
|
|
||
| fun trackEnd() { | ||
| trackEvent("/end") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this app-exit? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
src/main/kotlin/app/Analytics.kt
Outdated
| fun trackError() { | ||
| // TODO(anatoly): Send message with exd, consider limit 150 bytes. | ||
| trackEvent("/error", listOf("t" to HIT_EXCEPTION)) | ||
| trackEvent("error", listOf("t" to HIT_EXCEPTION)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally, you don't want to change your logged events because those that are logged will stay in GA forever. So any change to log format, like renaming events, will impact funnels and their historical availability. I will let this one slip this one time, but please follow up with detailed error codes asap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use special error tracking software, e.g. https://sentry.io, because error code is not enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For GA error urls probably best solution is to use exception names, agree?
No description provided.