-
Notifications
You must be signed in to change notification settings - Fork 473
1570647 - Do not send 'metrics' ping if the app was not used #3993
Conversation
This is silly but the test I added ( |
981ae04
to
e7fc7b9
Compare
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.
Looks good. Just one additional thing to test, if possible.
// If this is the first ON_START event since the app was launched, Glean wouldn't be | ||
// initialized yet. | ||
if (Glean.isInitialized()) { | ||
Glean.metricsPingScheduler.startupCheck() |
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.
The risk of this change might be that when it enters foreground multiple times during the same 24 hour period, the ping is scheduled for sending twice (at the same 4AM instant the next morning). I think the fact that we use WorkManager.getInstance().enqueueUniqueWork()
makes that impossible, but I wonder if there's a way to write a test for that.
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 could also check to see if a Worker
is already enqueued, which I didn't really think to do either. I agree we should be okay since we do use the enqueueUniqueWork
but a test and/or a check wouldn't hurt.
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.
One test could be to use the workmanager testing api to enqueue two unique work units and check if both are there. But that would only test the WorkManager API, and I bet that such a test is already there, for them
...rvice/glean/src/main/java/mozilla/components/service/glean/scheduler/MetricsPingScheduler.kt
Outdated
Show resolved
Hide resolved
...ice/glean/src/main/java/mozilla/components/service/glean/scheduler/GleanLifecycleObserver.kt
Outdated
Show resolved
Hide resolved
// If this is the first ON_START event since the app was launched, Glean wouldn't be | ||
// initialized yet. | ||
if (Glean.isInitialized()) { | ||
Glean.metricsPingScheduler.startupCheck() |
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.
One test could be to use the workmanager testing api to enqueue two unique work units and check if both are there. But that would only test the WorkManager API, and I bet that such a test is already there, for them
...e/glean/src/test/java/mozilla/components/service/glean/scheduler/MetricsPingSchedulerTest.kt
Outdated
Show resolved
Hide resolved
...e/glean/src/test/java/mozilla/components/service/glean/scheduler/MetricsPingSchedulerTest.kt
Outdated
Show resolved
Hide resolved
...rvice/glean/src/main/java/mozilla/components/service/glean/scheduler/MetricsPingScheduler.kt
Outdated
Show resolved
Hide resolved
e47bf4d
to
af0d5ce
Compare
...e/glean/src/test/java/mozilla/components/service/glean/scheduler/MetricsPingSchedulerTest.kt
Outdated
Show resolved
Hide resolved
...rvice/glean/src/main/java/mozilla/components/service/glean/scheduler/MetricsPingScheduler.kt
Outdated
Show resolved
Hide resolved
68bc886
to
50556c4
Compare
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 to me. When porting this to glean-core, we should document the new specifications (we don't send if we were not in foreground in the measurement window).
Let's get a review from Sebastian and Mike as well. Please also take this for a manual test drive.
Sounds good to me, working on the manual test drive today and looks like you already flagged @mdboom and @pocmo |
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.
LGTM
c235333
to
a51d300
Compare
Also removes unnecessary type arguments from MetricsPingSchedulerTest.kt
This attempts to address the issue around sending of metrics pings when the app hasn't been used for that day.
Pull Request checklist
After merge