Refactor custom events

This commit is contained in:
Brahim Hadriche committed 2025-09-06 13:58:42 -04:00
1 parent c9a0e96905
commit 47a7ea21e6
6 files changed
+14 -11

No files matched your search

+2 -2
View File
@@ -118,11 +118,11 @@ function OnLineSysLog(event as object, dateTime as object, logsFile as string, b
' They're usually repetitive, one is reported for each stream in a DASH
' when a video is blocked
if m.sysLogEventDropCounter = 0
m.global.telemetry.LogEvent = {
LogTelemetryEvent({
level: "error"
message: line
fingerprint: ["SysLog", info.Status, info.LogType, info.HttpCode, info.Method]
}
})
end if
m.sysLogEventDropCounter = (m.sysLogEventDropCounter + 1) mod 10
end function
@@ -112,7 +112,7 @@ namespace InnertubeService
return GetVideoMetadata(videoId, options)
end if
if code = "MISSING_FORMAT_FIELD"
m.global.telemetry.LogEvent = {
LogTelemetryEvent({
level: "error"
message: code
fingerprint: code
@@ -125,7 +125,7 @@ namespace InnertubeService
content_type: "application/json"
data: playerResponse.Text()
}]
}
})
end if
throw exception
end try
@@ -1745,8 +1745,7 @@ namespace Innertube
nodeDataString = FormatJson(nodeData)
LogWarnNoTelemetry(message + `\n` + nodeDataString)
m.global.telemetry.LogEvent = {
LogTelemetryEvent ({
level: "warning"
message: message
fingerprint: message
@@ -1759,6 +1758,6 @@ namespace Innertube
content_type: "text/plain"
data: context.response.request.ToCurlCommand()
}]
}
})
end function
end namespace
@@ -571,12 +571,12 @@ function ReportVideoError(errorData as object, url as string) as void
end if
end if
m.global.telemetry.LogEvent = {
LogTelemetryEvent({
level: "error"
message: errorData.title + " " + errorData.body + `\n url: ${url}`
fingerprint: errorData.fingerprint
attachments: attachments
}
})
end function
function OnVideoFinished() as void
@@ -100,11 +100,11 @@ namespace Http
if operation = invalid or operation = ""
LogErrorNoTelemetry("empty request")
m.global.telemetry.LogEvent = {
LogTelemetryEvent({
level: "error"
message: "empty request: " + FormatJson({ "m.buffer": m.buffer, "m.buffer_index": m.buffer_index })
fingerprint: ["HttpRequest: empty request"]
}
})
m.ready_for_response = true
return false
end if
+4
View File
@@ -29,6 +29,10 @@ function LogDebug(_arg1 = invalid as dynamic, _arg2 = invalid as dynamic, _arg3
throw "FATAL: Calling LogDebug() which is a stub function"
end function
function LogTelemetryEvent(event as object)
m.global.telemetry.LogEvent = event
end function
function ToString(value as dynamic) as string
if getInterface(value, "ifString") <> invalid
return value