Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ The compiler URL can be configured in the `.env` file:
VITE_COMPILER_URL=https://compiler.sensebox.de
```

### Sentry Error Tracking

Sentry is configured for error tracking. Set the following environment variables:

```env
VITE_SENTRY_DSN=your-sentry-dsn
VITE_SENTRY_ENVIRONMENT=development
VITE_APP_VERSION=1.0.0
VITE_SENTRY_TRACES_SAMPLE_RATE=0.1
```

## 📝 Development Guidelines

### Code Style
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@blockly/block-plus-minus": "^9.0.1",
"@blockly/field-colour": "^6.0.4",
"@blockly/field-multilineinput": "^6.0.5",
"@blockly/field-grid-dropdown": "^6.0.6",
"@blockly/field-multilineinput": "^6.0.5",
"@blockly/field-slider": "8.0.2",
"@blockly/plugin-scroll-options": "^7.0.1",
"@blockly/plugin-typed-variable-modal": "^9.0.2",
Expand All @@ -26,6 +26,7 @@
"@mui/lab": "^5.0.0-alpha.110",
"@mui/material": "^5.10.16",
"@mui/styles": "^5.10.16",
"@sentry/react": "^10.34.0",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^7.2.1",
Expand Down
12 changes: 11 additions & 1 deletion src/components/ErrorBoundary.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import * as Sentry from "@sentry/react";

export default class ErrorBoundary extends React.Component {
constructor(props) {
Expand All @@ -12,8 +13,17 @@ export default class ErrorBoundary extends React.Component {
}

componentDidCatch(error, errorInfo) {
// You can also log the error to an error reporting service
// Log the error to console for development
console.log(error, errorInfo);

// Capture the error with Sentry
Sentry.captureException(error, {
contexts: {
react: {
componentStack: errorInfo.componentStack,
},
},
});
}

handleReset = () => {
Expand Down
3 changes: 3 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from "react";
import ReactDOM from "react-dom";
import { initSentry } from "./sentry";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import store from "./store";
import { fetchSensors } from "./actions/sensorwikiActions";

initSentry();

// store.dispatch(fetchSensors());

// fetchSensors();
Expand Down
54 changes: 54 additions & 0 deletions src/sentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as Sentry from "@sentry/react";
import { browserTracingIntegration, reactRouterV6BrowserTracingIntegration } from "@sentry/react";

Copilot AI Jan 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The browserTracingIntegration is already imported from @sentry/react on line 1 via the namespace import * as Sentry. This redundant import should be removed and the integration should be accessed as Sentry.browserTracingIntegration on line 37.

Copilot uses AI. Check for mistakes.

Copilot AI Jan 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since browserTracingIntegration is already available through the namespace import on line 1, this named import creates redundancy. Remove the named import and use Sentry.reactRouterV6BrowserTracingIntegration instead for consistency.

Copilot uses AI. Check for mistakes.
import {
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
} from "react-router-dom";

const SENTRY_DSN = import.meta.env.VITE_SENTRY_DSN;
const ENVIRONMENT = import.meta.env.VITE_SENTRY_ENVIRONMENT || import.meta.env.MODE || "development";
const RELEASE = import.meta.env.VITE_APP_VERSION || "unknown";
const IS_PRODUCTION = ENVIRONMENT === "production";
const IS_DEVELOPMENT = ENVIRONMENT === "development";

const getTracesSampleRate = () => {
const customRate = import.meta.env.VITE_SENTRY_TRACES_SAMPLE_RATE;
if (customRate) {
return parseFloat(customRate);
}
return IS_PRODUCTION ? 0.1 : 1.0;
};

export const initSentry = () => {
if (!SENTRY_DSN) {
if (IS_DEVELOPMENT) {
console.warn("Sentry DSN not configured. Error tracking disabled.");
}
return;
}

Sentry.init({
dsn: SENTRY_DSN,
environment: ENVIRONMENT,
release: RELEASE,
integrations: [
browserTracingIntegration({
routingInstrumentation: reactRouterV6BrowserTracingIntegration({
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
}),
}),
Comment on lines +37 to +44

Copilot AI Jan 15, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect Sentry integration API usage. reactRouterV6BrowserTracingIntegration should be used as a standalone integration, not as the routingInstrumentation parameter to browserTracingIntegration. The correct usage is to pass reactRouterV6BrowserTracingIntegration with the router hooks directly in the integrations array, replacing the browserTracingIntegration wrapper entirely.

Copilot uses AI. Check for mistakes.
],
tracesSampleRate: getTracesSampleRate(),
ignoreErrors: [
"ResizeObserver loop limit exceeded",
"ResizeObserver loop completed with undelivered notifications",
"Non-Error promise rejection captured",
],
});
};

Loading