-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Pixels when app restarts in foreground by automatic data clearer #858
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
Add Pixels when app restarts in foreground by automatic data clearer #858
Conversation
… when app restarts due to data clearing onAppForeground
…ned from an external link restarts state.
malmstein
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.
Just a couple of comments on error handling, but haven't tested this on a device
app/src/main/java/com/duckduckgo/app/fire/DataClearerForegroundAppRestartPixel.kt
Outdated
Show resolved
Hide resolved
| fun firePendingPixels() { | ||
| firePendingPixels(pendingAppForegroundRestart, Pixel.PixelName.FORGET_ALL_AUTO_RESTART) | ||
| firePendingPixels(pendingAppForegroundRestartWithIntent, Pixel.PixelName.FORGET_ALL_AUTO_RESTART_WITH_INTENT) | ||
| resetCount() |
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 is called from the Application class and there is no crash handling. Specially because resetCount() uses preferences who might not have been initialized properly.
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.
We talked about this offline, and we think it's fine to keep it as it's right now.
app/src/main/java/com/duckduckgo/app/systemsearch/SystemSearchActivity.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/systemsearch/SystemSearchActivity.kt
Outdated
Show resolved
Hide resolved
| it.addObserver(defaultBrowserObserver) | ||
| it.addObserver(appEnjoymentLifecycleObserver) | ||
| it.addObserver(dataClearerForegroundAppRestartPixel) | ||
| } |
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.
You could use apply instance of also.
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, they are equivalent, but no strong preference on styles here. So for now, it's fine to keep it as it is now and focus in related changes to our initial goal. But that was a nice catch. 👍
| private fun submitUnsentFireAppRestartedWithIntentPixels() { | ||
| dataClearerForegroundAppRestartPixel.firePendingPixels() | ||
| } |
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 you create a function just for this?
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, why not 🤷♀️
app/src/main/java/com/duckduckgo/app/statistics/pixels/Pixel.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/duckduckgo/app/fire/DataClearerForegroundAppRestartPixel.kt
Outdated
Show resolved
Hide resolved
| detectedUserIntent = false | ||
| } | ||
|
|
||
| fun registerIntent(intent: Intent?) { |
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 we find a better name for this? it's not clear from the name what it does or where/when to call it
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 come up with a better name, like I previously expected. No problem since this will be removed once we work on the fix at some point.
app/src/main/java/com/duckduckgo/app/fire/DataClearerForegroundAppRestartPixel.kt
Outdated
Show resolved
Hide resolved
…ns and improves readability.
Task/Issue URL: https://app.asana.com/0/0/1180090817363681/f
Tech Design URL:
CC:
Description:
This PR adds logic to send pixels when the app gets restarted due to automatic data clearer being triggered with the app in foreground.
We will send pixels to detect if the user opened the app from an external intent or without it. This will give us some insights about the impact of this issue: #780
Steps to test this PR:
In order to test this, we need to:
scheduleBackgroundTimerToTriggerClear(clearWhenOption.durationMilliseconds())Test 1:
mf_rsentTest 2:
mf_risentTest 3:
mf_risentTest 3:
mf_rsentInternal references:
Software Engineering Expectations
Technical Design Template