WordPress-Android icon indicating copy to clipboard operation
WordPress-Android copied to clipboard

Clicking on the Stats Widget after Closing the App Prompts User to Enable Site Stats Again

Open igotdes opened this issue 2 years ago • 6 comments

Expected behavior

If a user has already previously enabled stats, they shouldn't be prompted to enable it again.

Actual behavior

The user is prompted to enable stats. However, clicking on "Enable site stats" only results in an "Unable to activate site stats" error.

Steps to reproduce the behavior

  1. Add a stats widget to your device's home screen
  2. View the list of active apps and swipe on the WordPress app to close it
  3. Click on the stats widget
Tested on a OnePlus 9, Android 12, WPAndroid 19.8.1
Replicated on a Samsung Galaxy Note20 Ultra 5G, Android 12, WPAndroid 19.9-rc-2 (1220)

igotdes avatar May 25 '22 06:05 igotdes

Hi @igotdes, thanks for reporting this! I wasn't able to reproduce this, so I may be setting things up differently than you are.

Can you let us know:

  1. Which stats widget you are using? (At a glance, All-time, Today, or this Week?)
  2. Whether your site is hosted on WordPress.com or elsewhere? (Stats relies on a Jetpack connection, so we'll want to try to replicate your setup for that)
  3. Are you able to view stats successfully if you open the WordPress app directly and head to My Site > Stats?

Thanks!

thehenrybyrd avatar May 31 '22 08:05 thehenrybyrd

Hi, @thehenrybyrd. 👋 Thank you for looking into this!

Previously, I was testing on an AT site with the Today widget.

I just tested again. For nos. 1 and 2, I tested all four stats widgets—At a glance, All-time, Today, and Views this Week—on a self-hosted site that's on Pressable, a simple WordPress.com site, and an AT site.

For each site, the issue now occurs at random.

For no. 3, not sure if this is the scenario you're thinking of, but after I see the "Enable site stats" notice, if I head to my phone's home screen to open the WordPress app again:

  1. I get the "Enable site stats" notice again
  2. Clicking the back arrow takes me back to my phone's home screen

To view stats successfully again, I need to:

  1. Close the app
  2. Open the app from my phone's home screen so that it opens just on the My Site screen
  3. Click on Stats from there

I hope that helps a bit more, but please let me know if I can test anything else!

igotdes avatar Jun 01 '22 08:06 igotdes

Thanks @igotdes! One final thing I can think of is to check the Jetpack connection status of each site, to make sure they are not in a "site-only" ("userless") state. I've run into that state causing the "enable site stats" notice to appear before, so want to rule that out. (I'm honestly not sure if that's possible on a simple WordPress.com site though)

To check that, you can head into the site's Jetpack dashboard and scroll down to the "Connections" section. There, make sure there's both a Site Connection and an Account Connection listed.

To view stats successfully again, I need to

Based on your steps here, it sounds like you can always get around this by restarting the app, then opening it directly from the app icon (rather than a widget). Am I understanding that correctly?

Thanks!

thehenrybyrd avatar Jun 15 '22 13:06 thehenrybyrd

Based on your steps here, it sounds like you can always get around this by restarting the app, then opening it directly from the app icon (rather than a widget). Am I understanding that correctly?

Yes, that's correct!

igotdes avatar Jun 20 '22 09:06 igotdes

We've had a report of this bug on the forums here https://wordpress.com/forums/topic/unable-to-activate-site-stats/?view=all

aleone89 avatar Jul 22 '22 08:07 aleone89

I was able to reproduce this issue in the Jetpack app, with three sites: a WordPress.com simple site (private), WordPress.com simple site (public) and an old Atomic site. Tested on a Samsung Galaxy S21, Android 12

To reproduce:

  1. Close the Jetpack app
  2. Long-press on the Jetpack app and select widgets, then add the "Views this week" widget.
  3. While the app is still closed, tap on a stat in the widget.
  4. Note the widget opens into "Stats" but states "Looking for stats?" - "Enable site stats".

To "fix" the situation from here:

  1. Open the Jetpack app, and navigate to Stats
  2. Close the Jetpack app
  3. Tap a stat on the widget

To see it break again:

  1. Open the Jetpack app and navigate away from Stats.
  2. Close the Jetpack app
  3. Tap a stat on the widget

Initial reproduction:

https://user-images.githubusercontent.com/15107387/190413952-7ea859d6-3460-4099-bd5b-5f686ff6196d.mov

Reproducing "Fixing" it:

https://user-images.githubusercontent.com/15107387/190414635-0fb1d1d9-9220-40d3-a9ad-d933925b35a7.mov

thehenrybyrd avatar Sep 15 '22 13:09 thehenrybyrd

While testing Android 20.8, I ran into this issue (p5T066-3Ak-p2#comment-13505).

Testing details:

  • Device: Samsung Galaxy A53 5G / SM-A536U1
  • OS: Android 12
  • App versions: Jetpack 20.8-rc-1 / WordPress 20.8-rc-1
  • Site: Hosted on WordPress.com (private)

Repo steps:

  • Clean install either WordPress or Jetpack
  • Login
  • Close the app
  • Long-press on the app and add the All-time stats widget
  • Tap on one of the stats

The "fix" in https://github.com/wordpress-mobile/WordPress-Android/issues/16637#issuecomment-1248095157 did not work for me. The only time it'd work properly is if the app was already running.

https://user-images.githubusercontent.com/2454408/192331887-d4f5edf7-f6ac-4a0e-bde0-460fefd98527.mp4

Additionally, tapping on the widget header seems to work properly. When I tapped on "All-time", it would bring me to the stats screen correctly.

https://user-images.githubusercontent.com/2454408/192331997-7a21e4c2-5993-4201-b7da-4979575bd237.mp4

wargcm avatar Sep 26 '22 16:09 wargcm

The issue seems to have cropped up after this change

This is working alright when tapping on the widget header but not on the content. Mystery needs to be resolved!

ravishanker avatar Sep 28 '22 07:09 ravishanker

The "fix" in #16637 (comment) did not work for me. The only time it'd work properly is if the app was already running.

I also observed the same as @wargcm , so perhaps this behavior has changed since the issue was opened.

This is working alright when tapping on the widget header but not on the content. Mystery needs to be resolved!

I also observed this. I believe the reason for this is that the title lives outside of the list, and thus has its own PendingIntent, while the items inside the list use a fillIn with a pendingIntentTemplate. The problem is that this template for the list items is immutable, so per the docs:

This means that the additional intent argument passed to the send methods to fill in unpopulated properties of this intent will be ignored.

One solution to this is to set this template with FLAG_MUTABLE, and this seems to resolve the issue. Another possibility would be to provide siteId in the template intent directly, but this would leave all the subview intents undifferentiated (rendering the fillins useless).

I have opened a PR for this here: https://github.com/wordpress-mobile/WordPress-Android/pull/17439

mkevins avatar Nov 08 '22 04:11 mkevins