Files
flipper/desktop/flipper-server-core/src/utils/tracker.tsx
Lorenzo Blasa 0db4e99aff Track bootstrap diagnostics
Summary:
^

In addition to logging to the console bootstrap performance metrics, track these events to scuba as well.

Reviewed By: aigoncharov

Differential Revision: D46648876

fbshipit-source-id: 191704c13158884bb8cfbca614a23f2a64f1fd93
2023-06-13 02:45:57 -07:00

63 lines
1.7 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {getLogger, CertificateExchangeMedium} from 'flipper-common';
type AppConnectionPayload = {
app: string;
os: string;
device: string;
device_id: string;
medium?: CertificateExchangeMedium;
};
type AppConnectionCertificateExchangePayload = AppConnectionPayload & {
successful: boolean;
error?: string;
};
type ServerBootstrapPerformancePayload = {
loggerInitializedMS: number;
keytarLoadedMS: number;
runningInstanceShutdownMS: number;
httpServerStartedMS: number;
serverCreatedMS: number;
companionEnvironmentInitializedMS: number;
appServerStartedMS: number;
developmentServerAttachedMS: number;
serverStartedMS: number;
};
type TrackerEvents = {
'server-bootstrap-performance': ServerBootstrapPerformancePayload;
'server-started': {port: number; tcp: boolean};
'server-auth-token-verification': {
successful: boolean;
present: boolean;
error?: string;
};
'server-socket-already-in-use': {};
'server-proxy-error': {error: string};
'app-connection-created': AppConnectionPayload;
'app-connection-secure-attempt': AppConnectionPayload;
'app-connection-insecure-attempt': AppConnectionPayload;
'app-connection-certificate-exchange': AppConnectionCertificateExchangePayload;
};
class ServerCoreTracker {
track<Event extends keyof TrackerEvents>(
event: Event,
payload: TrackerEvents[Event],
): void {
getLogger().track('usage', event, payload);
}
}
export const tracker = new ServerCoreTracker();