diff --git a/frontend/mulighetsrommet-veileder-flate/src/api/api.ts b/frontend/mulighetsrommet-veileder-flate/src/api/api.ts index f78dac1473..c9532634d2 100644 --- a/frontend/mulighetsrommet-veileder-flate/src/api/api.ts +++ b/frontend/mulighetsrommet-veileder-flate/src/api/api.ts @@ -1,10 +1,6 @@ import { ALL_TOGGLES, Features } from './features'; import useFetch from '@nutgaard/use-fetch'; -import { APP_NAME } from '../utils/constants'; - -const headers = { - headers: { 'Nav-Consumer-Id': APP_NAME }, -}; +import { headers } from './utils'; const toggles = ALL_TOGGLES.map(element => 'feature=' + element).join('&'); diff --git a/frontend/mulighetsrommet-veileder-flate/src/api/logger.ts b/frontend/mulighetsrommet-veileder-flate/src/api/logger.ts index e643210f36..111b786769 100644 --- a/frontend/mulighetsrommet-veileder-flate/src/api/logger.ts +++ b/frontend/mulighetsrommet-veileder-flate/src/api/logger.ts @@ -3,18 +3,18 @@ import { createMockFrontendLogger, DEFAULT_FRONTENDLOGGER_API_URL, } from '@navikt/frontendlogger/lib'; -import { APP_NAME } from '../utils/constants'; +import { LOG_NAME } from '../constants'; export const logger = import.meta.env.DEV - ? createMockFrontendLogger(APP_NAME) - : createFrontendLogger(APP_NAME, DEFAULT_FRONTENDLOGGER_API_URL); + ? createMockFrontendLogger(LOG_NAME) + : createFrontendLogger(LOG_NAME, DEFAULT_FRONTENDLOGGER_API_URL); export const logError = (fields?: {}, tags?: {}): void => { - logger.event(`${APP_NAME}.error`, fields, tags); + logger.event(`${LOG_NAME}.error`, fields, tags); }; export const logMetrikk = (metrikkNavn: string, fields?: {}, tags?: {}): void => { - logger.event(`${APP_NAME}.metrikker.${metrikkNavn}`, fields, tags); + logger.event(`${LOG_NAME}.metrikker.${metrikkNavn}`, fields, tags); }; export const logEvent = (logTag: string, fields?: {}, tags?: {}): void => { diff --git a/frontend/mulighetsrommet-veileder-flate/src/api/utils.ts b/frontend/mulighetsrommet-veileder-flate/src/api/utils.ts index 0fb60c9421..f08f022a94 100644 --- a/frontend/mulighetsrommet-veileder-flate/src/api/utils.ts +++ b/frontend/mulighetsrommet-veileder-flate/src/api/utils.ts @@ -1,4 +1,5 @@ import { hasData as _hasData, WithData, WithError, WithoutData } from '@nutgaard/use-fetch'; +import { APPLICATION_NAME } from '../constants'; type AsyncData = WithoutData | WithData | WithError; @@ -6,3 +7,7 @@ type AsyncData = WithoutData | WithData | WithError; export function hasData(result: AsyncData): result is WithData { return (result as WithData).data != null && _hasData(result); } + +export const headers = { + headers: { 'Nav-Consumer-Id': APPLICATION_NAME }, +}; diff --git a/frontend/mulighetsrommet-veileder-flate/src/constants.ts b/frontend/mulighetsrommet-veileder-flate/src/constants.ts index ca5748b287..ba71813c57 100644 --- a/frontend/mulighetsrommet-veileder-flate/src/constants.ts +++ b/frontend/mulighetsrommet-veileder-flate/src/constants.ts @@ -1,5 +1,5 @@ export const APPLICATION_NAME = 'mulighetsrommet-veileder-flate'; - +export const LOG_NAME = 'mulighetsrommet'; /** * The id references an HTML tag available through `veilarbpersonflatefs`, in which this application * gets mounted. diff --git a/frontend/mulighetsrommet-veileder-flate/src/index.tsx b/frontend/mulighetsrommet-veileder-flate/src/index.tsx index 8de3196dbb..5bd8cd5f8f 100644 --- a/frontend/mulighetsrommet-veileder-flate/src/index.tsx +++ b/frontend/mulighetsrommet-veileder-flate/src/index.tsx @@ -6,10 +6,10 @@ import { OpenAPI } from 'mulighetsrommet-api-client'; import Navspa from '@navikt/navspa'; import { worker } from './mock/worker'; import { APPLICATION_NAME } from './constants'; +import { headers } from './api/utils'; + +OpenAPI.HEADERS = headers.headers; -OpenAPI.HEADERS = { - 'Nav-Consumer-Id': APPLICATION_NAME, -}; OpenAPI.BASE = String(import.meta.env.VITE_MULIGHETSROMMET_API_BASE ?? ''); if (import.meta.env.VITE_MULIGHETSROMMET_API_MOCK === 'true') { diff --git a/frontend/mulighetsrommet-veileder-flate/src/mock/api/data.ts b/frontend/mulighetsrommet-veileder-flate/src/mock/api/data.ts index 0f5f277adb..9e867067f8 100644 --- a/frontend/mulighetsrommet-veileder-flate/src/mock/api/data.ts +++ b/frontend/mulighetsrommet-veileder-flate/src/mock/api/data.ts @@ -2,5 +2,5 @@ import { Features, ALERT_INFO, FAKE_DOOR } from '../../api/features'; export const mockFeatures: Features = { [ALERT_INFO]: true, - [FAKE_DOOR]: true, + [FAKE_DOOR]: false, }; diff --git a/frontend/mulighetsrommet-veileder-flate/src/utils/constants.ts b/frontend/mulighetsrommet-veileder-flate/src/utils/constants.ts deleted file mode 100644 index fa49774282..0000000000 --- a/frontend/mulighetsrommet-veileder-flate/src/utils/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const APP_NAME = 'mulighetsrommet';