Skip to content

Commit 5697ded

Browse files
committed
sentry does this
1 parent 362dead commit 5697ded

File tree

2 files changed

+2
-46
lines changed

2 files changed

+2
-46
lines changed

src/app/Flash.jsx

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useRef, useState } from 'react'
22
import posthog from 'posthog-js'
3-
import { addBreadcrumb, setTags, setTag, setContext, captureSessionSummary } from '../utils/telemetry'
3+
import { addBreadcrumb, setTags, setTag, captureSessionSummary } from '../utils/telemetry'
44

55
import { FlashManager, StepCode, ErrorCode, DeviceType } from '../utils/manager'
66
import { useImageManager } from '../utils/image'
@@ -55,38 +55,6 @@ const originalConsole = { log: console.log, warn: console.warn, error: console.e
5555
// Unique per-page session id for correlating events
5656
const SESSION_ID = (crypto && 'randomUUID' in crypto) ? crypto.randomUUID() : String(Math.random()).slice(2)
5757

58-
// Helper for building environment metadata
59-
function buildEnvMeta() {
60-
const ua = navigator.userAgent
61-
let os = 'Unknown'
62-
if (ua.includes('Windows NT 10.0')) os = 'Windows 10/11'
63-
else if (ua.includes('Windows NT 6.3')) os = 'Windows 8.1'
64-
else if (ua.includes('Windows NT 6.2')) os = 'Windows 8'
65-
else if (ua.includes('Windows NT 6.1')) os = 'Windows 7'
66-
else if (ua.includes('Mac OS X')) {
67-
const match = ua.match(/Mac OS X (\d+[._]\d+[._]?\d*)/)
68-
os = match ? `macOS ${match[1].replace(/_/g, '.')}` : 'macOS'
69-
} else if (ua.includes('Linux')) {
70-
os = 'Linux'
71-
if (ua.includes('Ubuntu')) os += ' (Ubuntu)'
72-
else if (ua.includes('Fedora')) os += ' (Fedora)'
73-
else if (ua.includes('Debian')) os += ' (Debian)'
74-
} else if (ua.includes('CrOS')) os = 'ChromeOS'
75-
76-
const sandboxHints = []
77-
if (ua.includes('snap')) sandboxHints.push('Snap')
78-
if (ua.includes('Flatpak')) sandboxHints.push('Flatpak')
79-
if (navigator.userAgentData?.brands?.some(b => b.brand.includes('snap'))) sandboxHints.push('Snap')
80-
81-
return {
82-
os,
83-
sandbox: sandboxHints.length ? sandboxHints.join(', ') : 'None detected',
84-
browser: navigator.userAgent,
85-
url: window.location.href,
86-
version: import.meta.env.VITE_PUBLIC_GIT_SHA || 'dev',
87-
}
88-
}
89-
9058
// Debug info component for error reporting
9159
function DebugInfo({ error, step, selectedDevice, serial, message, onClose }) {
9260
const [copied, setCopied] = useState(false)
@@ -717,7 +685,6 @@ export default function Flash() {
717685
// Telemetry: set static tags/context once
718686
useEffect(() => {
719687
setTags({ session_id: SESSION_ID })
720-
setContext('env', buildEnvMeta())
721688
}, [])
722689

723690
// Telemetry: tag device selection
@@ -751,14 +718,7 @@ export default function Flash() {
751718
})
752719

753720
// Sentry (for errors with full context)
754-
const meta = {
755-
...buildEnvMeta(),
756-
selectedDevice,
757-
connected,
758-
serial,
759-
step,
760-
message,
761-
}
721+
const meta = { selectedDevice, serial, step, message }
762722
const tail = consoleLogs.slice(-200)
763723
captureSessionSummary({
764724
sessionId: SESSION_ID,

src/utils/telemetry.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ export function setTag(key, value) {
1717
Sentry.setTag(key, value)
1818
}
1919

20-
export function setContext(key, context) {
21-
Sentry.setContext(key, context)
22-
}
23-
2420
export function addBreadcrumb({ category, message, level = 'info', data }) {
2521
Sentry.addBreadcrumb({ category, message, level, data })
2622
}

0 commit comments

Comments
 (0)