Sending events
Automatic events, your own milestones, stages, devices and flushing.
Automatic events
| Event | When | Includes |
|---|---|---|
session_started | A player joins | — |
player_died | A character dies | Position of the HumanoidRootPart |
player_quit | A player leaves | Last known position |
session_ended | A player leaves | durationSeconds in metadata |
Your own events
analytics:track(player, "stage_completed", {
stageId = "stage_3",
position = true, -- or a Vector3
metadata = { seconds = 41, attempts = 3 },
})
analytics:setStage(player, "stage_4") -- default stageId for this player's later events
analytics:setDevice(player, "touch") -- keyboard | touch | gamepad | vr | unknownposition = true samples the player's character. Positions are Roblox studs with no axis conversion, rounded to 0.01. Send positions on meaningful events such as deaths and checkpoints, not on a timer.
Flushing and stats
analytics:flush() -- yields; sends what is queued
print(analytics:stats()) -- queued, inFlight, requests, sentEvents, droppedEvents, retriesOn server shutdown the SDK ends open sessions and flushes for up to 20 seconds automatically.