Improve stats collection for plugins in the background

Summary:
This diff improves two things:
1. Stats are now gathered on every `trackUsage` tick, rather than only when there is a selection
2. The stats now include a delta to compare it with the previous tick

Reviewed By: passy

Differential Revision: D19514231

fbshipit-source-id: 1854c1dc03c63a03db8c7040c185d2629e1b9ea2
This commit is contained in:
Michel Weststrate
2020-01-22 07:08:47 -08:00
committed by Facebook Github Bot
parent c8b9dd949b
commit a3a3db5363
2 changed files with 43 additions and 10 deletions

View File

@@ -13,7 +13,10 @@ import {performance} from 'perf_hooks';
import {Store} from '../reducers/index';
import {Logger} from '../fb-interfaces/Logger';
import Client from '../Client';
import {getPluginBackgroundStats} from '../utils/messageQueue';
import {
getPluginBackgroundStats,
resetPluginBackgroundStatsDelta,
} from '../utils/messageQueue';
import {
clearTimeline,
TrackingEvent,
@@ -90,6 +93,9 @@ export default (store: Store, logger: Logger) => {
}),
);
logger.track('usage', 'plugin-stats', getPluginBackgroundStats());
resetPluginBackgroundStatsDelta();
if (
!state.application.windowIsFocused ||
!selectedDevice ||
@@ -115,7 +121,6 @@ export default (store: Store, logger: Logger) => {
os: selectedDevice.os,
device: selectedDevice.title,
plugin: selectedPlugin,
pluginStats: getPluginBackgroundStats(),
app,
sdkVersion,
isForeground: state.application.windowIsFocused,