diff --git a/playlet-lib/src/components/Telemetry/Telemetry.bs b/playlet-lib/src/components/Telemetry/Telemetry.bs index 405e2662..4bfbfd0a 100644 --- a/playlet-lib/src/components/Telemetry/Telemetry.bs +++ b/playlet-lib/src/components/Telemetry/Telemetry.bs @@ -48,6 +48,7 @@ function TelemetryLoop() as void m.dist = GetDist(m.tags) m.userId = GetUserId() + ReportSessionStart() ReportLastExitCrash() m.top.observeField("LogInfo", msgPort) @@ -153,6 +154,18 @@ function TelemetryLoop() as void end while 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 appInfo = m.applicationInfo tags = appInfo@.GetAppInfo() diff --git a/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs b/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs index 67d6b977..965fa283 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs @@ -33,6 +33,10 @@ function ExecuteJob() as void service = new Invidious.InvidiousService(invidiousNode) backend = preferencesNode["backend.selected"] + backendId = ResolveBackendId(backend, service) + contentNode.addFields({ backend: backendId }) + contentNode.backend = backendId + cancellation = JobGetCancellation() 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) 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 instance = service.GetInstance() proxyVideos = preferences["invidious.proxy_videos"] diff --git a/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs b/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs index e3b3deb7..ac6e1571 100644 --- a/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs +++ b/playlet-lib/src/components/VideoPlayerDev/VideoPlayerDev.bs @@ -805,7 +805,7 @@ function EnforceTransportFreeze(source as string) as void LogErrorNoTelemetry(healInfo) if m.healCount <= INV_D1_TELEMETRY_CAP LogTelemetryEvent({ - level: "error" + level: "warning" message: healInfo fingerprint: ["INV-D1 heal", m.transport.transportMode, source] }) @@ -842,7 +842,7 @@ end function function SendHealSummary() as void if m.healCount > INV_D1_TELEMETRY_CAP 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)` fingerprint: ["INV-D1 heal suppressed"] }) @@ -1152,7 +1152,7 @@ function OnVideoContentJobDone(event as object) as void content = m.top.content if not info.success - LogError("VideoContentJob FAILED:", info.error) + LogError(`VideoContentJob FAILED: ${info.error}\nbackend: ${ContentBackend(content)}`) decision = ErrorDialogController.DecideContentJobFailure(content, info.error) ShowErrorDialog(decision) Lounge.SendOnStateChange() @@ -1442,6 +1442,13 @@ function GetPlayerErrorData(videoId as string, errorInfo as object) as object return { title: title, body: body, fingerprint: fingerprint } 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 ' 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 @@ -1464,21 +1471,19 @@ function ReportVideoError(errorData as object, url as dynamic, urls as object, u data: ValidString(ReadAsciiFile("cachefs:/last_player_response.json")) }] end if - potAttached = "false" + potAttached = false potSource = "none" - loggedIn = "false" + loggedIn = false content = m.top.content if content <> invalid - if ValidBool(content.potAttached) - potAttached = "true" - end if + potAttached = ValidBool(content.potAttached) + loggedIn = ValidBool(content.loggedIn) if not StringUtils.IsNullOrEmpty(content.potSource) potSource = content.potSource end if - if ValidBool(content.loggedIn) - loggedIn = "true" - end if end if + backend = ContentBackend(content) + isLive = m.transport.isLive message = [ errorData.title errorData.body @@ -1491,11 +1496,15 @@ function ReportVideoError(errorData as object, url as dynamic, urls as object, u `pot_attached: ${potAttached}` `pot_source: ${potSource}` `logged_in: ${loggedIn}` + `backend: ${backend}` + `is_live: ${isLive}` ].Join(Chr(10)) errorData.fingerprint.Push(shownInDialog) errorData.fingerprint.Push(potAttached) errorData.fingerprint.Push(potSource) errorData.fingerprint.Push(loggedIn) + errorData.fingerprint.Push(backend) + errorData.fingerprint.Push(isLive) if shownInDialog level = "error" else diff --git a/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevMock.bs b/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevMock.bs index 4cc2d195..465f2191 100644 --- a/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevMock.bs +++ b/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevMock.bs @@ -151,6 +151,10 @@ function TestPlaybackErrorDialog(errorFields as object) as object playletStreamUrls: [] playletStreamUrlIndex: 0 }) + if errorFields.backend <> invalid + content.addField("backend", "string", false) + content.backend = errorFields.backend + end if m.top.content = content m.top.errorMsg = errorFields.errorMsg diff --git a/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevSeam.spec.bs b/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevSeam.spec.bs index 52691049..86b8e9df 100644 --- a/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevSeam.spec.bs +++ b/playlet-lib/src/components/VideoPlayerDev/tests/VideoPlayerDevSeam.spec.bs @@ -183,6 +183,38 @@ namespace Tests m.assertTrue(snap.title.Instr("dQw4w9WgXcQ") >= 0, "dialog title dropped the videoId") 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). @it("Up reveals the chrome when it is hidden in idle") function _()