-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
report: allow custom strings for throttling/device #11796
Conversation
@@ -13,6 +13,11 @@ | |||
/** @type {LH.Config.Json} */ | |||
const config = { | |||
extends: 'lighthouse:default', | |||
settings: { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -424,12 +424,23 @@ class Util { | |||
networkThrottling = Util.i18n.strings.runtimeUnknown; | |||
} | |||
|
|||
const deviceEmulation = settings.formFactor === 'mobile' | |||
let device = !settings.screenEmulation ? Util.i18n.strings.runtimeNoEmulation : |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
/** Descriptive explanation for emulation setting when emulating a Moto G4 mobile device. */ | ||
runtimeMobileEmulation: 'Emulated Moto G4', | ||
/** Descriptive explanation for emulation setting when emulating a mobile device. */ | ||
runtimeMobileEmulation: 'Emulated Mobile', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to stop saying Moto G4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The settings they provide just tell us mobile or no. What sort of mobile device is determined by the UA. So yeah we gotta be more general with this tring.
This reverts commit 6cb6812.
2f148a0
to
b806ea9
Compare
} | ||
`); | ||
}); | ||
|
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
clonedSampleResult.configSettings.providedNetworkThrottlingString = 'Packet-level throtting'; | ||
clonedSampleResult.configSettings.providedCPUThrottlingString = 'cgroups cpu throttling'; | ||
|
||
const descs = opts => Util.getEmulationDescriptions(opts); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@@ -66,6 +66,7 @@ class Util { | |||
if (!clone.configSettings.locale) { | |||
clone.configSettings.locale = 'en'; | |||
} | |||
// If LHR is older than v7, it uses emulatedFormFactor instead of formFactor. https://github.com/GoogleChrome/lighthouse/blob/master/docs/emulation.md#changes-made-in-v7 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these will also automatically work as CLI flags, so should probably document them unless you purposefully didn't want them documented there :)
types/externs.d.ts
Outdated
@@ -175,6 +175,12 @@ declare global { | |||
throttlingMethod?: 'devtools'|'simulate'|'provided'; | |||
/** The throttling config settings. */ | |||
throttling?: ThrottlingSettings; | |||
/** A user-facing string to display in Runtime Settings for the Device row */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry to bikeshed, but we are going to be stuck with these indefinitely, so... 😬
Exploring the possibility space:
- should these be nested under an object of provided override strings? Keeps them all in one place, allows for a home for future override strings without things getting ridiculous, etc
- didn't we eventually decide "provided" is confusing, since it's not always clear who is providing what? What about something like
override*
?display*
?
types/externs.d.ts
Outdated
/** A user-facing string to display in Runtime Settings for the Network throttling row */ | ||
providedNetworkThrottlingString?: string | null; | ||
/** A user-facing string to display in Runtime Settings for the CPU throttling row */ | ||
providedCPUThrottlingString?: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've stuck to
providedCPUThrottlingString?: string | null; | |
providedCpuThrottlingString?: string | null; |
style for all the other settings with acronyms/initialisms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -103,6 +103,8 @@ const defaultSettings = { | |||
screenEmulation: screenEmulationMetrics.mobile, | |||
emulatedUserAgent: userAgents.mobile, | |||
|
|||
displayStrings: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not the prettiest thing to default to {}
, but after discussion we think maybe this is the best compromise given the constraints of the Settings
type today. It would be kind of nice to default to not defined if there are no strings in it, but semantically I think it's still ok (the empty set of display strings)
types/config.d.ts
Outdated
@@ -151,6 +151,7 @@ declare global { | |||
export interface Settings extends Required<SharedFlagsSettings> { | |||
throttling: Required<ThrottlingSettings>; | |||
screenEmulation: ScreenEmulationSettings; | |||
displayStrings: DisplayStrings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is this necessary to set manually? It should already be set to this from the base Required<SharedFlagsSettings>
, I believe...
@@ -176,6 +185,8 @@ declare global { | |||
throttlingMethod?: 'devtools'|'simulate'|'provided'; | |||
/** The throttling config settings. */ | |||
throttling?: ThrottlingSettings; | |||
/* Optional object of user-facing strings to be used instead of Lighthouse's given values. */ | |||
displayStrings?: DisplayStrings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seeing it now, lhr.configSettings.displayStringsisn't the clearest that it's not the equivalent of
rendererFormattedStrings`, its user defined displayStrings, but I'm also ok with it if you like the name :)
…actor-providedstrings
This implementation is pretty stale now. And it's a low priority feature. The UI is wildly different now. Ben/others, if you still really want this, holler and we'll figure something out. |
@paulirish ok to close from my perspective. we don't output using lighthouse html, though I imagine some other downstream users of LH might. can always be reopened in the future! thanks y'all. |
fixes #7053
also addresses's brendan's review on #11876
(i guess this is technically not breaking.
\o/
)Impl is mostly adding the new properties so the strings are exposed. But also, as patrick called out (https://github.com/GoogleChrome/lighthouse/pull/11779/files/f3c6d3528eab9cdd1b5c0978eafe3b617e0fc45a#r538013675) the logic for building the "Device" Runtime Settings string didn't make sense anymore, so that's changed.
cc @benschwarz