Crashreporter Plugin
Summary: Desktop side of Crash reporter plugin Reviewed By: jknoxville Differential Revision: D13176724 fbshipit-source-id: d77b86b2bd9c78c0626f2e3b8c0057227d75e2b2
This commit is contained in:
committed by
Facebook Github Bot
parent
19485d076b
commit
543bc6c4fb
10457
package-lock.json
generated
Normal file
10457
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
74
src/plugins/crash_reporter/index.js
Normal file
74
src/plugins/crash_reporter/index.js
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @flow
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {FlipperPlugin} from 'flipper';
|
||||||
|
import type {Notification} from '../../plugin';
|
||||||
|
|
||||||
|
type Crash = {|
|
||||||
|
notificationID: number,
|
||||||
|
callStack: [string],
|
||||||
|
reason: string,
|
||||||
|
name: string,
|
||||||
|
|};
|
||||||
|
type PersistedState = {|
|
||||||
|
crashes: Array<Crash>,
|
||||||
|
|};
|
||||||
|
|
||||||
|
export default class extends FlipperPlugin {
|
||||||
|
static title = 'Crash Reporter';
|
||||||
|
static id = 'CrashReporter';
|
||||||
|
static icon = 'apps';
|
||||||
|
|
||||||
|
static defaultPersistedState = {
|
||||||
|
crashes: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reducer to process incoming "send" messages from the mobile counterpart.
|
||||||
|
*/
|
||||||
|
static persistedStateReducer = (
|
||||||
|
persistedState: PersistedState,
|
||||||
|
method: string,
|
||||||
|
payload: Object,
|
||||||
|
): PersistedState => {
|
||||||
|
if (method === 'crash-report') {
|
||||||
|
return {
|
||||||
|
...persistedState,
|
||||||
|
crashes: persistedState.crashes.concat([
|
||||||
|
{
|
||||||
|
notificationID: Math.random(), // All notifications are unique
|
||||||
|
callStack: payload.callstack,
|
||||||
|
name: payload.name,
|
||||||
|
reason: payload.reason,
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return persistedState;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Callback to provide the currently active notifications.
|
||||||
|
*/
|
||||||
|
static getActiveNotifications = (
|
||||||
|
persistedState: PersistedState,
|
||||||
|
): Array<Notification> => {
|
||||||
|
return persistedState.crashes.map((crash: Crash) => {
|
||||||
|
return {
|
||||||
|
id: 'crash-notification:' + crash.notificationID,
|
||||||
|
message: crash.callStack,
|
||||||
|
severity: 'error',
|
||||||
|
title: 'CRASH: ' + crash.name + ' ' + crash.reason,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return 'Dedicated space to debug crashes. Look out for crash notifications.';
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/plugins/crash_reporter/package.json
Normal file
8
src/plugins/crash_reporter/package.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "flipper-plugin-crash-reporter",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "A plugin which will display a crash",
|
||||||
|
"main": "index.js",
|
||||||
|
"repository": "https://github.com/facebook/flipper",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
4
src/plugins/crash_reporter/yarn.lock
Normal file
4
src/plugins/crash_reporter/yarn.lock
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user