mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
* refactor(mobile): give relay and encryption concrete owners * refactor(mobile): organize session and review feature owners * refactor(mobile): organize RPC and host ownership * test(mobile): point render fixtures at concrete owners * refactor(mobile): use explicit type-only owner imports
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { sanitizeCrashReportString } from '../../../src/shared/crash-report-redaction'
|
|
import { captureBridgeError } from '../mobile-web-shell/bridge/bridge-error-capture'
|
|
import { connectionLogStore } from './connection/persisted-connection-log-store'
|
|
|
|
export const NATIVE_APP_LOG_ID = 'orca:native-app'
|
|
let sequence = 0
|
|
|
|
export function recordNativeRenderError(error: unknown, route: string): void {
|
|
const ts = Date.now()
|
|
const category = captureBridgeError(error).category
|
|
let frames = ''
|
|
try {
|
|
if (error instanceof Error && typeof error.stack === 'string') {
|
|
// Only frames: multiline error messages can contain user content.
|
|
const prefix = `${error.name}: ${error.message}`
|
|
frames = (error.stack.startsWith(prefix) ? error.stack.slice(prefix.length) : '')
|
|
.split(/\r?\n/)
|
|
.filter((line) => /^\s+at /.test(line))
|
|
.join('\n')
|
|
}
|
|
} catch {
|
|
// A thrown value can have an unreadable stack getter.
|
|
}
|
|
connectionLogStore.append(NATIVE_APP_LOG_ID, {
|
|
id: `native-render-${ts}-${++sequence}`,
|
|
ts,
|
|
level: 'error',
|
|
code: 'native-render-failed',
|
|
message: 'Native screen failed to render',
|
|
detail: sanitizeCrashReportString(`/${route || 'index'}: ${category}\n${frames}`, 2_000)
|
|
})
|
|
}
|