Batch startup events
This commit is contained in:
1 parent
37c61d8ba7
commit
029582817f
2 files changed
+18
-15
No files matched your search
@@ -1,19 +1,17 @@
|
|||||||
#const DEBUG_THROW_ON_UNKNOWN_EXIT_CODE = true
|
#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"
|
import "pkg:/source/utils/Types.bs"
|
||||||
|
|
||||||
function ReportLastExitCrash() as void
|
function CreateLastExitCrashEvent() as dynamic
|
||||||
scene = m.top.getScene()
|
scene = m.top.getScene()
|
||||||
if scene = invalid or not scene.hasField("lastExitInfo")
|
if scene = invalid or not scene.hasField("lastExitInfo")
|
||||||
return
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
lastExitInfo = scene.lastExitInfo
|
lastExitInfo = scene.lastExitInfo
|
||||||
scene.lastExitInfo = invalid
|
scene.lastExitInfo = invalid
|
||||||
if not IsAssociativeArray(lastExitInfo)
|
if not IsAssociativeArray(lastExitInfo)
|
||||||
return
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
crashExitCodes = {
|
crashExitCodes = {
|
||||||
@@ -63,7 +61,7 @@ function ReportLastExitCrash() as void
|
|||||||
#end if
|
#end if
|
||||||
|
|
||||||
if crashExitCodes[exitCode] = false
|
if crashExitCodes[exitCode] = false
|
||||||
return
|
return invalid
|
||||||
end if
|
end if
|
||||||
|
|
||||||
message = `[FATAL][LastExit] App crashed: ${exitCode}`
|
message = `[FATAL][LastExit] App crashed: ${exitCode}`
|
||||||
@@ -71,7 +69,7 @@ function ReportLastExitCrash() as void
|
|||||||
message += `\n${key}: ${ToString(lastExitInfo[key])}`
|
message += `\n${key}: ${ToString(lastExitInfo[key])}`
|
||||||
end for
|
end for
|
||||||
|
|
||||||
Sentry.SendEvents([{
|
return {
|
||||||
level: "fatal"
|
level: "fatal"
|
||||||
message: message
|
message: message
|
||||||
timestamp: ValidString(lastExitInfo.timestamp)
|
timestamp: ValidString(lastExitInfo.timestamp)
|
||||||
@@ -80,5 +78,5 @@ function ReportLastExitCrash() as void
|
|||||||
dist: m.dist
|
dist: m.dist
|
||||||
tags: m.tags
|
tags: m.tags
|
||||||
userId: m.userId
|
userId: m.userId
|
||||||
}])
|
}
|
||||||
end function
|
end function
|
||||||
@@ -53,9 +53,6 @@ function TelemetryLoop() as void
|
|||||||
m.top.observeField("LogError", msgPort)
|
m.top.observeField("LogError", msgPort)
|
||||||
m.top.observeField("LogEvent", msgPort)
|
m.top.observeField("LogEvent", msgPort)
|
||||||
|
|
||||||
ReportSessionStart()
|
|
||||||
ReportLastExitCrash()
|
|
||||||
|
|
||||||
#if SUPPORTS_BATCHING
|
#if SUPPORTS_BATCHING
|
||||||
debouceMs = 2000
|
debouceMs = 2000
|
||||||
debounceCountLimit = 20
|
debounceCountLimit = 20
|
||||||
@@ -63,8 +60,11 @@ function TelemetryLoop() as void
|
|||||||
debounceTimer = CreateObject("roTimeSpan")
|
debounceTimer = CreateObject("roTimeSpan")
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
retryAfter = 0
|
|
||||||
retryAfterTimer = CreateObject("roTimeSpan")
|
retryAfterTimer = CreateObject("roTimeSpan")
|
||||||
|
retryAfter = Sentry.SendEvents(CreateLaunchEvents())
|
||||||
|
if retryAfter > 0
|
||||||
|
retryAfterTimer.Mark()
|
||||||
|
end if
|
||||||
|
|
||||||
levelMap = {
|
levelMap = {
|
||||||
"LogInfo": "info"
|
"LogInfo": "info"
|
||||||
@@ -160,8 +160,8 @@ function TelemetryLoop() as void
|
|||||||
end while
|
end while
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function ReportSessionStart() as void
|
function CreateLaunchEvents() as object
|
||||||
Sentry.SendEvents([{
|
events = [{
|
||||||
level: "info"
|
level: "info"
|
||||||
message: "[SESSION] start"
|
message: "[SESSION] start"
|
||||||
fingerprint: ["session start"]
|
fingerprint: ["session start"]
|
||||||
@@ -169,7 +169,12 @@ function ReportSessionStart() as void
|
|||||||
dist: m.dist
|
dist: m.dist
|
||||||
tags: m.tags
|
tags: m.tags
|
||||||
userId: m.userId
|
userId: m.userId
|
||||||
}])
|
}]
|
||||||
|
lastExitCrashEvent = CreateLastExitCrashEvent()
|
||||||
|
if lastExitCrashEvent <> invalid
|
||||||
|
events.Push(lastExitCrashEvent)
|
||||||
|
end if
|
||||||
|
return events
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function GetTags() as object
|
function GetTags() as object
|
||||||
|
|||||||
Reference in new issue
Block a user