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

core(base-artifacts): add FormFactorIsMobile base artifact #7280

Merged
merged 10 commits into from
Mar 5, 2019

Conversation

mattzeunert
Copy link
Contributor

Summary

Extract the logic for this from the content-width audit so we can use it for other audits.

@patrickhulce I know we were talking about an Environment artifact to wrap these two properties, but since there are already other environment-related properties directly on baseArtifacts I just added them there.

Related Issues/PRs

Closes #7043

@mattzeunert mattzeunert changed the title core(baseArtifacts): Add IsMobile and IsMobileHost base artifacts core(baseArtifacts): add IsMobile and IsMobileHost base artifacts Feb 20, 2019
@mattzeunert mattzeunert changed the title core(baseArtifacts): add IsMobile and IsMobileHost base artifacts core(base-artifacts): add IsMobile and IsMobileHost base artifacts Feb 20, 2019
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

nice! LGTM, I'm not a huge fan of having both dangling but we can do another pass as part of #6747 before we make artifacts a real solidified API for folks

lighthouse-core/test/audits/content-width-test.js Outdated Show resolved Hide resolved
lighthouse-core/test/gather/fake-driver.js Show resolved Hide resolved
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

looking good, though I only took an initial gander.

I know we were talking about an Environment artifact to wrap these two properties, but since there are already other environment-related properties directly on baseArtifacts I just added them there.

I'm not a huge fan of having both dangling but we can do another pass as part of #6747

yeah, same, and I'm fine with waiting as well. We mostly don't consider artifacts to be part of our public API for semver yet (we will for v5 and plugins becoming a thing?), so the other environment props can get wrapped up then too.

types/artifacts.d.ts Outdated Show resolved Hide resolved
types/artifacts.d.ts Outdated Show resolved Hide resolved
@@ -23,6 +23,10 @@ declare global {
fetchTime: string;
/** A set of warnings about unexpected things encountered while loading and testing the page. */
LighthouseRunWarnings: string[];
/** Whether the page was loaded on either a real or emulated mobile device */
IsMobile: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

we might need to bikeshed on these. When I see artifacts.isMobile, my first thought is "is what mobile?" :)

It'll make a little more sense when nested in an environment artifact, but do we have other ideas?

(I also like reusing host for the UA string artifacts, but (super nitpicky) dislike the host prefix vs suffix :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IsMobileFormFactor?

brendankenny and others added 4 commits February 21, 2019 15:35
Co-Authored-By: mattzeunert <matt@mostlystatic.com>
Co-Authored-By: mattzeunert <matt@mostlystatic.com>
/** Whether the page was loaded on either a real or emulated mobile device. */
IsMobile: boolean;
/** Whether Lighthouse was run on a mobile device (i.e. not on a desktop machine). */
IsMobileHost: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

apparently, this is false if it was real mobile hardware but desktop was emulated.
which isn't what I expected given the name.

Copy link
Member

Choose a reason for hiding this comment

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

how about slightly different booleans?

isMobileHardware
isMobileEmulated

They will combine differently, but I think they communicate all the same things?

Copy link
Member

Choose a reason for hiding this comment

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

how about slightly different booleans?
isMobileHardware
isMobileEmulated

That kind of just punts the question back to the audits again, though. Really we just want to be able to easily answer "were my artifacts gathered in a mobile environment, whether real or emulated?".

The value should be true if run on desktop with mobile emulation, run on mobile with mobile emulation, or run on mobile with no emulation, otherwise false.

Maybe we should just drop IsMobileHost for now (I don't think anything needs it at this point?) and just pick a name we all like for isMobile/IsMobileFormFactor/isMobileEmulated?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like isMobileHardware to replace isMobileHost 👍

when discussing @paulirish 's comment we just used the phrase isMobileConditions which I kinda like over isMobile/isMobileFormFactor. I'd want to avoid Emulated since that's not really what we are getting at

Copy link
Member

Choose a reason for hiding this comment

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

isMobileHardware
wasMobileConditions
???

the second is past tense because it's sometimes true and sometimes not.
crazy but semantically reasonable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to FormFactorIsMobile and removed IsMobileHost from the base artifacts for now.

Copy link
Member

Choose a reason for hiding this comment

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

at first read, I'd probably have to look up whether FormFactorIsMobile meant either tested on actual mobile hardware or the definition we're going for.

What about something around TestedAsMobileDevice?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm starting to circle back around to @mattzeunert 's suggestion that this represents whether the device presented itself as mobile to the site, i.e network user agent was mobile :)

at this point though, I think we've all identified it's hard to name and we should just document well in the comment above it what it really represents

Copy link
Member

Choose a reason for hiding this comment

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

user agent is independent of form factor, though, isn't it? That's why I was suggesting we go with whatever awkward string reasonably encapsulates RanLighthouseWithADeviceThatEitherWasOrPretendedToBeAMobileOne, which would include the UA string and screen characteristics

Copy link
Contributor Author

@mattzeunert mattzeunert Mar 2, 2019

Choose a reason for hiding this comment

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

TestedAsMobileDevice works for me, updated the PR.

@mattzeunert mattzeunert changed the title core(base-artifacts): add IsMobile and IsMobileHost base artifacts core(base-artifacts): add FormFactorIsMobile base artifact Mar 1, 2019
@mattzeunert
Copy link
Contributor Author

We're using TestedAsMobileDevice now. @brendankenny What do you think?

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM2

@brendankenny
Copy link
Member

everyone else ok with TestedAsMobileDevice? :)

@patrickhulce
Copy link
Collaborator

everyone else ok with TestedAsMobileDevice?

WFM

@paulirish
Copy link
Member

lgtm on naming :)

@brendankenny brendankenny merged commit 299ca2b into master Mar 5, 2019
@brendankenny brendankenny deleted the is-mobile-artifacts branch March 5, 2019 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants