Understanding player behavior and server performance is key to growth.
Key metrics to track for server health:
FiveM provides the gameEventTriggered event which captures native game actions (damage, kills, vehicle entry).
AddEventHandler('gameEventTriggered', function(name, args)
if name == 'CEventNetworkEntityDamage' then
local victim = args[1]
local attacker = args[2]
local isFatal = args[6] == 1
if isFatal then
print('Kill detected: ' .. victim .. ' killed by ' .. attacker)
-- Send to analytics endpoint
end
end
end)Sentry is excellent for tracking Lua errors in real-time.
sentry-fivem or simple HTTP reporting.-- Client-side error catching
Citizen.CreateThread(function()
local originalTrace = Citizen.Trace
Citizen.Trace = function(data)
if string.match(data, "Error") or string.match(data, "SCRIPT ERROR") then
TriggerServerEvent('log:sentry', data)
end
originalTrace(data)
end
end)For your server’s website or Tebex store, Plausible provides privacy-friendly analytics.
For gameplay analytics (who robbed the bank, who sold drugs), log to a database or external API, NOT just Discord webhooks.
INSERT INTO analytics_events (event_type, player_id, metadata, created_at)
VALUES ('robbery_start', 'char:123', '{"bank": "fleeca_01"}', NOW());