From 1ce91ba58d6c9b733dcc4529ad492a76984335c2 Mon Sep 17 00:00:00 2001 From: Ludvig Hozman Date: Fri, 7 Jun 2024 13:45:21 +0200 Subject: [PATCH] Formater med prettier & fiks litt bugs --- .../useDecoratorConfig.tsx | 4 ---- src/sentry-route.tsx | 5 +++- src/utils/logger/frontendLogger.ts | 24 ++++++++++--------- src/utils/observability.ts | 13 ++++++---- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/app/internarbeidsflatedecorator/useDecoratorConfig.tsx b/src/app/internarbeidsflatedecorator/useDecoratorConfig.tsx index 910a289edc..b0d63bfdbf 100644 --- a/src/app/internarbeidsflatedecorator/useDecoratorConfig.tsx +++ b/src/app/internarbeidsflatedecorator/useDecoratorConfig.tsx @@ -73,10 +73,6 @@ function lagConfigV3( const { sokFnr, userKey } = getFnrFraUrl(); const fnr = useGjeldendeBruker(); const onsketFnr = sokFnr ?? fnr; -<<<<<<< HEAD -======= - ->>>>>>> 551b9c345 (Bruk faro til frontend observability) const environment = import.meta.env.PROD ? getEnvFromHost() : 'mock'; return { diff --git a/src/sentry-route.tsx b/src/sentry-route.tsx index 396be17f47..a6b5867851 100644 --- a/src/sentry-route.tsx +++ b/src/sentry-route.tsx @@ -2,7 +2,10 @@ import React, { ComponentProps } from 'react'; import { FaroRoute } from '@grafana/faro-react'; import { Route } from 'react-router-dom'; -export const SentryRoute = ({ children, ...props }: ComponentProps) => { +export const SentryRoute = ({ + children, + ...props +}: ComponentProps & ComponentProps) => { if (window.faro) { return {children}; } diff --git a/src/utils/logger/frontendLogger.ts b/src/utils/logger/frontendLogger.ts index 7e9eafdb0f..be857406ff 100644 --- a/src/utils/logger/frontendLogger.ts +++ b/src/utils/logger/frontendLogger.ts @@ -4,7 +4,6 @@ import { useEffect } from 'react'; import { erKontaktsenter } from '../enheter-utils'; import innloggetSaksbehandler from '../../rest/resources/innloggetSaksbehandlerResource'; import { useValgtenhet } from '../../context/valgtenhet-state'; -import { Faro } from '@grafana/faro-web-sdk'; let ident = 'ikke satt'; let enhet = 'ikke valgt'; @@ -25,7 +24,7 @@ interface ValuePairs { [name: string]: string | number | boolean | object | undefined; } -const faro = window.faro as Faro | undefined; +const faro = window.faro; function frontendLoggerIsInitialized(): boolean { if (!faro) { @@ -92,14 +91,17 @@ export function loggError(error: Error, message?: string, ekstraFelter?: ValuePa } export function emptyStringToUndefined(valuePairs: ValuePairs) { - return Object.keys(valuePairs).reduce((acc, key: string) => { - const value = valuePairs[key] === '' ? undefined : valuePairs[key]?.toString(); + return Object.keys(valuePairs).reduce( + (acc, key: string) => { + const value = valuePairs[key] === '' ? undefined : valuePairs[key]?.toString(); - return value - ? { - ...acc, - [key]: value - } - : acc; - }, {} as Record); + return value + ? { + ...acc, + [key]: value + } + : acc; + }, + {} as Record + ); } diff --git a/src/utils/observability.ts b/src/utils/observability.ts index 509a9d4441..bf3c6446ba 100644 --- a/src/utils/observability.ts +++ b/src/utils/observability.ts @@ -1,10 +1,15 @@ -import { getWebInstrumentations, initializeFaro, ReactIntegration, ReactRouterVersion } from '@grafana/faro-react'; -import { History } from 'history'; +import { + getWebInstrumentations, + initializeFaro, + ReactIntegration, + ReactRouterHistory, + ReactRouterVersion +} from '@grafana/faro-react'; import { Route } from 'react-router-dom'; import { getEnvFromHost } from './environment'; import { getWindowFeature } from './featureToggles'; -export const initializeObservability = (history: History) => { +export const initializeObservability = (history: ReactRouterHistory) => { if (!getWindowFeature('enableFaro') && !import.meta.env.VITE_GRAFANA_COLLECTOR) return; const env = getEnvFromHost(); @@ -15,7 +20,7 @@ export const initializeObservability = (history: History) => { console.log(import.meta.env.VITE_GRAFANA_COLLECTOR); initializeFaro({ url: - import.meta.env.VITE_GRAFANA_COLLECTOR ?? + (import.meta.env.VITE_GRAFANA_COLLECTOR as string) ?? (env === 'prod' ? 'https://telemetry.nav.no/collect' : 'https://telemetry.ekstern.dev.nav.no/collect'), app: { name: 'modiapersonoversikt'