diff --git a/playlet-lib/src/components/Telemetry/LastExitCrash.bs b/playlet-lib/src/components/Telemetry/LastExitCrash.bs index d525ae8c..6980bba0 100644 --- a/playlet-lib/src/components/Telemetry/LastExitCrash.bs +++ b/playlet-lib/src/components/Telemetry/LastExitCrash.bs @@ -1,19 +1,17 @@ #const DEBUG_THROW_ON_UNKNOWN_EXIT_CODE = true -import "pkg:/components/Telemetry/Sentry.bs" -import "pkg:/source/utils/Logging.bs" import "pkg:/source/utils/Types.bs" -function ReportLastExitCrash() as void +function CreateLastExitCrashEvent() as dynamic scene = m.top.getScene() if scene = invalid or not scene.hasField("lastExitInfo") - return + return invalid end if lastExitInfo = scene.lastExitInfo scene.lastExitInfo = invalid if not IsAssociativeArray(lastExitInfo) - return + return invalid end if crashExitCodes = { @@ -63,7 +61,7 @@ function ReportLastExitCrash() as void #end if if crashExitCodes[exitCode] = false - return + return invalid end if message = `[FATAL][LastExit] App crashed: ${exitCode}` @@ -71,7 +69,7 @@ function ReportLastExitCrash() as void message += `\n${key}: ${ToString(lastExitInfo[key])}` end for - Sentry.SendEvents([{ + return { level: "fatal" message: message timestamp: ValidString(lastExitInfo.timestamp) @@ -80,5 +78,5 @@ function ReportLastExitCrash() as void dist: m.dist tags: m.tags userId: m.userId - }]) + } end function diff --git a/playlet-lib/src/components/Telemetry/Telemetry.bs b/playlet-lib/src/components/Telemetry/Telemetry.bs index 0274e636..814cbed9 100644 --- a/playlet-lib/src/components/Telemetry/Telemetry.bs +++ b/playlet-lib/src/components/Telemetry/Telemetry.bs @@ -53,9 +53,6 @@ function TelemetryLoop() as void m.top.observeField("LogError", msgPort) m.top.observeField("LogEvent", msgPort) - ReportSessionStart() - ReportLastExitCrash() - #if SUPPORTS_BATCHING debouceMs = 2000 debounceCountLimit = 20 @@ -63,8 +60,11 @@ function TelemetryLoop() as void debounceTimer = CreateObject("roTimeSpan") #end if - retryAfter = 0 retryAfterTimer = CreateObject("roTimeSpan") + retryAfter = Sentry.SendEvents(CreateLaunchEvents()) + if retryAfter > 0 + retryAfterTimer.Mark() + end if levelMap = { "LogInfo": "info" @@ -160,8 +160,8 @@ function TelemetryLoop() as void end while end function -function ReportSessionStart() as void - Sentry.SendEvents([{ +function CreateLaunchEvents() as object + events = [{ level: "info" message: "[SESSION] start" fingerprint: ["session start"] @@ -169,7 +169,12 @@ function ReportSessionStart() as void dist: m.dist tags: m.tags userId: m.userId - }]) + }] + lastExitCrashEvent = CreateLastExitCrashEvent() + if lastExitCrashEvent <> invalid + events.Push(lastExitCrashEvent) + end if + return events end function function GetTags() as object