Environments and query overrides
Environments and query overrides
SDK.environment is a string you can read after init() resolves. It is "disabled" until then.
| Value | Meaning |
|---|---|
zokogames |
The game is inside the portal's iframe (the live site, the Preview tool or the build preview in the console). All features are real. |
local |
The in-page mock described in local testing. |
disabled |
Neither of the above. Every SDK method except init() fails with sdkDisabled. |
How the SDK decides#
- If the page is the top-level window (not in an iframe), it is
localwhen the host islocalhost,127.0.0.1,[::1]or*.localhost, or when the URL hasuseLocalSdk=true. Otherwise it isdisabled. - If the page is in an iframe, the SDK sends a handshake to the parent and waits up to 1.5 seconds for the portal to answer. A valid answer gives
zokogames. If nothing answers, the SDK falls back tolocalwhen local mode is allowed by the rules above, and todisabledotherwise.
The practical consequence: a game uploaded to a random web host does not get a mock unless you add ?useLocalSdk=true, which is deliberate. A game that ships its own copy of itself elsewhere keeps working, it just does not talk to the portal.
await SDK.init();
switch (SDK.environment) {
case "zokogames": break; // production behaviour
case "local": showDevBadge(); break; // your machine
case "disabled": hidePortalFeatures(); break;
}Query parameters the SDK reads#
| Parameter | Where it applies | Purpose |
|---|---|---|
useLocalSdk=true |
Any host | Allows local mode off localhost. |
sdk_debug=true |
Everywhere | Logs every call. Turn it on to diagnose a problem in the preview tool. |
qaTool=true |
Everywhere | Makes SDK.isQaTool true. |
Mock switches (disableChat, muteAudio, user_response and so on) |
Local mode only | Listed in local testing. |
In the portal these parameters are ignored for anything except logging. Players cannot change their identity or ad behaviour by editing the URL.
Initialisation errors#
init() itself never rejects. Failures show up as disabled. After that:
- Calling a method before
init()resolved rejects (or throws, for synchronous members) withsdkNotInitialized. - Calling it while disabled gives
sdkDisabled.
See errors for the full list.