Track session length

Differential Revision: D51172955

fbshipit-source-id: d4f93564a94e232066347c945fa4798033dc0da1
This commit is contained in:
Andrey Goncharov
2023-11-09 14:34:52 -08:00
committed by Facebook GitHub Bot
parent 8ef29c8160
commit 6e19c4155c
2 changed files with 5 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ import {
import {URLSearchParams} from 'url';
import {tracker} from '../tracker';
import {getFlipperServerConfig} from '../FlipperServerConfig';
import {performance} from 'perf_hooks';
const safe = (f: () => void) => {
try {
@@ -53,6 +54,8 @@ export function attachSocketServer(
companionEnv: FlipperServerCompanionEnv,
) {
socket.on('connection', (client, req) => {
const t0 = performance.now();
const clientAddress =
(req.socket.remoteAddress &&
` ${req.socket.remoteAddress}:${req.socket.remotePort}`) ||
@@ -246,6 +249,7 @@ export function attachSocketServer(
tracker.track('server-client-close', {
code,
error,
sessionLength: performance.now() - t0,
});
if (