Skip to content
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

Moving jetpack_is_mobile into a package #16129

Merged
merged 15 commits into from
Jun 25, 2020
Merged

Conversation

dero
Copy link
Collaborator

@dero dero commented Jun 11, 2020

  • Needs tests.

Changes proposed in this Pull Request:

  • Moves jetpack_is_mobile into a separate package.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • This is decoupling a feature from Jetpack.

Testing instructions:

  • Make sure jetpack_is_mobile is still usable and returns the same values as before.
  • Make sure Automattic\Jetpack\Mobile::is_mobile works.

Proposed changelog entry for your changes:

  • Move jetpack_is_mobile method into a separate package.

@github-actions github-actions bot added the [Status] Needs Package Release This PR made changes to a package. Let's update that package now. label Jun 11, 2020
@jetpackbot
Copy link

jetpackbot commented Jun 11, 2020

Warnings
⚠️

pre-commit hook was skipped for one or more commits

⚠️ The Privacy section is missing for this PR. Please specify whether this PR includes any changes to data or privacy.

This is an automated check which relies on PULL_REQUEST_TEMPLATE. We encourage you to follow that template as it helps Jetpack maintainers do their job. If you think 'Testing instructions' or 'Proposed changelog entry' are not needed for your PR - please explain why you think so. Thanks for cooperation 🤖

E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16129

Generated by 🚫 dangerJS against b1f20eb

@dero dero self-assigned this Jun 16, 2020
@dero dero marked this pull request as ready for review June 16, 2020 15:15
@dero dero changed the title [WIP] Moving jetpack_is_mobile into a package Moving jetpack_is_mobile into a package Jun 16, 2020
@dero dero added the [Status] Needs Review To request a review from Crew. Label will be renamed soon. label Jun 16, 2020
Copy link
Contributor

@fgiannar fgiannar left a comment

Choose a reason for hiding this comment

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

I was wondering if you could maybe explain the reasoning behind the decision to move jetpack_is_mobile into a package.
Is there maybe a discussion or a P2 about it so we can better understand it?
What mostly troubles me here is that jetpack_is_mobile is also widely used in WP.com so porting this change there could be an issue.
Furthermore, if we were to create a package, maybe it would make sense to have something more generic than Mobile, like User_Agent for example, since the functionality ported there is not necessarily mobile-specific.

@fgiannar fgiannar added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jun 17, 2020
@dero
Copy link
Collaborator Author

dero commented Jun 17, 2020

Is there maybe a discussion or a P2 about it so we can better understand it?

@fgiannar That's certainly a relevant concern, thank you for asking. @gravityrail should be able to provide more context. It's needed for an (yet) undisclosed A8C project.

@gravityrail
Copy link
Contributor

gravityrail commented Jun 17, 2020

We want to reuse this function in a separate project. If there's a better form for extracting it, let me know.

Master thread is pbIAo1-g-p2

Copy link
Contributor

@gravityrail gravityrail left a comment

Choose a reason for hiding this comment

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

Left a few comments, mostly around naming.

class.jetpack.php Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
packages/mobile/README.md Outdated Show resolved Hide resolved
packages/mobile/README.md Outdated Show resolved Hide resolved
@gravityrail
Copy link
Contributor

Is there maybe a discussion or a P2 about it so we can better understand it?

There is not a public discussion, this is for a prototype. Beyond the p2 link above, we do have a ticket and project. Basically, the project wants to estimate the viewport size from the user agent. Jetpack's user agent detection is much richer and more reliable than core's so we wanted to have this as a shared package that we can reuse in our own plugin.

What mostly troubles me here is that jetpack_is_mobile is also widely used in WP.com so porting this change there could be an issue.

I share that concern. Let's leave a compatibility function in-place with the same name, that calls through to the package. That is an approach that we have used before.

@dero
Copy link
Collaborator Author

dero commented Jun 19, 2020

@gravityrail Could you please have another look?

@jeherve jeherve added this to the 8.7 milestone Jun 19, 2020
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Some quick notes after a first review for me:


It seems you committed a package-lock.json in here. We don't need it so you can remove it I think 👍


Do you think you could look at the linting errors this brings up? We try to keep the /packages directory free of any errors. I realize a lot of those carry over from the old files, but I think it'd be nice to fix them instead of having to bypass the pre-commit hook every time we have to make changes to those files in the future.

class.jetpack-user-agent.php Outdated Show resolved Hide resolved
class.jetpack-user-agent.php Outdated Show resolved Hide resolved
class.jetpack-user-agent.php Show resolved Hide resolved
@dero
Copy link
Collaborator Author

dero commented Jun 22, 2020

Maybe we should keep the Jetpack_User_Agent_Info class around for a few more releases, with the methods that are still in use elsewhere, and in those add a deprecation message recommending the switch to the package, and then calling the matching method in the package.

Absolutely, thank you for checking, @jeherve – I will try to push the needed changes tomorrow.

@dero
Copy link
Collaborator Author

dero commented Jun 23, 2020

@jeherve Added Jetpack_User_Agent_Info back with deprecation notices in f74e9c9.

@dero dero added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jun 23, 2020
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Thanks a lot. I only have one comment left.

class.jetpack-user-agent.php Outdated Show resolved Hide resolved
@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jun 24, 2020
@dero dero added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jun 25, 2020
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This looks good to me. Merging this now.

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Jun 25, 2020
@jeherve jeherve dismissed gravityrail’s stale review June 25, 2020 12:27

Changes addressed

@jeherve jeherve merged commit a8aec09 into master Jun 25, 2020
@jeherve jeherve deleted the add/jetpack-mobile-package branch June 25, 2020 12:27
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Jun 25, 2020
@jeherve jeherve added [Status] Needs Testing We need to add this change to the testing call for this month's release and removed [Status] Needs Package Release This PR made changes to a package. Let's update that package now. labels Jun 25, 2020
@jeherve
Copy link
Member

jeherve commented Jun 25, 2020

automattic/jetpack-device-detection v1.0.0 is now available and can be used in other projects:
https://packagist.org/packages/automattic/jetpack-device-detection

@jeherve
Copy link
Member

jeherve commented Jun 25, 2020

  • D45479-code: the package is now available on WordPress.com.
  • D45478-code: working on bringing the rest of the changes over.

*
* @return bool
*/
public function is_tablet() {
Copy link
Member

@dereksmart dereksmart Jul 7, 2020

Choose a reason for hiding this comment

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

This change from static is throwing fatals for sites running the p2-breathe theme. https://wordpress.com/theme/p2-breathe

Copy link
Member

Choose a reason for hiding this comment

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

Follow-up: #16430

@jeherve jeherve removed the [Status] Needs Testing We need to add this change to the testing call for this month's release label Apr 27, 2021
This was referenced Oct 18, 2022
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.

None yet

7 participants