Skip to content

Commit

Permalink
Merge pull request #265 from GoogleChrome/attribution-fixes
Browse files Browse the repository at this point in the history
Ensure attribution object is always present in attribution build
  • Loading branch information
philipwalton authored Oct 4, 2022
2 parents 10b5845 + 7a598d1 commit 201b766
Show file tree
Hide file tree
Showing 7 changed files with 829 additions and 748 deletions.
1,494 changes: 786 additions & 708 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,29 +143,29 @@
}
},
"devDependencies": {
"@babel/core": "^7.18.13",
"@babel/preset-env": "^7.18.10",
"@babel/core": "^7.19.3",
"@babel/preset-env": "^7.19.3",
"@rollup/plugin-replace": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^5.34.0",
"@typescript-eslint/parser": "^5.34.0",
"@wdio/cli": "^7.23.0",
"@wdio/local-runner": "^7.23.0",
"@wdio/mocha-framework": "^7.23.0",
"@wdio/selenium-standalone-service": "^7.23.0",
"@wdio/spec-reporter": "^7.23.0",
"@typescript-eslint/eslint-plugin": "^5.38.1",
"@typescript-eslint/parser": "^5.38.1",
"@wdio/cli": "^7.25.1",
"@wdio/local-runner": "^7.25.1",
"@wdio/mocha-framework": "^7.25.1",
"@wdio/selenium-standalone-service": "^7.25.1",
"@wdio/spec-reporter": "^7.25.1",
"body-parser": "^1.20.0",
"chromedriver": "^104.0.0",
"eslint": "^8.22.0",
"chromedriver": "^106.0.1",
"eslint": "^8.24.0",
"eslint-config-google": "^0.14.0",
"express": "^4.18.1",
"fs-extra": "^10.1.0",
"husky": "^8.0.1",
"npm-run-all": "^4.1.5",
"nunjucks": "^3.2.3",
"rollup": "^2.78.1",
"rollup": "^2.79.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.7.4",
"wdio-chromedriver-service": "^7.3.2"
"typescript": "^4.8.4",
"wdio-chromedriver-service": "^8.0.0"
}
}
5 changes: 3 additions & 2 deletions src/attribution/onCLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ const attributeCLS = (metric: CLSMetric): void => {
largestShiftEntry: largestEntry,
loadState: getLoadState(largestEntry.startTime),
};
return;
}
}
} else {
(metric as CLSMetricWithAttribution).attribution = {};
}
// Set an empty object if no other attribution has been set.
(metric as CLSMetricWithAttribution).attribution = {};
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/attribution/onFCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ const attributeFCP = (metric: FCPMetric): void => {
navigationEntry,
fcpEntry,
};
return;
}
} else {
// There are no entries when restored from bfcache.
(metric as FCPMetricWithAttribution).attribution = {
timeToFirstByte: 0,
firstByteToFCP: metric.value,
loadState: getLoadState(getBFCacheRestoreTime()),
};
}
// Set an empty object if no other attribution has been set.
(metric as FCPMetricWithAttribution).attribution = {
timeToFirstByte: 0,
firstByteToFCP: metric.value,
loadState: getLoadState(getBFCacheRestoreTime()),
};
};

/**
Expand Down
5 changes: 3 additions & 2 deletions src/attribution/onINP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ const attributeINP = (metric: INPMetric): void => {
eventEntry: longestEntry,
loadState: getLoadState(longestEntry.startTime),
};
} else {
(metric as INPMetricWithAttribution).attribution = {};
return;
}
// Set an empty object if no other attribution has been set.
(metric as INPMetricWithAttribution).attribution = {};
};

/**
Expand Down
16 changes: 8 additions & 8 deletions src/attribution/onLCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ const attributeLCP = (metric: LCPMetric) => {
}

(metric as LCPMetricWithAttribution).attribution = attribution;
return;
}
} else {
// There are no entries when restored from bfcache.
(metric as LCPMetricWithAttribution).attribution = {
timeToFirstByte: 0,
resourceLoadDelay: 0,
resourceLoadTime: 0,
elementRenderDelay: metric.value,
};
}
// Set an empty object if no other attribution has been set.
(metric as LCPMetricWithAttribution).attribution = {
timeToFirstByte: 0,
resourceLoadDelay: 0,
resourceLoadTime: 0,
elementRenderDelay: metric.value,
};
};

/**
Expand Down
15 changes: 8 additions & 7 deletions src/attribution/onTTFB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ const attributeTTFB = (metric: TTFBMetric): void => {
requestTime: metric.value - requestStart,
navigationEntry: navigationEntry,
};
} else {
(metric as TTFBMetricWithAttribution).attribution = {
waitingTime: 0,
dnsTime: 0,
connectionTime: 0,
requestTime: 0,
};
return;
}
// Set an empty object if no other attribution has been set.
(metric as TTFBMetricWithAttribution).attribution = {
waitingTime: 0,
dnsTime: 0,
connectionTime: 0,
requestTime: 0,
};
};

/**
Expand Down

0 comments on commit 201b766

Please sign in to comment.