|
| 1 | +// Load environment variables |
| 2 | +const dotenv = require('dotenv'); |
| 3 | +dotenv.config(); |
| 4 | + |
1 | 5 | // dependencies
|
2 | 6 | const lighthouse = require('lighthouse');
|
3 | 7 | const chrome_launcher = require('chrome-launcher');
|
4 | 8 | const db = require('./database');
|
5 | 9 | const fs = require('fs');
|
6 | 10 | const path = require('path');
|
7 | 11 | const neat_csv = require('neat-csv');
|
8 |
| -const dotenv = require('dotenv'); |
9 |
| - |
10 |
| -// Load environment variables |
11 |
| -dotenv.config(); |
12 | 12 |
|
13 | 13 | // Is this a recurring report or no?
|
14 | 14 | let should_repeat = false;
|
@@ -41,7 +41,7 @@ if (should_repeat) {
|
41 | 41 | if (isNaN(auto_report_interval) || isNaN(auto_report_lifetime) ||
|
42 | 42 | auto_report_interval < 1 || auto_report_lifetime < 1) {
|
43 | 43 | console.log('$$$Sorry, please check your input.');
|
44 |
| - return; |
| 44 | + process.exit(1); |
45 | 45 | }
|
46 | 46 |
|
47 | 47 | if (should_repeat) {
|
@@ -116,6 +116,10 @@ async function parseReportAndStore (url, template, report) {
|
116 | 116 | const time_to_interactive = report['audits']['interactive']['numericValue'];
|
117 | 117 | const first_meaningful_paint = report['audits']['first-meaningful-paint']['numericValue'];
|
118 | 118 | const first_cpu_idle = report['audits']['first-cpu-idle']['numericValue'];
|
| 119 | + const largest_contentful_paint = report['audits']['largest-contentful-paint']['numericValue']; |
| 120 | + const cumulative_layout_shift = report['audits']['cumulative-layout-shift']['numericValue']; |
| 121 | + const total_blocking_time = report['audits']['total-blocking-time']['numericValue']; |
| 122 | + const speed_index = report['audits']['speed-index']['numericValue']; |
119 | 123 |
|
120 | 124 | // These are lists and will have to be iterated
|
121 | 125 | const network_resources = report['audits']['network-requests']['details']['items'];
|
@@ -252,10 +256,14 @@ async function parseReportAndStore (url, template, report) {
|
252 | 256 | max_potential_fid,
|
253 | 257 | time_to_interactive,
|
254 | 258 | first_meaningful_paint,
|
255 |
| - first_cpu_idle |
| 259 | + first_cpu_idle, |
| 260 | + largest_contentful_paint, |
| 261 | + cumulative_layout_shift, |
| 262 | + total_blocking_time, |
| 263 | + speed_index |
256 | 264 | )
|
257 | 265 | VALUES (
|
258 |
| - $1, $2, $3, $4, $5, $6, $7, $8, $9 |
| 266 | + $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13 |
259 | 267 | )`;
|
260 | 268 |
|
261 | 269 | const resource_chart_query_text = `INSERT INTO resource_chart (
|
@@ -311,7 +319,11 @@ async function parseReportAndStore (url, template, report) {
|
311 | 319 | max_potential_fid,
|
312 | 320 | time_to_interactive,
|
313 | 321 | first_meaningful_paint,
|
314 |
| - first_cpu_idle |
| 322 | + first_cpu_idle, |
| 323 | + largest_contentful_paint, |
| 324 | + cumulative_layout_shift, |
| 325 | + total_blocking_time, |
| 326 | + speed_index |
315 | 327 | ];
|
316 | 328 |
|
317 | 329 | // Execute the queries
|
@@ -444,7 +456,6 @@ async function doAutomaticReporting () {
|
444 | 456 | console.log('Done automatically reporting!');
|
445 | 457 |
|
446 | 458 | db.disconnect();
|
447 |
| - return; |
448 | 459 | }
|
449 | 460 |
|
450 | 461 | // Let's get started
|
|
0 commit comments