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

MWPW-155489 [PEP] Add device type as PEP criteria #2931

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

sharmrj
Copy link
Contributor

@sharmrj sharmrj commented Sep 23, 2024

Due to our specific viewport breakpoints, PEP was being served to iPhone/iPad users browsing with their device held horizontally. This lead to a requirement for serving PEP only to desktop users.

  • We've used the same check MEP uses to determine if the user is on a mobile device or not
  • We haven't imported the MEP check since, in pages where personalization is turned off, the browser would needlessly download and parse the personalization.js just for the User Agent check.
  • Requirements for MEP and PEP won't necessarily move in lockstep, so it makes sense to maintain our own list of User Agents we'll check for in PEP.

Note: As MDN recommends, it's preferable to not do useragent sniffing and prefer feature detection instead. In our case this would mean, if we're redirecting to a web app, do the feature detection for that particular webapp before we decide to redirect the user to that webapp. But this is a more complicated problem to solve and it'll need to be looked into (if it's even worth the effort).

Resolves: MWPW-155489

Test URLs:

Copy link
Contributor

aem-code-sync bot commented Sep 23, 2024

Page Scores Audits Google
📱 /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

1 similar comment
Copy link
Contributor

aem-code-sync bot commented Sep 23, 2024

Page Scores Audits Google
📱 /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.23%. Comparing base (c80cf18) to head (668fc8c).
Report is 29 commits behind head on stage.

Additional details and impacted files
@@            Coverage Diff             @@
##            stage    #2931      +/-   ##
==========================================
- Coverage   96.24%   96.23%   -0.01%     
==========================================
  Files         236      236              
  Lines       54253    54281      +28     
==========================================
+ Hits        52216    52239      +23     
- Misses       2037     2042       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@spadmasa spadmasa self-assigned this Sep 23, 2024
@sharmrj
Copy link
Contributor Author

sharmrj commented Sep 23, 2024

Nala tests seem to be failing for a reason unrelated to my changes

@@ -637,9 +637,12 @@ class Gnav {
const state = getMetadata('app-prompt')?.toLowerCase();
const entName = getMetadata('app-prompt-entitlement')?.toLowerCase();
const promptPath = getMetadata('app-prompt-path')?.toLowerCase();
const hasMobileUA = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Touch/i.test(navigator.userAgent);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: wouldn't isMobile be clearer?

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 have checks like isDesktop that check viewport size, which is what we check by default. I'd like to keep this name to differentiate it from the viewport size checks.

Copy link
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

@spadmasa
Copy link

Validation has been done on user agent , actual device testing can be done only once the pr gets merged to stage. Details are updated in
https://jira.corp.adobe.com/browse/MWPW-158882 on testing

@spadmasa spadmasa added verified PR has been E2E tested by a reviewer Ready for Stage labels Sep 26, 2024
@@ -637,9 +637,12 @@ class Gnav {
const state = getMetadata('app-prompt')?.toLowerCase();
const entName = getMetadata('app-prompt-entitlement')?.toLowerCase();
const promptPath = getMetadata('app-prompt-path')?.toLowerCase();
const hasMobileUA = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Touch/i.test(navigator.userAgent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any analytics data pointing to all of these being used by our users? The iPod was discontinued more than 2 years ago. Blackberry, IEMobile and Touch don't seem to be all that popular either according to this.

@milo-pr-merge milo-pr-merge bot merged commit 96edd14 into adobecom:stage Sep 26, 2024
22 checks passed
@milo-pr-merge milo-pr-merge bot mentioned this pull request Sep 26, 2024
jenssingler pushed a commit to jenssingler/milo that referenced this pull request Oct 7, 2024
PEP now checks if the the useragent is one of a number of mobile devices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready for Stage verified PR has been E2E tested by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants