Call exportState function before exporting metrics

Summary:
This diff fetches the additional data by calling the hook added in each plugins when the headless tries to export metrics directly out of the store rather than from the trace.

I added `fetchMetadata` function which will be called while exporting the state as well as exporting the metrics. We do not need to fetch metadata in the case when the metrics are exported from the given trace.

Reviewed By: passy

Differential Revision: D15560129

fbshipit-source-id: 9b14340e565ce17d1825bc2d32520d7b0c2b2219
This commit is contained in:
Pritesh Nandgaonkar
2019-06-03 15:03:25 -07:00
committed by Facebook Github Bot
parent 023135ad74
commit 95fae7d4e8
3 changed files with 76 additions and 41 deletions

View File

@@ -12,7 +12,7 @@ import yargs from 'yargs';
import dispatcher from '../src/dispatcher/index.js';
import {init as initLogger} from '../src/fb-stubs/Logger.js';
import reducers from '../src/reducers/index.js';
import {exportStore} from '../src/utils/exportData.js';
import {exportStore, pluginsClassMap} from '../src/utils/exportData.js';
import {
exportMetricsWithoutTrace,
exportMetricsFromTrace,
@@ -120,7 +120,10 @@ async function exitActions(
const {metrics, exit} = userArguments;
if (shouldExportMetric(metrics) && metrics && metrics.length > 0) {
try {
const payload = await exportMetricsFromTrace(metrics, store.getState());
const payload = await exportMetricsFromTrace(
metrics,
pluginsClassMap(store.getState()),
);
originalConsole.log(payload);
} catch (error) {
console.error(error);
@@ -133,7 +136,7 @@ async function exitActions(
if (shouldExportMetric(metrics) && !metrics) {
const state = store.getState();
const payload = await exportMetricsWithoutTrace(
state,
store,
state.pluginStates,
);
originalConsole.log(payload);