Async config file (#682)

* initial

* only donwload config once

* formatting

* update sample config

* sentry

* refactor load state

* fix build yaml

* Upper case enums

* change how defaults work. review fixes

* abstract initialization

* copyright

* gitignore styleing

* refactor initialization

* use dafualt as fallback

* internalInstance rename

* review

* remove acidentally added posthog file

* DSN rename

* update Copyright

* remove olm from the initializer

Co-authored-by: Timo K <timok@element.io>
This commit is contained in:
Timo 2022-11-03 19:43:41 +01:00 committed by GitHub
commit 78a313c373
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 293 additions and 88 deletions

View file

@ -23,17 +23,10 @@ import "matrix-js-sdk/src/browser-index";
import React, { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { createBrowserHistory } from "history";
import * as Sentry from "@sentry/react";
import { Integrations } from "@sentry/tracing";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import Backend from "i18next-http-backend";
import LanguageDetector from "i18next-browser-languagedetector";
import "./index.css";
import App from "./App";
import { init as initRageshake } from "./settings/rageshake";
import { getUrlParams } from "./UrlParams";
initRageshake();
@ -108,47 +101,6 @@ if (import.meta.env.VITE_CUSTOM_THEME) {
const history = createBrowserHistory();
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN as string,
environment:
(import.meta.env.VITE_SENTRY_ENVIRONMENT as string) ?? "production",
integrations: [
new Integrations.BrowserTracing({
routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),
}),
],
tracesSampleRate: 1.0,
});
const languageDetector = new LanguageDetector();
languageDetector.addDetector({
name: "urlFragment",
// Look for a language code in the URL's fragment
lookup: () => getUrlParams().lang ?? undefined,
});
i18n
.use(Backend)
.use(languageDetector)
.use(initReactI18next)
.init({
fallbackLng: "en-GB",
defaultNS: "app",
keySeparator: false,
nsSeparator: false,
pluralSeparator: "|",
contextSeparator: "|",
interpolation: {
escapeValue: false, // React has built-in XSS protections
},
detection: {
// No localStorage detectors or caching here, since we don't have any way
// of letting the user manually select a language
order: ["urlFragment", "navigator"],
caches: [],
},
});
root.render(
<StrictMode>
<App history={history} />