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