Add event id for BSOD email url

This commit is contained in:
SleepWalker 2018-05-02 21:22:13 +03:00
parent aaad2006ab
commit 993dd4dbb5
2 changed files with 62 additions and 27 deletions

View File

@ -1,9 +1,8 @@
// @flow // @flow
import React from 'react'; import React from 'react';
import { FormattedMessage as Message } from 'react-intl'; import { FormattedMessage as Message } from 'react-intl';
import { IntlProvider } from 'components/i18n'; import { IntlProvider } from 'components/i18n';
import logger from 'services/logger';
import appInfo from 'components/auth/appInfo/AppInfo.intl.json'; import appInfo from 'components/auth/appInfo/AppInfo.intl.json';
import styles from './styles.scss'; import styles from './styles.scss';
@ -12,32 +11,64 @@ import messages from './BSoD.intl.json';
// TODO: probably it is better to render this view from the App view // TODO: probably it is better to render this view from the App view
// to remove dependencies from store and IntlProvider // to remove dependencies from store and IntlProvider
export default function BSoD({store}: {store: *}) { export default class BSoD extends React.Component<{
return ( store: Object
<IntlProvider store={store}> }, {
<div className={styles.body}> lastEventId?: string,
<canvas className={styles.canvas} }> {
ref={(el: ?HTMLCanvasElement) => el && new BoxesField(el)} state = {};
/>
<div className={styles.wrapper}> componentDidMount() {
<div className={styles.title}> // poll for event id
<Message {...appInfo.appName} /> const timer = setInterval(() => {
</div> if (!logger.getLastEventId()) {
<div className={styles.lineWithMargin}> return;
<Message {...messages.criticalErrorHappened} /> }
</div>
<div className={styles.line}> clearInterval(timer);
<Message {...messages.reloadPageOrContactUs} />
</div> this.setState({
<a href="mailto:support@ely.by" className={styles.support}> lastEventId: logger.getLastEventId()
support@ely.by });
</a> }, 500);
<div className={styles.easterEgg}> }
<Message {...messages.alsoYouCanInteractWithBackground}/>
render() {
const {store} = this.props;
const {lastEventId} = this.state;
let emailUrl = 'mailto:support@ely.by';
if (lastEventId) {
emailUrl += `?subject=Bug report for #${lastEventId}`;
}
return (
<IntlProvider store={store}>
<div className={styles.body}>
<canvas className={styles.canvas}
ref={(el: ?HTMLCanvasElement) => el && new BoxesField(el)}
/>
<div className={styles.wrapper}>
<div className={styles.title}>
<Message {...appInfo.appName} />
</div>
<div className={styles.lineWithMargin}>
<Message {...messages.criticalErrorHappened} />
</div>
<div className={styles.line}>
<Message {...messages.reloadPageOrContactUs} />
</div>
<a href={emailUrl} className={styles.support}>
support@ely.by
</a>
<div className={styles.easterEgg}>
<Message {...messages.alsoYouCanInteractWithBackground}/>
</div>
</div> </div>
</div> </div>
</div> </IntlProvider>
</IntlProvider> );
); }
} }

View File

@ -66,6 +66,10 @@ class Logger {
warn(message: string | Error, context: Object) { warn(message: string | Error, context: Object) {
log('warning', message, context); log('warning', message, context);
} }
getLastEventId(): string | void {
return Raven.lastEventId();
}
} }
function log( function log(