Enable desktop crash reporting
Summary: Sends native crash reports for production internal builds. Reviewed By: passy Differential Revision: D15391757 fbshipit-source-id: a4149c2a264eb5ef38fb6f1cc43d52361ac83748
This commit is contained in:
committed by
Facebook Github Bot
parent
d85a357428
commit
841d5d57a2
@@ -20,3 +20,5 @@ export const INSIGHT_INTERN_APP_TOKEN = '';
|
|||||||
|
|
||||||
// Enables the flipper data to be exported through shareabale link
|
// Enables the flipper data to be exported through shareabale link
|
||||||
export const ENABLE_SHAREABLE_LINK = false;
|
export const ENABLE_SHAREABLE_LINK = false;
|
||||||
|
|
||||||
|
export const IS_PUBLIC_BUILD = true;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import dispatcher from './dispatcher/index.js';
|
|||||||
import TooltipProvider from './ui/components/TooltipProvider.js';
|
import TooltipProvider from './ui/components/TooltipProvider.js';
|
||||||
import config from './utils/processConfig.js';
|
import config from './utils/processConfig.js';
|
||||||
import {initLauncherHooks} from './utils/launcher.js';
|
import {initLauncherHooks} from './utils/launcher.js';
|
||||||
|
import initCrashReporter from './utils/electronCrashReporter';
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
const store = createStore(
|
const store = createStore(
|
||||||
@@ -59,6 +60,8 @@ function init() {
|
|||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
|
|
||||||
initLauncherHooks(config(), store);
|
initLauncherHooks(config(), store);
|
||||||
|
const sessionId = store.getState().application.sessionId;
|
||||||
|
initCrashReporter(sessionId || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// make init function callable from outside
|
// make init function callable from outside
|
||||||
|
|||||||
50
src/utils/electronCrashReporter.js
Normal file
50
src/utils/electronCrashReporter.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2018-present Facebook.
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {exists, mkdir} from 'fs';
|
||||||
|
import {promisify} from 'util';
|
||||||
|
import {crashReporter, remote} from 'electron';
|
||||||
|
import isProduction from '../utils/isProduction.js';
|
||||||
|
import {IS_PUBLIC_BUILD} from '../fb-stubs/constants';
|
||||||
|
import {tmpName} from 'tmp';
|
||||||
|
import {resolve} from 'path';
|
||||||
|
|
||||||
|
// Cross platform way to find the /tmp directory or equivalent.
|
||||||
|
// The tempPath set should be persistent across app restarts.
|
||||||
|
const tempPathPromise: Promise<string> = promisify(tmpName)({
|
||||||
|
template: '/tmp/tmp-XXXXXX',
|
||||||
|
}).then(name => resolve(name, '..', 'flipper'));
|
||||||
|
|
||||||
|
export default function initCrashReporter(sessionId: string): Promise<void> {
|
||||||
|
const flipperVersion = remote.app.getVersion();
|
||||||
|
return tempPathPromise.then(tempPath => {
|
||||||
|
return promisify(exists)(tempPath)
|
||||||
|
.then(pathExists => {
|
||||||
|
if (!pathExists) {
|
||||||
|
return promisify(mkdir)(tempPath);
|
||||||
|
}
|
||||||
|
return Promise.resolve();
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
remote.app.setPath('temp', tempPath);
|
||||||
|
const electronCrashReporterArgs = {
|
||||||
|
productName: 'Flipper',
|
||||||
|
companyName: 'Facebook',
|
||||||
|
submitURL: 'https://www.facebook.com/intern/flipper/crash_upload',
|
||||||
|
uploadToServer: isProduction() && !IS_PUBLIC_BUILD,
|
||||||
|
ignoreSystemCrashHandler: true,
|
||||||
|
extra: {
|
||||||
|
flipper_version: flipperVersion,
|
||||||
|
session_id: sessionId,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
remote.crashReporter.start(electronCrashReporterArgs);
|
||||||
|
crashReporter.start(electronCrashReporterArgs);
|
||||||
|
remote.process.crash();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user