diff --git a/src/App.tsx b/src/App.tsx index 6728bbf..fc4cbd4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,41 +1,8 @@ import "@/App.css"; -import { - ConsoleInstrumentation, - ConsoleTransport, - FetchTransport, - getWebInstrumentations, - initializeFaro, - ReactIntegration, - WebVitalsInstrumentation, -} from "@grafana/faro-react"; import Dashboard from "@/components/Dashboard/Dashboard"; 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 ; } diff --git a/src/main.tsx b/src/main.tsx index 5f86e7d..7d92a62 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,9 +1,42 @@ +import { + ConsoleInstrumentation, + ConsoleTransport, + FetchTransport, + getWebInstrumentations, + initializeFaro, + ReactIntegration, + WebVitalsInstrumentation, +} from "@grafana/faro-react"; import { StrictMode } from "react"; import { createRoot } from "react-dom/client"; import "./index.css"; 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 createRoot(document.getElementById("root")!).render(