Merge pull request #20172 from prlanzarin/u30/feat/app-crash-logs

fix(bbb-html5): add specific logCodes for root error boundaries
This commit is contained in:
Ramón Souza 2024-05-08 09:49:36 -03:00 committed by GitHub
commit 333a97a463
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 8 deletions

View File

@ -13,15 +13,18 @@ import StartupDataFetch from '/imports/ui/components/connection-manager/startup-
import GraphqlToMiniMongoAdapterManager from '/imports/ui/components/components-data/graphqlToMiniMongoAdapterManager/component';
const STARTUP_CRASH_METADATA = { logCode: 'app_startup_crash', logMessage: 'Possible startup crash' };
const APP_CRASH_METADATA = { logCode: 'app_crash', logMessage: 'Possible app crash' };
const Main: React.FC = () => {
// Meteor.disconnect();
return (
<StartupDataFetch>
<ErrorBoundary Fallback={ErrorScreen}>
<ErrorBoundary Fallback={ErrorScreen} logMetadata={STARTUP_CRASH_METADATA}>
<LoadingScreenHOC>
<IntlLoaderContainer>
{/* from there the error messages are located */}
<LocatedErrorBoundary Fallback={ErrorScreen}>
<LocatedErrorBoundary Fallback={ErrorScreen} logMetadata={APP_CRASH_METADATA}>
<ConnectionManager>
<PresenceManager>
<GraphqlToMiniMongoAdapterManager>

View File

@ -6,11 +6,19 @@ const propTypes = {
children: PropTypes.element.isRequired,
Fallback: PropTypes.element,
errorMessage: PropTypes.string,
logMetadata: PropTypes.shape({
logCode: PropTypes.string,
logMessage: PropTypes.string,
}),
};
const defaultProps = {
Fallback: null,
errorMessage: 'Something went wrong',
logMetadata: {
logCode: 'Error_Boundary_wrapper',
logMessage: 'generic error boundary logger',
},
};
class ErrorBoundary extends Component {
@ -30,13 +38,17 @@ class ErrorBoundary extends Component {
}
componentDidUpdate() {
const { code, error, errorInfo } = this.state;
const log = code === '403' ? 'warn' : 'error';
const { error, errorInfo } = this.state;
const { logMetadata: { logCode, logMessage } } = this.props;
if (error || errorInfo) {
logger[log]({
logCode: 'Error_Boundary_wrapper',
extraInfo: { error, errorInfo },
}, 'generic error boundary logger');
logger.error({
logCode,
extraInfo: {
errorMessage: error?.message,
errorStack: error?.stack,
errorInfo,
},
}, logMessage);
}
}