Record success rate of screenshot capture
Summary: Android and iOS each have a separate metric Reviewed By: passy Differential Revision: D13763758 fbshipit-source-id: f679360ec0ee008b434bfe12107ac6548d882a1f
This commit is contained in:
committed by
Facebook Github Bot
parent
18d9244b7e
commit
eeb40b5944
@@ -15,6 +15,7 @@ import adb from 'adbkit-fb';
|
|||||||
import {exec, spawn} from 'child_process';
|
import {exec, spawn} from 'child_process';
|
||||||
import {remote} from 'electron';
|
import {remote} from 'electron';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import {recordSuccessMetric} from '../utils/metrics';
|
||||||
|
|
||||||
let CAPTURE_LOCATION = remote.app.getPath('desktop');
|
let CAPTURE_LOCATION = remote.app.getPath('desktop');
|
||||||
try {
|
try {
|
||||||
@@ -125,14 +126,17 @@ class ScreenCaptureButtons extends Component<Props, State> {
|
|||||||
const {selectedDevice} = this.props;
|
const {selectedDevice} = this.props;
|
||||||
|
|
||||||
if (selectedDevice instanceof AndroidDevice) {
|
if (selectedDevice instanceof AndroidDevice) {
|
||||||
return selectedDevice.adb
|
return recordSuccessMetric(
|
||||||
|
selectedDevice.adb
|
||||||
.screencap(selectedDevice.serial)
|
.screencap(selectedDevice.serial)
|
||||||
.then(writePngStreamToFile)
|
.then(writePngStreamToFile)
|
||||||
.then(openFile)
|
.then(openFile),
|
||||||
.catch(console.error);
|
'captureScreenshotAndroid',
|
||||||
|
).catch(console.error);
|
||||||
} else if (selectedDevice instanceof IOSDevice) {
|
} else if (selectedDevice instanceof IOSDevice) {
|
||||||
const screenshotPath = path.join(CAPTURE_LOCATION, getFileName('png'));
|
const screenshotPath = path.join(CAPTURE_LOCATION, getFileName('png'));
|
||||||
return new Promise((resolve, reject) => {
|
return recordSuccessMetric(
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
exec(
|
exec(
|
||||||
`xcrun simctl io booted screenshot "${screenshotPath}"`,
|
`xcrun simctl io booted screenshot "${screenshotPath}"`,
|
||||||
async (err, data) => {
|
async (err, data) => {
|
||||||
@@ -144,7 +148,9 @@ class ScreenCaptureButtons extends Component<Props, State> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
}),
|
||||||
|
'captureScreenshotIos',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user