From c5fbccff328b607033cd820e38a88463fcc0aff2 Mon Sep 17 00:00:00 2001 From: Ken Gullaksen Date: Thu, 18 Jan 2024 14:28:04 +0100 Subject: [PATCH 1/2] fjern deprecation warning react 17 -> 18 render --- index.html | 2 +- src/index.tsx | 32 ++++---------------------------- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/index.html b/index.html index 42875ac8c..ba283feb9 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@ })() -
+
diff --git a/src/index.tsx b/src/index.tsx index 5493b6442..f58687ef9 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,5 @@ -import 'core-js/stable'; -import 'regenerator-runtime/runtime'; import React from 'react'; -import ReactDOM from 'react-dom'; +import { createRoot } from 'react-dom/client'; import * as Sentry from '@sentry/react'; import 'whatwg-fetch'; import environment, { gittMiljo } from './utils/environment'; @@ -73,28 +71,6 @@ Sentry.init({ transport: SentryDebugTransport, }, }), - ignoreErrors: [ - 'Error: Failed to fetch', - 'TypeError: Failed to fetch', - 'Error: NetworkError when attempting to fetch resource.', - 'TypeError: NetworkError when attempting to fetch resource.', - 'Error: Load failed', - 'TypeError: Load failed', - 'Error: cancelled', - 'TypeError: cancelled', - 'Error: avbrutt', - 'TypeError: avbrutt', - 'Error: cancelado', - 'TypeError: cancelado', - 'Error: anulowane', - 'TypeError: anulowane', - 'Error: avbruten', - 'TypeError: avbruten', - 'Error: anulat', - 'TypeError: anulat', - 'Error: The operation was aborted.', - 'AbortError: The operation was aborted.', - ], }); injectDecoratorClientSide({ @@ -111,7 +87,8 @@ injectDecoratorClientSide({ }, }).catch(Sentry.captureException); -ReactDOM.render( +const root = createRoot(document.getElementById('app')!); +root.render( gittMiljo({ prod: , other: ( @@ -120,6 +97,5 @@ ReactDOM.render( {' '} ), - }), - document.getElementById('root') + }) ); From d137a4d3e5d7967a3af9b803499cfd3b93588903 Mon Sep 17 00:00:00 2001 From: Ken Gullaksen Date: Thu, 18 Jan 2024 14:28:26 +0100 Subject: [PATCH 2/2] legg til faro for observability --- package-lock.json | 155 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + src/index.tsx | 14 ++++- 3 files changed, 168 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b67accdc5..c9afabc2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "min-side-arbeidsgiver", "version": "0.1.0", "dependencies": { + "@grafana/faro-web-sdk": "1.3.6", "@navikt/aksel-icons": "^5.12.0", "@navikt/arbeidsgiver-notifikasjon-widget": "6.4.2", "@navikt/bedriftsmeny": "6.13.0", @@ -1956,6 +1957,26 @@ "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.1.6.tgz", "integrity": "sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A==" }, + "node_modules/@grafana/faro-core": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/@grafana/faro-core/-/faro-core-1.3.6.tgz", + "integrity": "sha512-1N/VWOIuukvqJUbpGRmendbJSG8hEvMqUV79+jPrhSRjM2VlNsqtFC/0VdW9mpQPpZh2cOyI5bPjuAZsRe7+Xw==", + "dependencies": { + "@opentelemetry/api": "^1.7.0", + "@opentelemetry/otlp-transformer": "^0.45.1", + "murmurhash-js": "^1.0.0" + } + }, + "node_modules/@grafana/faro-web-sdk": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/@grafana/faro-web-sdk/-/faro-web-sdk-1.3.6.tgz", + "integrity": "sha512-hxqHRZM1AERK6YZtJpCM1PJoj9/CLhCfQcfprcv751l5xkLCOzCoUWiH8CSW3gfiu7egIzEq0luHF7544Xezvg==", + "dependencies": { + "@grafana/faro-core": "^1.3.6", + "ua-parser-js": "^1.0.32", + "web-vitals": "^3.1.1" + } + }, "node_modules/@graphql-codegen/cli": { "version": "2.16.5", "resolved": "https://registry.npmjs.org/@graphql-codegen/cli/-/cli-2.16.5.tgz", @@ -3567,6 +3588,129 @@ "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", "dev": true }, + "node_modules/@opentelemetry/api": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.7.0.tgz", + "integrity": "sha512-AdY5wvN0P2vXBi3b29hxZgSFvdhdxPB9+f0B6s//P9Q8nibRWeA3cHm8UmLpio9ABigkVHJ5NMPk+Mz8VCCyrw==", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@opentelemetry/api-logs": { + "version": "0.45.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.45.1.tgz", + "integrity": "sha512-zVGq/k70l+kB/Wuv3O/zhptP2hvDhEbhDu9EtHde1iWZJf3FedeYS/nWVcMBkkyPAjS/JKNk86WN4CBQLGUuOw==", + "dependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@opentelemetry/core": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.18.1.tgz", + "integrity": "sha512-kvnUqezHMhsQvdsnhnqTNfAJs3ox/isB0SVrM1dhVFw7SsB7TstuVa6fgWnN2GdPyilIFLUvvbTZoVRmx6eiRg==", + "dependencies": { + "@opentelemetry/semantic-conventions": "1.18.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "node_modules/@opentelemetry/otlp-transformer": { + "version": "0.45.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.45.1.tgz", + "integrity": "sha512-FhIHgfC0b0XtoBrS5ISfva939yWffNl47ypXR8I7Ru+dunlySpmf2TLocKHYLHGcWiuoeSNO5O4dZCmSKOtpXw==", + "dependencies": { + "@opentelemetry/api-logs": "0.45.1", + "@opentelemetry/core": "1.18.1", + "@opentelemetry/resources": "1.18.1", + "@opentelemetry/sdk-logs": "0.45.1", + "@opentelemetry/sdk-metrics": "1.18.1", + "@opentelemetry/sdk-trace-base": "1.18.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.8.0" + } + }, + "node_modules/@opentelemetry/resources": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.18.1.tgz", + "integrity": "sha512-JjbcQLYMttXcIabflLRuaw5oof5gToYV9fuXbcsoOeQ0BlbwUn6DAZi++PNsSz2jjPeASfDls10iaO/8BRIPRA==", + "dependencies": { + "@opentelemetry/core": "1.18.1", + "@opentelemetry/semantic-conventions": "1.18.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "node_modules/@opentelemetry/sdk-logs": { + "version": "0.45.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.45.1.tgz", + "integrity": "sha512-z0RRgW4LeKEKnhXS4F/HnqB6+7gsy63YK47F4XAJYHs4s1KKg8XnQ2RkbuL31i/a9nXkylttYtvsT50CGr487g==", + "dependencies": { + "@opentelemetry/core": "1.18.1", + "@opentelemetry/resources": "1.18.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.4.0 <1.8.0", + "@opentelemetry/api-logs": ">=0.39.1" + } + }, + "node_modules/@opentelemetry/sdk-metrics": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.18.1.tgz", + "integrity": "sha512-TEFgeNFhdULBYiCoHbz31Y4PDsfjjxRp8Wmdp6ybLQZPqMNEb+dRq+XN8Xw3ivIgTaf9gYsomgV5ensX99RuEQ==", + "dependencies": { + "@opentelemetry/core": "1.18.1", + "@opentelemetry/resources": "1.18.1", + "lodash.merge": "^4.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.3.0 <1.8.0" + } + }, + "node_modules/@opentelemetry/sdk-trace-base": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.18.1.tgz", + "integrity": "sha512-tRHfDxN5dO+nop78EWJpzZwHsN1ewrZRVVwo03VJa3JQZxToRDH29/+MB24+yoa+IArerdr7INFJiX/iN4gjqg==", + "dependencies": { + "@opentelemetry/core": "1.18.1", + "@opentelemetry/resources": "1.18.1", + "@opentelemetry/semantic-conventions": "1.18.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": ">=1.0.0 <1.8.0" + } + }, + "node_modules/@opentelemetry/semantic-conventions": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.18.1.tgz", + "integrity": "sha512-+NLGHr6VZwcgE/2lw8zDIufOCGnzsA5CbQIMleXZTrgkBd0TanCX+MiDYJ1TOS4KL/Tqk0nFRxawnaYr6pkZkA==", + "engines": { + "node": ">=14" + } + }, "node_modules/@peculiar/asn1-schema": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.3.6.tgz", @@ -11062,6 +11206,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/murmurhash-js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/murmurhash-js/-/murmurhash-js-1.0.0.tgz", + "integrity": "sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw==" + }, "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -13688,7 +13837,6 @@ "version": "1.0.36", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.36.tgz", "integrity": "sha512-znuyCIXzl8ciS3+y3fHJI/2OhQIXbXw9MWC/o3qwyR+RGppjZHrM27CGFSKCJXi2Kctiz537iOu2KnXs1lMQhw==", - "dev": true, "funding": [ { "type": "opencollective", @@ -15318,6 +15466,11 @@ "node": ">= 8" } }, + "node_modules/web-vitals": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-3.5.1.tgz", + "integrity": "sha512-xQ9lvIpfLxUj0eSmT79ZjRoU5wIRfIr7pNukL7ZE4EcWZSmfZQqOlhuAGfkVa3EFmzPHZhWhXfm2i5ys+THVPg==" + }, "node_modules/webcrypto-core": { "version": "1.7.7", "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.7.7.tgz", diff --git a/package.json b/package.json index c2e6fdcfe..3a236ba3a 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "private": true, "homepage": "/min-side-arbeidsgiver", "dependencies": { + "@grafana/faro-web-sdk": "1.3.6", "@navikt/aksel-icons": "^5.12.0", "@navikt/arbeidsgiver-notifikasjon-widget": "6.4.2", "@navikt/bedriftsmeny": "6.13.0", diff --git a/src/index.tsx b/src/index.tsx index f58687ef9..480853b6b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,12 +1,12 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; import * as Sentry from '@sentry/react'; -import 'whatwg-fetch'; import environment, { gittMiljo } from './utils/environment'; import '@navikt/ds-css'; import Pages from './Pages/Pages'; import * as SentryTypes from '@sentry/types'; import { injectDecoratorClientSide } from '@navikt/nav-dekoratoren-moduler'; +import { initializeFaro } from '@grafana/faro-web-sdk'; window.localStorage.removeItem('ForebyggeFraværInfoBoksLukket'); window.localStorage.removeItem('InntektsmeldingUndersøkelse'); @@ -23,6 +23,18 @@ class SentryDebugTransport implements SentryTypes.Transport { } } +initializeFaro({ + url: gittMiljo({ + prod: 'https://telemetry.nav.no/collect', + dev: 'https://telemetry.ekstern.dev.nav.no/collect', + other: '/collect', + }), + app: { + name: 'min-side-arbeidsgiver', + version: environment.GIT_COMMIT, + }, +}); + Sentry.init({ dsn: 'https://57108359840e4a28b979e36baf5e5c6c@sentry.gc.nav.no/27', release: environment.GIT_COMMIT,