-
Notifications
You must be signed in to change notification settings - Fork 927
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
Pixel: Add tab activity stats to a daily pixel #5278
Conversation
c4762cf
to
04acf5e
Compare
import org.mockito.Mockito.mock | ||
import org.mockito.kotlin.whenever | ||
|
||
class DefaultTabStatsBucketingTest { |
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 doesn’t have to be an Android Test, we can move it to unitTest instead and run it as such.
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.
Good point!
} | ||
|
||
@Test | ||
fun testGetNumberOfOpenTabsExactly1() = runBlocking { |
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.
Instead of runBlocking
, runTest
is better to use in tests.
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.
Good call 👍
} | ||
} | ||
|
||
@ContributesBinding(AppScope::class) |
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.
Curious q, does it have to be AppScope
?
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.
Not really, it could have been FragmentScope
, as well, but since the only dependency here is the TabManager
which is also scoped in AppScope
, this allows the class to be used from anywhere.
val inactive2w = viewModelScope.async(dispatchers.io()) { tabStatsBucketing.getTabsActiveTwoWeeksAgo() } | ||
val inactive3w = viewModelScope.async(dispatchers.io()) { tabStatsBucketing.getTabsActiveMoreThanThreeWeeksAgo() } | ||
|
||
viewModelScope.launch { |
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.
Would it make sense to run this on io as well, since we have a bunch of await() calls here?
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.
Sure.
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.
Tested and works as expected. A few comments that would be good to clarify before merging.
@karlenDimla I’ve addressed your comments in the code. |
Task/Issue URL: https://app.asana.com/0/1207418217763355/1208414748460831/f
Description
This PR adds the following parameters to the
m_tab_manager_clicked_daily
pixel:tab_count
: The number of open tabstab_active_7d
: The number of tabs access within the last 7 daystab_inactive_1w
: Tabs not accessed for more than a week, but less than 2 weekstab_inactive_2w
: Tabs not accessed for more than 2 weeks, but less than 3 weekstab_inactive_3w
: Tabs not accessed for at least 3 weeksAll stats are reported within buckets due to privacy reasons:
A new column was added to the
TabEntity
— thelastAccessTime
, which is updated every time a tab is activated.Steps to test this PR
DB migration
Pixel firing
m_tab_manager_clicked_daily
pixel is fired with all of the parameters mentioned aboveLast access time updates
app.db
databasetabs
tablelastAccessTime
was updated for the access tabs using correct time