Capturing Logs
Capture React Native app events, live-session log lines, SDK bridge logs, and grouped session properties.
Use app events for timeline entries. Use sendClientLog(...) for ad hoc live-session log lines.
App Events
await Ansight.event({
label: "Checkout loaded",
type: "Info",
details: "route=/checkout",
});
await Ansight.event({
label: "Payment failed",
type: "Error",
details: "httpStatus=500",
});
Live Client Logs
await Ansight.sendClientLog("Checkout loaded cartId=debug-42");
sendClientLog(...) sends the line over the active live session. It does not automatically mirror console.log.
Unhandled JavaScript Errors
installErrorHandlers(...) records unhandled JavaScript errors and promise rejections as Ansight exception events and adds them to the native crash outbox as framework candidates:
const uninstallErrorHandlers = Ansight.installErrorHandlers({
chain: true,
});
// Later, restore the previous global ErrorUtils handler.
uninstallErrorHandlers();
chain: true forwards unhandled JavaScript errors to the previous global handler after recording them. Set chain: false only when the app intentionally replaces that behavior.
Record app-owned framework context directly when needed:
await Ansight.recordCrashCandidate({
runtime: "react-native-js",
kind: "caught_boundary_error",
message: error.message,
stack: error.stack,
fatal: false,
metadata: { component: "CheckoutBoundary" },
});
Non-fatal JavaScript candidates are context for an independently confirmed native exit; they are not crash reports by themselves. Crash capture is enabled by default and recovered after the next launch. See Crash Capture, and do not include secrets or personal data in error messages, stacks, or metadata.
SDK Bridge Logs
const subscription = Ansight.addLogListener((entry) => {
console.debug(`[Ansight:${entry.level}] ${entry.message}`);
});
subscription.remove();
Session Properties
await Ansight.registerCustomProperty("app", "region", "au");
await Ansight.removeCustomProperty("app", "region");
await Ansight.clearCustomProperties();
Grouped properties are sent with session.open and updated during an active live session.