The bridge SDK, analytics and PlayServ
Add one script tag for analytics, error reports, remote config and premium session events, and learn what the PlayServ control room offers.
In short
- The bridge SDK is one optional script:
<script src="/__oneprompt/bridge.js"></script>. Your game works without it. - With it you get sessions, a "playable" signal, custom events and automatic error reports in your dashboard, plus remote configuration from the PlayServ control room.
- Premium games can listen to the play page's session state (
active,paused,awaiting_consent,ended) and pause themselves. - The SDK uses no cookies and sends no personal data. Analytics must never break your game, so every failure inside the SDK is silent.
- Multiplayer runs on PlayServ, the multiplayer backend OnePrompt is part of. You build it with PlayServ's own SDK, and your game is allowed to connect to PlayServ.
Adding the SDK
Add this line to your entrypoint HTML, before your game's own scripts:
<script src="/__oneprompt/bridge.js"></script>
The path is served by the platform on every game origin, so there is nothing to download or bundle. In local development the file is missing; guard your calls so the game still runs:
const op = window.OnePrompt;
if (op) op.ready();
Telling us when the game is playable
OnePrompt.ready();
Call ready() once, when the player can first interact (for example when your main menu appears). It is what the dashboard's Playable rate is based on: the share of sessions that reached a playable state. A low rate usually means a slow or failing load. Calling it more than once does nothing.
Custom events
OnePrompt.event('level_complete', { level: 3, stars: 2, hard_mode: true });
Rules, so your events arrive:
- The event name starts with a lowercase letter and uses lowercase letters, digits and underscores, up to 40 characters. Invalid names are dropped and
event()returnsfalse. - Up to 10 properties per event, with names following the same rule.
- Property values may be strings (cut to 100 characters), finite numbers or booleans. Other values are dropped.
- Events are batched and sent every 5 seconds and when the page is hidden or closed.
Do not put personal data such as names or email addresses in events.
Automatic error reports
Once the SDK is loaded, uncaught script errors, failed resource loads and unhandled promise rejections are reported as a category plus a short message, at most 10 per visit. URLs in messages are replaced with [url], and no stack traces are sent. They appear as Errors on your project page.
Remote config
OnePrompt.config().then(function (c) {
const speed = c.values.enemy_speed ?? 1;
});
config() returns the production remote config values you set in the PlayServ control room, as { version, values }. If the values cannot be loaded, you get empty values with stale: true, so always keep sensible defaults in the game. Changing remote config does not need a new deployment.
Session ids
OnePrompt.started is a promise that resolves with an anonymous id for this visit once the SDK has connected; after that, OnePrompt.sessionId holds the same id. It identifies a visit, not a person.
Premium session events
Inside the play page, premium games can follow the session state:
OnePrompt.onSession(function (state) {
if (state === 'active') game.resume();
else game.pause();
});
The states mean:
active: the player is playing (and, for premium games, being charged after any free minutes).paused: the player's Play Credits cannot pay for the next minute. The play page offers a top-up; nothing is charged while paused.awaiting_consent: a price increase has just taken effect and the player has not accepted it yet. Nothing is charged while waiting.ended: the player exited, the session timed out, or there was no top-up or consent within 2 minutes.
Good to know:
- The callback receives only the state string. No price, balance or player data ever reaches your game.
- You can register several callbacks; one that throws does not stop the others.
- While a session is paused or awaiting consent, the play page removes your game's frame and reloads the game when play resumes. So save progress on
paused,awaiting_consentandendedrather than relying on resuming from memory. - Messages are accepted only from the OnePrompt play page, so another site cannot feed your game a fake state.
- Events fire only inside the play page's frame. Free games opened directly on their own address, and games with
cross_origin_isolation: true(which open in the full window), receive no session events. - Honouring the state is optional but recommended. Metering and charging happen on our side from the play page, never from your game, so your game cannot over- or under-charge anyone.
Your analytics in the dashboard
Dashboard → Projects → your project → Last 30 days shows, from bridge data:
- Sessions and a bar chart of sessions per day;
- Playable rate (sessions that called
ready()); - Median play time per session;
- Delivered traffic;
- Errors;
- top countries and devices.
Export raw events downloads your project's raw event data. Agents with the analytics:read scope can read the same summary through the oneprompt_usage_get MCP tool, and the REST API offers /v1/projects/{id}/analytics and /v1/projects/{id}/usage.
The PlayServ control room
OnePrompt is part of PlayServ, and every project gets a PlayServ control room. Open it from Dashboard → your project → PlayServ control room → Open control room. Its status shows next to the button: provisioning right after you create a project, then ready. If it shows degraded, synchronisation is retrying in the background; your game keeps running either way.
In the control room you can see your project's release and deployment history, recent event traffic, and edit the production remote config (JSON values your game reads with OnePrompt.config()). It also lists PlayServ capabilities with their status: analytics and remote config are live there, while player data, micro-backend and multiplayer are shown as preview. Multiplayer itself you build directly with PlayServ, as described below.
Multiplayer
Multiplayer on OnePrompt runs on PlayServ, the multiplayer backend OnePrompt is part of. PlayServ gives your game rooms and matchmaking, player accounts, game data and server functions, so adding online play is a matter of minutes rather than running your own servers.
You build multiplayer with PlayServ's own SDK and documentation at https://playserv.io. The bridge SDK on this page is separate: it handles analytics, remote config and premium session events, and you do not need it for multiplayer.
Your game page is allowed to connect to PlayServ's services: that is part of your game's network rules. You can declare the capability in your manifest:
playserv:
sdk: optional
capabilities:
- multiplayer
A few things to keep in mind:
- Connections to other servers stay blocked: the security policy limits network requests to your game origin, the OnePrompt API and PlayServ (see What your game can and cannot do in the browser). Run your online features on PlayServ rather than on your own game servers elsewhere.
- Multiplayer games must follow the player conduct rules in the Community & Content Policy, and should give players reasonable ways to deal with abuse, such as muting or reporting.
Local multiplayer (several players on one device, for example with several gamepads) needs no server at all.