diff --git a/index.html b/index.html index acc29a8f79..8245dd82d1 100644 --- a/index.html +++ b/index.html @@ -15,12 +15,6 @@ - - - - + + + + + Modia Personoversikt diff --git a/src/app/AppContainer.tsx b/src/app/AppContainer.tsx index e22025a3de..3ead286150 100644 --- a/src/app/AppContainer.tsx +++ b/src/app/AppContainer.tsx @@ -49,7 +49,6 @@ import { LandingPage } from './internarbeidsflatedecorator/LandingPage'; import { createBrowserHistory } from 'history'; import { ConnectedRouter, routerMiddleware } from 'connected-react-router'; import { initializeObservability } from '../utils/observability'; -import { FaroRoute } from '@grafana/faro-react'; const AppStyle = styled.div` height: 100vh; @@ -145,12 +144,12 @@ function AppContainer() { - + {!window.erChatvisning && } - + diff --git a/src/index.tsx b/src/index.tsx index 948523bb63..8e9cd6f6f1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -9,7 +9,8 @@ setupTimeSpentMetrics(); if (import.meta.env.DEV) { window.applicationFeatureToggles = { - useNewDecorator: true + useNewDecorator: true, + enableFaro: true }; } diff --git a/src/mock/index.ts b/src/mock/index.ts index 69f8e66708..bb861ed1ad 100644 --- a/src/mock/index.ts +++ b/src/mock/index.ts @@ -420,7 +420,3 @@ setupStandardteksterMock(mock); setUpSaksbehandlersEnheterMock(mock); setupSaksbehandlerInnstillingerMock(mock); setupDraftMock(mock); - -window.applicationFeatureToggles = { - useNewDecorator: true -}; diff --git a/src/sentry-route.ts b/src/sentry-route.ts deleted file mode 100644 index 8f0f4c9f93..0000000000 --- a/src/sentry-route.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { FaroRoute } from '@grafana/faro-react'; - -export const SentryRoute = FaroRoute; diff --git a/src/sentry-route.tsx b/src/sentry-route.tsx new file mode 100644 index 0000000000..396be17f47 --- /dev/null +++ b/src/sentry-route.tsx @@ -0,0 +1,10 @@ +import React, { ComponentProps } from 'react'; +import { FaroRoute } from '@grafana/faro-react'; +import { Route } from 'react-router-dom'; + +export const SentryRoute = ({ children, ...props }: ComponentProps) => { + if (window.faro) { + return {children}; + } + return {children}; +}; diff --git a/src/utils/observability.ts b/src/utils/observability.ts index e422c2f1d1..cf603ae7a9 100644 --- a/src/utils/observability.ts +++ b/src/utils/observability.ts @@ -1,21 +1,32 @@ -import { getWebInstrumentations, initializeFaro, ReactIntegration, ReactRouterVersion } from '@grafana/faro-react'; +import { + getWebInstrumentations, + initializeFaro, + InternalLoggerLevel, + ReactIntegration, + ReactRouterVersion +} from '@grafana/faro-react'; import { History } from 'history'; import { Route } from 'react-router-dom'; import { getEnvFromHost } from './environment'; import { getWindowFeature } from './featureToggles'; export const initializeObservability = (history: History) => { - if (!getWindowFeature('enableFaro')) return; + if (!getWindowFeature('enableFaro') && !import.meta.env.VITE_GRAFANA_COLLECTOR) return; const env = getEnvFromHost(); - if (!['q2'].includes(env)) { + if (!['q2'].includes(env) && !import.meta.env.VITE_GRAFANA_COLLECTOR) { console.info('Not running in GCP, web observability disabled'); } + + console.log(import.meta.env.VITE_GRAFANA_COLLECTOR); initializeFaro({ - url: env === 'prod' ? 'https://telemetry.nav.no/collect' : 'https://telemetry.ekstern.dev.nav.no/collect', + url: + import.meta.env.VITE_GRAFANA_COLLECTOR ?? + (env === 'prod' ? 'https://telemetry.nav.no/collect' : 'https://telemetry.ekstern.dev.nav.no/collect'), app: { name: 'modiapersonoversikt' }, + internalLoggerLevel: InternalLoggerLevel.VERBOSE, instrumentations: [ ...getWebInstrumentations(), new ReactIntegration({ diff --git a/src/window-variabler.ts b/src/window-variabler.ts index 2bc9a71b14..1a78eb2e39 100644 --- a/src/window-variabler.ts +++ b/src/window-variabler.ts @@ -1,9 +1,13 @@ +import { Faro } from "@grafana/faro-web-sdk"; + declare global { interface Window { erChatvisning: boolean; applicationFeatureToggles: { useNewDecorator: string | boolean; + enableFaro: string | boolean; }; + faro?: Faro } }