Remove idb device polling record

Summary:
If listing devices is successful, then don't record the event
as this is triggered every X amount of seconds.

Reviewed By: antonk52

Differential Revision: D47995681

fbshipit-source-id: 2d0fa68fd7b9c4ce74bad9e8cc0296691d9b8880
This commit is contained in:
Lorenzo Blasa
2023-08-11 08:19:51 -07:00
committed by Facebook GitHub Bot
parent 3b99e386a2
commit f93da44ee5

View File

@@ -28,6 +28,7 @@ export type IdbConfig = {
// Use debug to get helpful logs when idb fails // Use debug to get helpful logs when idb fails
const IDB_LOG_LEVEL = 'DEBUG'; const IDB_LOG_LEVEL = 'DEBUG';
const LOG_TAG = 'iOSContainerUtility'; const LOG_TAG = 'iOSContainerUtility';
const CMD_RECORD_THROTTLE_COUNT = 10;
const mutex = new Mutex(); const mutex = new Mutex();
@@ -49,6 +50,10 @@ export type DeviceTarget = {
name: string; name: string;
}; };
let idbDeviceListing = 0;
let idbCompanionDeviceListing = 0;
let xcodeDeviceListing = 0;
async function isAvailable(idbPath: string): Promise<boolean> { async function isAvailable(idbPath: string): Promise<boolean> {
if (!idbPath) { if (!idbPath) {
return false; return false;
@@ -88,12 +93,17 @@ async function queryTargetsWithXcode(
}); });
throw new Error('No output from command'); throw new Error('No output from command');
} }
recorder.event('cmd', {
cmd, xcodeDeviceListing++;
description, if (xcodeDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) {
success: true, recorder.event('cmd', {
context, cmd,
}); description,
success: true,
context,
});
}
return stdout return stdout
.toString() .toString()
.split('\n') .split('\n')
@@ -141,12 +151,15 @@ async function queryTargetsWithIdb(
throw new Error('No output from command'); throw new Error('No output from command');
} }
recorder.event('cmd', { idbDeviceListing++;
cmd, if (idbDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) {
description, recorder.event('cmd', {
success: true, cmd,
context, description,
}); success: true,
context,
});
}
return parseIdbTargets(stdout.toString()); return parseIdbTargets(stdout.toString());
} catch (e) { } catch (e) {
@@ -187,12 +200,15 @@ async function queryTargetsWithIdbCompanion(
throw new Error('No output from command'); throw new Error('No output from command');
} }
recorder.event('cmd', { idbCompanionDeviceListing++;
cmd, if (idbCompanionDeviceListing % CMD_RECORD_THROTTLE_COUNT === 0) {
description, recorder.event('cmd', {
success: true, cmd,
context, description,
}); success: true,
context,
});
}
const devices = parseIdbTargets(stdout.toString()); const devices = parseIdbTargets(stdout.toString());
if (devices.length > 0 && !isPhysicalDeviceEnabled) { if (devices.length > 0 && !isPhysicalDeviceEnabled) {