Breadcrumbs
Breadcrumbs are a lightweight way to add logging to your session. They provide context to user activity in sessions, while adding little CPU or memory overhead.
Adding Context to Sessions
Embrace can collect basic session data and crashes as you've already seen in the Crash Reporting and Session Reporting sections. Embrace can also collect your logging data and include it as context within your sessions. Here's how you add a breadcrumb to the session:
Embrace.client?
.add(event: .breadcrumb("something happened RIGHT NOW"))
Important
Breadcrumb messages must be 256 characters or less.
Note here that the .add(event:)
method adds a SpanEvent to the session span. Embrace's Breadcrumbs are an OpenTelemetry-compliant subclass of SpanEvents, and are add in-context in the User Timeline.
info
For how to best use Breadcrumbs, check out the Best Practices page.