Skip to content

Commit

Permalink
Skru av all telemetry i gh pages
Browse files Browse the repository at this point in the history
  • Loading branch information
LudvigHz committed Jan 24, 2025
1 parent 8fd06fd commit e96a424
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/utils/amplitude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
28 changes: 16 additions & 12 deletions src/utils/observability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ const customPageMeta: () => Pick<Meta, 'page'> = () => {
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);
}
};
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<slot environment="prod">((.|\s)*?)<\/slot>/, '');
const content = removed.match(/<slot not-environment="prod">((.|\s)*?)<\/slot>/)?.[1];
return removed.replace(/<slot not-environment="prod">((.|\s)*?)<\/slot>/, content ?? '');
Expand Down

0 comments on commit e96a424

Please sign in to comment.