Restructure with Turborepo
Run Tests on Branches / Backend Tests (push) Successful in 3m38s
Run Tests on Branches / Frontend Tests (push) Successful in 3m28s

This commit is contained in:
Antoni Nuñez Romeu
2026-07-06 15:51:53 +02:00
parent f66cafbbc3
commit 190b3d163d
277 changed files with 53253 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
// Grafana Faro — browser RUM SDK initializer.
// Sends Web Vitals, JS errors, console messages, fetch/XHR, navigation,
// and React component lifecycle events to Grafana Alloy via OTLP HTTP.
//
// Required env vars (Vite injects VITE_* at build time):
// VITE_FARO_ENDPOINT — e.g. http://localhost:4318
// VITE_FARO_APP_NAME — e.g. farmaclic-frontend
// VITE_FARO_ENV — e.g. production | staging | development
// VITE_FARO_APP_VERSION — optional, defaults to 1.0.0
import {
getWebInstrumentations,
ReactIntegration,
initializeFaro,
} from '@grafana/faro-react';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';
import { OtlpHttpTransport } from '@grafana/faro-transport-otlp-http';
let initialized = false;
export function initFaro() {
if (initialized) return;
initialized = true;
const endpoint = import.meta.env.VITE_FARO_ENDPOINT;
if (!endpoint) {
// Faro is optional. If the endpoint is not configured (e.g. local dev
// without an Alloy collector), do nothing so the app still runs.
return;
}
const appName = import.meta.env.VITE_FARO_APP_NAME || 'farmaclic-frontend';
const environment = import.meta.env.VITE_FARO_ENV || 'production';
const version = import.meta.env.VITE_FARO_APP_VERSION || '1.0.0';
try {
initializeFaro({
url: `${endpoint.replace(/\/$/, '')}/v1/traces`,
app: {
name: appName,
environment,
version,
},
instrumentations: [
...getWebInstrumentations({
captureConsole: true,
captureConsoleDisabledLevels: ['debug'],
captureException: true,
captureMessage: true,
captureResource: true,
captureUserInteraction: true,
captureXHRInstrumentation: true,
captureFetchInstrumentation: true,
captureWebVitals: true,
captureNavigation: true,
}),
new ReactIntegration(),
new TracingInstrumentation(),
],
transport: new OtlpHttpTransport({
url: `${endpoint.replace(/\/$/, '')}/v1/traces`,
}),
});
} catch (err) {
// Never let Faro init failure break the app.
// eslint-disable-next-line no-console
console.warn('[faro] init failed', err);
}
}