use better place to init faro

This commit is contained in:
2026-07-15 20:58:44 +02:00
parent 11060b66e7
commit b31320af33
2 changed files with 33 additions and 33 deletions
-33
View File
@@ -1,41 +1,8 @@
import "@/App.css"; import "@/App.css";
import {
ConsoleInstrumentation,
ConsoleTransport,
FetchTransport,
getWebInstrumentations,
initializeFaro,
ReactIntegration,
WebVitalsInstrumentation,
} from "@grafana/faro-react";
import Dashboard from "@/components/Dashboard/Dashboard"; import Dashboard from "@/components/Dashboard/Dashboard";
function App() { function App() {
const isProduction = import.meta.env.PROD;
if (window.location.hostname === "localhost" && isProduction) {
initializeFaro({
app: {
name: "monitor-im-flur",
version: "0.0.1",
environment: "test",
},
instrumentations: [
...getWebInstrumentations(),
new ConsoleInstrumentation(),
new WebVitalsInstrumentation(),
new ReactIntegration(),
],
transports: [
new FetchTransport({
url: "http://192.168.2.51:12347/collect",
}),
new ConsoleTransport(),
],
});
}
return <Dashboard />; return <Dashboard />;
} }
+33
View File
@@ -1,9 +1,42 @@
import {
ConsoleInstrumentation,
ConsoleTransport,
FetchTransport,
getWebInstrumentations,
initializeFaro,
ReactIntegration,
WebVitalsInstrumentation,
} from "@grafana/faro-react";
import { StrictMode } from "react"; import { StrictMode } from "react";
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
import "./index.css"; import "./index.css";
import App from "./App.tsx"; import App from "./App.tsx";
const isProduction = import.meta.env.PROD;
if (window.location.hostname === "localhost" && isProduction) {
initializeFaro({
app: {
name: "monitor-im-flur",
version: "0.0.1",
environment: "test",
},
instrumentations: [
...getWebInstrumentations(),
new ConsoleInstrumentation(),
new WebVitalsInstrumentation(),
new ReactIntegration(),
],
transports: [
new FetchTransport({
url: "http://192.168.2.51:12347/collect",
}),
new ConsoleTransport(),
],
});
}
// biome-ignore lint/style/noNonNullAssertion: if the root element is not found, the app should not render // biome-ignore lint/style/noNonNullAssertion: if the root element is not found, the app should not render
createRoot(document.getElementById("root")!).render( createRoot(document.getElementById("root")!).render(
<StrictMode> <StrictMode>