HTML5 game publishing
updateScore, updateLevel and happyMoment: The PlayKovo SDK Lifecycle Hooks
What the reporting hooks are described as, when to call each, how to name happy moments and why they never replace saving or a third-party analytics SDK.
Near the end of the SDK reference there is a short group of methods that do not show ads, save games or pause anything: updateScore, updateLevel and happyMoment. The documentation calls them safe lifecycle hooks for future reporting. This post explains what that means, why it is worth calling them now, and what not to expect from them.
What the documentation says
In the storage section of the reference, three methods are listed together: updateScore, updateLevel and happyMoment. They are described as safe lifecycle hooks for future reporting. The example shows updateLevel(8) and happyMoment("boss_defeated").
window.PlayKovoSDK.updateLevel(8);
window.PlayKovoSDK.happyMoment("boss_defeated");
The words "for future reporting" matter. They tell you that the platform accepts these calls today without failing, and that more may be done with them later. They do not promise a leaderboard, a feature on the site or revenue. Treat them as cheap markers that make your game easier to understand from the outside, and do not design anything around an effect you cannot see.
What each hook is for
| Method | Send it when | Example |
|---|---|---|
updateScore | The player's score changes in a meaningful way, such as at the end of a run | updateScore(finalScore) |
updateLevel | The player reaches a new level or stage | updateLevel(8) |
happyMoment | Something good has just happened that you would want the player to feel | happyMoment("boss_defeated") |
I use "meaningful" on purpose. A score changes dozens of times in a run; do not call updateScore on every point. Call it when a number is final, or at a natural checkpoint.
Why a happy moment is a good idea
A happy moment is a name for the instant when a player feels rewarded: a boss falls, a record is broken, a rare item drops. By marking these instants you document the best parts of your game. Whether the platform uses them to time interface elements or ads is not described, so do not rely on it. But there is a design benefit that does not depend on the platform: if you have to name your happy moments, you find out whether your game has any.
It also connects to ad timing. The documentation recommends putting interstitials at natural breaks, such as between levels, after a completed run or at the pause menu. A happy moment is the opposite: it is not a break, it is a peak. Never put an ad on top of one. See naming ad placements after the moment they fire.
Naming
- Use lowercase words with underscores:
boss_defeated,new_record,level_unlocked. - Name the event, not the screen.
new_recordis better thanresult_screen. - Keep the list short. Five or six distinct moments are easier to reason about than thirty.
- Do not put personal data or the player's name into an event name.
Calling them safely
The hooks are described as safe, so a call should not break your game. Even so, the guard you already use for the rest of the SDK applies: do not assume the SDK exists. A small wrapper keeps the rest of your code tidy.
const pkv = {
level(n) { try { window.PlayKovoSDK?.updateLevel(n); } catch (e) {} },
score(n) { try { window.PlayKovoSDK?.updateScore(n); } catch (e) {} },
happy(name) { try { window.PlayKovoSDK?.happyMoment(name); } catch (e) {} },
};
With this wrapper a game that runs outside PlayKovo, for example on your own test page, still works.
What not to do
- Do not add your own analytics service next to them. A third-party analytics SDK or extra network calls can get a submission rejected; see trackers and network calls.
- Do not use them in place of saving. They report; they do not store. Saving is covered in cloud save with a local fallback.
- Do not call them in a loop. One call per event.
The methods are listed in the JavaScript SDK reference, and how they fit with the start and stop of play is in gameplayStart and gameplayStop.


