build(analytics): track bundle size
This will send bundle sizes (before and after gzip) to Google Analytics so that we can track bundle size over time for every bundle we produce. Closes #5294
This commit is contained in:
@ -99,7 +99,7 @@ function getDartVersion() {
|
||||
}
|
||||
|
||||
|
||||
function recordEvent(eventType, actionCategory, actionName, duration) {
|
||||
function recordEvent(eventType, actionCategory, actionName, duration, label) {
|
||||
// if universal-analytics is not yet installed, don't bother doing anything (e.g. when tracking initial npm install)
|
||||
// build-analytics will however store the starting timestamp, so at least we can record the success/error event with duration
|
||||
if (!ua) return;
|
||||
@ -111,19 +111,19 @@ function recordEvent(eventType, actionCategory, actionName, duration) {
|
||||
switch (eventType) {
|
||||
case 'start':
|
||||
visitor.
|
||||
event(actionCategory, actionName + ' (start)', 'testLabel', null, customParams).
|
||||
event(actionCategory, actionName + ' (start)', label, null, customParams).
|
||||
send();
|
||||
break;
|
||||
case 'success':
|
||||
visitor.
|
||||
event(actionCategory, actionName, 'testLabel', duration, customParams).
|
||||
timing(actionCategory, actionName, duration, customParams).
|
||||
event(actionCategory, actionName, label, duration, customParams).
|
||||
timing(actionCategory, actionName, duration, label, customParams).
|
||||
send();
|
||||
break;
|
||||
case 'error':
|
||||
visitor.
|
||||
event(actionCategory, actionName + ' (errored)', 'testLabel', duration, customParams).
|
||||
timing(actionCategory, actionName, duration, customParams).
|
||||
event(actionCategory, actionName + ' (errored)', label, duration, customParams).
|
||||
timing(actionCategory, actionName, duration, label, customParams).
|
||||
send();
|
||||
break;
|
||||
default:
|
||||
@ -168,5 +168,9 @@ module.exports = {
|
||||
|
||||
ciError: (actionName, duration) => {
|
||||
recordEvent('success', 'ci', actionName, duration);
|
||||
},
|
||||
|
||||
bundleSize: (filePath, sizeInBytes, compressionLevel) => {
|
||||
recordEvent('success', 'payload', compressionLevel, sizeInBytes, filePath);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user