mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { extractPostHogConfig } from '@documenso/lib/constants/feature-flags';
|
|
import { dynamicActivate } from '@documenso/lib/utils/i18n';
|
|
import { i18n } from '@lingui/core';
|
|
import { detect, fromHtmlTag } from '@lingui/detect-locale';
|
|
import { I18nProvider } from '@lingui/react';
|
|
import { StrictMode, startTransition, useEffect } from 'react';
|
|
import { hydrateRoot } from 'react-dom/client';
|
|
import { HydratedRouter } from 'react-router/dom';
|
|
|
|
import './utils/polyfills/promise-with-resolvers';
|
|
|
|
function PosthogInit() {
|
|
const postHogConfig = extractPostHogConfig();
|
|
|
|
useEffect(() => {
|
|
if (postHogConfig) {
|
|
void import('posthog-js').then(({ default: posthog }) => {
|
|
posthog.init(postHogConfig.key, {
|
|
api_host: postHogConfig.host,
|
|
capture_exceptions: true,
|
|
});
|
|
});
|
|
}
|
|
}, []);
|
|
|
|
return null;
|
|
}
|
|
|
|
async function main() {
|
|
const locale = detect(fromHtmlTag('lang')) || 'en';
|
|
|
|
await dynamicActivate(locale);
|
|
|
|
startTransition(() => {
|
|
hydrateRoot(
|
|
document,
|
|
<StrictMode>
|
|
<I18nProvider i18n={i18n}>
|
|
<HydratedRouter />
|
|
</I18nProvider>
|
|
|
|
<PosthogInit />
|
|
</StrictMode>,
|
|
);
|
|
});
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
main();
|