Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const conf = {
"browserName": process.env.WTP_BROWSER_NAME_PATH || 'data.median.firstView.browser_name',
"browserVer": process.env.WTP_BROWSER_VER_PATH || 'data.median.firstView.browser_version',
"lcp": process.env.LCP_PATH || "data.median.firstView.largestPaints",
"lcpURL": process.env.LCP_URL_PATH || "data.median.firstView.LargestContentfulPaintImageURL"
"lcpURL": process.env.LCP_URL_PATH || "data.median.firstView.LargestContentfulPaintImageURL",
"pageParts": process.env.PAGE_PARTS || "data.median.firstView.breakdown"
},
timeout: process.env.WTP_TIMEOUT || 30000
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"async": "^3.2.0",
"body-parser": "~1.19.0",
"bytes": "^3.1.0",
"cloudinary": "https://github.com/cloudinary/cloudinary_npm.git#analyze_api_legacy",
"cloudinary": "https://github.com/cloudinary/cloudinary_npm.git#analyze_api",
"config": "^3.3.6",
"cookie-parser": "~1.4.5",
"debug": "~4.3.1",
Expand Down
15 changes: 14 additions & 1 deletion wtp/wtpResultsParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const parseTestResults = (testJson) => {
const screenShot = _.get(testJson, config.get('wtp.paths.screenShot'));
let location = _.get(testJson, config.get('wtp.paths.location'));
const lcp = extractLCP(_.get(testJson, config.get('wtp.paths.lcp')));
const lcpURL = _.get(testJson, config.get('wtp.paths.lcpURL'))
const lcpURL = _.get(testJson, config.get('wtp.paths.lcpURL'));
const weights = getPageWeight(_.get(testJson, config.get('wtp.paths.pageParts')));
if (location && location.indexOf(":") !== -1) {
location = location.split(":")[0];
}
Expand All @@ -77,6 +78,7 @@ const parseTestResults = (testJson) => {
userAgent: userAgent,
lcp: lcp,
lcpURL: lcpURL,
weights: weights,
imageList: {isCut: imageList.length < origLength, origLength:origLength}
}
};
Expand Down Expand Up @@ -131,6 +133,17 @@ const filterByResolution = (imageList) => {
})
};

const getPageWeight = (parts) => {
let totals = {compressed: 0, uncompressed: 0};
if (parts) {
let t = Object.values(parts).reduce((total, p) => {
return {compressed: total.compressed + p.bytes, uncompressed: total.uncompressed + p.bytesUncompressed}
}, totals)
t.images = {compressed: parts.image.bytes, uncompressed: parts.image.bytesUncompressed};
return t;
}
return totals;
}

module.exports = {
parseTestResults: parseTestResults,
Expand Down
37 changes: 22 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,19 @@ cliui@^7.0.2:
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"

"cloudinary@https://github.com/cloudinary/cloudinary_npm.git#analyze_api_legacy":
version "1.9.0"
resolved "https://github.com/cloudinary/cloudinary_npm.git#1df08647e6983b578234282e12754f376a725579"
cloudinary-core@^2.10.2:
version "2.11.4"
resolved "https://registry.yarnpkg.com/cloudinary-core/-/cloudinary-core-2.11.4.tgz#1d191935bcdcd412d499a91b928a94b266fee49d"
integrity sha512-F1BZczD6f5mB73D0c8gl/iuacVQQO+UhckNZxeeS9ZIVeIHbsfqwWiAZMQmIvEb7Wti/9MLU0xVwaWOak2THHA==

"cloudinary@https://github.com/cloudinary/cloudinary_npm.git#analyze_api":
version "1.26.0"
resolved "https://github.com/cloudinary/cloudinary_npm.git#61d3a62c037d31f47f32771f034c91297c8a8e45"
dependencies:
lodash "3.10.x"
q "1.4.x"
cloudinary-core "^2.10.2"
core-js "3.6.5"
lodash "^4.17.11"
q "^1.5.1"

color-convert@^1.9.0, color-convert@^1.9.1:
version "1.9.3"
Expand Down Expand Up @@ -374,6 +381,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==

[email protected]:
version "3.6.5"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.6.5.tgz#7395dc273af37fb2e50e9bd3d9fe841285231d1a"
integrity sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==

[email protected], core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -932,12 +944,7 @@ lodash.merge@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

[email protected]:
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=

lodash@^4.17.20, lodash@^4.17.21:
lodash@^4.17.11, lodash@^4.17.20, lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
Expand Down Expand Up @@ -1173,10 +1180,10 @@ punycode@^2.1.0, punycode@^2.1.1:
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==

q@1.4.x:
version "1.4.1"
resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e"
integrity sha1-VXBbzZPF82c1MMLCy8DCs63cKG4=
q@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=

[email protected]:
version "6.7.0"
Expand Down