How do server events work in Manalens?
Your backend sends track and identify events to the same endpoint as the game, POST /v0/events, with channel server. The request uses the project secret key, which starts with mana_sk_. A request with an Origin header and a secret key is refused, so the key cannot work from a browser.
One request holds 1 to 100 events and at most 256 KB. A user_id alone is enough. Old timestamps are allowed for backfills, and a timestamp more than 5 minutes in the future is refused. Server events have their own rate limit, so a flood of browser traffic does not use up your backend quota.
Sources: Manalens server events documentation.
What does an example look like?
Example: a player buys a $9.99 supporter pack on your own store. The payment webhook reaches your backend 3 hours later. Your game sent its anonymous ID and session ID with the checkout request, and your backend puts both on the purchase event. The purchase then counts in the session where the player clicked buy, with revenue of 9.99. It does not change the session duration.
Sources: worked example; Manalens server events documentation.
Why do server events matter for indie PC and web games?
A game build and a web page run on the player's machine, so their events can be blocked or changed. A purchase that your backend checked is a stronger fact. Google describes its Measurement Protocol the same way: it records server to server and offline interactions, to add to client collection, not to replace it.
Never put the secret key in a game build or a web page. Keep it in a server-side secret store.
Sources: Google Analytics Measurement Protocol documentation; Manalens server events documentation.
Frequently asked questions
Can I put the secret key in my game?
No. The secret key is for your backend only. A request with an Origin header and a secret key is refused with 403 SECRET_KEY_FROM_BROWSER. Your game uses the publishable key, which can send game events but cannot send server events.
Can I backfill old events from my server?
Yes. Server events allow old timestamps, so you can backfill events from your own records. A timestamp more than 5 minutes in the future is refused. Set a message_id on each event, so that a retry counts once. One request holds 1 to 100 events and at most 256 KB, so send a large backfill in many requests.
How do I put a server purchase in the player's session?
Send the anonymous ID and the session ID of the client with the event. The game reads both from the SDK and sends them with its request to your backend. The purchase then counts in that session, even when the webhook arrives hours later.