WordPress-Android
WordPress-Android copied to clipboard
Clicking on the Stats Widget after Closing the App Prompts User to Enable Site Stats Again
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
- Add a stats widget to your device's home screen
- View the list of active apps and swipe on the WordPress app to close it
- 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)
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:
- Which stats widget you are using? (At a glance, All-time, Today, or this Week?)
- 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)
- Are you able to view stats successfully if you open the WordPress app directly and head to My Site > Stats?
Thanks!
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:
- I get the "Enable site stats" notice again
- Clicking the back arrow takes me back to my phone's home screen
To view stats successfully again, I need to:
- Close the app
- Open the app from my phone's home screen so that it opens just on the My Site screen
- Click on Stats from there
I hope that helps a bit more, but please let me know if I can test anything else!
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!
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!
We've had a report of this bug on the forums here https://wordpress.com/forums/topic/unable-to-activate-site-stats/?view=all
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:
- Close the Jetpack app
- Long-press on the Jetpack app and select widgets, then add the "Views this week" widget.
- While the app is still closed, tap on a stat in the widget.
- Note the widget opens into "Stats" but states "Looking for stats?" - "Enable site stats".
To "fix" the situation from here:
- Open the Jetpack app, and navigate to Stats
- Close the Jetpack app
- Tap a stat on the widget
To see it break again:
- Open the Jetpack app and navigate away from Stats.
- Close the Jetpack app
- 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
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
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!
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