Skip to content

Commit

Permalink
Record success rate of screenshot capture
Browse files Browse the repository at this point in the history
Summary: Android and iOS each have a separate metric

Reviewed By: passy

Differential Revision: D13763758

fbshipit-source-id: f679360ec0ee008b434bfe12107ac6548d882a1f
  • Loading branch information
jknoxville authored and facebook-github-bot committed Jan 22, 2019
1 parent 18d9244 commit eeb40b5
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/chrome/ScreenCaptureButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import adb from 'adbkit-fb';
import {exec, spawn} from 'child_process';
import {remote} from 'electron';
import path from 'path';
import {recordSuccessMetric} from '../utils/metrics';

let CAPTURE_LOCATION = remote.app.getPath('desktop');
try {
Expand Down Expand Up @@ -125,26 +126,31 @@ class ScreenCaptureButtons extends Component<Props, State> {
const {selectedDevice} = this.props;
if (selectedDevice instanceof AndroidDevice) {
return selectedDevice.adb
.screencap(selectedDevice.serial)
.then(writePngStreamToFile)
.then(openFile)
.catch(console.error);
return recordSuccessMetric(
selectedDevice.adb
.screencap(selectedDevice.serial)
.then(writePngStreamToFile)
.then(openFile),
'captureScreenshotAndroid',
).catch(console.error);
} else if (selectedDevice instanceof IOSDevice) {
const screenshotPath = path.join(CAPTURE_LOCATION, getFileName('png'));
return new Promise((resolve, reject) => {
exec(
`xcrun simctl io booted screenshot "${screenshotPath}"`,
async (err, data) => {
if (err) {
reject(err);
} else {
openFile(screenshotPath);
resolve();
}
},
);
});
return recordSuccessMetric(
new Promise((resolve, reject) => {
exec(
`xcrun simctl io booted screenshot "${screenshotPath}"`,
async (err, data) => {
if (err) {
reject(err);
} else {
openFile(screenshotPath);
resolve();
}
},
);
}),
'captureScreenshotIos',
);
}
};
Expand Down

0 comments on commit eeb40b5

Please sign in to comment.