diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index ade78ef72..9b1d37cc7 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -39,7 +39,7 @@ jobs: - name: Build env: VITE_APP_BASE_PATH: '/modiapersonoversikt' - GH_PAGES: 'true' + VITE_GH_PAGES: 'true' run: pnpm run build - name: Deploy diff --git a/src/utils/amplitude.ts b/src/utils/amplitude.ts index cc01c6007..5249edf46 100644 --- a/src/utils/amplitude.ts +++ b/src/utils/amplitude.ts @@ -41,7 +41,7 @@ const maskereFnrPlugin = (): amplitude.Types.BeforePlugin => ({ }); export const initAmplitude = () => { - if (!import.meta.env.PROD) return; + if (!import.meta.env.PROD || import.meta.env.VITE_GH_PAGES) return; if (window.amplitude) { return; } diff --git a/src/utils/observability.ts b/src/utils/observability.ts index ec994fea9..b522dc6f0 100644 --- a/src/utils/observability.ts +++ b/src/utils/observability.ts @@ -14,16 +14,20 @@ const customPageMeta: () => Pick = () => { export const initializeObservability = () => { const env = getEnvFromHost(); - initializeFaro({ - url: - (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' - }, - metas: [customPageMeta], - paused: !import.meta.env.PROD, - instrumentations: [...getWebInstrumentations()].filter((v): v is Instrumentation => !!v), - ignoreUrls: [/\d{11}/] - }); + try { + initializeFaro({ + url: + (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' + }, + metas: [customPageMeta], + paused: !import.meta.env.PROD || import.meta.env.VITE_GH_PAGES, + instrumentations: [...getWebInstrumentations()].filter((v): v is Instrumentation => !!v), + ignoreUrls: [/\d{11}/] + }); + } catch (e) { + console.warn('Could not initialize Faro', e); + } }; diff --git a/vite.config.ts b/vite.config.ts index 3cf8d3338..32d4165be 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -27,7 +27,7 @@ const modiaFrontendCompat = (): { return { name: 'modia-frontend-html-transform', transformIndexHtml(html, ctx) { - if (ctx.server || process.env.GH_PAGES === 'true') { + if (ctx.server || process.env.VITE_GH_PAGES === 'true') { const removed = html.replace(/((.|\s)*?)<\/slot>/, ''); const content = removed.match(/((.|\s)*?)<\/slot>/)?.[1]; return removed.replace(/((.|\s)*?)<\/slot>/, content ?? '');