diff --git a/bin/log-perormance-results.js b/bin/log-perormance-results.js index 0405b69791bdd0..158b51c1fcde25 100755 --- a/bin/log-perormance-results.js +++ b/bin/log-perormance-results.js @@ -6,12 +6,27 @@ const fs = require( 'fs' ); const path = require( 'path' ); const https = require( 'https' ); +const { mapKeys } = require( 'lodash' ); const [ token, branch, hash, baseHash, timestamp ] = process.argv.slice( 2 ); -const performanceResults = JSON.parse( - fs.readFileSync( - path.join( __dirname, '../post-editor-performance-results.json' ), - 'utf8' +const resultsFiles = [ + { + file: 'post-editor-performance-results.json', + metricsPrefix: '', + }, + { + file: 'front-end-block-theme-performance-results.json', + metricsPrefix: 'block-theme-', + }, + { + file: 'front-end-classic-theme-performance-results.json', + metricsPrefix: 'classic-theme-', + }, +]; + +const performanceResults = resultsFiles.map( ( { file } ) => + JSON.parse( + fs.readFileSync( path.join( __dirname, '../' + file ), 'utf8' ) ) ); @@ -21,8 +36,27 @@ const data = new TextEncoder().encode( hash, baseHash, timestamp: parseInt( timestamp, 10 ), - metrics: performanceResults[ hash ], - baseMetrics: performanceResults[ baseHash ], + metrics: resultsFiles.reduce( ( result, { metricsPrefix }, index ) => { + return { + ...result, + ...mapKeys( + performanceResults[ index ][ hash ], + ( _, key ) => metricsPrefix + key + ), + }; + }, {} ), + baseMetrics: resultsFiles.reduce( + ( result, { metricsPrefix }, index ) => { + return { + ...result, + ...mapKeys( + performanceResults[ index ][ baseHash ], + ( _, key ) => metricsPrefix + key + ), + }; + }, + {} + ), } ) );