Skip to content

Commit

Permalink
Formater med prettier & fiks litt bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
LudvigHz committed Jun 11, 2024
1 parent 99f7ad7 commit 1ce91ba
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
4 changes: 0 additions & 4 deletions src/app/internarbeidsflatedecorator/useDecoratorConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion src/sentry-route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof FaroRoute>) => {
export const SentryRoute = ({
children,
...props
}: ComponentProps<typeof FaroRoute> & ComponentProps<typeof Route>) => {
if (window.faro) {
return <FaroRoute {...props}>{children}</FaroRoute>;
}
Expand Down
24 changes: 13 additions & 11 deletions src/utils/logger/frontendLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down Expand Up @@ -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<string, string>);
return value
? {
...acc,
[key]: value
}
: acc;
},
{} as Record<string, string>
);
}
13 changes: 9 additions & 4 deletions src/utils/observability.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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'
Expand Down

0 comments on commit 1ce91ba

Please sign in to comment.