# Automatic events

> Everything the analytics module records on its own once Start has run, with exact event names, timing and properties.

After `Analytics:Start`, the SDK records sessions, server lifecycle and marketplace prompts without any code from you. This page lists exactly what is sent, when, and with which properties. Types and limits for every reserved event are on the [event reference](https://docs.bloxlytics.app/sdk/event-reference).

| Event | When | Turned off by |
| --- | --- | --- |
| `$server_start` | Once, just after start-up | — |
| `$server_heartbeat` | About every 30 seconds | — |
| `$server_stop` | When the server shuts down | — |
| `$session_start` | A player joins (or is already in the server at start-up) | `AutoTrackSessions = false`, or **Sessions** off in the dashboard |
| `$session_end` | A player leaves, or the server shuts down | `AutoTrackSessions = false`, or **Sessions** off in the dashboard |
| `$purchase` (game pass) | A game pass purchase prompt closes | `AutoTrackGamePasses = false`, or **Purchases** off in the dashboard |
| `$purchase` (developer product attempt) | A developer product purchase prompt closes | **Purchases** off in the dashboard |

None of these are sent from Studio unless you set `TrackInStudio = true`.

## What every event carries

Each event in a batch has these fields (see [event format](https://docs.bloxlytics.app/api/ingest/event-format)):

| Field | Value |
| --- | --- |
| `id` | A random GUID made by `HttpService:GenerateGUID`. The API uses it to drop duplicates when a batch is retried. |
| `name` | The event name, such as `$session_start`. |
| `ts` | When the call was made, in Unix seconds with millisecond precision (`DateTime.now().UnixTimestampMillis / 1000`). |
| `userId` | The player's `UserId`, for events about a player. Absent on server events. |
| `sessionId` | The player's current session id, when they have one. |
| `props` | The event's properties. Left out when there are none. |

Each batch also describes the server once:

| Field | Value |
| --- | --- |
| `jobId` | `Analytics.ServerKey`: `game.JobId`, or a key like `studio-1a2b3c4d` in Studio. |
| `placeId` | `game.PlaceId` |
| `placeVersion` | `game.PlaceVersion`, so you can compare place versions. |
| `privateServerId` | `game.PrivateServerId`, only in private servers. |
| `isStudio` | `RunService:IsStudio()` |

## Server lifecycle

### `$server_start`

Sent once, from the SDK's start-up thread, right after the first attempt to fetch remote configuration.

| Property | Type | Value |
| --- | --- | --- |
| `maxPlayers` | number | `Players.MaxPlayers` |
| `tags` | string | Your [server tags](https://docs.bloxlytics.app/sdk/reference#setservertag) as a JSON object, for example `{"mode":"Classic"}`. |
| `studio` | boolean | Whether this is a Studio session. |

Tags you set with `SetServerTag` before `Start`, or straight after it, are included.

### `$server_heartbeat`

Sent about every 30 seconds for as long as the server runs. Heartbeats drive the live server list, concurrent players and "who is online where" in Bloxlytics. They don't appear in the live event feed.

| Property | Type | Value |
| --- | --- | --- |
| `playerCount` | number | Number of players in the server. |
| `maxPlayers` | number | `Players.MaxPlayers` |
| `players` | string | The user ids of everyone in the server, comma separated, for example `"1001,1002"`. |
| `bridge` | boolean | `true` when the [Cmdr bridge](https://docs.bloxlytics.app/sdk/cmdr-bridge) has registered and is enabled for the project. |
| `tags` | string | Current server tags as a JSON object. |
| `studio` | boolean | Whether this is a Studio session. |

### `$server_stop`

Sent from the SDK's `BindToClose` handler, after every open session has been ended. It has no properties. Bloxlytics marks the server as stopped and removes it from the live list.

## Sessions

A session is one visit by one player to one server. The SDK starts one in `Players.PlayerAdded` and ends it in `Players.PlayerRemoving`. Players already in the server when `Start` runs also get a session, started just after the first remote configuration fetch.

Each session has a random id. Every event you track for that player while the session is open carries it as `sessionId`, which is how Bloxlytics groups a player's events into a visit.

### `$session_start`

| Property | Type | Source |
| --- | --- | --- |
| `username` | string | `player.Name` |
| `displayName` | string | `player.DisplayName` |
| `accountAge` | number | `player.AccountAge`, in days. |
| `premium` | boolean | `player.MembershipType == Enum.MembershipType.Premium` |
| `locale` | string | `player.LocaleId`, for example `en-us`. |
| `country` | string | `LocalizationService:GetCountryRegionForPlayerAsync(player)`, an ISO 3166-1 alpha-2 code such as `GB`. Left out if Roblox's call fails. |
| `teleported` | boolean | `true` when `player:GetJoinData().SourcePlaceId` is set, meaning the player arrived by teleport. |

The country lookup yields briefly. If the player leaves before it returns, the start event isn't sent.

### `$session_end`

| Property | Type | Value |
| --- | --- | --- |
| `duration` | number | Whole seconds since the session started. |

When the server shuts down, the SDK ends every open session first, so players still in a closing server get a `$session_end` too.

### Turning sessions off

- `AutoTrackSessions = false` in the configuration turns session tracking off on that server: no handlers are connected and no sessions exist.
- The **Sessions** switch in the dashboard's SDK configuration stops new sessions being started on every server once they load the change (within 5 minutes), and the API starts rejecting session events within about 30 seconds of the change.

Without a session, your events for a player have no `sessionId`, and [experiment exposures](https://docs.bloxlytics.app/sdk/experiments#exposure-events) aren't logged.

## Marketplace prompts

The SDK listens to Roblox's prompt events so purchase funnels work with no code. Product names and prices come from `MarketplaceService:GetProductInfo`, looked up on a separate thread and cached for the life of the server. Details are on [purchases](https://docs.bloxlytics.app/sdk/purchases).

### Game passes

When `MarketplaceService.PromptGamePassPurchaseFinished` fires, the SDK sends a `$purchase` with `status = "attempted"`, and, if `wasPurchased` is true, a second `$purchase` with `status = "completed"` and `receiptId` set to `gp-<userId>-<gamePassId>`.

| Property | Type | Value |
| --- | --- | --- |
| `kind` | string | `"gamepass"` |
| `productId` | number | The game pass id. |
| `productName` | string | From `GetProductInfo`, when it succeeds. |
| `robux` | number | `PriceInRobux` from `GetProductInfo`, when available. |
| `status` | string | `"attempted"` or `"completed"` |
| `receiptId` | string | `gp-<userId>-<gamePassId>`, on completions only. |

### Developer products

When `MarketplaceService.PromptProductPurchaseFinished` fires for a player in the server, the SDK sends a `$purchase` with `kind = "developer_product"` and `status = "attempted"`, whether or not the player bought it. The completion is recorded only from your `ProcessReceipt` handler, which is the authoritative signal; wrap it with [`WrapProcessReceipt`](https://docs.bloxlytics.app/sdk/purchases#processreceipt).

## What isn't automatic

These need a call from your code, because only your game knows when they happen:

- [custom events](https://docs.bloxlytics.app/sdk/custom-events), funnels and progression;
- [currency sources, sinks, balances and transfers](https://docs.bloxlytics.app/sdk/economy);
- completed developer product purchases ([`WrapProcessReceipt`](https://docs.bloxlytics.app/sdk/purchases#processreceipt));
- [player properties and roles](https://docs.bloxlytics.app/sdk/reference#player-properties);
- [experiment exposures](https://docs.bloxlytics.app/sdk/experiments), which are logged when you call `GetVariant`.
