Skip to content

Commit

Permalink
Ikke feil hardt når faro ikke er satt opp
Browse files Browse the repository at this point in the history
  • Loading branch information
LudvigHz committed Jun 27, 2024
1 parent 94557f8 commit 178df24
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/components/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ import { FaroErrorBoundary } from '@grafana/faro-react';
const ErrorBoundary = ({ children, boundaryName }: React.PropsWithChildren<{ boundaryName: string }>) => {
return (
<FaroErrorBoundary
beforeCapture={() => {
if (!window.faro) {
window.faro = {
// @ts-expect-error Vi overskriver faro siden error boundarien ikke tar
// hensyn til at faro ikke er tilgjengelig
api: {
pushError: () => {
console.warn('Not pushing error to grafana. Faro is not initialized.');
}
}
};
}
}}
fallback={<AlertStripe type={'advarsel'}>Beklager, det skjedde en feil. ({boundaryName})</AlertStripe>}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/observability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getEnvFromHost } from './environment';
import { getWindowFeature } from './featureToggles';

export const initializeObservability = (history: ReactRouterHistory) => {
if (!import.meta.env.PROD) return;
if (!getWindowFeature('enableFaro') && !import.meta.env.VITE_GRAFANA_COLLECTOR) return;

const env = getEnvFromHost();
Expand All @@ -25,6 +24,7 @@ export const initializeObservability = (history: ReactRouterHistory) => {
app: {
name: 'modiapersonoversikt'
},
paused: !import.meta.env.PROD,
instrumentations: [
...getWebInstrumentations(),
new ReactIntegration({
Expand Down

0 comments on commit 178df24

Please sign in to comment.