From 2b93cf3610da3db6d55ab50ff8dfe0d555781385 Mon Sep 17 00:00:00 2001 From: OrchestrAI Bot Date: Fri, 27 Feb 2026 00:47:50 +0100 Subject: [PATCH] Add dynatrace instrumentation Instrumented 1 files with dynatrace tracking code. --- frontend/src/main.tsx | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index 0d80ea6f8d..72d175ba05 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -23,6 +23,39 @@ const handleApiError = (error: Error) => { window.location.href = "/login" } } + +// Initialize Dynatrace user identification and session properties +const initializeDynatrace = () => { + if (typeof (window as any).dtrum !== 'undefined') { + // Identify user if authenticated + const accessToken = localStorage.getItem("access_token") + if (accessToken) { + try { + const payload = JSON.parse(atob(accessToken.split('.')[1])) + if (payload.sub) { + (window as any).dtrum.identifyUser(payload.sub) + } + } catch (e) { + // Token parsing failed, continue without user identification + } + } + + // Add session properties + (window as any).dtrum.sendSessionProperties({ + 'app.name': 'frontend', + 'app.environment': import.meta.env.MODE || 'development', + 'app.version': import.meta.env.VITE_APP_VERSION || '1.0.0' + }) + } +} + +// Initialize Dynatrace when DOM is ready +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', initializeDynatrace) +} else { + initializeDynatrace() +} + const queryClient = new QueryClient({ queryCache: new QueryCache({ onError: handleApiError, @@ -47,4 +80,4 @@ ReactDOM.createRoot(document.getElementById("root")!).render( , -) +) \ No newline at end of file