diff --git a/src/plugins/network/index.js b/src/plugins/network/index.js index 0ab7735dd..eb04f6bb3 100644 --- a/src/plugins/network/index.js +++ b/src/plugins/network/index.js @@ -7,6 +7,7 @@ import type {TableHighlightedRows, TableRows, TableBodyRow} from 'flipper'; +import type {NotificationSet} from '../../plugin'; import { ContextMenu, FlexColumn, @@ -152,6 +153,26 @@ export default class extends FlipperPlugin { this.props.setPersistedState({responses: {}, requests: {}}); }; + computeNotifications(props: *, state: State) { + const notifications: NotificationSet = {}; + const persistedState = props.persistedState; + for (const response in persistedState.responses) { + const status = persistedState.responses[response].status; + if (status >= 400) { + const url = persistedState.requests[response]?.url; + const startTime = persistedState.requests[response]?.timestamp; + const endTime = persistedState.responses[response].timestamp; + notifications[`${url}-${startTime}`] = { + timestamp: endTime, + title: 'Failed network request', + message: `Response for ${url} failed with status code ${status}`, + severity: 'error', + }; + } + } + return notifications; + } + renderSidebar = () => { const {requests, responses} = this.props.persistedState; const {selectedIds} = this.state;