From 4eca8d1088b2833f5831e363447fa694364f63f6 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Fri, 27 May 2022 02:37:53 -0700 Subject: [PATCH] Add isHeadlessBuild to EnvironmentInfo Summary: Allows to attribute errors to flipper server or flipper electron Reviewed By: passy Differential Revision: D36698504 fbshipit-source-id: 6d07216fd05aa48b7c8cca5b53145916b64526eb --- desktop/app/src/init.tsx | 6 +++++- desktop/flipper-common/src/settings.tsx | 1 + desktop/flipper-dump/src/index.tsx | 2 +- desktop/flipper-server-core/src/utils/environmentInfo.tsx | 2 ++ desktop/flipper-server/src/startFlipperServer.tsx | 2 +- desktop/scripts/jest-setup-after.tsx | 1 + 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/desktop/app/src/init.tsx b/desktop/app/src/init.tsx index 66325b6ff..686eff79e 100644 --- a/desktop/app/src/init.tsx +++ b/desktop/app/src/init.tsx @@ -51,7 +51,11 @@ async function getEmbeddedFlipperServer( const staticPath = getStaticDir(); const isProduction = !/node_modules[\\/]electron[\\/]/.test(execPath); const env = process.env; - const environmentInfo = await getEnvironmentInfo(staticPath, isProduction); + const environmentInfo = await getEnvironmentInfo( + staticPath, + isProduction, + false, + ); let keytar: any = undefined; try { diff --git a/desktop/flipper-common/src/settings.tsx b/desktop/flipper-common/src/settings.tsx index a97f74dd5..dd6264e1f 100644 --- a/desktop/flipper-common/src/settings.tsx +++ b/desktop/flipper-common/src/settings.tsx @@ -104,6 +104,7 @@ export type Platform = export type EnvironmentInfo = { processId: number; isProduction: boolean; + isHeadlessBuild: boolean; releaseChannel: ReleaseChannel; flipperReleaseRevision?: string; appVersion: string; diff --git a/desktop/flipper-dump/src/index.tsx b/desktop/flipper-dump/src/index.tsx index b1fd2be0e..4b9738293 100644 --- a/desktop/flipper-dump/src/index.tsx +++ b/desktop/flipper-dump/src/index.tsx @@ -85,7 +85,7 @@ async function start(deviceQuery: string, appName: string, pluginId: string) { console.debug = () => {}; console.info = console.error; - const environmentInfo = await getEnvironmentInfo(staticPath, false); + const environmentInfo = await getEnvironmentInfo(staticPath, false, true); // TODO: initialise FB user manager to be able to do certificate exchange const server = new FlipperServerImpl( diff --git a/desktop/flipper-server-core/src/utils/environmentInfo.tsx b/desktop/flipper-server-core/src/utils/environmentInfo.tsx index 89311a932..f6368c783 100644 --- a/desktop/flipper-server-core/src/utils/environmentInfo.tsx +++ b/desktop/flipper-server-core/src/utils/environmentInfo.tsx @@ -16,6 +16,7 @@ import {EnvironmentInfo, ReleaseChannel} from 'flipper-common'; export async function getEnvironmentInfo( packageJsonDir: string, isProduction: boolean, + isHeadlessBuild: boolean, ): Promise { const packageJson = await fs.readJSON( path.resolve(packageJsonDir, 'package.json'), @@ -41,6 +42,7 @@ export async function getEnvironmentInfo( return { processId: process.pid, isProduction, + isHeadlessBuild, releaseChannel, flipperReleaseRevision, appVersion, diff --git a/desktop/flipper-server/src/startFlipperServer.tsx b/desktop/flipper-server/src/startFlipperServer.tsx index a3371747b..92cfa23be 100644 --- a/desktop/flipper-server/src/startFlipperServer.tsx +++ b/desktop/flipper-server/src/startFlipperServer.tsx @@ -75,7 +75,7 @@ export async function startFlipperServer( console.error('Failed to load keytar:', e); } - const environmentInfo = await getEnvironmentInfo(appPath, isProduction); + const environmentInfo = await getEnvironmentInfo(appPath, isProduction, true); return new FlipperServerImpl( { diff --git a/desktop/scripts/jest-setup-after.tsx b/desktop/scripts/jest-setup-after.tsx index af92fa4e0..3122705ad 100644 --- a/desktop/scripts/jest-setup-after.tsx +++ b/desktop/scripts/jest-setup-after.tsx @@ -101,6 +101,7 @@ function createStubRenderHost(): RenderHost { processId: process.pid, appVersion: '0.0.0', isProduction: false, + isHeadlessBuild: false, releaseChannel: ReleaseChannel.DEFAULT, flipperReleaseRevision: '000', os: {