Change keys for PageXray assets to use URL instead of array position (#1341)
The keys for assets in PageXray is broken when we send it to Graphite, because we cannot identify which asset we send, instead of the URL we use the position in the array. However: Please don't send all the assets to Graphite, it will fill your disk. Closes #1313 and check #1289
This commit is contained in:
parent
3070c775fe
commit
705d2c854d
|
|
@ -40,7 +40,7 @@ module.exports = {
|
|||
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||
}
|
||||
|
||||
function recursiveFlatten(target, keyPrefix, value) {
|
||||
function recursiveFlatten(target, keyPrefix, value, type) {
|
||||
// super simple version to avoid flatten HAR and screenshot data
|
||||
if (keyPrefix.match(/(screenshots\.|har\.)/)) {
|
||||
return;
|
||||
|
|
@ -58,8 +58,20 @@ module.exports = {
|
|||
if (value === null) {
|
||||
break;
|
||||
}
|
||||
|
||||
Object.keys(value).forEach((key) => {
|
||||
recursiveFlatten(target, joinNonEmpty([keyPrefix, toSafeKey(key)], '.'), value[key]);
|
||||
|
||||
// Hey are you coming to the future from 1980s? Please don't
|
||||
// look at this code, it's a ugly hack to make sure we can send assets
|
||||
// to Graphite and don't send them with array position, instead
|
||||
// use the url to generate the key
|
||||
|
||||
if (type === 'pagexray.pageSummary' && keyPrefix === 'assets') {
|
||||
recursiveFlatten(target, joinNonEmpty([keyPrefix, toSafeKey(value[key].url)], '.'), value[key], type);
|
||||
}
|
||||
else {
|
||||
recursiveFlatten(target, joinNonEmpty([keyPrefix, toSafeKey(key)], '.'), value[key], type);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
|
@ -86,7 +98,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
let retVal = {};
|
||||
recursiveFlatten(retVal, '', message.data);
|
||||
recursiveFlatten(retVal, '', message.data, message.type);
|
||||
return retVal;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue