diff --git a/CHANGELOG.md b/CHANGELOG.md
index 11d849d9..b895e85a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Attempt to fix the "The page needs to be reloaded" error by refreshing the signature timestamp automatically
- Playlists with more than one page of videos no longer stop loading after the first ~100 videos
+- Report previous-run crashes to diagnostics
## [0.47.1] - 2026-06-18
diff --git a/playlet-app/src/components/BootstrapScene/BootstrapScene.xml b/playlet-app/src/components/BootstrapScene/BootstrapScene.xml
index 9d72279d..1ccc7130 100644
--- a/playlet-app/src/components/BootstrapScene/BootstrapScene.xml
+++ b/playlet-app/src/components/BootstrapScene/BootstrapScene.xml
@@ -6,6 +6,7 @@
+
diff --git a/playlet-app/src/source/AppManager.bs b/playlet-app/src/source/AppManager.bs
new file mode 100644
index 00000000..4c8f91ea
--- /dev/null
+++ b/playlet-app/src/source/AppManager.bs
@@ -0,0 +1,14 @@
+namespace AppManager
+
+ function CaptureLastExitInfo(scene as object) as void
+ manager = CreateObject("roAppManager")
+ ' roAppManager.GetLastExitInfo() is only available on Roku OS 13 and above
+ if FindMemberFunction(manager, "GetLastExitInfo") = invalid
+ return
+ end if
+ lastExitInfo = manager.GetLastExitInfo()
+ Logger.LogLastExitInfo(lastExitInfo)
+ scene.lastExitInfo = lastExitInfo
+ end function
+
+end namespace
diff --git a/playlet-app/src/source/AppManager.spec.bs b/playlet-app/src/source/AppManager.spec.bs
new file mode 100644
index 00000000..d6e979a8
--- /dev/null
+++ b/playlet-app/src/source/AppManager.spec.bs
@@ -0,0 +1,29 @@
+namespace Tests
+
+ @suite
+ class AppManagerTests extends Rooibos.BaseTestSuite
+
+ @describe("AppManager")
+
+ @it("captures the device's last exit info onto the scene")
+ function _()
+ manager = CreateObject("roAppManager")
+ scene = {}
+ AppManager.CaptureLastExitInfo(scene)
+
+ if FindMemberFunction(manager, "GetLastExitInfo") = invalid
+ ' Roku OS < 13: nothing to capture
+ m.assertInvalid(scene.lastExitInfo)
+ else
+ info = scene.lastExitInfo
+ m.assertAAHasKeys(info, ["exit_code", "timestamp", "app_state", "console_log"])
+ m.assertTrue(info.exit_code.StartsWith("EXIT_"), "exit_code should be an EXIT_* string")
+ m.assertTrue(Len(info.timestamp) > 0, "timestamp should be a non-empty string")
+ m.assertTrue(Len(info.app_state) > 0, "app_state should be a non-empty string")
+ m.assertTrue(GetInterface(info.console_log, "ifString") <> invalid, "console_log should be a string")
+ end if
+ end function
+
+ end class
+
+end namespace
diff --git a/playlet-app/src/source/Logger.bs b/playlet-app/src/source/Logger.bs
index 5a872b26..69a7ed50 100644
--- a/playlet-app/src/source/Logger.bs
+++ b/playlet-app/src/source/Logger.bs
@@ -16,15 +16,7 @@ namespace Logger
buffer.AppendFile(LOGS_FILE_PATH)
end function
- function LogLastExitInfo() as void
- ' roAppManager.GetLastExitInfo() is only available on Roku OS 13 and above
- appManager = CreateObject("roAppManager")
- hasMethod = FindMemberFunction(appManager, "GetLastExitInfo") <> invalid
- if not hasMethod
- return
- end if
-
- lastExitInfo = appManager.GetLastExitInfo()
+ function LogLastExitInfo(lastExitInfo as object) as void
if lastExitInfo = invalid
return
end if
diff --git a/playlet-app/src/source/Main.bs b/playlet-app/src/source/Main.bs
index 37ba603d..f853f5ac 100644
--- a/playlet-app/src/source/Main.bs
+++ b/playlet-app/src/source/Main.bs
@@ -24,11 +24,11 @@ function Main(args as object) as void
Registry.ClearPlayletLibUrlsIfNeeded(args)
Registry.ClearRegistryIfNeeded(args)
- Logger.LogLastExitInfo()
-
scene = screen.CreateScene("BootstrapScene")
screen.show()
+ AppManager.CaptureLastExitInfo(scene)
+
SetScenePalette(scene)
scene.ObserveField("exitChannel", port)
scene.launchArgs = args
diff --git a/playlet-lib/src/components/Telemetry/LastExitCrash.bs b/playlet-lib/src/components/Telemetry/LastExitCrash.bs
new file mode 100644
index 00000000..c21553d5
--- /dev/null
+++ b/playlet-lib/src/components/Telemetry/LastExitCrash.bs
@@ -0,0 +1,93 @@
+#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
+ scene = m.top.getScene()
+ if scene = invalid or not scene.hasField("lastExitInfo")
+ return
+ end if
+
+ lastExitInfo = scene.lastExitInfo
+ scene.lastExitInfo = invalid
+ if not IsAssociativeArray(lastExitInfo)
+ return
+ end if
+
+ crashExitCodes = {
+ "EXIT_BRIGHTSCRIPT_CRASH": true
+ "EXIT_BRIGHTSCRIPT_STOP": true
+ "EXIT_BRIGHTSCRIPT_UNK_FUNC": true
+ "EXIT_BRIGHTSCRIPT_TIMEOUT": true
+ "EXIT_OUT_OF_MEMORY": true
+ "EXIT_CHANNEL_MEM_LIMIT_FG": true
+ "EXIT_CHANNEL_MEM_LIMIT_BG": true
+ "EXIT_SYSTEM_KILL": true
+ "EXIT_GRAPHICS_NOT_RELEASED": true
+ "EXIT_DECODER_NOT_RELEASED": true
+ "EXIT_RUNNING_AFTER_SUSPEND": true
+ "EXIT_NOT_RESUMED": true
+ "EXIT_SIGNAL_TIMEOUT": true
+ "EXIT_APP_ERROR": true
+ "EXIT_UNKNOWN": false
+ "EXIT_POWER_MODE": false
+ "EXIT_DIAL_DELETE": false
+ "EXIT_IDLE_AUTO_EXIT": false
+ "EXIT_USER_KILL": false
+ "EXIT_USER_NAV": false
+ "EXIT_AM_LOWRESOURCE": false
+ "EXIT_UNLOADED": false
+ "EXIT_GUEST_MODE_ENABLED": false
+ "EXIT_GUEST_MODE_DISABLED": false
+ "EXIT_GUEST_CHECKOUT": false
+ "EXIT_OS_UPDATE": false
+ "EXIT_CHANNEL_UPDATE": false
+ "EXIT_CHANNEL_SIDELOAD": false
+ "EXIT_CHANNEL_RESTART": false
+ "EXIT_TILE_HIDDEN": false
+ "EXIT_SETTINGS_UPDATE": false
+ "EXIT_ADDON_DEPENDENCY": false
+ "EXIT_SOFTFAIL": false
+ }
+ exitCode = ValidString(lastExitInfo.exit_code)
+
+ #if DEBUG_THROW_ON_UNKNOWN_EXIT_CODE
+ #if DEBUG
+ if not crashExitCodes.DoesExist(exitCode)
+ throw "Unhandled exit code: " + exitCode
+ end if
+ #end if
+ #end if
+
+ if crashExitCodes[exitCode] = false
+ return
+ end if
+
+ message = `[FATAL][LastExit] App crashed: ${exitCode}`
+ for each key in lastExitInfo
+ message += `\n${key}: ${ToString(lastExitInfo[key])}`
+ end for
+ message = RedactAuthHeaders(message)
+
+ Sentry.SendEvents([{
+ level: "fatal"
+ message: message
+ timestamp: ValidString(lastExitInfo.timestamp)
+ fingerprint: [exitCode]
+ release: m.release
+ dist: m.dist
+ tags: m.tags
+ userId: m.userId
+ }])
+end function
+
+function RedactAuthHeaders(text as string) as string
+ authRegex = /Authorization: [^\r\n]*/i
+ matches = authRegex.MatchAll(text)
+ for each match in matches
+ text = text.Replace(match[0], "Authorization: ")
+ end for
+ return text
+end function
diff --git a/playlet-lib/src/components/Telemetry/Telemetry.bs b/playlet-lib/src/components/Telemetry/Telemetry.bs
index f2f4821e..e2e14cb5 100644
--- a/playlet-lib/src/components/Telemetry/Telemetry.bs
+++ b/playlet-lib/src/components/Telemetry/Telemetry.bs
@@ -1,6 +1,7 @@
#const SUPPORTS_BATCHING = false
import "pkg:/components/Telemetry/Sentry.bs"
+import "pkg:/components/Telemetry/LastExitCrash.bs"
import "pkg:/source/utils/Logging.bs"
import "pkg:/source/utils/Types.bs"
@@ -47,6 +48,8 @@ function TelemetryLoop() as void
m.dist = GetDist(m.tags)
m.userId = GetUserId()
+ ReportLastExitCrash()
+
m.top.observeField("LogInfo", msgPort)
m.top.observeField("LogWarn", msgPort)
m.top.observeField("LogError", msgPort)