Add metrics

Summary:
Add some usage and failure rate stats to the PluginInstaller. Small
typo fix and added a helper to the metrics utils to make simple
usage tracking a little more intuitive.

Reviewed By: jknoxville

Differential Revision: D17760511

fbshipit-source-id: 957031d428f3124435925415619b1555a0c2dc2a
This commit is contained in:
Pascal Hartig
2019-10-04 08:25:06 -07:00
committed by Facebook Github Bot
parent a3f7e6aa59
commit ff76b17a5b
2 changed files with 35 additions and 7 deletions

View File

@@ -108,6 +108,19 @@ export function tryCatchReportPlatformFailures<T>(
}
}
/**
* Track usage of a feature.
* @param action Unique name for the action performed. E.g. captureScreenshot
* @param data Optional additional metadata attached to the event.
*/
export function reportUsage(
action: string,
data?: {[key: string]: string},
plugin?: string,
) {
getInstance().track('usage', action, data, plugin);
}
function logPlatformSuccessRate(name: string, result: Result) {
if (result.kind === 'success') {
getInstance().track('success-rate', name, {value: 1});