Quickstart Guide
1. Server Initialization
Section titled “1. Server Initialization”Create a Script inside ServerScriptService (e.g. ServerScriptService/AnalyticsRunner.server.luau):
local ReplicatedStorage = game:GetService("ReplicatedStorage")local AnalyticsModule = require(ReplicatedStorage:WaitForChild("AnalyticsModule"))
-- Initialize with debug mode enabled for local Studio testinglocal Analytics = AnalyticsModule.init({ debugMode = true, -- Prints formatted event batches to output autoTrackSessions = true, -- Measures playtime and AFK states autoTrackServerUptime = true, -- Monitors memory, uptime, and server FPS autoTrackBadges = true, -- Hooks badge completions enableRetentionTracking = true, -- Tracks D1/D7/D30 cohorts via DataStore autoTrackDeaths = true, -- Logs player death coordinates autoTrackDemographics = true, -- Profiles client platform & input mode})
print("Analytics Module initialized!")2. Client Initialization
Section titled “2. Client Initialization”Create a LocalScript inside StarterPlayerScripts (e.g. StarterPlayerScripts/AnalyticsClient.client.luau):
local ReplicatedStorage = game:GetService("ReplicatedStorage")local AnalyticsModule = require(ReplicatedStorage:WaitForChild("AnalyticsModule"))
-- Automatically boots client performance, demographics, and error forwardinglocal AnalyticsClient = AnalyticsModule.init()
-- Fire a custom client event (e.g., UI interactions)AnalyticsClient:track("MenuOpened", { menuName = "Shop" })3. Verifying Events in Studio Output
Section titled “3. Verifying Events in Studio Output”With debugMode = true, you will see structured output in the Studio Output Window:
[RealisticAnalytics] --- Batch of 4 Event(s) --- [1] (server) ServerInit -> {"jobId":"","placeId":0,"placeVersion":0} [2] (session) SessionStart [User: 123456] -> {"accountAgeDays":120,"locale":"en_us"} [3] (demographics) ClientDemographics [User: 123456] -> {"platform":"PC","inputDevice":"KeyboardMouse","networkPingMs":35} [4] (server) ServerHeartbeat -> {"uptimeSeconds":60,"memoryUsageMb":312,"heartbeatFps":60}[RealisticAnalytics] ---------------------------------------------