Add analytics integration with Horchposten backend
Implements session-based analytics tracking that sends gameplay
stats to the Horchposten API. Adds stats.{c,h} for accumulating
per-session metrics (kills, deaths, shots, dashes, jumps, pickups,
damage, time) and analytics.{c,h} with EM_JS bridge for fetch()
calls to the backend. Client ID is persisted in localStorage.
Session start/end hooks are wired into all game lifecycle events
(level transitions, restart, quit, tab close via sendBeacon).
Analytics URL/key are configured via data attributes on the canvas
container. Non-WASM builds compile with no-op stubs.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "game/player.h"
|
||||
#include "game/sprites.h"
|
||||
#include "game/projectile.h"
|
||||
#include "game/stats.h"
|
||||
#include "engine/input.h"
|
||||
#include "engine/physics.h"
|
||||
#include "engine/renderer.h"
|
||||
@@ -301,6 +302,7 @@ void player_update(Entity *self, float dt, const Tilemap *map) {
|
||||
|
||||
if (input_pressed(ACTION_DASH) && pd->dash_charges > 0) {
|
||||
pd->dash_charges--;
|
||||
stats_record_dash();
|
||||
/* Start recharge timer only if not already recharging */
|
||||
if (pd->dash_recharge_timer <= 0) {
|
||||
pd->dash_recharge_timer = (pd->jetpack_boost_timer > 0)
|
||||
@@ -410,6 +412,7 @@ void player_update(Entity *self, float dt, const Tilemap *map) {
|
||||
pd->jumping = true;
|
||||
pd->jump_buffer_timer = 0;
|
||||
pd->coyote_timer = 0;
|
||||
stats_record_jump();
|
||||
audio_play_sound(s_sfx_jump, 96);
|
||||
}
|
||||
|
||||
@@ -460,6 +463,7 @@ void player_update(Entity *self, float dt, const Tilemap *map) {
|
||||
}
|
||||
|
||||
projectile_spawn_dir(s_em, bullet_pos, shoot_dir, true);
|
||||
stats_record_shot_fired();
|
||||
/* Muzzle flash slightly ahead of bullet origin (at barrel tip) */
|
||||
Vec2 flash_pos = vec2(
|
||||
bullet_pos.x + shoot_dir.x * 4.0f,
|
||||
|
||||
Reference in New Issue
Block a user