From d8fbb1dc3470bad3582bfc174deced5b6ef487ad Mon Sep 17 00:00:00 2001 From: Kyrylo Shmidt Date: Mon, 5 Aug 2024 10:32:02 +0200 Subject: [PATCH] Pass app id to the error event --- src/components/common/App/index.tsx | 5 +++-- src/components/common/App/types.ts | 1 + src/containers/Dashboard/index.tsx | 6 ++++-- src/containers/Documentation/index.tsx | 6 ++++-- src/containers/InstallationWizard/index.tsx | 6 ++++-- src/containers/Main/index.tsx | 6 ++++-- src/containers/Notifications/index.tsx | 6 ++++-- src/containers/RecentActivity/index.tsx | 6 ++++-- src/containers/Troubleshooting/index.tsx | 6 ++++-- 9 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/components/common/App/index.tsx b/src/components/common/App/index.tsx index 9dfef1ae7..dbf09f4de 100644 --- a/src/components/common/App/index.tsx +++ b/src/components/common/App/index.tsx @@ -57,7 +57,7 @@ const getTheme = (): Theme => { const defaultMainFont = isString(window.mainFont) ? window.mainFont : ""; const defaultCodeFont = isString(window.codeFont) ? window.codeFont : ""; -export const App = ({ theme, children }: AppProps) => { +export const App = ({ theme, children, id }: AppProps) => { const [currentTheme, setCurrentTheme] = useState(theme ?? getTheme()); const [mainFont, setMainFont] = useState(defaultMainFont); const [codeFont, setCodeFont] = useState(defaultCodeFont); @@ -104,7 +104,8 @@ export const App = ({ theme, children }: AppProps) => { logger.error(error, info); sendErrorTrackingEvent(error, { severity: "high", - level: "App react component" + level: "App react component", + app: id }); }; diff --git a/src/components/common/App/types.ts b/src/components/common/App/types.ts index be476acde..c9828af53 100644 --- a/src/components/common/App/types.ts +++ b/src/components/common/App/types.ts @@ -6,6 +6,7 @@ import { InsightViewType } from "../../Insights/types"; export interface AppProps { children: ReactNode; theme?: Theme; + id?: string; } export type InstallationType = diff --git a/src/containers/Dashboard/index.tsx b/src/containers/Dashboard/index.tsx index ba17ccc0c..c49f7e1f9 100644 --- a/src/containers/Dashboard/index.tsx +++ b/src/containers/Dashboard/index.tsx @@ -12,13 +12,15 @@ import { isString } from "../../typeGuards/isString"; import { handleUncaughtError } from "../../utils/handleUncaughtError"; import { GlobalStyle } from "./styles"; +const APP_ID = "dashboard"; + initializeDigmaMessageListener(dispatcher); window.sendMessageToDigma = sendMessage; window.cancelMessageToDigma = cancelMessage; window.addEventListener("error", (e) => { - handleUncaughtError("dashboard", e); + handleUncaughtError(APP_ID, e); }); const rootElement = document.getElementById("root"); @@ -40,7 +42,7 @@ const getView = () => { if (rootElement) { const root = createRoot(rootElement); root.render( - + {getView()} diff --git a/src/containers/Documentation/index.tsx b/src/containers/Documentation/index.tsx index 5a11b2f08..944e4bb18 100644 --- a/src/containers/Documentation/index.tsx +++ b/src/containers/Documentation/index.tsx @@ -10,13 +10,15 @@ import { dispatcher } from "../../dispatcher"; import { handleUncaughtError } from "../../utils/handleUncaughtError"; import { GlobalStyle } from "./styles"; +const APP_ID = "documentation"; + initializeDigmaMessageListener(dispatcher); window.sendMessageToDigma = sendMessage; window.cancelMessageToDigma = cancelMessage; window.addEventListener("error", (e) => { - handleUncaughtError("documentation", e); + handleUncaughtError(APP_ID, e); }); const rootElement = document.getElementById("root"); @@ -24,7 +26,7 @@ const rootElement = document.getElementById("root"); if (rootElement) { const root = createRoot(rootElement); root.render( - + diff --git a/src/containers/InstallationWizard/index.tsx b/src/containers/InstallationWizard/index.tsx index 88b074187..6c979ab57 100644 --- a/src/containers/InstallationWizard/index.tsx +++ b/src/containers/InstallationWizard/index.tsx @@ -10,13 +10,15 @@ import { dispatcher } from "../../dispatcher"; import { handleUncaughtError } from "../../utils/handleUncaughtError"; import { GlobalStyle } from "./styles"; +const APP_ID = "installationWizard"; + initializeDigmaMessageListener(dispatcher); window.sendMessageToDigma = sendMessage; window.cancelMessageToDigma = cancelMessage; window.addEventListener("error", (e) => { - handleUncaughtError("installationWizard", e); + handleUncaughtError(APP_ID, e); }); const rootElement = document.getElementById("root"); @@ -24,7 +26,7 @@ const rootElement = document.getElementById("root"); if (rootElement) { const root = createRoot(rootElement); root.render( - + diff --git a/src/containers/Main/index.tsx b/src/containers/Main/index.tsx index 2cd3638f3..f2519db8e 100644 --- a/src/containers/Main/index.tsx +++ b/src/containers/Main/index.tsx @@ -10,13 +10,15 @@ import { dispatcher } from "../../dispatcher"; import { handleUncaughtError } from "../../utils/handleUncaughtError"; import { router } from "./router"; +const APP_ID = "main"; + initializeDigmaMessageListener(dispatcher); window.sendMessageToDigma = sendMessage; window.cancelMessageToDigma = cancelMessage; window.addEventListener("error", (e) => { - handleUncaughtError("main", e); + handleUncaughtError(APP_ID, e); }); const rootElement = document.getElementById("root"); @@ -24,7 +26,7 @@ const rootElement = document.getElementById("root"); if (rootElement) { const root = createRoot(rootElement); root.render( - + ); diff --git a/src/containers/Notifications/index.tsx b/src/containers/Notifications/index.tsx index 47392348f..11cf7b884 100644 --- a/src/containers/Notifications/index.tsx +++ b/src/containers/Notifications/index.tsx @@ -10,13 +10,15 @@ import { dispatcher } from "../../dispatcher"; import { handleUncaughtError } from "../../utils/handleUncaughtError"; import { GlobalStyle } from "./styles"; +const APP_ID = "notifications"; + initializeDigmaMessageListener(dispatcher); window.sendMessageToDigma = sendMessage; window.cancelMessageToDigma = cancelMessage; window.addEventListener("error", (e) => { - handleUncaughtError("notifications", e); + handleUncaughtError(APP_ID, e); }); const rootElement = document.getElementById("root"); @@ -24,7 +26,7 @@ const rootElement = document.getElementById("root"); if (rootElement) { const root = createRoot(rootElement); root.render( - + diff --git a/src/containers/RecentActivity/index.tsx b/src/containers/RecentActivity/index.tsx index 0bcd401fb..5d5752501 100644 --- a/src/containers/RecentActivity/index.tsx +++ b/src/containers/RecentActivity/index.tsx @@ -10,13 +10,15 @@ import { dispatcher } from "../../dispatcher"; import { handleUncaughtError } from "../../utils/handleUncaughtError"; import { GlobalStyle } from "./styles"; +const APP_ID = "recentActivity"; + initializeDigmaMessageListener(dispatcher); window.sendMessageToDigma = sendMessage; window.cancelMessageToDigma = cancelMessage; window.addEventListener("error", (e) => { - handleUncaughtError("recentActivity", e); + handleUncaughtError(APP_ID, e); }); const rootElement = document.getElementById("root"); @@ -24,7 +26,7 @@ const rootElement = document.getElementById("root"); if (rootElement) { const root = createRoot(rootElement); root.render( - + diff --git a/src/containers/Troubleshooting/index.tsx b/src/containers/Troubleshooting/index.tsx index d7053e1ed..06a375980 100644 --- a/src/containers/Troubleshooting/index.tsx +++ b/src/containers/Troubleshooting/index.tsx @@ -10,13 +10,15 @@ import { dispatcher } from "../../dispatcher"; import { handleUncaughtError } from "../../utils/handleUncaughtError"; import { GlobalStyle } from "./styles"; +const APP_ID = "troubleshooting"; + initializeDigmaMessageListener(dispatcher); window.sendMessageToDigma = sendMessage; window.cancelMessageToDigma = cancelMessage; window.addEventListener("error", (e) => { - handleUncaughtError("troubleshooting", e); + handleUncaughtError(APP_ID, e); }); const rootElement = document.getElementById("root"); @@ -24,7 +26,7 @@ const rootElement = document.getElementById("root"); if (rootElement) { const root = createRoot(rootElement); root.render( - +