Info
- Sessions, events and recordings for the app's Analytics on ServiceHub, only what the signed-in player allows: usage data or the research studies they take part in
- Code in
ServiceHub/Analytics (assembly Polis.Core.ServiceHub.Analytics)
- Needs the Analytics service turned on for the app, see App Settings. Endpoints under
/api/analytics: API
- Session values come from
RuntimeContext keys, see Utilities
Setup
- Kit prefab
Multiplayer/ServiceHub/AnalyticsManager.prefab, load item AnalyticsManagerLoader. AnalyticsManager waits for the ServiceHubManager
- Settings SO
AnalyticsSettings in the project (Create > Polis/ServiceHub/Analytics Settings), addressable with the Settings label. Without one: defaults, no event sources or recordings
- Sending - Send Interval (5 s), Batch Size (100, the hub takes up to 500), Heartbeat Interval (60 s, an empty batch keeps the session open)
- Offline - Max Queue Megabytes (100), Max Queue Days (30). The oldest recordings go first, then the oldest events, never the current session's
- Event Sources -
IAnalyticsEventSources, each one data category
BugReportEventSource - bug_reports: bug_report_sent
RoomEventSource - rooms: room_joined (join code, host), room_left (join code, minutes). Playing offline isn't a room
XRInteractionEventSource - interactions: interaction with type (activate, deactivate, select, deselect), object and hand. Only objects the rig hovers
- Event Categories -
AnalyticsEventCategory: the project's own events bundled by purpose. Id, English name (shown on the hub and in study consents), default (Usage or Study), event names
- Recordings -
AnalyticsRecordingDefinitions, Chunk Seconds (20), Max Local Copy Megabytes (500)
- Context Categories - runtime context keys that go only while their data category is collected, e.g.
room for rooms. Keys without one follow usage data
- Data category ids: 1 to 64 lowercase letters, digits,
_, . or -. Others are left out with an error
Sessions and events
- A session is one run of the app: app version, build number, release channel (
editor in the editor, out of the hub's production view), platform key, device, OS, headset, resolution, refresh rate, language
Track(eventName, props, category) - flat properties: text, numbers or yes/no. Ignored while nothing is recorded or its category isn't collected, without a category it follows usage data. Names: 1 to 64 letters, digits, ., - or _, others are dropped with an error, since the hub refuses a whole batch for one bad name
- Own events:
headset_on / headset_off, focus_gained / focus_lost. Runtime context keys go as $values events, the session id goes into the context as session
TrackAnalyticsEventAction - IAction that tracks an event without code, e.g. from a button. Category from the settings, typed properties
- Events wait in a queue on the device (
persistentDataPath/AnalyticsQueue) and go in batches every send interval, a heartbeat while there are none. A session's first batch carries the catalog of data categories the app can collect
- A run that didn't end cleanly is sent as
crashed_session with the next start's first batch. A pause the app never came back from (quit from the headset menu) ends the session at the pause instead
- Offline, signed out or the hub down: everything stays queued. Dedicated servers send their own sessions with the server's login
What is recorded
AnalyticsManager.IsCollected(category) - only what the signed-in player allows
- Usage data:
Sharing (AnalyticsSharing: Share, Required when the app's terms require it, Asked), from the sign-in answer or the hub. A player who hasn't answered shares nothing. The hub lists the categories usage data includes, until then the categories with the Usage default
- Studies:
Studies (AnalyticsStudy), the research studies the player is in. A running study they agreed to records its categories even with usage data off. Consent in the app asks with the study's text, consent given before the study (e.g. on paper) shows a notice once the researchers have the form
- Until the hub answers for the player, events wait on the device unsent. The last answer is kept per player, so an opted-out player isn't recorded meanwhile