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.
- Going to the background ends nothing. Come back within 15 minutes of the session's last activity and the same session continues; return later and a new session begins, named after the one before it and the pause since.
- A session lives at most 4 hours: past that, the next event starts a new one with the app still in use.
- A process that dies — a crash, a memory kill, a quit — ends its session. The next launch reports that session's end at the moment it was last seen, then starts a fresh one.
session.endgoes out once per session and carries its duration. - Fifteen minutes and four hours are the platform's numbers, the same on every platform — not a setting.
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:
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(_:traits:), events are also linked to your own user id, so one user's activity connects across their sessions and installs. 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.