2017-05-12 00:23:56 +00:00
|
|
|
// @flow
|
2020-09-01 01:42:12 +00:00
|
|
|
import "mobx-react-lite/batchingForReactDom";
|
2020-09-13 06:27:23 +00:00
|
|
|
import "focus-visible";
|
2020-08-09 05:53:59 +00:00
|
|
|
import { Provider } from "mobx-react";
|
2020-06-20 20:59:15 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import { render } from "react-dom";
|
|
|
|
import { BrowserRouter as Router } from "react-router-dom";
|
2016-02-27 21:53:11 +00:00
|
|
|
|
2020-11-30 04:04:58 +00:00
|
|
|
import { initI18n } from "shared/i18n";
|
2020-08-09 05:53:59 +00:00
|
|
|
import stores from "stores";
|
2020-06-20 20:59:15 +00:00
|
|
|
import ErrorBoundary from "components/ErrorBoundary";
|
|
|
|
import ScrollToTop from "components/ScrollToTop";
|
|
|
|
import Theme from "components/Theme";
|
2020-08-09 05:53:59 +00:00
|
|
|
import Toasts from "components/Toasts";
|
2020-06-20 20:59:15 +00:00
|
|
|
import Routes from "./routes";
|
2020-07-18 18:02:40 +00:00
|
|
|
import env from "env";
|
2017-09-04 21:48:56 +00:00
|
|
|
|
2020-11-30 04:04:58 +00:00
|
|
|
initI18n();
|
|
|
|
|
2020-06-20 20:59:15 +00:00
|
|
|
const element = document.getElementById("root");
|
2018-05-05 23:16:08 +00:00
|
|
|
|
|
|
|
if (element) {
|
|
|
|
render(
|
2020-08-23 18:51:56 +00:00
|
|
|
<ErrorBoundary>
|
|
|
|
<Provider {...stores}>
|
|
|
|
<Theme>
|
|
|
|
<Router>
|
|
|
|
<>
|
|
|
|
<ScrollToTop>
|
|
|
|
<Routes />
|
|
|
|
</ScrollToTop>
|
|
|
|
<Toasts />
|
|
|
|
</>
|
|
|
|
</Router>
|
|
|
|
</Theme>
|
|
|
|
</Provider>
|
|
|
|
</ErrorBoundary>,
|
2018-05-05 23:16:08 +00:00
|
|
|
element
|
|
|
|
);
|
|
|
|
}
|
2018-02-11 07:23:50 +00:00
|
|
|
|
2020-06-20 20:59:15 +00:00
|
|
|
window.addEventListener("load", async () => {
|
2018-02-11 07:23:50 +00:00
|
|
|
// installation does not use Google Analytics, or tracking is blocked on client
|
|
|
|
// no point loading the rest of the analytics bundles
|
2020-07-18 18:02:40 +00:00
|
|
|
if (!env.GOOGLE_ANALYTICS_ID || !window.ga) return;
|
2018-02-11 07:23:50 +00:00
|
|
|
|
2018-02-11 07:54:54 +00:00
|
|
|
// https://github.com/googleanalytics/autotrack/issues/137#issuecomment-305890099
|
2020-06-20 20:59:15 +00:00
|
|
|
await import("autotrack/autotrack.js");
|
2018-02-11 07:23:50 +00:00
|
|
|
|
2020-06-20 20:59:15 +00:00
|
|
|
window.ga("require", "outboundLinkTracker");
|
|
|
|
window.ga("require", "urlChangeTracker");
|
|
|
|
window.ga("require", "eventTracker", {
|
|
|
|
attributePrefix: "data-",
|
2019-06-25 05:14:59 +00:00
|
|
|
});
|
2018-02-11 07:23:50 +00:00
|
|
|
});
|