-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.tsx
57 lines (53 loc) · 1.75 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { getWebInstrumentations, initializeFaro } from '@grafana/faro-web-sdk';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';
import React from 'react';
import { createRoot } from 'react-dom/client';
import { SWRConfig } from 'swr';
import App from './App';
import DevTools from './dev/DevTools';
import faroConfig from './faroConfig';
import { ApplikasjonContextProvider } from './felles/ApplikasjonContext';
import './index.css';
import { VarslingContextProvider } from 'felles/varsling/Varsling';
if (import.meta.env.PROD || import.meta.env.VITE_LOKAL_FARO) {
initializeFaro({
url: faroConfig.telemetryCollectorURL,
app: faroConfig.app,
instrumentations: [
...getWebInstrumentations({
captureConsole: true,
}),
new TracingInstrumentation(),
],
});
}
async function enableMocking() {
if (import.meta.env.DEV) {
const { mswWorker } = await import('../mock/setup');
await mswWorker.start({
onUnhandledRequest: 'bypass',
});
} else {
return Promise.resolve();
}
}
const element = document.getElementById('rekrutteringsbistand');
const root = createRoot(element as HTMLElement);
enableMocking().then(() => {
root.render(
<React.StrictMode>
<SWRConfig
value={{
revalidateOnFocus: false,
}}
>
{import.meta.env.DEV ? <DevTools /> : null}
<VarslingContextProvider>
<ApplikasjonContextProvider>
<App />
</ApplikasjonContextProvider>
</VarslingContextProvider>
</SWRConfig>
</React.StrictMode>
);
});