GameAction API
GameAction API
A namespace for reporting the lifecycle of a single game round (round / stage / level) to the platform. The recorded actions are used by the platform for analytics and reporting. All calls are fire-and-forget and do not wait for a response.
TudadaSDK.gameAction exposes three methods:
start(options?)— round startedcomplete(options)— round cleared normallyexit(options)— round ended abnormally (abandoned / timeout)
start(options?)
Reports that a round has started. All options are optional.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
payload.round | number | - | Round number |
payload.stage | number | - | Stage number |
payload.level | number | - | Level number |
additionalPayload | string | - | Free-form metadata (any string the game wants to attach) |
// Example 1: no arguments
TudadaSDK.gameAction.start();
// Example 2: with stage info
TudadaSDK.gameAction.start({
payload: { stage: 3 },
});
// Example 3: with free-form metadata
TudadaSDK.gameAction.start({
payload: { round: 1, stage: 3, level: 5 },
additionalPayload: JSON.stringify({ tutorial: true }),
});
complete(options)
Reports that a round has been cleared normally. result and playTime are required.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
payload.result | 'WIN' | 'LOSE' | 'DRAW' | 'DONE' | ✅ | End result |
payload.playTime | number | ✅ | Round duration (ms) |
payload.score | number | - | Score achieved |
payload.round | number | - | Round number |
payload.stage | number | - | Stage number |
payload.level | number | - | Level number |
additionalPayload | string | - | Free-form metadata |
TudadaSDK.gameAction.complete({
payload: {
result: 'WIN',
playTime: 12345,
score: 9000,
stage: 3,
},
});
exit(options)
Reports that a round was ended without normal completion (e.g. the player abandoned it, or a time limit expired). playTime and reason are required.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
payload.playTime | number | ✅ | Round duration (ms) |
payload.reason | 'TIMEOUT' | 'ABANDONED' | ✅ | Exit reason |
additionalPayload | string | - | Free-form metadata |
// Player abandoned the round
TudadaSDK.gameAction.exit({
payload: { playTime: 4500, reason: 'ABANDONED' },
});
// Time limit reached
TudadaSDK.gameAction.exit({
payload: { playTime: 60000, reason: 'TIMEOUT' },
});
tip
exit() should be called explicitly by the game code when it decides a round has ended. It is independent of page unload (web view close).