Understand app behavior with logs

Preserve Cordova/Capacitor app events, JavaScript errors, and diagnostic context so session review includes what the app reported.

App events help explain what happened beneath a visible result. Record meaningful milestones and errors with the session, then compare them with screenshots, gestures, and telemetry during investigation.

Send an app event or live log line:

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 the local host. General OS and unrelated process logs remain in Xcode or Apple device tooling.