Report error from react to firebase console

Multi tool use
Report error from react to firebase console
I'd like to report an error when my apps crash to firebase directly from a react app, I've have enabled client logging according to this answer.
firebase.database.enableLogging(true);
I have created a component to handle errors, like this:
import React, { Component } from 'react';
class ErrorBoundary extends Component {
constructor(props) {
super(props);
this.state = {
hasError: false
};
}
componentDidCatch(error, info) {
this.setState({
hasError: true
});
//how to log the error to firebase console?
console.error(new Error(error, info))
}
render() {
if (this.state.hasError) {
return <h1>Something went wrong.</h1>;
}
return this.props.children;
}
}
export default ErrorBoundary;
I'm wondering how can I log the error from the client?, I've read about how to do it but using nodejs but not with just plain javascript (react)
Any ideas?
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.