Skip to content

Conversation

@cmonfortep
Copy link
Contributor

@cmonfortep cmonfortep commented Jun 12, 2020

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:

  1. Disable WorkManager: comment line AutomaticDataClearer#121 scheduleBackgroundTimerToTriggerClear(clearWhenOption.durationMilliseconds())
  2. Enable automatic data clearer in settings (5 seconds for testing purposes)

Test 1:

  1. Start the app as normal after being inactive for 5 seconds
  2. Ensure app restarts due to automatic dataclearer
  3. Ensure pixel mf_r sent

Test 2:

  1. Start the app from a home screen icon or any external link after being inactive for 5 seconds
  2. Ensure app restarts due to automatic dataclearer
  3. Ensure pixel mf_ri sent

Test 3:

  1. Start the app from search widget after being inactive for 5 seconds
  2. Ensure app restarts due to automatic dataclearer
  3. Ensure pixel mf_ri sent

Test 3:

  1. Start the app from an external link in less than 5 seconds
  2. Ensure app didn't restart
  3. Send the app to backgound (home button or turn off screen)
  4. Bring back the app to foreground after being inactive for 5 seconds
  5. Ensure app restarts due to automatic dataclearer
  6. Ensure pixel mf_r sent

Internal references:

Software Engineering Expectations
Technical Design Template

@cmonfortep cmonfortep changed the title Feature/cristian/pixel external link restart Add Pixels when app restarts in foreground by automatic data clearer Jun 12, 2020
@cmonfortep cmonfortep marked this pull request as ready for review June 12, 2020 08:59
@CDRussell CDRussell self-assigned this Jun 12, 2020
Copy link
Contributor

@malmstein malmstein left a 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

fun firePendingPixels() {
firePendingPixels(pendingAppForegroundRestart, Pixel.PixelName.FORGET_ALL_AUTO_RESTART)
firePendingPixels(pendingAppForegroundRestartWithIntent, Pixel.PixelName.FORGET_ALL_AUTO_RESTART_WITH_INTENT)
resetCount()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

it.addObserver(defaultBrowserObserver)
it.addObserver(appEnjoymentLifecycleObserver)
it.addObserver(dataClearerForegroundAppRestartPixel)
}

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.

Copy link
Contributor Author

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. 👍

Comment on lines 265 to 267
private fun submitUnsentFireAppRestartedWithIntentPixels() {
dataClearerForegroundAppRestartPixel.firePendingPixels()
}

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, why not 🤷‍♀️

detectedUserIntent = false
}

fun registerIntent(intent: Intent?) {
Copy link
Member

@CDRussell CDRussell Jun 22, 2020

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

Copy link
Contributor Author

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.

@cmonfortep cmonfortep merged commit e1890ba into develop Jun 26, 2020
@cmonfortep cmonfortep deleted the feature/cristian/pixel_external_link_restart branch June 26, 2020 09:05
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.

4 participants