diff --git a/lib/plugins/browsertime/index.js b/lib/plugins/browsertime/index.js index 1d14fd393..60a5ad863 100644 --- a/lib/plugins/browsertime/index.js +++ b/lib/plugins/browsertime/index.js @@ -289,6 +289,12 @@ module.exports = { run.description = result[resultIndex].info.description; } + if (result[resultIndex].info.android) { + run.android = result[resultIndex].info.android; + run.android.batteryTemperature = + result[resultIndex].android.batteryTemperature[runIndex]; + } + run.timestamp = dayjs( result[resultIndex].timestamps[runIndex] ).format(TIME_FORMAT); diff --git a/lib/plugins/html/htmlBuilder.js b/lib/plugins/html/htmlBuilder.js index fc2203702..83ac3b47f 100644 --- a/lib/plugins/html/htmlBuilder.js +++ b/lib/plugins/html/htmlBuilder.js @@ -168,36 +168,10 @@ class HTMLBuilder { coach: coachData }; - const summaryRenders = Object.keys(this.summary).map(name => - this._renderSummaryPage( - name, - merge( - { - options, - noPages: dataCollector.getURLs().length, - css, - h: helpers, - rootPath: '', - assetsPath: assetsBaseURL || '', - menu: name, - pageTitle: name, - pageDescription: '', - headers: this.summary, - version: packageInfo.version, - timestamp: this.timestamp, - context: this.context, - get, - friendlyNames, - html: { - pageSummaryMetrics: toArray(options.html.pageSummaryMetrics) - } - }, - dataCollector.getSummary(name), - this.summary[name] - ) - ) - ); - + let browser; + let android; + let usingBrowsertime; + let usingWebPageTest; const urlPageRenders = []; let pageNumber = 0; const testedPages = Object.keys(validPages).length; @@ -210,8 +184,11 @@ class HTMLBuilder { const harIndex = pageNumber + (medianRun.runIndex - 1) * testedPages; let summaryPageHAR = get(pageInfo, 'data.browsertime.har'); pageNumber++; + // In the future we can fix so we just pickup the setup messages + usingBrowsertime = pageInfo.data.browsertime; + usingWebPageTest = pageInfo.data.webpagetest; // if we don't use Browsertime, we don't get the browser version - const browser = summaryPageHAR + browser = summaryPageHAR ? { name: summaryPageHAR.log.browser.name, version: summaryPageHAR.log.browser.version @@ -220,6 +197,8 @@ class HTMLBuilder { name: '', version: '' }; + android = get(pageInfo, 'data.browsertime.pageSummary.info.android'); + // if we are on the summary page we inline the HAR and then make sure // we only pick one HAR run (medianRun). But you can also choose to // fetch the HAR in the HTML, then it isn't included. @@ -278,6 +257,7 @@ class HTMLBuilder { summaryPageHAR, medianRun, browser, + android, hasScreenShots: dataCollector.browsertimeScreenshots, screenShotType: dataCollector.browsertimeScreenshotsType, css, @@ -344,6 +324,7 @@ class HTMLBuilder { options, runPages, browser, + android, hasScreenShots: dataCollector.browsertimeScreenshots, screenShotType: dataCollector.browsertimeScreenshotsType, css, @@ -378,6 +359,41 @@ class HTMLBuilder { } } + // do this late so we can pickup data (browser/android etc) + const summaryRenders = Object.keys(this.summary).map(name => + this._renderSummaryPage( + name, + merge( + { + options, + noPages: dataCollector.getURLs().length, + css, + h: helpers, + rootPath: '', + assetsPath: assetsBaseURL || '', + menu: name, + pageTitle: name, + pageDescription: '', + browser, + android, + usingBrowsertime, + usingWebPageTest, + headers: this.summary, + version: packageInfo.version, + timestamp: this.timestamp, + context: this.context, + get, + friendlyNames, + html: { + pageSummaryMetrics: toArray(options.html.pageSummaryMetrics) + } + }, + dataCollector.getSummary(name), + this.summary[name] + ) + ) + ); + let res; if (this.options.html.assetsBaseURL) { res = Promise.resolve(); diff --git a/lib/plugins/html/templates/detailed.pug b/lib/plugins/html/templates/detailed.pug index b9e05aa57..b680e6ff4 100644 --- a/lib/plugins/html/templates/detailed.pug +++ b/lib/plugins/html/templates/detailed.pug @@ -3,27 +3,27 @@ include _tableMixins block content include runInfo - .responsive - table(data-sortable, id='detailed') - thead + .responsive + table(data-sortable, id='detailed') + thead + tr + th name + th min + th median + th mean + th p90 + th max + each metric in metrics + if metric.node && metric.node.min tr - th name - th min - th median - th mean - th p90 - th max - each metric in metrics - if metric.node && metric.node.min - tr - td(data-title='Metric', data-value=metric.name) - if (metric.metricName) - - url = 'help.html#' + metric.metricName - a(href=url) #{metric.name} - else - | #{metric.name} - td(data-title='min', data-value=metric.node.min) #{metric.h(metric.node.min)} - td(data-title='median', data-value=metric.node.median) #{metric.h(metric.node.median)} - td(data-title='mean', data-value=metric.node.mean) #{metric.h(metric.node.mean)} - td(data-title='p90', data-value=metric.node.p90) #{metric.h(metric.node.p90)} - td(data-title='max', data-value=metric.node.max) #{metric.h(metric.node.max)} + td(data-title='Metric', data-value=metric.name) + if (metric.metricName) + - url = 'help.html#' + metric.metricName + a(href=url) #{metric.name} + else + | #{metric.name} + td(data-title='min', data-value=metric.node.min) #{metric.h(metric.node.min)} + td(data-title='median', data-value=metric.node.median) #{metric.h(metric.node.median)} + td(data-title='mean', data-value=metric.node.mean) #{metric.h(metric.node.mean)} + td(data-title='p90', data-value=metric.node.p90) #{metric.h(metric.node.p90)} + td(data-title='max', data-value=metric.node.max) #{metric.h(metric.node.max)} diff --git a/lib/plugins/html/templates/runInfo.pug b/lib/plugins/html/templates/runInfo.pug index 678a891b1..561481021 100644 --- a/lib/plugins/html/templates/runInfo.pug +++ b/lib/plugins/html/templates/runInfo.pug @@ -1,17 +1,26 @@ +h2.url #{h.plural(noPages,'page')} analysed for #{options.name ? options.name : h.short(context.name, 30)} -- const profile = options.mobile ? 'mobile' : 'desktop' -- const connectivity = options.browsertime.connectivity.alias || options.browsertime.connectivity.profile - h2.url #{h.plural(noPages,'page')} analysed for #{options.name ? options.name : h.short(context.name, 30)} - p.small Tested #{timestamp} using #{h.cap(options.browsertime.browser)} for - | #{ h.get(options, 'browsertime.chrome.android.package') ? h.get(options, 'browsertime.chrome.android.package') + ' ': ''} - | #{options.preURL ? 'preURL ' + h.short(options.preURL, 60) + ' ' : ''} - | #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{connectivity}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode.' : ''} - | #{options.chrome && options.chrome.CPUThrottlingRate ? ' CPU Throttle Rate ' + options.chrome.CPUThrottlingRate + '.':''} +if usingBrowsertime + - const profile = options.mobile ? 'mobile' : 'desktop' + - const connectivity = options.browsertime.connectivity.alias || options.browsertime.connectivity.profile + - const browserName = h.get(browser,'name'); + - const browserVersion = h.get(browser,'version'); + - const androidModel = h.get(android,'model'); + - const androidVersion = h.get(android,'androidVersion'); + p.small Tested #{timestamp} using #{h.cap(browserName || options.browsertime.browser)} #{browserVersion} + if (androidModel) + |  #{androidModel} (Android version #{androidVersion}) + | . if (options.safari && options.safari.deviceType) | Testing using an #{options.safari.deviceType}. + | #{options.preURL ? ' preURL ' + h.short(options.preURL, 60) + ' ' : ''} + | #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{connectivity}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode.' : ''} + | #{options.chrome && options.chrome.CPUThrottlingRate ? ' CPU Throttle Rate ' + options.chrome.CPUThrottlingRate + '.':''} if options.multi && options.html.showScript | ( a(href= rootPath + 'scripts.html')= 'script' | ). - else if options.multi | . + +else if usingWebPageTest + p.small Tested #{timestamp} using WebPageTest #{options.webpagetest.location} using connectivity #{options.webpagetest.connectivity} for #{h.plural(options.webpagetest.runs, 'run')}. diff --git a/lib/plugins/html/templates/url/includes/pageRunInfo.pug b/lib/plugins/html/templates/url/includes/pageRunInfo.pug index 00d994330..4cf75c1e3 100644 --- a/lib/plugins/html/templates/url/includes/pageRunInfo.pug +++ b/lib/plugins/html/templates/url/includes/pageRunInfo.pug @@ -1,16 +1,29 @@ -- const profile = options.mobile ? 'mobile' : 'desktop' -- const runTime = h.get(pageInfo, 'pageInfo.data.browsertime.run.timestamp', timestamp) -- const connectivity = options.browsertime.connectivity.alias || options.browsertime.connectivity.profile -p.small Tested #{runTime} using #{h.cap(options.browsertime.browser)} #{browser.version} for - | #{ h.get(options, 'browsertime.chrome.android.package') ? ' ' + h.get(options, 'browsertime.chrome.android.package') + ' ': ''} - | #{options.preURL ? 'preURL ' + h.short(options.preURL, 60) + ' ': ''} - | #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{connectivity}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode.' : ''} - | #{options.chrome && options.chrome.CPUThrottlingRate ? ' CPU Throttle Rate ' + options.chrome.CPUThrottlingRate + '.':''} - if (options.safari && options.safari.deviceType) - | Testing using an #{options.safari.deviceType}. - if options.multi && options.html.showScript - | ( - a(href= rootPath + 'scripts.html')= 'script' - | ). - else if options.multi +if pageInfo.data.browsertime + - const profile = options.mobile ? 'mobile' : 'desktop' + - const runTime = h.get(pageInfo, 'pageInfo.data.browsertime.run.timestamp', timestamp) + - const android = pageInfo.data.browsertime.run ? pageInfo.data.browsertime.run.android : pageInfo.data.browsertime.pageSummary.info.android + - const browserName = h.get(browser,'name'); + - const browserVersion = h.get(browser,'version',''); + - const androidModel = h.get(android,'model',''); + - const androidVersion = h.get(android,'androidVersion',''); + - const connectivity = options.browsertime.connectivity.alias || options.browsertime.connectivity.profile + p.small Tested #{runTime} using #{h.cap(browserName || options.browsertime.browser)} #{browser.version} + if (androidModel) + |  #{androidModel} (Android version #{androidVersion}) + if pageInfo.data.browsertime && pageInfo.data.browsertime.run && pageInfo.data.browsertime.run.android + |  with battery temperature #{pageInfo.data.browsertime.run.android.batteryTemperature.start}℃ | . + if (options.safari && options.safari.deviceType) + | Testing using an #{options.safari.deviceType}. + | #{options.preURL ? ' preURL ' + h.short(options.preURL, 60) + ' ': ''} + | #{h.plural(options.browsertime.iterations, 'run')} with #{profile} profile and connectivity #{connectivity}.#{ options.replay ? ' Using WebPageReplay.' : ''}#{ options.multi ? ' Using multi mode.' : ''} + | #{options.chrome && options.chrome.CPUThrottlingRate ? ' CPU Throttle Rate ' + options.chrome.CPUThrottlingRate + '.':''} + if options.multi && options.html.showScript + | ( + a(href= rootPath + 'scripts.html')= 'script' + | ). + else if options.multi + | . + +else if pageInfo.data.webpagetest + p.small Tested #{timestamp} using WebPageTest #{options.webpagetest.location} using connectivity #{options.webpagetest.connectivity} for #{h.plural(options.webpagetest.runs, 'run')}. diff --git a/lib/plugins/webpagetest/analyzer.js b/lib/plugins/webpagetest/analyzer.js index fc84dd75b..61c0a4672 100644 --- a/lib/plugins/webpagetest/analyzer.js +++ b/lib/plugins/webpagetest/analyzer.js @@ -52,6 +52,8 @@ module.exports = { } if ( + data.data.median && + data.data.median.firstView && data.data.median.firstView.numSteps && data.data.median.firstView.numSteps > 1 ) {