only init faro when env is production

This commit is contained in:
2026-07-11 17:48:54 +02:00
parent 1a207185ff
commit 018bd6d87d
3 changed files with 19 additions and 4 deletions
+5
View File
@@ -27,9 +27,14 @@ jobs:
exit 1 exit 1
fi fi
# Get version from package.json
VERSION=$(node -p "require('./package.json').version")
cat > .env.production <<EOF cat > .env.production <<EOF
VITE_FLATTASTIC_API_KEY=${VITE_FLATTASTIC_API_KEY} VITE_FLATTASTIC_API_KEY=${VITE_FLATTASTIC_API_KEY}
VITE_HA_TOKEN=${VITE_HA_TOKEN} VITE_HA_TOKEN=${VITE_HA_TOKEN}
VITE_APP_VERSION=${VERSION}
VITE_APP_ENV=production
EOF EOF
env: env:
VITE_FLATTASTIC_API_KEY: ${{ secrets.VITE_FLATTASTIC_API_KEY }} VITE_FLATTASTIC_API_KEY: ${{ secrets.VITE_FLATTASTIC_API_KEY }}
+7 -1
View File
@@ -1,5 +1,11 @@
FROM nginx:alpine FROM nginx:alpine
# Set production environment
ENV VITE_APP_ENV=production
COPY ./dist /usr/share/nginx/html COPY ./dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80 EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]
+7 -3
View File
@@ -8,13 +8,17 @@ import {
import Dashboard from "@/components/Dashboard/Dashboard"; import Dashboard from "@/components/Dashboard/Dashboard";
function App() { function App() {
if (window.location.hostname === "localhost") { const isProduction = import.meta.env.PROD;
if (isProduction) {
console.debug("Initializing Faro environment...");
initializeFaro({ initializeFaro({
url: "http://localhost:12347/collect", url: "http://localhost:12347/collect",
app: { app: {
name: "monitor-im-flur", name: "monitor-im-flur",
version: "0.0.1", version: import.meta.env.VITE_APP_VERSION || "0.0.1",
environment: "development", environment: "production",
}, },
instrumentations: [ instrumentations: [
...getWebInstrumentations(), ...getWebInstrumentations(),