Track browser connections
Reviewed By: lblasa Differential Revision: D50225630 fbshipit-source-id: 31842fcde494ec05edf2458396d466239397d2c8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
77d67c24db
commit
0e664d274a
@@ -27,6 +27,8 @@ import {
|
|||||||
} from 'flipper-server-companion';
|
} from 'flipper-server-companion';
|
||||||
import {URLSearchParams} from 'url';
|
import {URLSearchParams} from 'url';
|
||||||
import {getFlipperServerConfig} from '../FlipperServerConfig';
|
import {getFlipperServerConfig} from '../FlipperServerConfig';
|
||||||
|
import {tracker} from '../tracker';
|
||||||
|
import {performance} from 'perf_hooks';
|
||||||
|
|
||||||
const safe = (f: () => void) => {
|
const safe = (f: () => void) => {
|
||||||
try {
|
try {
|
||||||
@@ -50,6 +52,14 @@ export function attachSocketServer(
|
|||||||
server: FlipperServerImpl,
|
server: FlipperServerImpl,
|
||||||
companionEnv: FlipperServerCompanionEnv,
|
companionEnv: FlipperServerCompanionEnv,
|
||||||
) {
|
) {
|
||||||
|
const t0 = performance.now();
|
||||||
|
const browserConnectionTimeout = setTimeout(() => {
|
||||||
|
tracker.track('browser-connection-created', {
|
||||||
|
successful: false,
|
||||||
|
timeMS: performance.now() - t0,
|
||||||
|
});
|
||||||
|
}, 20000);
|
||||||
|
|
||||||
socket.on('connection', (client, req) => {
|
socket.on('connection', (client, req) => {
|
||||||
const clientAddress =
|
const clientAddress =
|
||||||
(req.socket.remoteAddress &&
|
(req.socket.remoteAddress &&
|
||||||
@@ -59,6 +69,12 @@ export function attachSocketServer(
|
|||||||
console.log('Client connected', clientAddress);
|
console.log('Client connected', clientAddress);
|
||||||
numberOfConnectedClients++;
|
numberOfConnectedClients++;
|
||||||
|
|
||||||
|
clearTimeout(browserConnectionTimeout);
|
||||||
|
tracker.track('browser-connection-created', {
|
||||||
|
successful: true,
|
||||||
|
timeMS: performance.now() - t0,
|
||||||
|
});
|
||||||
|
|
||||||
let connected = true;
|
let connected = true;
|
||||||
|
|
||||||
let flipperServerCompanion: FlipperServerCompanion | undefined;
|
let flipperServerCompanion: FlipperServerCompanion | undefined;
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ type TrackerEvents = {
|
|||||||
error?: string;
|
error?: string;
|
||||||
};
|
};
|
||||||
'server-socket-already-in-use': {};
|
'server-socket-already-in-use': {};
|
||||||
|
'browser-connection-created': {
|
||||||
|
successful: boolean;
|
||||||
|
timeMS: number;
|
||||||
|
};
|
||||||
'app-connection-created': AppConnectionPayload;
|
'app-connection-created': AppConnectionPayload;
|
||||||
'app-connection-secure-attempt': AppConnectionPayload;
|
'app-connection-secure-attempt': AppConnectionPayload;
|
||||||
'app-connection-insecure-attempt': AppConnectionPayload;
|
'app-connection-insecure-attempt': AppConnectionPayload;
|
||||||
|
|||||||
Reference in New Issue
Block a user