2017-10-24 21:01:58 +08:00
|
|
|
/* eslint no-unused-vars: 0 */
|
2016-05-04 04:40:46 +08:00
|
|
|
import React from 'react';
|
2016-04-29 03:02:51 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { render } from 'react-dom';
|
2018-06-20 00:46:59 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2018-09-21 23:43:10 +08:00
|
|
|
import Base from '/imports/startup/client/base';
|
2018-11-15 01:11:10 +08:00
|
|
|
import JoinHandler from '/imports/ui/components/join-handler/component';
|
|
|
|
import AuthenticatedHandler from '/imports/ui/components/authenticated-handler/component';
|
2019-04-25 04:48:16 +08:00
|
|
|
import Subscriptions from '/imports/ui/components/subscriptions/component';
|
2016-05-12 04:43:07 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
Meteor.startup(() => {
|
2018-06-20 00:46:59 +08:00
|
|
|
// Logs all uncaught exceptions to the client logger
|
2017-10-24 20:59:23 +08:00
|
|
|
window.addEventListener('error', (e) => {
|
2019-06-25 05:11:38 +08:00
|
|
|
let message = e.message || e.error.toString();
|
|
|
|
|
|
|
|
// Chrome will add on "Uncaught" to the start of the message for some reason. This
|
|
|
|
// will strip that so the errors can hopefully be grouped better.
|
|
|
|
if (message) message = message.replace(/^Uncaught/, '').trim();
|
|
|
|
|
|
|
|
let { stack } = e.error;
|
2018-06-20 00:46:59 +08:00
|
|
|
|
|
|
|
// Checks if stack includes the message, if not add the two together.
|
2019-06-25 05:11:38 +08:00
|
|
|
if (!stack.includes(message)) {
|
|
|
|
stack = `${message}\n${stack}`;
|
2018-10-25 23:51:53 +08:00
|
|
|
}
|
2019-07-31 20:30:34 +08:00
|
|
|
logger.error({
|
|
|
|
logCode: 'startup_error',
|
|
|
|
extraInfo: {
|
|
|
|
stackTrace: stack,
|
|
|
|
},
|
|
|
|
}, message);
|
2017-10-24 20:59:23 +08:00
|
|
|
});
|
2018-09-21 23:43:10 +08:00
|
|
|
|
|
|
|
// TODO make this a Promise
|
2018-11-15 01:11:10 +08:00
|
|
|
render(
|
2019-08-17 05:38:17 +08:00
|
|
|
<JoinHandler>
|
|
|
|
<AuthenticatedHandler>
|
|
|
|
<Subscriptions>
|
|
|
|
<Base />
|
|
|
|
</Subscriptions>
|
|
|
|
</AuthenticatedHandler>
|
|
|
|
</JoinHandler>,
|
2018-11-15 01:11:10 +08:00
|
|
|
document.getElementById('app'),
|
|
|
|
);
|
2016-01-13 04:15:16 +08:00
|
|
|
});
|