Detect Flipper reloads, to remove false positives in quick restart detection
Reviewed By: nikoant Differential Revision: D25783368 fbshipit-source-id: 35a9cbbbb5bac4c7b6b7b40c45db2055ff4cfa09
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c460cb767f
commit
cfd1c22814
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ipcRenderer} from 'electron';
|
import {ipcRenderer, remote} from 'electron';
|
||||||
import {performance} from 'perf_hooks';
|
import {performance} from 'perf_hooks';
|
||||||
import {EventEmitter} from 'events';
|
import {EventEmitter} from 'events';
|
||||||
|
|
||||||
@@ -71,10 +71,13 @@ export default (store: Store, logger: Logger) => {
|
|||||||
|
|
||||||
const oldExitData = loadExitData();
|
const oldExitData = loadExitData();
|
||||||
if (oldExitData) {
|
if (oldExitData) {
|
||||||
|
const isReload = remote.process.pid === oldExitData.pid;
|
||||||
const timeSinceLastStartup =
|
const timeSinceLastStartup =
|
||||||
Date.now() - parseInt(oldExitData.lastSeen, 10);
|
Date.now() - parseInt(oldExitData.lastSeen, 10);
|
||||||
logger.track('usage', 'restart', {
|
// console.log(isReload ? 'reload' : 'restart', oldExitData);
|
||||||
|
logger.track('usage', isReload ? 'reload' : 'restart', {
|
||||||
...oldExitData,
|
...oldExitData,
|
||||||
|
pid: undefined,
|
||||||
timeSinceLastStartup,
|
timeSinceLastStartup,
|
||||||
});
|
});
|
||||||
// create fresh exit data
|
// create fresh exit data
|
||||||
@@ -277,6 +280,7 @@ interface ExitData {
|
|||||||
plugin: string;
|
plugin: string;
|
||||||
app: string;
|
app: string;
|
||||||
cleanExit: boolean;
|
cleanExit: boolean;
|
||||||
|
pid: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadExitData(): ExitData | undefined {
|
function loadExitData(): ExitData | undefined {
|
||||||
@@ -317,6 +321,7 @@ export function persistExitData(
|
|||||||
plugin: state.selectedPlugin || '',
|
plugin: state.selectedPlugin || '',
|
||||||
app: state.selectedApp ? deconstructClientId(state.selectedApp).app : '',
|
app: state.selectedApp ? deconstructClientId(state.selectedApp).app : '',
|
||||||
cleanExit,
|
cleanExit,
|
||||||
|
pid: remote.process.pid,
|
||||||
};
|
};
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
flipperExitDataKey,
|
flipperExitDataKey,
|
||||||
|
|||||||
Reference in New Issue
Block a user