Skip to content

Commit c9cc03c

Browse files
Adam RaineDevtools-frontend LUCI CQ
authored andcommitted
[RPP Observations] Remove collapsible container for env recs
https://screenshot.googleplex.com/ACPKBbu5GhDdTK2 Bug: None Change-Id: Ib44671217c74f8beb76a7565843ae029dcbb0701 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5941208 Reviewed-by: Connor Clark <[email protected]> Commit-Queue: Adam Raine <[email protected]>
1 parent 985fc84 commit c9cc03c

File tree

3 files changed

+77
-75
lines changed

3 files changed

+77
-75
lines changed

front_end/panels/timeline/components/LiveMetricsView.test.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function getFieldMetricValue(view: Element, metric: string): HTMLElement|null {
3737
}
3838

3939
function getEnvironmentRecs(view: Element): HTMLElement[] {
40-
return Array.from(view.shadowRoot!.querySelectorAll<HTMLElement>('.environment-recs li'));
40+
return Array.from(view.shadowRoot!.querySelectorAll<HTMLElement>('.environment-rec'));
4141
}
4242

4343
function getInteractions(view: Element): HTMLElement[] {
@@ -726,10 +726,11 @@ describeWithMockConnection('LiveMetricsView', () => {
726726
await coordinator.done();
727727

728728
const envRecs = getEnvironmentRecs(view);
729-
assert.lengthOf(envRecs, 0);
729+
assert.strictEqual(envRecs[0].textContent, 'Not enough data');
730+
assert.strictEqual(envRecs[1].textContent, 'Not enough data');
730731

731732
const fieldMessage = getFieldMessage(view);
732-
assert.isNull(fieldMessage);
733+
assert.match(fieldMessage!.textContent!, /Not enough data/);
733734

734735
const dataDescriptions = getDataDescriptions(view);
735736
assert.match(dataDescriptions.innerText, /local metrics/);
@@ -883,7 +884,7 @@ describeWithMockConnection('LiveMetricsView', () => {
883884

884885
const envRecs = getEnvironmentRecs(view);
885886
assert.lengthOf(envRecs, 2);
886-
assert.match(envRecs[0].textContent!, /60%.*desktop/);
887+
assert.strictEqual(envRecs[0].textContent, '30% mobile, 60% desktop');
887888
assert.match(envRecs[1].textContent!, /Slow 4G/);
888889
});
889890

@@ -896,8 +897,8 @@ describeWithMockConnection('LiveMetricsView', () => {
896897
await coordinator.done();
897898

898899
const envRecs = getEnvironmentRecs(view);
899-
assert.lengthOf(envRecs, 1);
900-
assert.match(envRecs[0].textContent!, /60%.*desktop/);
900+
assert.strictEqual(envRecs[0].textContent, '30% mobile, 60% desktop');
901+
assert.strictEqual(envRecs[1].textContent, 'Not enough data');
901902
});
902903

903904
it('should suggest no throttling for very low latency', async () => {
@@ -912,9 +913,8 @@ describeWithMockConnection('LiveMetricsView', () => {
912913
await coordinator.done();
913914

914915
const envRecs = getEnvironmentRecs(view);
915-
assert.lengthOf(envRecs, 2);
916-
assert.match(envRecs[0].textContent!, /60%.*desktop/);
917-
assert.match(envRecs[1].textContent!, /no throttling/);
916+
assert.strictEqual(envRecs[0].textContent, '30% mobile, 60% desktop');
917+
assert.match(envRecs[1].textContent!, /too fast to simulate with throttling/);
918918
});
919919

920920
it('should ignore presets that are generally too far off', async () => {
@@ -929,8 +929,8 @@ describeWithMockConnection('LiveMetricsView', () => {
929929
await coordinator.done();
930930

931931
const envRecs = getEnvironmentRecs(view);
932-
assert.lengthOf(envRecs, 1);
933-
assert.match(envRecs[0].textContent!, /60%.*desktop/);
932+
assert.strictEqual(envRecs[0].textContent, '30% mobile, 60% desktop');
933+
assert.strictEqual(envRecs[1].textContent, 'Not enough data');
934934
});
935935
});
936936

@@ -943,8 +943,7 @@ describeWithMockConnection('LiveMetricsView', () => {
943943
await coordinator.done();
944944

945945
const envRecs = getEnvironmentRecs(view);
946-
assert.lengthOf(envRecs, 2);
947-
assert.match(envRecs[0].textContent!, /60%.*desktop/);
946+
assert.strictEqual(envRecs[0].textContent, '30% mobile, 60% desktop');
948947
assert.match(envRecs[1].textContent!, /Slow 4G/);
949948
});
950949

@@ -962,8 +961,7 @@ describeWithMockConnection('LiveMetricsView', () => {
962961
await coordinator.done();
963962

964963
const envRecs = getEnvironmentRecs(view);
965-
assert.lengthOf(envRecs, 2);
966-
assert.match(envRecs[0].textContent!, /80%.*mobile/);
964+
assert.strictEqual(envRecs[0].textContent, '80% mobile, 10% desktop');
967965
assert.match(envRecs[1].textContent!, /Slow 4G/);
968966
});
969967

@@ -981,8 +979,8 @@ describeWithMockConnection('LiveMetricsView', () => {
981979
await coordinator.done();
982980

983981
const envRecs = getEnvironmentRecs(view);
984-
assert.lengthOf(envRecs, 1);
985-
assert.match(envRecs[0].textContent!, /Slow 4G/);
982+
assert.strictEqual(envRecs[0].textContent, '49% mobile, 49% desktop');
983+
assert.match(envRecs[1].textContent!, /Slow 4G/);
986984
});
987985
});
988986
});

front_end/panels/timeline/components/LiveMetricsView.ts

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ const UIStrings = {
8181
* @example {Mobile} PH1
8282
*/
8383
showFieldDataForDevice: 'Show field data for device type: {PH1}',
84+
/**
85+
* @description Text indicating that there is not enough data to report real user statistics.
86+
*/
87+
notEnoughData: 'Not enough data',
88+
/**
89+
* @description Label for a text block that describes the network connections of real users.
90+
* @example {75th percentile is similar to Slow 4G throttling} PH1
91+
*/
92+
network: 'Network: {PH1}',
8493
/**
8594
* @description Label for an select box that selects which device type field data be shown for (e.g. desktop/mobile/all devices/etc).
8695
* @example {Mobile} PH1
@@ -141,30 +150,20 @@ const UIStrings = {
141150
*/
142151
showFieldDataForPage: 'Show field data for {PH1}',
143152
/**
144-
* @description Tooltip text explaining that real user connections are similar to a test environment with no throttling. "latencies" refers to the time it takes for a website server to respond. "throttling" is when the network is intentionally slowed down to simulate a slower connection.
153+
* @description Tooltip text explaining that real user connections are similar to a test environment with no throttling. "throttling" is when the network is intentionally slowed down to simulate a slower connection.
145154
*/
146-
tryDisablingThrottling:
147-
'The 75th percentile of real users experienced network latencies similar to a connection with no throttling.',
155+
tryDisablingThrottling: '75th percentile is too fast to simulate with throttling',
148156
/**
149-
* @description Tooltip text explaining that real user connections are similar to a specif network throttling setup. "latencies" refers to the time it takes for a website server to respond. "throttling" is when the network is intentionally slowed down to simulate a slower connection.
157+
* @description Tooltip text explaining that real user connections are similar to a specif network throttling setup. "throttling" is when the network is intentionally slowed down to simulate a slower connection.
150158
* @example {Slow 4G} PH1
151159
*/
152-
tryUsingThrottling: 'The 75th percentile of real users experienced network latencies similar to {PH1} throttling.',
160+
tryUsingThrottling: '75th percentile is similar to {PH1} throttling',
153161
/**
154-
* @description Tooltip text explaining that a majority of users are using a mobile form factor with the specific percentage.
162+
* @description Text block listing what percentage of real users are on different device form factors.
155163
* @example {60%} PH1
164+
* @example {30%} PH2
156165
*/
157-
mostUsersMobile: '{PH1} of users are on mobile.',
158-
/**
159-
* @description Tooltip text explaining that a majority of users are using a desktop form factor with the specific percentage.
160-
* @example {60%} PH1
161-
*/
162-
mostUsersDesktop: '{PH1} of users are on desktop.',
163-
/**
164-
* @description Text for a percentage value.
165-
* @example {60} PH1
166-
*/
167-
percentage: '{PH1}%',
166+
percentDevices: '{PH1}% mobile, {PH2}% desktop',
168167
/**
169168
* @description Text block explaining how to simulate different mobile and desktop devices. The placeholder at the end will be a link with the text "simulate different devices" translated separately.
170169
* @example {simulate different devices} PH1
@@ -205,8 +204,9 @@ const UIStrings = {
205204
}`,
206205
/**
207206
* @description Label for a a range of dates that represents the period of time a set of field data is collected from.
207+
* @example {Oct 1, 2024 - Nov 1, 2024} PH1
208208
*/
209-
collectionPeriod: 'Collection period:',
209+
collectionPeriod: 'Collection period: {PH1}',
210210
/**
211211
* @description Text showing a range of dates meant to represent a period of time.
212212
* @example {Oct 1, 2024} PH1
@@ -246,9 +246,9 @@ const UIStrings = {
246246
*/
247247
clearCurrentLog: 'Clear the current log',
248248
/**
249-
* @description Title for an expandable section that contains more information about real user environments. This message is meant to prompt the user to understand the conditions experienced by real users.
249+
* @description Title for a section that contains more information about real user environments. This message is meant to prompt the user to understand the conditions experienced by real users.
250250
*/
251-
considerRealUser: 'Consider real user environments',
251+
realUserEnvironments: 'Real user environments',
252252
/**
253253
* @description Title for a page load phase that measures the time between when the page load starts and the time when the first byte of the initial document is downloaded.
254254
*/
@@ -610,47 +610,44 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
610610
return i18nString(UIStrings.tryUsingThrottling, {PH1: title});
611611
}
612612

613-
#getDeviceRec(): Common.UIString.LocalizedString|null {
613+
#getDeviceRec(): string|null {
614614
// `form_factors` metric is only populated if CrUX data is fetched for all devices.
615615
const fractions = this.#cruxPageResult?.[`${this.#fieldPageScope}-ALL`]?.record.metrics.form_factors?.fractions;
616616
if (!fractions) {
617617
return null;
618618
}
619619

620-
if (fractions.desktop > 0.5) {
621-
const percentage = i18nString(UIStrings.percentage, {PH1: Math.round(fractions.desktop * 100)});
622-
return i18nString(UIStrings.mostUsersDesktop, {PH1: percentage});
623-
}
624-
625-
if (fractions.phone > 0.5) {
626-
const percentage = i18nString(UIStrings.percentage, {PH1: Math.round(fractions.phone * 100)});
627-
return i18nString(UIStrings.mostUsersMobile, {PH1: percentage});
628-
}
629-
630-
return null;
620+
return i18nString(UIStrings.percentDevices, {
621+
PH1: Math.round(fractions.phone * 100),
622+
PH2: Math.round(fractions.desktop * 100),
623+
});
631624
}
632625

633626
#renderRecordingSettings(): LitHtml.LitTemplate {
634-
const envRecs = [
635-
this.#getDeviceRec(),
636-
this.#getNetworkRec(),
637-
].filter(rec => rec !== null);
627+
const fieldEnabled = CrUXManager.CrUXManager.instance().getConfigSetting().get().enabled;
638628

639629
const deviceLinkEl = UI.XLink.XLink.create(
640630
'https://developer.chrome.com/docs/devtools/device-mode', i18nString(UIStrings.simulateDifferentDevices));
641631
const deviceMessage = i18n.i18n.getFormatLocalizedString(str_, UIStrings.useDeviceToolbar, {PH1: deviceLinkEl});
642632

633+
const deviceRecEl = document.createElement('span');
634+
deviceRecEl.classList.add('environment-rec');
635+
deviceRecEl.textContent = this.#getDeviceRec() || i18nString(UIStrings.notEnoughData);
636+
637+
const networkRecEl = document.createElement('span');
638+
networkRecEl.classList.add('environment-rec');
639+
networkRecEl.textContent = this.#getNetworkRec() || i18nString(UIStrings.notEnoughData);
640+
643641
// clang-format off
644642
return html`
645643
<h3 class="card-title">${i18nString(UIStrings.environmentSettings)}</h3>
646644
<div class="device-toolbar-description">${deviceMessage}</div>
647-
${envRecs.length > 0 ? html`
648-
<details class="environment-recs">
649-
<summary>${i18nString(UIStrings.considerRealUser)}</summary>
650-
<ul class="environment-recs-list">
651-
${envRecs.map(rec => html`<li>${rec}</li>`)}
652-
</ul>
653-
</details>
645+
${fieldEnabled ? html`
646+
<div class="environment-recs-title">${i18nString(UIStrings.realUserEnvironments)}</div>
647+
<ul class="environment-recs-list">
648+
<li>${i18n.i18n.getFormatLocalizedString(str_, UIStrings.device, {PH1: deviceRecEl})}</li>
649+
<li>${i18n.i18n.getFormatLocalizedString(str_, UIStrings.network, {PH1: networkRecEl})}</li>
650+
</ul>
654651
` : nothing}
655652
<div class="environment-option">
656653
<devtools-cpu-throttling-selector></devtools-cpu-throttling-selector>
@@ -837,10 +834,10 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
837834
// clang-format on
838835
}
839836

840-
#renderCollectionPeriod(): LitHtml.LitTemplate {
837+
#getCollectionPeriodRange(): string|null {
841838
const selectedResponse = this.#getSelectedFieldResponse();
842839
if (!selectedResponse) {
843-
return LitHtml.nothing;
840+
return null;
844841
}
845842

846843
const {firstDate, lastDate} = selectedResponse.record.collectionPeriod;
@@ -864,18 +861,25 @@ export class LiveMetricsView extends LegacyWrapper.LegacyWrapper.WrappableCompon
864861
day: 'numeric',
865862
};
866863

867-
const dateEl = document.createElement('span');
868-
dateEl.classList.add('collection-period-range');
869-
dateEl.textContent = i18nString(UIStrings.dateRange, {
864+
return i18nString(UIStrings.dateRange, {
870865
PH1: formattedFirstDate.toLocaleDateString(undefined, options),
871866
PH2: formattedLastDate.toLocaleDateString(undefined, options),
872867
});
868+
}
869+
870+
#renderCollectionPeriod(): LitHtml.LitTemplate {
871+
const range = this.#getCollectionPeriodRange();
872+
873+
const dateEl = document.createElement('span');
874+
dateEl.classList.add('collection-period-range');
875+
dateEl.textContent = range || i18nString(UIStrings.notEnoughData);
876+
877+
const message = i18n.i18n.getFormatLocalizedString(str_, UIStrings.collectionPeriod, {
878+
PH1: dateEl,
879+
});
873880

874881
return html`
875-
<div class="field-data-message">
876-
${i18nString(UIStrings.collectionPeriod)}
877-
${dateEl}
878-
</div>
882+
<div class="field-data-message">${message}</div>
879883
`;
880884
}
881885

front_end/panels/timeline/components/liveMetricsView.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,20 +301,20 @@ x-link { /* stylelint-disable-line selector-type-no-unknown */
301301
width: 18px;
302302
}
303303

304-
.environment-recs {
305-
margin: 12px 0;
306-
}
307-
308-
.environment-recs > summary {
304+
.environment-recs-title {
305+
margin-top: 12px;
309306
font-weight: var(--ref-typeface-weight-medium);
310-
margin-bottom: 4px;
311307
}
312308

313309
.environment-recs-list {
314310
margin: 0;
315311
padding-left: 20px;
316312
}
317313

314+
.environment-rec {
315+
font-weight: var(--ref-typeface-weight-medium);
316+
}
317+
318318
.link-to-log {
319319
padding: unset;
320320
background: unset;

0 commit comments

Comments
 (0)