Skip to content

Conversation

@shiki
Copy link
Contributor

@shiki shiki commented Apr 15, 2019

Fixes the Site → Blog Posts part of #9625.

Findings

The changes in Automattic/wp-calypso#31160 expected the Android app to have "wp-android" in its user agent. You can see this being done in the Automattic/wp-calypso#31830 PR. See also related discussion in p4TIVU-9dz-p2.

It looks like for WebViewActivity, we never change the user agent at all. We removed that in #1312. At that time, the user agent fully replaced the default. It looked like this:

wp-android/4.7 (Android 6.0; en_US; <...>)

After the changes in #3410, the user agent is now the default plus the custom "wp-android" text. It looks like this:

Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ2A.190305.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/73.0.3683.90 Mobile Safari/537.36 wp-android/<version>

Solution

I believe it is now safe to restore the user agent and that's what was done here. This appends "wp-android/<version>" to the default user agent.

// Before
Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ2A.190305.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/73.0.3683.90 Mobile Safari/537.36

// After
Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ2A.190305.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/73.0.3683.90 Mobile Safari/537.36 wp-android/<version>
Before After
2019-04-15 14 08 45 2019-04-15 14 41 31

Testing

  1. Go to a WPCom site's Blog Posts
  2. Click on a post's View button.

Validate that the Calypso UI is no longer shown.

Please also test for possible regressions that you can remember that's related to the removal of the user agent.

Release notes

  • If there are user-facing changes, I have added an item to RELEASE-NOTES.txt.

shiki added 2 commits April 15, 2019 14:32
The user agent was removed in 9aa37f1 because it was causing issues like websites not showing their mobile version. Some websites use the user agent to detect whether the browser being used is from a mobile app. However, after the change in ae321eb, the `WordPress.getUserAgent()` now extends the default instead of replacing it. I believe it should be safe to use the user agent again.
@shiki shiki added this to the 12.3 milestone Apr 15, 2019
@shiki shiki requested review from daniloercoli and nbradbury April 15, 2019 20:50
@shiki shiki self-assigned this Apr 15, 2019
@shiki shiki requested a review from maxme April 15, 2019 20:57
Copy link
Contributor

@daniloercoli daniloercoli left a comment

Choose a reason for hiding this comment

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

I tested this on many sites and did not find any problems. Also tested on notifications and reader.

Note: May worth to try the Jetpack connection flow, and see if everything is working ok.
Note 2: Our stats bumping routine (on wpcom) may see the new UA string, and bump the view as app-view.

@shiki shiki mentioned this pull request Apr 16, 2019
2 tasks
@shiki
Copy link
Contributor Author

shiki commented Apr 16, 2019

Tested the Jetpack flow and it works. I also checked opengrok and did not find anything that might be affected by this.

Copy link
Contributor

@maxme maxme left a comment

Choose a reason for hiding this comment

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

LGTM!

@shiki shiki merged commit 71a0043 into develop Apr 16, 2019
@shiki shiki deleted the issue/9625-hide-calypso-in-webview branch April 16, 2019 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants