Capturing Logs
Capture Cordova/Capacitor app events, live-session log lines, JavaScript errors, native SDK diagnostics, and grouped properties.
await Ansight.event({
label: "Sync completed",
type: "App",
details: JSON.stringify({ records: 7 }),
});
await Ansight.sendClientLog("Settings loaded");
Listen to native SDK diagnostics:
const subscription = Ansight.addLogListener((entry) => {
console.debug(`[Ansight ${entry.level}] ${entry.message}`);
});
.withErrorCapture() installs handlers for unhandled JavaScript errors and rejections. It records exception events and adds framework context to the native crash outbox. Set consoleErrors: true only when intentionally mirroring console.error into session events.
Record app-owned context directly when needed:
await Ansight.recordCrashCandidate({
runtime: "capacitor-js",
kind: "caught_boundary_error",
message: error.message,
stack: error.stack,
fatal: false,
metadata: JSON.stringify({ component: "checkout" }),
});
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.
On a paired physical iPhone or iPad, app-provided lines, captured JavaScript errors, and Ansight SDK diagnostics stream to Studio. General OS and unrelated process logs remain in Xcode or Apple device tooling.