Skip to content

Commit

Permalink
Merge pull request #1778 from navikt/faro
Browse files Browse the repository at this point in the history
Ta i bruk Faro for observability i web klient
  • Loading branch information
kenglxn authored Jan 19, 2024
2 parents a70091c + d137a4d commit 1bc06d0
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 31 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
})()
</script>
<noscript>You need to enable JavaScript to run this app.</noscript>
<main id="root"></main>
<main id="app"></main>

<script type="module" src="/src/index.tsx"></script>
</body>
Expand Down
155 changes: 154 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
46 changes: 17 additions & 29 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
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';
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');
Expand All @@ -25,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://[email protected]/27',
release: environment.GIT_COMMIT,
Expand Down Expand Up @@ -73,28 +83,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({
Expand All @@ -111,7 +99,8 @@ injectDecoratorClientSide({
},
}).catch(Sentry.captureException);

ReactDOM.render(
const root = createRoot(document.getElementById('app')!);
root.render(
gittMiljo({
prod: <Pages />,
other: (
Expand All @@ -120,6 +109,5 @@ ReactDOM.render(
<Pages />{' '}
</React.StrictMode>
),
}),
document.getElementById('root')
})
);

0 comments on commit 1bc06d0

Please sign in to comment.