From 7531120b87ac3a50f4bda267b42a4723a01b3265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sindre=20S=C3=A6grov?= Date: Wed, 11 Dec 2024 07:54:11 +0100 Subject: [PATCH] =?UTF-8?q?Legg=20til=20faro=20params=20som=20env=20variab?= =?UTF-8?q?ler=20istedet=20for=20=C3=A5=20bruke=20nais.js=20som=20blir=20i?= =?UTF-8?q?njected=20med=20svart=20magi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 3 +++ .nais/nais.yaml | 5 +++++ .nais/vars-dev.yaml | 2 ++ .nais/vars-prod.yaml | 2 ++ app/faro.ts | 9 +++++---- app/nais.js | 7 ------- app/root.tsx | 2 ++ app/utils/env.utils.ts | 2 ++ vite.config.ts | 3 --- 9 files changed, 21 insertions(+), 14 deletions(-) delete mode 100644 app/nais.js diff --git a/.env.example b/.env.example index 24a67cb6..4a32860d 100644 --- a/.env.example +++ b/.env.example @@ -21,5 +21,8 @@ SANITY_PROJECT_ID="rt6o382n" SANITY_ACCESS_TOKEN="" SANITY_DATASET="development" +FARO_URL="http://localhost:12347/collect" +GITHUB_SHA="local" + UNLEASH_SERVER_API_TOKEN="" # Finn token her https://dagpenger-unleash-web.iap.nav.cloud.nais.io/admin/api UNLEASH_SERVER_API_URL=https://dagpenger-unleash-api.nav.cloud.nais.io/api diff --git a/.nais/nais.yaml b/.nais/nais.yaml index 82aefa93..85ca42df 100644 --- a/.nais/nais.yaml +++ b/.nais/nais.yaml @@ -90,6 +90,11 @@ spec: - name: UNLEASH_SERVER_API_URL value: {{unleash.url}} + - name: FARO_URL + value: {{faro_url}} + - name: GITHUB_SHA + value: {{githubSha}} + envFrom: - secret: dp-saksbehandling-frontend-unleash-api-token diff --git a/.nais/vars-dev.yaml b/.nais/vars-dev.yaml index b450638e..1289442e 100644 --- a/.nais/vars-dev.yaml +++ b/.nais/vars-dev.yaml @@ -22,6 +22,8 @@ sanity_project_id: "rt6o382n" sanity_access_token: "" sanity_dataset: "production" +faro_url: "https://telemetry.ekstern.dev.nav.no/collect" + unleash: url: https://dagpenger-unleash-api.nav.cloud.nais.io/api environment: development diff --git a/.nais/vars-prod.yaml b/.nais/vars-prod.yaml index ab98d411..5d4eb5f3 100644 --- a/.nais/vars-prod.yaml +++ b/.nais/vars-prod.yaml @@ -22,6 +22,8 @@ sanity_project_id: "rt6o382n" sanity_access_token: "" sanity_dataset: "production" +faro_url: "https://telemetry.nav.no/collect" + unleash: url: https://dagpenger-unleash-api.nav.cloud.nais.io/api environment: production diff --git a/app/faro.ts b/app/faro.ts index 7f666fc1..08cdee01 100644 --- a/app/faro.ts +++ b/app/faro.ts @@ -3,8 +3,6 @@ import { TracingInstrumentation } from "@grafana/faro-web-tracing"; import { getEnv } from "~/utils/env.utils"; -import nais from "./nais.js"; - let faro: Faro | null = null; export function initFaro() { @@ -14,8 +12,11 @@ export function initFaro() { faro = initializeFaro({ paused: getEnv("IS_LOCALHOST") === "true", - url: nais.telemetryCollectorURL, - app: nais.app, + url: getEnv("FARO_URL"), + app: { + name: "dp-saksbehandling-frontend", + version: getEnv("GITHUB_SHA"), + }, sessionTracking: { enabled: true, persistent: true, diff --git a/app/nais.js b/app/nais.js deleted file mode 100644 index 4c15554d..00000000 --- a/app/nais.js +++ /dev/null @@ -1,7 +0,0 @@ -export default { - telemetryCollectorURL: "http://localhost:12347/collect", - app: { - name: "myapplication", - version: "dev", - }, -}; diff --git a/app/root.tsx b/app/root.tsx index 1bcbe52b..7acbaa40 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -118,6 +118,8 @@ export async function loader({ request }: LoaderFunctionArgs) { INNTEKTREDIGERING_URL: process.env.INNTEKTREDIGERING_URL, GRISEN_URL: process.env.GRISEN_URL, DAGPENGER_NORGE_URL: process.env.DAGPENGER_NORGE_URL, + GITHUB_SHA: process.env.GITHUB_SHA, + FARO_URL: process.env.FARO_URL, }, }); } diff --git a/app/utils/env.utils.ts b/app/utils/env.utils.ts index 3382abd6..8880a758 100644 --- a/app/utils/env.utils.ts +++ b/app/utils/env.utils.ts @@ -24,6 +24,8 @@ interface IEnv { NAIS_FRONTEND_TELEMETRY_COLLECTOR_URL: string; UNLEASH_SERVER_API_URL: string; UNLEASH_SERVER_API_TOKEN: string; + FARO_URL: string; + GITHUB_SHA: string; } export function getEnv(value: keyof IEnv) { diff --git a/vite.config.ts b/vite.config.ts index 1d457d6a..3095c002 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,9 +23,6 @@ export default defineConfig({ build: { manifest: true, sourcemap: true, - rollupOptions: { - external: ["./nais.js"], - }, }, resolve: { alias: {