telemetry fixes

This commit is contained in:
Brahim Hadriche committed 2026-07-23 13:39:43 -04:00
1 parent 156a4b5172
commit 95deab6ca4
5 files changed
+83 -11

No files matched your search

@@ -48,6 +48,7 @@ function TelemetryLoop() as void
m.dist = GetDist(m.tags) m.dist = GetDist(m.tags)
m.userId = GetUserId() m.userId = GetUserId()
ReportSessionStart()
ReportLastExitCrash() ReportLastExitCrash()
m.top.observeField("LogInfo", msgPort) m.top.observeField("LogInfo", msgPort)
@@ -153,6 +154,18 @@ function TelemetryLoop() as void
end while end while
end function end function
function ReportSessionStart() as void
Sentry.SendEvents([{
level: "info"
message: "[SESSION] start"
fingerprint: ["session start"]
release: m.release
dist: m.dist
tags: m.tags
userId: m.userId
}])
end function
function GetTags() as object function GetTags() as object
appInfo = m.applicationInfo appInfo = m.applicationInfo
tags = appInfo@.GetAppInfo() tags = appInfo@.GetAppInfo()
@@ -33,6 +33,10 @@ function ExecuteJob() as void
service = new Invidious.InvidiousService(invidiousNode) service = new Invidious.InvidiousService(invidiousNode)
backend = preferencesNode["backend.selected"] backend = preferencesNode["backend.selected"]
backendId = ResolveBackendId(backend, service)
contentNode.addFields({ backend: backendId })
contentNode.backend = backendId
cancellation = JobGetCancellation() cancellation = JobGetCancellation()
if backend = "playlet" if backend = "playlet"
@@ -220,6 +224,16 @@ function SessionDataComplete(sessionData as object) as boolean
return IsAssociativeArray(sessionData) and not StringUtils.IsNullOrEmpty(sessionData.visitorData) and not StringUtils.IsNullOrEmpty(sessionData.livingRoomPoTokenId) return IsAssociativeArray(sessionData) and not StringUtils.IsNullOrEmpty(sessionData.visitorData) and not StringUtils.IsNullOrEmpty(sessionData.livingRoomPoTokenId)
end function end function
function ResolveBackendId(backend as string, service as Invidious.InvidiousService) as string
if backend = "playlet"
return "playlet"
end if
if service.GetInstance() = Invidious.PLAYLET_BUILT_IN_INSTANCE
return "built-in"
end if
return "invidious"
end function
function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object, backend as string, playletServerPort as integer) as object function CreateStreamUrls(metadata as object, service as Invidious.InvidiousService, preferences as object, backend as string, playletServerPort as integer) as object
instance = service.GetInstance() instance = service.GetInstance()
proxyVideos = preferences["invidious.proxy_videos"] proxyVideos = preferences["invidious.proxy_videos"]
@@ -805,7 +805,7 @@ function EnforceTransportFreeze(source as string) as void
LogErrorNoTelemetry(healInfo) LogErrorNoTelemetry(healInfo)
if m.healCount <= INV_D1_TELEMETRY_CAP if m.healCount <= INV_D1_TELEMETRY_CAP
LogTelemetryEvent({ LogTelemetryEvent({
level: "error" level: "warning"
message: healInfo message: healInfo
fingerprint: ["INV-D1 heal", m.transport.transportMode, source] fingerprint: ["INV-D1 heal", m.transport.transportMode, source]
}) })
@@ -842,7 +842,7 @@ end function
function SendHealSummary() as void function SendHealSummary() as void
if m.healCount > INV_D1_TELEMETRY_CAP if m.healCount > INV_D1_TELEMETRY_CAP
LogTelemetryEvent({ LogTelemetryEvent({
level: "error" level: "warning"
message: `INV-D1 heal: ${m.healCount} heals over one content (${m.healCount - INV_D1_TELEMETRY_CAP} past the telemetry cap)` message: `INV-D1 heal: ${m.healCount} heals over one content (${m.healCount - INV_D1_TELEMETRY_CAP} past the telemetry cap)`
fingerprint: ["INV-D1 heal suppressed"] fingerprint: ["INV-D1 heal suppressed"]
}) })
@@ -1152,7 +1152,7 @@ function OnVideoContentJobDone(event as object) as void
content = m.top.content content = m.top.content
if not info.success if not info.success
LogError("VideoContentJob FAILED:", info.error) LogError(`VideoContentJob FAILED: ${info.error}\nbackend: ${ContentBackend(content)}`)
decision = ErrorDialogController.DecideContentJobFailure(content, info.error) decision = ErrorDialogController.DecideContentJobFailure(content, info.error)
ShowErrorDialog(decision) ShowErrorDialog(decision)
Lounge.SendOnStateChange() Lounge.SendOnStateChange()
@@ -1442,6 +1442,13 @@ function GetPlayerErrorData(videoId as string, errorInfo as object) as object
return { title: title, body: body, fingerprint: fingerprint } return { title: title, body: body, fingerprint: fingerprint }
end function end function
function ContentBackend(content as object) as string
if content <> invalid and not StringUtils.IsNullOrEmpty(content.backend)
return content.backend
end if
return "unknown"
end function
' Send a stream error to telemetry. For malformed-data errors, attach the last generated DASH/HLS manifest and ' Send a stream error to telemetry. For malformed-data errors, attach the last generated DASH/HLS manifest and
' player response so the failure can be diagnosed from the report. ' player response so the failure can be diagnosed from the report.
function ReportVideoError(errorData as object, url as dynamic, urls as object, urlIndex as dynamic, shownInDialog as boolean) as void function ReportVideoError(errorData as object, url as dynamic, urls as object, urlIndex as dynamic, shownInDialog as boolean) as void
@@ -1464,21 +1471,19 @@ function ReportVideoError(errorData as object, url as dynamic, urls as object, u
data: ValidString(ReadAsciiFile("cachefs:/last_player_response.json")) data: ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
}] }]
end if end if
potAttached = "false" potAttached = false
potSource = "none" potSource = "none"
loggedIn = "false" loggedIn = false
content = m.top.content content = m.top.content
if content <> invalid if content <> invalid
if ValidBool(content.potAttached) potAttached = ValidBool(content.potAttached)
potAttached = "true" loggedIn = ValidBool(content.loggedIn)
end if
if not StringUtils.IsNullOrEmpty(content.potSource) if not StringUtils.IsNullOrEmpty(content.potSource)
potSource = content.potSource potSource = content.potSource
end if end if
if ValidBool(content.loggedIn)
loggedIn = "true"
end if
end if end if
backend = ContentBackend(content)
isLive = m.transport.isLive
message = [ message = [
errorData.title errorData.title
errorData.body errorData.body
@@ -1491,11 +1496,15 @@ function ReportVideoError(errorData as object, url as dynamic, urls as object, u
`pot_attached: ${potAttached}` `pot_attached: ${potAttached}`
`pot_source: ${potSource}` `pot_source: ${potSource}`
`logged_in: ${loggedIn}` `logged_in: ${loggedIn}`
`backend: ${backend}`
`is_live: ${isLive}`
].Join(Chr(10)) ].Join(Chr(10))
errorData.fingerprint.Push(shownInDialog) errorData.fingerprint.Push(shownInDialog)
errorData.fingerprint.Push(potAttached) errorData.fingerprint.Push(potAttached)
errorData.fingerprint.Push(potSource) errorData.fingerprint.Push(potSource)
errorData.fingerprint.Push(loggedIn) errorData.fingerprint.Push(loggedIn)
errorData.fingerprint.Push(backend)
errorData.fingerprint.Push(isLive)
if shownInDialog if shownInDialog
level = "error" level = "error"
else else
@@ -151,6 +151,10 @@ function TestPlaybackErrorDialog(errorFields as object) as object
playletStreamUrls: [] playletStreamUrls: []
playletStreamUrlIndex: 0 playletStreamUrlIndex: 0
}) })
if errorFields.backend <> invalid
content.addField("backend", "string", false)
content.backend = errorFields.backend
end if
m.top.content = content m.top.content = content
m.top.errorMsg = errorFields.errorMsg m.top.errorMsg = errorFields.errorMsg
@@ -183,6 +183,38 @@ namespace Tests
m.assertTrue(snap.title.Instr("dQw4w9WgXcQ") >= 0, "dialog title dropped the videoId") m.assertTrue(snap.title.Instr("dQw4w9WgXcQ") >= 0, "dialog title dropped the videoId")
end function end function
@it("the reported playback error carries the serving backend and the live flag")
function _()
m.top.callFunc("TestPlaybackErrorDialog", {
videoId: "dQw4w9WgXcQ"
errorMsg: "no valid bitrates"
errorCode: -5
errorStr: "buffer:loop:demux:Errors seen on all bitrates:last_err:503"
errorInfo: { category: "mediaerror", source: "buffer:loop:demux", ignored: false }
backend: "built-in"
})
reported = m.global.telemetry.LogEvent
m.assertTrue(reported.message.Instr("backend: built-in") > 0, "got: " + reported.message)
m.assertTrue(reported.message.Instr("is_live: false") > 0, "got: " + reported.message)
m.assertTrue(reported.message.Instr("pot_attached: false") > 0, "got: " + reported.message)
m.assertArrayContains(reported.fingerprint, "built-in")
end function
@it("a playback error on a content node with no backend reports it as unknown")
function _()
m.top.callFunc("TestPlaybackErrorDialog", {
videoId: "dQw4w9WgXcQ"
errorMsg: "no valid bitrates"
errorCode: -5
errorStr: "buffer:loop:demux:Errors seen on all bitrates:last_err:403"
errorInfo: { category: "mediaerror", source: "buffer:loop:demux", ignored: false }
})
reported = m.global.telemetry.LogEvent
m.assertTrue(reported.message.Instr("backend: unknown") > 0, "got: " + reported.message)
end function
' Up/Down reveal the chrome when it is hidden in idle (they otherwise do nothing). ' Up/Down reveal the chrome when it is hidden in idle (they otherwise do nothing).
@it("Up reveals the chrome when it is hidden in idle") @it("Up reveals the chrome when it is hidden in idle")
function _() function _()