linking to logs plugin

Summary: changing the payload to work with the updated logs plugin

Reviewed By: passy

Differential Revision: D13376392

fbshipit-source-id: ccfb1b1a7a2ec3e9d3899e70c9bdd199a489da88
This commit is contained in:
Daniel Büchele
2018-12-11 07:55:48 -08:00
committed by Facebook Github Bot
parent cbfbd0dd98
commit fd1a00f05e

View File

@@ -105,12 +105,13 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
persistedState: PersistedState, persistedState: PersistedState,
): Array<Notification> => { ): Array<Notification> => {
return persistedState.crashes.map((crash: Crash) => { return persistedState.crashes.map((crash: Crash) => {
const id = 'crash-notification:' + crash.notificationID;
return { return {
id: 'crash-notification:' + crash.notificationID, id,
message: crash.callStack, message: crash.callStack,
severity: 'error', severity: 'error',
title: 'CRASH: ' + crash.name + ' ' + crash.reason, title: 'CRASH: ' + crash.name + ' ' + crash.reason,
action: JSON.stringify(crash), action: id,
}; };
}); });
}; };
@@ -119,15 +120,23 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
return crash.callStack.reduce((acc, val) => acc.concat('\n', val)); return crash.callStack.reduce((acc, val) => acc.concat('\n', val));
} }
openInLogs = (crash: Crash) => {
this.props.selectPlugin(
'DeviceLogs',
crash.callStack
.slice(0, 5)
.join('\n\tat ')
.trim(),
);
};
render() { render() {
let crash = const crash =
this.props.persistedState.crashes.length > 0 this.props.persistedState.crashes.length > 0 &&
? this.props.persistedState.crashes.slice(-1)[0] this.props.persistedState.crashes[
: undefined; this.props.persistedState.crashes.length - 1
if (this.props.deepLinkPayload) { ];
// In case of the deeplink from the notifications use the notifications crash, otherwise show the latest crash
crash = JSON.parse(this.props.deepLinkPayload);
}
if (crash) { if (crash) {
const callStackString = this.convertCallstackToString(crash); const callStackString = this.convertCallstackToString(crash);
return ( return (
@@ -158,17 +167,8 @@ export default class CrashReporterPlugin extends FlipperDevicePlugin {
</CrashRow> </CrashRow>
{this.device.os == 'Android' && ( {this.device.os == 'Android' && (
<CrashRow> <CrashRow>
<Button <Button onClick={() => this.openInLogs(crash)}>
onClick={event => { Open in Logs
this.props.selectPlugin(
'DeviceLogs',
JSON.stringify({
...crash,
callStackString: callStackString,
}),
);
}}>
Deeplink to Logs
</Button> </Button>
</CrashRow> </CrashRow>
)} )}