Skip to content
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

Implement analytics plan #4734

Merged
merged 25 commits into from
Jan 20, 2022
Merged

Implement analytics plan #4734

merged 25 commits into from
Jan 20, 2022

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Dec 16, 2021

  • Introduce AnalyticsTracker interface which is now injected to be able to send event (only if user has opt-in of course)
  • Implement part of the existing plan.

=> Could be nice to merge this PR, which has just been rebased, and iterate later for the remaining Events.

@github-actions
Copy link

github-actions bot commented Dec 16, 2021

Unit Test Results

  72 files  +  4    72 suites  +4   50s ⏱️ -8s
141 tests +  5  141 ✔️ +  5  0 💤 ±0  0 ±0 
440 runs  +20  440 ✔️ +20  0 💤 ±0  0 ±0 

Results for commit 58197b8. ± Comparison against base commit e73992f.

♻️ This comment has been updated with latest results.

@bmarty bmarty mentioned this pull request Jan 5, 2022
@bmarty bmarty force-pushed the feature/bma/analytics_next branch from 1c2653f to 880b97c Compare January 19, 2022 14:22
@bmarty bmarty marked this pull request as ready for review January 19, 2022 14:50
@bmarty bmarty changed the title Implement analytics plan - WIP Implement analytics plan Jan 19, 2022
@ouchadam
Copy link
Contributor

is the plan to have future generated events pulled in automatically? #4956

@@ -324,7 +334,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
override fun onResume() {
super.onResume()
Timber.i("onResume Activity ${javaClass.simpleName}")

screenEvent = analyticsScreenName?.let { ScreenEvent(it) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of interest, how come we track on exit rather than entry?

I'm not sure if this has already been defined but it might be helpful to write up what counts as a screen view event across the different platforms

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We track on exit because we want to report the duration, and this is managed by ScreenEvent. It's a bit weird, I know, generally the duration could be managed by the analytics tools (since a screen replaces another, duration can be deduced). But as we do not track every screens it probably better like that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, thanks for explaining!

@github-actions
Copy link

github-actions bot commented Jan 19, 2022

Matrix SDK

Integration Tests Results:

  • [org.matrix.android.sdk.session]
    passed="21" failures="0" errors="0" skipped="2"
  • [org.matrix.android.sdk.account]
    passed="5" failures="0" errors="0" skipped="2"
  • [org.matrix.android.sdk.internal]
    passed="158" failures="0" errors="0" skipped="38"
  • [org.matrix.android.sdk.ordering]
    passed="16" failures="0" errors="0" skipped="0"
  • [org.matrix.android.sdk.PermalinkParserTest]
    passed="2" failures="0" errors="0" skipped="0"

@bmarty
Copy link
Member Author

bmarty commented Jan 19, 2022

is the plan to have future generated events pulled in automatically? #4956

Yes. It's already working, but since I called the script in this PR, I did not want to merge #4956 (and the previous ones)

@@ -56,7 +56,7 @@ interface SingletonEntryPoint {

fun pinLocker(): PinLocker

fun analytics(): VectorAnalytics
fun analyticsTracker(): AnalyticsTracker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -363,6 +373,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver

override fun onPause() {
super.onPause()
screenEvent?.send(analyticsTracker, analyticsScreenName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to be able to override the screen name in the send, can screens dynamically change at runtime?

if not we could use a val instead of var and drop the extra screenName parameter

// or non null and abstract to force all screens to supply a name
protected open val name: ScreenName? = null  

screenEvent = screenName?.let { ScreenEvent(it) }
...

screenEvent?.send(analyticsTracker)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the screen name can change during the screen life. I made this for this particular case - LoginActivity
This is not ideal, I admit and a bit not clear...

/**
* Track a screen display. Unique usage.
*/
class ScreenEvent(val screenName: Screen.ScreenName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit - mainly thinking out loud, tying the start time to the object creation is a little bit hidden and means where the instance is created is implicitly tied to the duration

another way to model the behaviour could be with a separate ScreenTracker (which could have its own injected dependencies for clocks, trackers etc)

data class TimedScreen(val startTime: Long, val screenName: ScreenName)

val timedScreen: TimedScreen = screenTracker.trackEntry(screenName)

screenTracker.trackExit(trackedScreen)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's probably a little better. Happy to iterate on a dedicated PR later.

@bmarty bmarty enabled auto-merge January 20, 2022 15:51
@bmarty bmarty merged commit 9bfeb6f into develop Jan 20, 2022
@bmarty bmarty deleted the feature/bma/analytics_next branch January 20, 2022 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants