Skip to content

Commit

Permalink
Merge pull request #3098 from catchpoint/master
Browse files Browse the repository at this point in the history
Promote to prod
  • Loading branch information
claud-io authored Aug 19, 2024
2 parents 13fa2a0 + 88e42a5 commit a74f63f
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 83 deletions.
2 changes: 1 addition & 1 deletion www/assets/css/pagestyle2.css
Original file line number Diff line number Diff line change
Expand Up @@ -7246,7 +7246,7 @@ td {
font-weight: 500;
display: block;
font-size: 0.9em;
color: #d580ff;
color: #b2bacb;
padding-top: 0.4em;
}

Expand Down
34 changes: 16 additions & 18 deletions www/experiments/common.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

require_once INCLUDES_PATH . '/include/thresholds.inc';
// container for assessment including opportunities, experiments to recommend

// initial host is used by a few opps, so we'll calculate it here
Expand Down Expand Up @@ -27,6 +28,7 @@ function documentRelativePath($url, $path)
return $url;
}

global $MetricThresholds;
// globals to be set by assessment includes and used here too
$blockingJSReqs = null;
$blockingCSSReqs = null;
Expand All @@ -52,7 +54,6 @@ $avgSiteCarbon = 0.6;
$hostsGreen = null;
$carbonCompare = null;


if ($metaInfo) {
$assessmentData = $metaInfo['experiment']['assessment'];
}
Expand Down Expand Up @@ -160,26 +161,23 @@ foreach ($assessment as $key => $cat) {
$assessment[$key]["num_good"] = $numGood;
$assessment[$key]["num_bad"] = $numChecks - $numGood;



if ($key === "Quick") {
// build sentiment
$summary = "This site ";
$ttfbCheck = $testStepResult->getMetric('TTFB');
if ($ttfbCheck > 2000) {
if ($ttfbCheck > $MetricThresholds['TTBF_POOR']) {
$summary .= "was very slow";
} elseif ($ttfbCheck > 1000) {
} elseif ($ttfbCheck > $MetricThresholds['TTBF_OK']) {
$summary .= "took little time";
} else {
$summary .= "was quick";
}
$summary .= " to connect and deliver initial code. It began rendering content";

$fcpCheck = $testStepResult->getMetric('firstContentfulPaint');
$fcpCheck = $fcpCheck / 1000;
if ($fcpCheck > 5) {
if ($fcpCheck > $MetricThresholds['FCP_POOR']) {
$summary .= " with considerable delay.";
} elseif ($fcpCheck > 2) {
} elseif ($fcpCheck > $MetricThresholds['FCP_OK']) {
$summary .= " with little delay.";
} else {
$summary .= " very quickly.";
Expand All @@ -193,9 +191,9 @@ foreach ($assessment as $key => $cat) {

if (isset($lcp)) {
$summary .= " The largest content rendered ";
if ($lcp['time'] > 3500) {
if ($lcp['time'] > $MetricThresholds['LCP_POOR']) {
$summary .= " later than ideal.";
} elseif ($lcp['time'] > 2500) {
} elseif ($lcp['time'] > $MetricThresholds['LCP_OK']) {
$summary .= " a little late.";
} else {
$summary .= " quickly.";
Expand All @@ -205,9 +203,9 @@ foreach ($assessment as $key => $cat) {
// build sentiment
$summary = "This site ";
if (isset($cls)) {
if ($cls > .25) {
if ($cls > $MetricThresholds['CLS_POOR']) {
$summary .= "had major layout shifts";
} elseif ($cls > 0) {
} elseif ($cls > $MetricThresholds['CLS_OK']) {
$summary .= "had minor layout shifts";
} else {
$summary .= "had good layout stability";
Expand All @@ -218,9 +216,9 @@ foreach ($assessment as $key => $cat) {
$tbtCheck = $testStepResult->getMetric('TotalBlockingTime');
if (isset($tbtCheck)) {
(isset($cls)) ? $summary .= " It took" : $summary .= "took";
if ($tbtCheck > 1000) {
if ($tbtCheck > $MetricThresholds['TBT_POOR']) {
$summary .= " a long time";
} elseif ($tbtCheck > 500) {
} elseif ($tbtCheck > $MetricThresholds['TBT_OK']) {
$summary .= " some time";
} else {
$summary .= " little time";
Expand All @@ -243,7 +241,7 @@ foreach ($assessment as $key => $cat) {
$genContentSize = floatval($genContentSize);
$genContentPercent = floatval($genContentPercent);

if ($genContentSize > .5 || $genContentPercent > 1) {
if ($genContentSize > $MetricThresholds['RenderBlockingContentSizeCheck'] || $genContentPercent > $MetricThresholds['RenderBlockingContentPercentCheck']) {
$summary .= " Some HTML was generated after delivery, potentially delaying usability.";
} else {
$summary .= " HTML content was mostly generated server-side.";
Expand All @@ -253,7 +251,7 @@ foreach ($assessment as $key => $cat) {
// build sentiment
$summary = "This site ";
if (isset($blocking3pReqs)) {
if (count($blocking3pReqs) > 2) {
if (count($blocking3pReqs) > $MetricThresholds['RenderBlockingThirdPartyRequestsCheck']) {
$summary .= "had many";
} elseif (count($blocking3pReqs) > 0) {
$summary .= "had";
Expand All @@ -280,7 +278,7 @@ foreach ($assessment as $key => $cat) {
$genContentSize = floatval($genContentSize);
$genContentPercent = floatval($genContentPercent);

if ($genContentSize > .5 || $genContentPercent > 1) {
if ($genContentSize > $MetricThresholds['RenderBlockingContentSizeCheck'] || $genContentPercent > $MetricThresholds['RenderBlockingContentPercentCheck']) {
$summary .= " Some HTML was generated after delivery, which can cause fragility.";
} else {
$summary .= " HTML content was mostly generated server-side.";
Expand All @@ -299,7 +297,7 @@ foreach ($assessment as $key => $cat) {
} elseif (
$numRecommended > 2
// and it's the quickness category and fcp is reasonably slow
&& ($key !== "Quick" || $key === "Quick" && $fcpCheck > 3 )
&& ($key !== "Quick" || $key === "Quick" && $fcpCheck > 3000 )
&& ($key !== "Resilient" || $key === "Resilient" && $blocking3pReqs > 0 )
&& ($key !== "Usable" || $key === "Usable" && ((isset($cls) && $cls > 0) || (isset($tbtCheck) && $tbtCheck > 2)) )
) {
Expand Down
3 changes: 0 additions & 3 deletions www/include/CrUX.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,13 @@ function InsertCruxHTML($fvRunResults, $metric = '')
InsertCruxMetricHTML($pageData, 'chromeUserTiming.LargestContentfulPaint', 'largest_contentful_paint', 'Largest Contentful Paint', 'LCP');
} elseif ($metric == 'cls') {
InsertCruxMetricHTML($pageData, 'chromeUserTiming.CumulativeLayoutShift', 'cumulative_layout_shift', 'Cumulative Layout Shift', 'CLS');
} elseif ($metric == 'fid') {
InsertCruxMetricHTML($pageData, null, 'first_input_delay', 'First Input Delay', 'FID');
} elseif ($metric == 'ttfb') {
InsertCruxMetricHTML($pageData, 'TTFB', 'experimental_time_to_first_byte', 'Time to First Byte', 'TTFB');
} elseif ($metric == 'inp') {
InsertCruxMetricHTML($pageData, null, 'interaction_to_next_paint', 'Interaction to Next Paint', 'INP');
} elseif ($metric == 'cwv') {
InsertCruxMetricHTML($pageData, 'chromeUserTiming.LargestContentfulPaint', 'largest_contentful_paint', 'Largest Contentful Paint', 'LCP');
InsertCruxMetricHTML($pageData, 'chromeUserTiming.CumulativeLayoutShift', 'cumulative_layout_shift', 'Cumulative Layout Shift', 'CLS');
InsertCruxMetricHTML($pageData, null, 'first_input_delay', 'First Input Delay', 'FID');
}


Expand Down
Loading

0 comments on commit a74f63f

Please sign in to comment.