Report versions of plugins and plugin load success rate (#1270)

Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/1270

1) Report versions of loaded plugins so we can track auto-updates
2) Report plugin load success rate

Reviewed By: jknoxville

Differential Revision: D22066598

fbshipit-source-id: 23ef2fb37260438cc1a9a873c88a50b75cd718f4
This commit is contained in:
Anton Nikolaev
2020-06-16 06:43:53 -07:00
committed by Facebook GitHub Bot
parent fec52a3989
commit c995fc8fc2
3 changed files with 74 additions and 25 deletions

View File

@@ -110,6 +110,29 @@ export function tryCatchReportPlatformFailures<T>(
}
}
/*
* Wraps a closure, preserving it's functionality but logging the success or
failure state of it.
*/
export function tryCatchReportPluginFailures<T>(
closure: () => T,
name: string,
plugin: string,
): T {
try {
const result = closure();
logPluginSuccessRate(name, plugin, {kind: 'success'});
return result;
} catch (e) {
logPluginSuccessRate(name, plugin, {
kind: 'failure',
supportedOperation: !(e instanceof UnsupportedError),
error: e,
});
throw e;
}
}
/**
* Track usage of a feature.
* @param action Unique name for the action performed. E.g. captureScreenshot