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

report: allow custom strings for throttling/device #11796

Closed
wants to merge 19 commits into from

Conversation

paulirish
Copy link
Member

@paulirish paulirish commented Dec 9, 2020

fixes #7053
also addresses's brendan's review on #11876

(i guess this is technically not breaking. \o/)

image

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

@@ -13,6 +13,11 @@
/** @type {LH.Config.Json} */
const config = {
extends: 'lighthouse:default',
settings: {

This comment was marked as resolved.

@@ -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.

/** 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',
Copy link
Collaborator

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?

Copy link
Member Author

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.

@paulirish paulirish added the 7.1 label Dec 14, 2020
Base automatically changed from emulation-flags-refactor to master December 16, 2020 01:24
}
`);
});

This comment was marked as resolved.

clonedSampleResult.configSettings.providedNetworkThrottlingString = 'Packet-level throtting';
clonedSampleResult.configSettings.providedCPUThrottlingString = 'cgroups cpu throttling';

const descs = opts => Util.getEmulationDescriptions(opts);

This comment was marked as resolved.

@@ -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.

Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

lgtm

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.

these will also automatically work as CLI flags, so should probably document them unless you purposefully didn't want them documented there :)

@@ -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 */
Copy link
Member

@brendankenny brendankenny Jan 13, 2021

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*?

/** 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;
Copy link
Member

Choose a reason for hiding this comment

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

we've stuck to

Suggested change
providedCPUThrottlingString?: string | null;
providedCpuThrottlingString?: string | null;

style for all the other settings with acronyms/initialisms

@paulirish paulirish added the P1 label Feb 11, 2021
@paulirish paulirish self-assigned this Feb 11, 2021
@paulirish paulirish removed the 7.1 label Feb 11, 2021
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.

LGTM!

@@ -103,6 +103,8 @@ const defaultSettings = {
screenEmulation: screenEmulationMetrics.mobile,
emulatedUserAgent: userAgents.mobile,

displayStrings: {},
Copy link
Member

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)

@@ -151,6 +151,7 @@ declare global {
export interface Settings extends Required<SharedFlagsSettings> {
throttling: Required<ThrottlingSettings>;
screenEmulation: ScreenEmulationSettings;
displayStrings: DisplayStrings;
Copy link
Member

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;
Copy link
Member

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 ofrendererFormattedStrings`, its user defined displayStrings, but I'm also ok with it if you like the name :)

@paulirish
Copy link
Member Author

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 paulirish closed this Apr 25, 2022
@paulirish paulirish deleted the emulation-flags-refactor-providedstrings branch April 25, 2022 21:32
@benschwarz
Copy link
Contributor

@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.

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.

HTML Report renderer incorrect labels for custom throttling & device
5 participants