diff --git a/package-lock.json b/package-lock.json index fd3d723..1f6162c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@maplibre/maplibre-gl-geocoder": "^1.5.0", "@mdi/js": "^7.4.47", "@mdi/react": "^1.6.1", + "@sentry/react": "^7.100.1", "bulma": "^0.9.4", "bulma-checkradio": "^2.1.3", "events": "^3.3.0", @@ -1408,6 +1409,126 @@ "win32" ] }, + "node_modules/@sentry-internal/feedback": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-7.100.1.tgz", + "integrity": "sha512-yqcRVnjf+qS+tC4NxOKLJOaSJ+csHmh/dHUzvCTkf5rLsplwXYRnny2r0tqGTQ4tuXMxwgSMKPYwicg81P+xuw==", + "dependencies": { + "@sentry/core": "7.100.1", + "@sentry/types": "7.100.1", + "@sentry/utils": "7.100.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry-internal/replay-canvas": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-7.100.1.tgz", + "integrity": "sha512-TnqxqJGhbFhhYRhTG2WLFer+lVieV7mNGeIxFBiw1L4kuj8KGl+C0sknssKyZSRVJFSahhHIosHJGRMkkD//7g==", + "dependencies": { + "@sentry/core": "7.100.1", + "@sentry/replay": "7.100.1", + "@sentry/types": "7.100.1", + "@sentry/utils": "7.100.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry-internal/tracing": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.100.1.tgz", + "integrity": "sha512-+u9RRf5eL3StiyiRyAHZmdkAR7GTSGx4Mt4Lmi5NEtCcWlTGZ1QgW2r8ZbhouVmTiJkjhQgYCyej3cojtazeJg==", + "dependencies": { + "@sentry/core": "7.100.1", + "@sentry/types": "7.100.1", + "@sentry/utils": "7.100.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/browser": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.100.1.tgz", + "integrity": "sha512-IxHQ08ixf0bmaWpe4yt1J4UUsOpg02fxax9z3tOQYXw5MSzz5pDXn8M8DFUVJB3wWuyXhHXTub9yD3VIP9fnoA==", + "dependencies": { + "@sentry-internal/feedback": "7.100.1", + "@sentry-internal/replay-canvas": "7.100.1", + "@sentry-internal/tracing": "7.100.1", + "@sentry/core": "7.100.1", + "@sentry/replay": "7.100.1", + "@sentry/types": "7.100.1", + "@sentry/utils": "7.100.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/core": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.100.1.tgz", + "integrity": "sha512-f+ItUge/o9AjlveQq0ZUbQauKlPH1FIJbC1TRaYLJ4KNfOdrsh8yZ29RmWv0cFJ/e+FGTr603gWpRPObF5rM8Q==", + "dependencies": { + "@sentry/types": "7.100.1", + "@sentry/utils": "7.100.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/react": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.100.1.tgz", + "integrity": "sha512-EdrBtrXVLK2LSx4Rvz/nQP7HZUZQmr+t3GHV8436RAhF6vs5mntACVMBoQJRWiUvtZ1iRo3rIsIdah7DLiFPgQ==", + "dependencies": { + "@sentry/browser": "7.100.1", + "@sentry/core": "7.100.1", + "@sentry/types": "7.100.1", + "@sentry/utils": "7.100.1", + "hoist-non-react-statics": "^3.3.2" + }, + "engines": { + "node": ">=8" + }, + "peerDependencies": { + "react": "15.x || 16.x || 17.x || 18.x" + } + }, + "node_modules/@sentry/replay": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry/replay/-/replay-7.100.1.tgz", + "integrity": "sha512-B1NFjzGEFaqejxBRdUyEzH8ChXc2kfiqlA/W/Lg0aoWIl2/7nuMk+l4ld9gW5F5bIAXDTVd5vYltb1lWEbpr7w==", + "dependencies": { + "@sentry-internal/tracing": "7.100.1", + "@sentry/core": "7.100.1", + "@sentry/types": "7.100.1", + "@sentry/utils": "7.100.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry/types": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.100.1.tgz", + "integrity": "sha512-fLM+LedHuKzOd8IhXBqaQuym+AA519MGjeczBa5kGakes/BbAsUMwsNfjsKQedp7Kh44RgYF99jwoRPK2oDrXw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/utils": { + "version": "7.100.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.100.1.tgz", + "integrity": "sha512-Ve6dXr1o6xiBe3VCoJgiutmBKrugryI65EZAbYto5XI+t+PjiLLf9wXtEMF24ZrwImo4Lv3E9Uqza+fWkEbw6A==", + "dependencies": { + "@sentry/types": "7.100.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", diff --git a/package.json b/package.json index d9e6e43..6fd34bd 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "@maplibre/maplibre-gl-geocoder": "^1.5.0", "@mdi/js": "^7.4.47", "@mdi/react": "^1.6.1", + "@sentry/react": "^7.100.1", "bulma": "^0.9.4", "bulma-checkradio": "^2.1.3", "events": "^3.3.0", diff --git a/src/index.tsx b/src/index.tsx index 3b53d8f..5c99dc3 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,8 +2,10 @@ import React from "react"; import ReactDOM from "react-dom/client"; import "~/i18n"; import "~/mystyles.css"; +import initSentry from "~/sentry"; import Main from "./Main"; +initSentry(); const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement, ); diff --git a/src/sentry.ts b/src/sentry.ts new file mode 100644 index 0000000..02668d2 --- /dev/null +++ b/src/sentry.ts @@ -0,0 +1,29 @@ +import * as Sentry from "@sentry/react"; + +export default function initSentry() { + if (shouldEnableSentry()) { + Sentry.init({ + dsn: "https://7f263ca9541cbb26b1fe3228e80a8b6f@o4506736017539072.ingest.sentry.io/4506736027959296", + integrations: [Sentry.browserTracingIntegration()], + // Performance Monitoring + tracesSampleRate: 1.0, // Capture 100% of the transactions + // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled + tracePropagationTargets: [ + "localhost:5173", + /^https:\/\/(dev.)?openaedmap\.org/, + ], + }); + } +} + +function shouldEnableSentry(): boolean { + const doNotTrack = + navigator.doNotTrack === "1" || + navigator.doNotTrack === "yes" || + navigator.doNotTrack === "true"; + const globalPrivacyControl = + navigator.globalPrivacyControl === true || + navigator.globalPrivacyControl === "true"; + // return !doNotTrack && !globalPrivacyControl; + return true; +}