measure clean versus unclean exits
Summary: This adds another field to the exit data to record whether we had a clean exit where the app was closed as it should. Note that doing a reload inside Flipper will be recorded as an unclean exit. Reviewed By: passy Differential Revision: D20915481 fbshipit-source-id: 240192d7a69bf620bfaa316e3e5cb0f45d6a34cc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
41a911379d
commit
220052d70d
@@ -54,6 +54,20 @@ export default (store: Store, logger: Logger) => {
|
|||||||
...oldExitData,
|
...oldExitData,
|
||||||
timeSinceLastStartup,
|
timeSinceLastStartup,
|
||||||
});
|
});
|
||||||
|
// create fresh exit data
|
||||||
|
const {
|
||||||
|
selectedDevice,
|
||||||
|
selectedApp,
|
||||||
|
selectedPlugin,
|
||||||
|
} = store.getState().connections;
|
||||||
|
persistExitData(
|
||||||
|
{
|
||||||
|
selectedDevice,
|
||||||
|
selectedApp,
|
||||||
|
selectedPlugin,
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function droppedFrameDetection(
|
function droppedFrameDetection(
|
||||||
@@ -81,7 +95,7 @@ export default (store: Store, logger: Logger) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcRenderer.on('trackUsage', () => {
|
ipcRenderer.on('trackUsage', (_e, ...args: any[]) => {
|
||||||
const state = store.getState();
|
const state = store.getState();
|
||||||
const {
|
const {
|
||||||
selectedDevice,
|
selectedDevice,
|
||||||
@@ -90,7 +104,10 @@ export default (store: Store, logger: Logger) => {
|
|||||||
clients,
|
clients,
|
||||||
} = state.connections;
|
} = state.connections;
|
||||||
|
|
||||||
persistExitData({selectedDevice, selectedPlugin, selectedApp});
|
persistExitData(
|
||||||
|
{selectedDevice, selectedPlugin, selectedApp},
|
||||||
|
args[0] === 'exit',
|
||||||
|
);
|
||||||
|
|
||||||
const currentTime = Date.now();
|
const currentTime = Date.now();
|
||||||
const usageSummary = computeUsageSummary(state.usageTracking, currentTime);
|
const usageSummary = computeUsageSummary(state.usageTracking, currentTime);
|
||||||
@@ -220,6 +237,7 @@ interface ExitData {
|
|||||||
deviceTitle: string;
|
deviceTitle: string;
|
||||||
plugin: string;
|
plugin: string;
|
||||||
app: string;
|
app: string;
|
||||||
|
cleanExit: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadExitData(): ExitData | undefined {
|
function loadExitData(): ExitData | undefined {
|
||||||
@@ -229,7 +247,11 @@ function loadExitData(): ExitData | undefined {
|
|||||||
const data = window.localStorage.getItem(flipperExitDataKey);
|
const data = window.localStorage.getItem(flipperExitDataKey);
|
||||||
if (data) {
|
if (data) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(data);
|
const res = JSON.parse(data);
|
||||||
|
if (res.cleanExit === undefined) {
|
||||||
|
res.cleanExit = true; // avoid skewing results for historical data where this info isn't present
|
||||||
|
}
|
||||||
|
return res;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('Failed to parse flipperExitData', e);
|
console.warn('Failed to parse flipperExitData', e);
|
||||||
}
|
}
|
||||||
@@ -237,11 +259,14 @@ function loadExitData(): ExitData | undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function persistExitData(state: {
|
export function persistExitData(
|
||||||
|
state: {
|
||||||
selectedDevice: BaseDevice | null;
|
selectedDevice: BaseDevice | null;
|
||||||
selectedPlugin: string | null;
|
selectedPlugin: string | null;
|
||||||
selectedApp: string | null;
|
selectedApp: string | null;
|
||||||
}) {
|
},
|
||||||
|
cleanExit: boolean,
|
||||||
|
) {
|
||||||
if (!window.localStorage) {
|
if (!window.localStorage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -252,6 +277,7 @@ export function persistExitData(state: {
|
|||||||
deviceTitle: state.selectedDevice ? state.selectedDevice.title : '',
|
deviceTitle: state.selectedDevice ? state.selectedDevice.title : '',
|
||||||
plugin: state.selectedPlugin || '',
|
plugin: state.selectedPlugin || '',
|
||||||
app: state.selectedApp ? deconstructClientId(state.selectedApp).app : '',
|
app: state.selectedApp ? deconstructClientId(state.selectedApp).app : '',
|
||||||
|
cleanExit,
|
||||||
};
|
};
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
flipperExitDataKey,
|
flipperExitDataKey,
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ function tryCreateWindow() {
|
|||||||
});
|
});
|
||||||
win.once('ready-to-show', () => win.show());
|
win.once('ready-to-show', () => win.show());
|
||||||
win.once('close', () => {
|
win.once('close', () => {
|
||||||
win.webContents.send('trackUsage');
|
win.webContents.send('trackUsage', 'exit');
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
// Removes as a default protocol for debug builds. Because even when the
|
// Removes as a default protocol for debug builds. Because even when the
|
||||||
// production application is installed, and one tries to deeplink through
|
// production application is installed, and one tries to deeplink through
|
||||||
|
|||||||
Reference in New Issue
Block a user