Guides

Sessions & analytics

Beyond crashes, Pharen records sessions automatically and lets you track your own events with two calls. All of it flows through the same durable, consent-gated queue.

Automatic sessions

A session is a run of foreground activity. You don't start or stop one — Pharen manages the lifecycle:

  • A session starts at launch.
  • When the app goes to the background, Pharen records the session's duration and ends it.
  • Come back within 30 minutes and the same session continues. Return after 30 minutes or more backgrounded and a new session begins. This is the standard mobile session-timeout rule.
  • A crash ends a session simply by ending the process — the next launch starts a fresh one.

Sessions are a behavioral-class event. Every other event Pharen sends carries the current session id, so you can see what happened within a single run of the app.

Tracking your own events

Two calls cover product analytics. track records a named event with optional properties; screen records a screen view:

swift
Pharen.shared?.track("checkout_completed", properties: [
    "order_value": 49.99,
    "items": 3
])

Pharen.shared?.screen("Cart")

Properties are a flexible bag for your own dimensions and metrics. Keep them free of personal data: the SDK drops obvious identifying keys before sending as a safeguard, and the server enforces the rule, but the properties bag is not the place for names, emails, or anything that identifies a person. To associate events with a known user, use identify() — see Privacy & consent.

track and screen are behavioral-class events, distinct from the telemetry class that crashes use. That distinction matters:

Identity, briefly

Every event carries a stable, pseudonymous install id generated on the device — no login required. After you call identify(_:), events also carry your customer id, so a person's activity connects across sessions and devices. Traits you pass to identify never travel on the event stream; the details are on Privacy & consent.

What the explorer shows

In your Pharen console, events arrive as a live stream — each with its type, properties, session, and device context — and sessions roll up into summaries (duration, the events they contain). Because every event shares one strict envelope, crashes, screens, and custom events sit in the same timeline and filter the same way.