diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24841bb9..2235ce67 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [Unreleased]
+
+### Fixed
+
+- Various telemetry issues
+- Ignore certain nodes in parser (such as movies, since they are not supported)
+- A bug where video title is missing while loading
+
## [0.41.1] - 2025-08-29
### Fixed
diff --git a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingJob.bs b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingJob.bs
index 54ade6ad..ac6d35a8 100644
--- a/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingJob.bs
+++ b/playlet-lib/src/components/Screens/SettingsScreen/InvidiousInstance/InvidiousInstanceTesting/InvidiousInstanceTestingJob.bs
@@ -62,7 +62,9 @@ function RunTests(instance as string, content as object, cancellation as object)
testNode.title = `${testNode.title} (${testNode.duration}ms)`
if testNode.state = "failed"
+ m.noTelemetry = true
LogError(testNode.details)
+ m.noTelemetry = false
end if
if CancellationUtils.IsCancelled(cancellation)
diff --git a/playlet-lib/src/components/Services/Dash/DashManifest.bs b/playlet-lib/src/components/Services/Dash/DashManifest.bs
index 5d6493a2..50e852c5 100644
--- a/playlet-lib/src/components/Services/Dash/DashManifest.bs
+++ b/playlet-lib/src/components/Services/Dash/DashManifest.bs
@@ -48,7 +48,9 @@ class DashManifest
audioStreams = m.getAudioStreams(adaptiveFormats)
videoStreams = m.getVideoStreams(adaptiveFormats, qualityFilter)
if videoStreams.Count() = 0
+ m.noTelemetry = true
LogWarn("No video streams found using quality filter:", qualityFilter, "Falling back to all video streams")
+ m.noTelemetry = false
videoStreams = m.getVideoStreams(adaptiveFormats, {})
end if
@@ -192,18 +194,19 @@ class DashManifest
id += 1
end for
- storyboardsAdded = false
' https://developer.roku.com/en-ca/docs/developer-program/media-playback/trick-mode/hls-and-dash.md#dash-standard-thumbnail-tiles
for each storyboard in storyboards
interval = ValidInt(storyboard.interval)
if interval = 0
- LogInfo("Invalid storyboard interval:", storyboard.interval)
+ LogWarn("Invalid storyboard interval:", storyboard.interval)
continue for
end if
templateUrl = storyboard.templateUrl
if templateUrl.Instr("$M") = -1
+ m.noTelemetry = true
LogInfo("Invalid storyboard url: url does not contain $M:", templateUrl)
+ m.noTelemetry = false
continue for
end if
@@ -268,13 +271,8 @@ class DashManifest
end if
id += 1
- storyboardsAdded = true
end for
- if storyboards.Count() > 0 and not storyboardsAdded
- LogWarn("No valid storyboards found")
- end if
-
xml.End()
end if
xml.End()
diff --git a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs
index 18210770..2b432fde 100644
--- a/playlet-lib/src/components/Services/Innertube/InnertubeService.bs
+++ b/playlet-lib/src/components/Services/Innertube/InnertubeService.bs
@@ -112,7 +112,20 @@ namespace InnertubeService
return GetVideoMetadata(videoId, options)
end if
if code = "MISSING_FORMAT_FIELD"
- m.global.telemetry.LogError = code + `\n` + playerRequest.ToCurlCommand() + `\n` + playerResponse.Text()
+ m.global.telemetry.LogEvent = {
+ level: "error"
+ message: code
+ fingerprint: code
+ attachments: [{
+ filename: "request.txt"
+ content_type: "text/plain"
+ data: playerRequest.ToCurlCommand()
+ }, {
+ filename: "response.json"
+ content_type: "application/json"
+ data: playerResponse.Text()
+ }]
+ }
end if
throw exception
end try
diff --git a/playlet-lib/src/components/Services/Innertube/NextEndpoint.bs b/playlet-lib/src/components/Services/Innertube/NextEndpoint.bs
index 27282ca9..4933b6c7 100644
--- a/playlet-lib/src/components/Services/Innertube/NextEndpoint.bs
+++ b/playlet-lib/src/components/Services/Innertube/NextEndpoint.bs
@@ -40,17 +40,37 @@ namespace Innertube
return parsedResponse
end if
- if not IsArray(parsedResponse.recommendedVideos)
- LogWarn("Invalid recommended videos", parsedResponse.recommendedVideos)
- return parsedResponse
- end if
-
if not IsAssociativeArray(payload)
LogWarn("Invalid payload", payload)
return parsedResponse
end if
- endscreen = ObjectUtils.Dig(payload, ["playerOverlays", "playerOverlayRenderer", "endScreen"])
+ playerOverlayRenderer = ObjectUtils.Dig(payload, ["playerOverlays", "playerOverlayRenderer"])
+ if not IsAssociativeArray(playerOverlayRenderer)
+ LogWarn("Invalid playerOverlayRenderer", playerOverlayRenderer)
+ return parsedResponse
+ end if
+
+ if StringUtils.IsNullOrEmpty(parsedResponse.title)
+ title = ParseText(ObjectUtils.Dig(playerOverlayRenderer, ["videoDetails", "playerOverlayVideoDetailsRenderer", "title"]))
+ if not StringUtils.IsNullOrEmpty(title)
+ parsedResponse.title = title
+ end if
+ end if
+
+ if StringUtils.IsNullOrEmpty(parsedResponse.author)
+ subtitle = ParseText(ObjectUtils.Dig(playerOverlayRenderer, ["videoDetails", "playerOverlayVideoDetailsRenderer", "subtitle"]))
+ if not StringUtils.IsNullOrEmpty(subtitle)
+ parsedResponse.author = subtitle
+ end if
+ end if
+
+ if not IsArray(parsedResponse.recommendedVideos)
+ LogWarn("Invalid recommended videos", parsedResponse.recommendedVideos)
+ return parsedResponse
+ end if
+
+ endscreen = playerOverlayRenderer["endScreen"]
feeds = Innertube.ParseResponseDataForFeeds(endscreen, { noContainers: true })
if feeds.Count() > 0
diff --git a/playlet-lib/src/components/Services/Innertube/NodesParser.bs b/playlet-lib/src/components/Services/Innertube/NodesParser.bs
index 62bea29f..c8640f7c 100644
--- a/playlet-lib/src/components/Services/Innertube/NodesParser.bs
+++ b/playlet-lib/src/components/Services/Innertube/NodesParser.bs
@@ -25,7 +25,7 @@ namespace Innertube
for each key in nodeData
directive = directives[key]
if directive = invalid
- LogWarn("Unknown node", key, `\n`, FormatJson(nodeData[key]))
+ Warning(`Unknown node ${key}`, nodeData[key])
#if DEBUG_THROW_ON_UNKNOWN_NODES
#if DEBUG
throw "Unknown node: " + key
@@ -91,6 +91,11 @@ namespace Innertube
"gridContinuation": ParseGridContinuation
"tvSurfaceContentContinuation": ParseTvSurfaceContentContinuation
' Ignored nodes:
+ ' Movies are not supported.
+ "movieRenderer": ParseNotImplemented
+ "compactMovieRenderer": ParseNotImplemented
+ "horizontalMovieListRenderer": ParseNotImplemented
+ "gridMovieRenderer": ParseNotImplemented
' Contains comments "teaser".
"commentsEntryPointHeaderRenderer": ParseNotImplemented
' Contains the owner of the video from "videoPrimaryInfoRenderer"
@@ -125,6 +130,15 @@ namespace Innertube
"feedNudgeRenderer": ParseNotImplemented
' "No results found, Try different keywords or remove search filters"
"backgroundPromoRenderer": ParseNotImplemented
+ ' Autocorrect for search terms
+ "showingResultsForRenderer": ParseNotImplemented
+ ' "This channel has no podcasts."
+ "channelOwnerEmptyStateRenderer": ParseNotImplemented
+ ' Live chat replay ("See what others said about this video while it was live.")
+ "videoMetadataCarouselViewModel": ParseNotImplemented
+ ' A link to some content, like a wikipedia article.
+ "infoPanelContentRenderer": ParseNotImplemented
+ "ticketShelfRenderer": ParseNotImplemented
"videoSurveyShelfRenderer": ParseNotImplemented
"searchBarRenderer": ParseNotImplemented
"clickTrackingParams": ParseNotImplemented
@@ -168,7 +182,7 @@ namespace Innertube
end if
if subItems.Count() = 0
- LogWarn("No results found in TwoColumnWatchNextResults", nodeData)
+ Warning("No results found in twoColumnWatchNextResults", nodeData)
return invalid
end if
return subItems
@@ -305,7 +319,7 @@ namespace Innertube
function ParseVideoRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in videoRenderer", nodeData)
return invalid
end if
@@ -407,7 +421,7 @@ namespace Innertube
function ParseGridVideoRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in gridVideoRenderer", nodeData)
return invalid
end if
@@ -492,7 +506,7 @@ namespace Innertube
function ParseCompactVideoRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in compactVideoRenderer", nodeData)
return invalid
end if
@@ -592,11 +606,13 @@ namespace Innertube
videoId = ObjectUtils.Dig(nodeData, ["updatedMetadataEndpoint", "updatedMetadataEndpoint", "videoId"])
if not IsString(videoId)
' TODO:P1 confirm that videoPrimaryInfoRenderer has the requested video
+ m.noTelemetry = true
#if DEBUG
LogWarn("Invalid video ID in videoPrimaryInfoRenderer", `\n`, FormatJson(nodeData))
#else
LogWarn("Invalid video ID in videoPrimaryInfoRenderer")
#end if
+ m.noTelemetry = false
return invalid
end if
end if
@@ -628,7 +644,7 @@ namespace Innertube
function ParseChannelVideoPlayerRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in channelVideoPlayerRenderer", nodeData)
return invalid
end if
@@ -657,7 +673,7 @@ namespace Innertube
function ParsePlaylistVideoRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID playlistVideoRenderer", nodeData)
return invalid
end if
@@ -706,7 +722,7 @@ namespace Innertube
function ParsePlaylistPanelVideoRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in playlistPanelVideoRenderer", nodeData)
return invalid
end if
@@ -772,7 +788,7 @@ namespace Innertube
function ParseEndScreenVideoRenderer(nodeData as object, context as object) as object
videoId = nodeData["videoId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in endScreenVideoRenderer", nodeData)
return invalid
end if
@@ -804,7 +820,7 @@ namespace Innertube
function ParseChannelRenderer(nodeData as object, context as object) as object
channelId = nodeData["channelId"]
if not IsString(channelId)
- LogWarn("Invalid channel ID", nodeData)
+ Warning("Invalid channel ID in channelRenderer", nodeData)
return invalid
end if
@@ -824,7 +840,7 @@ namespace Innertube
function ParseGridChannelRenderer(nodeData as object, context as object) as object
channelId = nodeData["channelId"]
if not IsString(channelId)
- LogWarn("Invalid channel ID", nodeData)
+ Warning("Invalid channel ID gridChannelRenderer", nodeData)
return invalid
end if
@@ -844,7 +860,7 @@ namespace Innertube
function ParsePlaylistRenderer(nodeData as object, context as object) as object
playlistId = nodeData["playlistId"]
if not IsString(playlistId)
- LogWarn("Invalid playlist ID", nodeData)
+ Warning("Invalid playlist ID in playlistRenderer", nodeData)
return invalid
end if
@@ -894,7 +910,7 @@ namespace Innertube
function ParseGridPlaylistRenderer(nodeData as object, context as object) as object
playlistId = nodeData["playlistId"]
if not IsString(playlistId)
- LogWarn("Invalid playlist ID", nodeData)
+ Warning("Invalid playlist ID gridPlaylistRenderer", nodeData)
return invalid
end if
@@ -970,7 +986,7 @@ namespace Innertube
return LockupViewModelTypeAlbum(nodeData, context)
end if
- LogWarn("Unknown content type:", contentType, `\n`, FormatJson(nodeData))
+ Warning(`Unknown content type: ${contentType}`, nodeData)
#if DEBUG_THROW_ON_UNKNOWN_NODES
#if DEBUG
throw "Unknown content type: " + contentType
@@ -982,7 +998,7 @@ namespace Innertube
function LockupViewModelTypeVideo(nodeData as object, context as object) as object
videoId = nodeData["contentId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in lockupViewModelTypeVideo", nodeData)
return invalid
end if
@@ -1041,7 +1057,7 @@ namespace Innertube
function LockupViewModelTypePlaylist(nodeData as object, context as object) as object
playlistId = nodeData["contentId"]
if not IsString(playlistId)
- LogWarn("Invalid playlist ID", nodeData)
+ Warning("Invalid playlist ID in lockupViewModelTypePlaylist", nodeData)
return invalid
end if
@@ -1090,7 +1106,7 @@ namespace Innertube
function LockupViewModelTypePodcast(nodeData as object, context as object) as object
playlistId = nodeData["contentId"]
if not IsString(playlistId)
- LogWarn("Invalid playlist ID", nodeData)
+ Warning("Invalid playlist ID in lockupViewModelTypePodcast", nodeData)
return invalid
end if
@@ -1125,7 +1141,7 @@ namespace Innertube
function LockupViewModelTypeAlbum(nodeData as object, context as object) as object
playlistId = nodeData["contentId"]
if not IsString(playlistId)
- LogWarn("Invalid playlist ID", nodeData)
+ Warning("Invalid playlist ID in lockupViewModelTypeAlbum", nodeData)
return invalid
end if
@@ -1165,7 +1181,7 @@ namespace Innertube
videoId = ObjectUtils.Dig(nodeData, ["onTap", "innertubeCommand", "reelWatchEndpoint", "videoId"])
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in shortsLockupViewModel", nodeData)
return invalid
end if
@@ -1228,7 +1244,7 @@ namespace Innertube
' A tileRenderer can be without a contentType, such as a
' button that says "Open YouTube Kids" or similar CTAs
if contentType = ""
- LogWarn(`TileRenderer without contentType:\n`, nodeData)
+ Warning("TileRenderer without contentType", nodeData)
return invalid
end if
@@ -1240,7 +1256,7 @@ namespace Innertube
return TileRendererTypePlaylist(nodeData, context)
end if
- LogWarn("Unknown content type:", contentType, `\n`, FormatJson(nodeData))
+ Warning(`Unknown content type: ${contentType}`, nodeData)
#if DEBUG_THROW_ON_UNKNOWN_NODES
#if DEBUG
throw "Unknown content type: " + contentType
@@ -1252,7 +1268,7 @@ namespace Innertube
function TileRendererTypeVideo(nodeData as object, context as object) as object
videoId = nodeData["contentId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in tileRendererTypeVideo", nodeData)
return invalid
end if
@@ -1341,7 +1357,7 @@ namespace Innertube
videoId = nodeData["contentId"]
if not IsString(videoId)
- LogWarn("Invalid video ID", `\n`, FormatJson(nodeData))
+ Warning("Invalid video ID in tileRendererTypeShorts", nodeData)
return invalid
end if
@@ -1384,7 +1400,7 @@ namespace Innertube
function TileRendererTypePlaylist(nodeData as object, context as object) as object
playlistId = nodeData["contentId"]
if not IsString(playlistId)
- LogWarn("Invalid playlist ID", nodeData)
+ Warning("Invalid playlist ID in tileRendererTypePlaylist", nodeData)
return invalid
end if
@@ -1711,4 +1727,19 @@ namespace Innertube
}
]
end function
+
+ function Warning(message as string, nodeData as object) as void
+ nodeDataString = FormatJson(nodeData)
+ fullMessage = message + `\n` + nodeDataString
+
+ m.noTelemetry = true
+ LogWarn(fullMessage)
+ m.noTelemetry = false
+
+ m.global.telemetry.LogEvent = {
+ level: "error"
+ message: fullMessage
+ fingerprint: message
+ }
+ end function
end namespace
diff --git a/playlet-lib/src/components/Services/LoungeService/LongPoller.bs b/playlet-lib/src/components/Services/LoungeService/LongPoller.bs
index 85e26280..a654273f 100644
--- a/playlet-lib/src/components/Services/LoungeService/LongPoller.bs
+++ b/playlet-lib/src/components/Services/LoungeService/LongPoller.bs
@@ -83,7 +83,9 @@ class LongPoller
' Not receiving data for LONG_POLL_TIMEOUT_MS seconds might be a sign of a dead connection
if m.socket_timer.TotalMilliseconds() > LONG_POLL_TIMEOUT_MS
+ m.noTelemetry = true
LogWarn("Timeout after", LONG_POLL_TIMEOUT_MS, "ms")
+ m.noTelemetry = false
m.CloseSocket()
return false
end if
diff --git a/playlet-lib/src/components/Telemetry/Sentry.bs b/playlet-lib/src/components/Telemetry/Sentry.bs
index 88093524..f567d0d7 100644
--- a/playlet-lib/src/components/Telemetry/Sentry.bs
+++ b/playlet-lib/src/components/Telemetry/Sentry.bs
@@ -5,49 +5,97 @@ const SENTRY_KEY = "0bda23ffe3634745f57a0edbffdd18be"
namespace Sentry
- function SendLogEvent(level as string, message as string, tags as object) as void
- eventId = GenerateEventId()
+ function SendEvents(events as object) as integer
timestamp = CreateObject("roDateTime").ToISOString()
- header = FormatJson({
- event_id: eventId
+ payload = FormatJson({
sent_at: timestamp
sdk: {
name: "sentry.roku.playlet"
version: "1.0.0"
}
- })
- event = `{"type":"event"}`
- eventPayload = FormatJson({
- event_id: eventId
- timestamp: timestamp
- platform: "roku"
- #if DEBUG
- environment: "development"
- #else
- environment: "production"
- #end if
- tags: tags
- level: level
- logentry: {
- formatted: message
- }
- })
+ }) + `\n`
- payload = header + `\n` + event + `\n` + eventPayload
+ for each event in events
+ payload += `{"type":"event"}` + `\n`
+
+ if StringUtils.IsNullOrEmpty(event.event_id)
+ event.event_id = GenerateEventId()
+ end if
+
+ if StringUtils.IsNullOrEmpty(event.timestamp)
+ event.timestamp = timestamp
+ end if
+
+ eventPayload = {
+ event_id: event.event_id
+ timestamp: event.timestamp
+ platform: "roku"
+ #if DEBUG
+ environment: "development"
+ #else
+ environment: "production"
+ #end if
+ release: event.release
+ tags: event.tags
+ level: event.level
+ logentry: {
+ formatted: event.message
+ }
+ user: {
+ id: event.userId
+ }
+ }
+
+ if event.fingerprint <> invalid
+ if IsString(event.fingerprint)
+ eventPayload.fingerprint = [event.fingerprint]
+ else if IsArray(event.fingerprint)
+ eventPayload.fingerprint = event.fingerprint
+ end if
+ end if
+
+ payload += FormatJson(eventPayload) + `\n`
+
+ if IsArray(event.attachments)
+ tmpBuffer = CreateObject("roByteArray")
+ for each attachment in event.attachments
+ data = attachment.data
+ attachment.Delete("data")
+ attachment["type"] = "attachment"
+ tmpBuffer.FromAsciiString(data)
+ attachment["length"] = tmpBuffer.Count()
+
+ payload += FormatJson(attachment) + `\n`
+ payload += data + `\n`
+ end for
+ end if
+ end for
request = HttpClient.Post(SENTRY_ENVELOPE_URL, payload)
request.QueryParam("sentry_key", SENTRY_KEY)
- request.Header("Content-Type", "text/plain;charset=UTF-8")
+ request.Header("Content-Type", "application/x-sentry-envelope")
response = request.Await()
if not response.IsSuccess()
#if DEBUG
- LogInfo("Failed to send event to Sentry:", response.ErrorMessage())
+ m.noTelemetry = true
+ LogError("Failed to send event to Sentry:", response.ErrorMessage())
+ m.noTelemetry = false
#end if
- return
+
+ statusCode = response.StatusCode()
+ if statusCode = 429
+ retryAfter = ValidInt(response.Headers()["Retry-After"])
+ if retryAfter = 0
+ retryAfter = 60
+ end if
+ return retryAfter
+ end if
+ return 0
end if
- LogDebug("Sent event to Sentry with ID:", eventId, "Response:", response.Text())
+ LogDebug("Sent events to Sentry. Response:", response.Text())
+ return 0
end function
function GenerateEventId() as string
diff --git a/playlet-lib/src/components/Telemetry/Telemetry.bs b/playlet-lib/src/components/Telemetry/Telemetry.bs
index 7c9fb227..fd464995 100644
--- a/playlet-lib/src/components/Telemetry/Telemetry.bs
+++ b/playlet-lib/src/components/Telemetry/Telemetry.bs
@@ -12,6 +12,9 @@ end function
function OnNodeReady() as void
m.tags = GetTags()
+ m.release = GetRelease(m.tags)
+ m.userId = GetUserId()
+
m.top.ObserveField("enabled", FuncName(OnEnabledChanged))
m.preferences.ObserveFieldScoped("dev.diagnostics.enabled", FuncName(OnPreferencesChanged))
enabled = m.preferences["dev.diagnostics.enabled"]
@@ -42,6 +45,15 @@ function TelemetryLoop() as void
m.top.observeField("LogInfo", msgPort)
m.top.observeField("LogWarn", msgPort)
m.top.observeField("LogError", msgPort)
+ m.top.observeField("LogEvent", msgPort)
+
+ ' debouceMs = 2000
+ ' debounceCountLimit = 20
+ ' debounceTimeLimit = 5000
+ ' debounceTimer = CreateObject("roTimeSpan")
+
+ retryAfter = 0
+ retryAfterTimer = CreateObject("roTimeSpan")
levelMap = {
"LogInfo": "info"
@@ -49,16 +61,82 @@ function TelemetryLoop() as void
"LogError": "error"
}
+ messages = []
+ events = []
+
while true
msg = wait(0, msgPort)
- msgType = type(msg)
- if msgType = "roSGNodeEvent"
- level = levelMap[msg.getField()]
- if level <> invalid
- Sentry.SendLogEvent(level, msg.getData(), m.tags)
+ if retryAfter > 0
+ if retryAfterTimer.TotalMilliseconds() < retryAfter * 1000
+ continue while
+ else
+ retryAfter = 0
end if
end if
+
+ messages.Push(msg)
+
+ ' Sentry might not support batching yet for errors, but maybe for logs
+ ' debounceTimer.Mark()
+ ' while true
+ ' LogDebug("Waiting for more messages...")
+ ' msg = wait(debouceMs, msgPort)
+ ' if msg = invalid
+ ' LogDebug("No more messages")
+ ' exit while
+ ' end if
+ ' messages.Push(msg)
+ ' if messages.Count() >= debounceCountLimit
+ ' LogDebug("Reached debounce count limit")
+ ' exit while
+ ' end if
+ ' if debounceTimer.TotalMilliseconds() >= debounceTimeLimit
+ ' LogDebug("Reached debounce time limit")
+ ' exit while
+ ' end if
+ ' end while
+
+ events.Clear()
+ for each msg in messages
+ msgType = type(msg)
+ if msgType <> "roSGNodeEvent"
+ continue for
+ end if
+
+ field = msg.getField()
+
+ if levelMap.DoesExist(field)
+ events.Push({
+ level: levelMap[field]
+ message: msg.getData()
+ release: m.release
+ tags: m.tags
+ userId: m.userId
+ })
+ else if field = "LogEvent"
+ data = msg.getData()
+ events.Push({
+ level: data.level
+ message: data.message
+ release: m.release
+ tags: m.tags
+ userId: m.userId
+ fingerprint: data.fingerprint
+ attachments: data.attachments
+ })
+ end if
+ end for
+ messages.Clear()
+
+ if events.Count() = 0
+ continue while
+ end if
+
+ retryAfter = Sentry.SendEvents(events)
+ if retryAfter > 0
+ retryAfterTimer.Mark()
+ end if
end while
end function
@@ -66,6 +144,9 @@ function GetTags() as object
appInfo = m.applicationInfo
tags = appInfo@.GetAppInfo()
tags.Append(appInfo@.GetDeviceInfo())
+
+ tags.Delete("friendly_name")
+
for each key in tags
if not IsString(tags[key])
tags[key] = ToString(tags[key])
@@ -73,3 +154,15 @@ function GetTags() as object
end for
return tags
end function
+
+function GetRelease(tags as object) as string
+ release = `${tags["app_version"]}-${tags["app_git_commit_hash"]}-${tags["lib_version"]}-${tags["lib_git_commit_hash"]}`
+ if tags["id"] = "dev"
+ release = release + "-dev"
+ end if
+ return release
+end function
+
+function GetUserId() as string
+ return CreateObject("roDeviceInfo").GetChannelClientId()
+end function
diff --git a/playlet-lib/src/components/Telemetry/Telemetry.xml b/playlet-lib/src/components/Telemetry/Telemetry.xml
index e1ef7207..a8497650 100644
--- a/playlet-lib/src/components/Telemetry/Telemetry.xml
+++ b/playlet-lib/src/components/Telemetry/Telemetry.xml
@@ -6,5 +6,6 @@
+
\ No newline at end of file
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentJob.bs b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentJob.bs
index 96e4d432..9d852e0a 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentJob.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentJob.bs
@@ -241,11 +241,15 @@ end function
function HandleFeedLoadErrorDialog(error as object, isCancelled as boolean, rowList as object) as void
error = ErrorUtils.Format(error)
+
if isCancelled
- LogInfo(error)
- else
- LogError(error)
+ m.noTelemetry = true
end if
+ LogError(error)
+ if isCancelled
+ m.noTelemetry = false
+ end if
+
rowList.onError = error
if rowList.hasField("dispose") and rowList.dispose
return
diff --git a/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs b/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs
index e8fa13d9..ca4a776f 100644
--- a/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs
+++ b/playlet-lib/src/components/VideoPlayer/VideoContentJob.bs
@@ -73,8 +73,15 @@ function ExecuteJob() as void
return
end if
- contentNode.title = metadata.title
- contentNode.secondaryTitle = metadata.author
+ title = metadata.title
+ if not StringUtils.IsNullOrEmpty(title)
+ contentNode.title = title
+ end if
+
+ author = metadata.author
+ if not StringUtils.IsNullOrEmpty(author)
+ contentNode.secondaryTitle = metadata.author
+ end if
contentNode.live = metadata.liveNow
if metadata.error <> invalid
diff --git a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs
index d047f562..d314cb1b 100644
--- a/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs
+++ b/playlet-lib/src/components/VideoPlayer/VideoPlayer.bs
@@ -136,8 +136,15 @@ function PlayWithContent(contentNode as object)
videoContentNode.title = contentNode.title
end if
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
- if not StringUtils.IsNullOrEmpty(contentNode._author)
- videoContentNode.secondaryTitle = contentNode._author
+ author = contentNode._author
+ if StringUtils.IsNullOrEmpty(author)
+ lines = contentNode.lines
+ if IsArray(lines) and lines.Count() > 0
+ author = lines[0]
+ end if
+ end if
+ if not StringUtils.IsNullOrEmpty(author)
+ videoContentNode.secondaryTitle = author
end if
metadata = contentNode.metadata
if IsAssociativeArray(metadata)
@@ -436,7 +443,17 @@ function OnVideoPlayerStateChange() as void
if state = "error"
errorInfo = m.top.errorInfo
- LogError(`Error playing video ${content.videoId}`, errorInfo)
+ errorData = GetPlayerErrorData(content.videoId, errorInfo)
+
+ m.noTelemetry = true
+ LogError(errorData.title, errorData.body)
+ m.noTelemetry = false
+ m.global.telemetry.LogEvent = {
+ level: "error"
+ message: errorData.title + `\n` + errorData.body
+ fingerprint: errorData.fingerprint
+ }
+
if m.videoPlayingSuccess <> true
' http for stream format, mediaerror for DASH
if errorInfo.category = "http" or errorInfo.category = "mediaerror"
@@ -481,24 +498,21 @@ function OnVideoPlayerStateChange() as void
end if
if state = "error"
- messageLines = []
- messageLines.push(`errorMsg: ${m.top.errorMsg}`)
- messageLines.push(`errorCode: ${m.top.errorCode}`)
- messageLines.push(`errorStr: ${m.top.errorStr}`)
-
errorInfo = m.top.errorInfo
- if errorInfo <> invalid
- for each info in errorInfo
- messageLines.push(`${info}: ${errorInfo[info]}`)
- end for
- end if
+ errorData = GetPlayerErrorData(content.videoId, errorInfo)
- title = Tr(Locale.VideoPlayer.ErrorPlayingVideo).Replace("%1", content.videoId)
- LogError(title, messageLines)
+ m.noTelemetry = true
+ LogError(errorData.title, errorData.body)
+ m.noTelemetry = false
+ m.global.telemetry.LogEvent = {
+ level: "error"
+ message: errorData.title + `\n` + errorData.body
+ fingerprint: errorData.fingerprint
+ }
buttons = [Tr(Locale.Buttons.PlayNextVideo), Tr(Locale.Buttons.Cancel)]
- dialog = DialogUtils.ShowTimedDialogButtons(messageLines, title, buttons, 0, 10, true)
+ dialog = DialogUtils.ShowTimedDialogButtons(errorData.body, errorData.title, buttons, 0, 10, true)
if dialog <> invalid
dialog.observeFieldScoped("wasClosed", FuncName(OnVideoContentJobErrorDialogResponse))
else
@@ -508,6 +522,39 @@ function OnVideoPlayerStateChange() as void
end if
end function
+function GetPlayerErrorData(videoId as string, errorInfo as object) as object
+ if errorInfo = invalid
+ return invalid
+ end if
+
+ errorMsg = m.top.errorMsg
+ errorCode = m.top.errorCode
+ errorStr = m.top.errorStr
+
+ title = Tr(Locale.VideoPlayer.ErrorPlayingVideo).Replace("%1", videoId)
+ body = `errorMsg: ${errorMsg}\nerrorCode: ${errorCode}\nerrorStr: ${errorStr}`
+ for each key in errorInfo
+ body += `\n${key}: ${errorInfo[key]}`
+ end for
+
+ fingerprint = [
+ Locale.VideoPlayer.ErrorPlayingVideo
+ errorMsg
+ errorCode
+ errorInfo.source
+ errorInfo.ignored
+ errorInfo.category
+ errorInfo.errcode
+ errorInfo.drmerrcode
+ ]
+
+ return {
+ title: title
+ body: body
+ fingerprint: fingerprint
+ }
+end function
+
function OnVideoFinished() as void
if not VideoQueueUtils.PlayNext(m.videoQueue, m.invidious, m.preferences)
m.videoQueue.closePlayer = true
diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs
index af7a4323..08342c54 100644
--- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs
+++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/HlsRouter.bs
@@ -171,7 +171,9 @@ namespace Http
end for
if includedQualitiesCount = 0
+ m.noTelemetry = true
LogWarn("No video streams found using quality filter:", qualityFilter, "Falling back to all video streams")
+ m.noTelemetry = false
return hlsManifest
end if
return newLines.join(`\n`)
diff --git a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs
index ca72d662..23a4f754 100644
--- a/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs
+++ b/playlet-lib/src/components/Web/PlayletWebServer/Middleware/PlayletInvidiousBackendRouter.bs
@@ -214,7 +214,9 @@ namespace Http
if not hasContinuation
page = ValidString(request.query.page).ToInt()
if page > 1
+ m.noTelemetry = true
LogError("Playlet backend does not use history pagination (use continuation instead)")
+ m.noTelemetry = false
response.Json({
"items": []
})
diff --git a/playlet-lib/src/components/Web/WebServer/Http/HttpConnection.bs b/playlet-lib/src/components/Web/WebServer/Http/HttpConnection.bs
index 45376172..6fb043c6 100644
--- a/playlet-lib/src/components/Web/WebServer/Http/HttpConnection.bs
+++ b/playlet-lib/src/components/Web/WebServer/Http/HttpConnection.bs
@@ -165,7 +165,9 @@ namespace Http
if m.socket.eSuccess()
LogDebug(op + " peer closed @" + m.client)
else
- LogInfo(op + " transfer error @" + m.client, m.socket.status())
+ m.noTelemetry = true
+ LogError(op + " transfer error @" + m.client, m.socket.status())
+ m.noTelemetry = false
end if
m.close = true
m.SetState(Http.HttpConnectionState.DONE)
diff --git a/tools/bs-plugins/logger-plugin.ts b/tools/bs-plugins/logger-plugin.ts
index f880ec78..0f390648 100644
--- a/tools/bs-plugins/logger-plugin.ts
+++ b/tools/bs-plugins/logger-plugin.ts
@@ -213,7 +213,7 @@ export class LoggerPlugin implements CompilerPlugin {
logLine = `"[${func.stringLevel}]" + ${msg}`
}
- return `
+ let result = `
function ${newFunctionName}(${args.join(', ')}) as void
logger = m.global.logger
if logger.logLevel < ${func.level}
@@ -221,9 +221,16 @@ function ${newFunctionName}(${args.join(', ')}) as void
end if
line = ${logLine}
logger.logLine = line
- ${(telemetryEnabled ? `m.global.telemetry.${level} = line` : '')}
-end function
`;
+ if (telemetryEnabled) {
+ result += ` if not (m.noTelemetry = true)
+ m.global.telemetry.${level} = line
+ end if
+`;
+ }
+ result += `end function
+`;
+ return result;
}
}