function getMetrics(lhr) {
  const metricsDetails = lhr.audits['metrics'].details;
  if (!metricsDetails || metricsDetails.type !== 'debugdata' ||
      !metricsDetails.items || !metricsDetails.items[0]) {
    return;
  }
  /** @type {LH.Artifacts.TimingSummary} */
  const metrics = JSON.parse(JSON.stringify(metricsDetails.items[0]));

  // Older versions of Lighthouse don't have max FID on the `metrics` audit, so get
  // it from somewhere else.
  if (!metrics.maxPotentialFID) {
    metrics.maxPotentialFID = lhr.audits['max-potential-fid'].numericValue;
  }

  return metrics;
}
@param {LH.Result} lhr
@return {LH.Artifacts.TimingSummary|undefined}