Skip to content

Commit

Permalink
Legg til faro params som env variabler istedet for å bruke nais.js so…
Browse files Browse the repository at this point in the history
…m blir injected med svart magi
  • Loading branch information
ssaegrov committed Dec 11, 2024
1 parent eb4a51b commit 7531120
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions .nais/nais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions .nais/vars-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .nais/vars-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions app/faro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions app/nais.js

This file was deleted.

2 changes: 2 additions & 0 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
}
Expand Down
2 changes: 2 additions & 0 deletions app/utils/env.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export default defineConfig({
build: {
manifest: true,
sourcemap: true,
rollupOptions: {
external: ["./nais.js"],
},
},
resolve: {
alias: {
Expand Down

0 comments on commit 7531120

Please sign in to comment.