diff --git a/gui/src/hooks/app.ts b/gui/src/hooks/app.ts index 1ec89f1b6..fd1dee2ad 100644 --- a/gui/src/hooks/app.ts +++ b/gui/src/hooks/app.ts @@ -4,7 +4,6 @@ import { Reducer, useContext, useEffect, - useLayoutEffect, useMemo, useReducer, useState, @@ -27,7 +26,7 @@ import { useDataFeedConfig } from './datafeed-config'; import { useWebsocketAPI } from './websocket-api'; import { error } from '@/utils/logging'; import { cacheWrap } from './cache'; -import { getSentryOrCompute } from '@/utils/sentry'; +import { updateSentryContext } from '@/utils/sentry'; export interface FirmwareRelease { name: string; @@ -116,6 +115,10 @@ export function useProvideAppContext(): AppContext { dispatch({ type: 'datafeed', value: packet }); }); + useEffect(() => { + updateSentryContext(state); + }, [state.datafeed?.devices]) + useRPCPacket(RpcMessage.ResetResponse, ({ status, resetType }: ResetResponseT) => { if (!config?.feedbackSound) return; try { diff --git a/gui/src/utils/sentry.ts b/gui/src/utils/sentry.ts index 0da47e262..ad79addce 100644 --- a/gui/src/utils/sentry.ts +++ b/gui/src/utils/sentry.ts @@ -7,6 +7,7 @@ import { useLocation, useNavigationType, } from 'react-router-dom'; +import { AppState } from '@/hooks/app'; export function getSentryOrCompute(enabled = false) { // if sentry is already initialized - SKIP @@ -51,6 +52,7 @@ export function getSentryOrCompute(enabled = false) { // Session Replay replaysSessionSampleRate: import.meta.env.PROD ? 0.1 : 1.0, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production. replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur. + normalizeDepth: 8, enabled, }); @@ -62,3 +64,19 @@ export function getSentryOrCompute(enabled = false) { return newClient; } + + +export function updateSentryContext(state: AppState) { + + // We filter out the shit we dont want. We dont need rotation data or ip addresses + const trackers = (state.datafeed?.devices || []).map(({ hardwareInfo, trackers, id }) => ({ + id: id?.id, + hardwareInfo: { ...hardwareInfo, ipAddress: undefined }, + trackers: trackers.map(({ info, trackerId }) => ({ info, trackerId: { trackerNum: trackerId?.trackerNum, deviceId: trackerId?.deviceId?.id } })) + })) + + // Will send the latest context to sentry when an error happens + Sentry.setContext('trackers', { + trackers + }); +}