Output GPSI info in HTML (#1007)

Added simple HTML output for gpsi and send the scrore to Graphite #948
This commit is contained in:
Peter Hedenskog 2016-06-18 15:24:49 +02:00 committed by GitHub
parent 2a07ac067d
commit 04a60f39e8
4 changed files with 41 additions and 3 deletions

View File

@ -5,9 +5,11 @@ var Promise = require('bluebird'),
messageMaker = require('../../support/messageMaker'),
aggregator = require('./aggregator'),
log = require('intel'),
filterRegistry = require('../../support/filterRegistry'),
analyzer = require('./analyzer');
const make = messageMaker('gpsi').make;
const DEFAULT_METRICS_PAGESUMMARY = ['ruleGroups.SPEED.score'];
module.exports = {
name() {
@ -15,6 +17,7 @@ module.exports = {
},
open(context, options) {
this.options = options;
filterRegistry.registerFilterForType(DEFAULT_METRICS_PAGESUMMARY, 'gpsi.pageSummary');
},
processMessage(message, queue) {
switch (message.type) {
@ -25,7 +28,7 @@ module.exports = {
.then((result) => {
log.info('Got ' + url + ' analysed from Google Page Speed Insights');
log.trace('Result from Google Page Speed Insights:%:2j', result);
queue.postMessage(make('gpsi.data', result, {
queue.postMessage(make('gpsi.pageSummary', result, {
url
}))
});
@ -39,8 +42,10 @@ module.exports = {
case 'summarize':
{
queue.postMessage(make('gpsi.speed', aggregator.speedAggregator.summarize()));
queue.postMessage(make('gpsi.summary', aggregator.pageStatsAggregator.summarize()));
// TODO lets implement the summary later, most important is to
// get the score per page
// queue.postMessage(make('gpsi.speed', aggregator.speedAggregator.summarize()));
// queue.postMessage(make('gpsi.summary', aggregator.pageStatsAggregator.summarize()));
}
}
}

View File

@ -0,0 +1,25 @@
a#gpsi
h2 Google Page Speed Insights
h4 Total performance score #{pageInfo.data.gpsi.data.ruleGroups.SPEED.score}
.responsive
table
thead
tr
th Rule name
th Summary
th Impact
tbody
each rule, name in pageInfo.data.gpsi.data.formattedResults.ruleResults
if (rule.ruleImpact > 0)
tr
td(data-title='Name') #{rule.localizedRuleName}
td.url(data-title='Summary') #{rule.summary.format}
//-each block in rule.urlBlocks
//- p #{block.header.format}
//- ul
//- each url in block.urls
//- each args in url
//- li #{args.value}
td(data-title='Impact') #{rule.ruleImpact}

View File

@ -48,3 +48,6 @@ block content
if d.webpagetest
include ./webpagetest/index.pug
if d.gpsi
include ./gpsi/index.pug

View File

@ -175,6 +175,11 @@ module.exports.parseCommandLine = function parseCommandLine() {
describe: 'The API key for you WebPageTest instance.',
group: 'WebPageTest'
})
/** Google Page Speed Insights */
.option('gpsi.key', {
describe: 'The key to use Google Page Speed Insight',
group: 'gpsi'
})
/**
Slack options
*/