MindAttic/MindAttic.Telemetry
Library

MindAttic.Telemetry.

Tune your game on real play, not guesses.

MindAttic.Telemetry records every turn, every state change and every "this happened" moment of a game session into one crash-safe, append-only NDJSON file, then reads it back as flat rows ready for pandas or ML.

Core complete C# .NET 10 netstandard2.1 Unity 6 NDJSON

What it is

Ask real questions of real play

What is the right heal-to-damage ratio? Where do players actually lose? Balance questions like these deserve data, not hunches. MindAttic.Telemetry gives a game four calls, Begin, RecordTurn, RecordEvent and FinishAsync, and turns every run into a replayable record you can analyse later.

Each session is one append-only file with one JSON object per line, flushed as it is written. Because every line on disk is independently valid, a crash loses nothing already recorded. The next launch finds the abandoned file with a simple file-lock probe, closes it with a recovered marker and moves on. No background service, no agent, nothing to install.

It never forces a universal event shape on you. A tactics RPG's turn looks nothing like a platformer's, so you pass the before, command, events and after objects your rules engine already produces, verbatim. On the analysis side, TelemetryReader.Flatten explodes every event, standalone or inside a turn, into one flat row.

It was extracted and genericized from a MindAttic tactics game's battle recorder, which was already tuning real balance decisions from this data before this library existed.

Who it's for

  • Game designers tuning balanceAnswer balance questions from recorded runs instead of play-test impressions.
  • Unity developersDrop in a Unity 6 package with static TelemetryUnity calls that run in editor and development builds by default.
  • .NET developersRecord sessions from any .NET app in-process with a dependency-free library.
  • Data analystsLoad sessions straight into pandas with read_json(lines=True), or iterate records from C#.

Features

What you get

01

One file per session

SessionStart, then Turn and Event lines, then SessionEnd: every record is {seq, kind, atUtc, name, payload} in plain NDJSON.

02

Crash-safe by construction

Every line is flushed and independently valid. A session that finishes cleanly is renamed from .ndjson.tmp to .ndjson; the rename is the clean-finish signal.

03

Automatic orphan recovery

The next Telemetry.Begin sweeps for abandoned .tmp files nobody still holds open, appends a {"recovered":true} end record and renames them.

04

Your shapes, verbatim

Full before/command/accepted/events/after turns from any event-sourced rules engine, or lightweight named events like shop.purchase, with whatever serializable data you already have.

05

Reader and flattener

TelemetryReader.Read streams typed records with JSON payloads; TelemetryReader.Flatten gives one flat row per event for analysis and ML.

06

Reproducible runs

Sessions record the game id, app and content version, seed and tags, so a run can be reconstructed by re-simulating it in your own deterministic engine.

07

Unity package included

com.mindattic.telemetry wraps the core for Unity 6 on any platform, with consistent camelCase member names and verbatim dictionary keys in both builds.

08

No dependencies, no services

The core targets netstandard2.1 and net10.0 with no third-party packages. Writes are synchronous file appends: nothing to detach and nothing to run in the background.

09

Bring your own logging

Problems such as a payload the serializer rejects go to an ITelemetryLog sink that a host bridges to ILogger, Unity's Debug.Log or anything else; a Trace-based sink is built in.

How it works

Four calls to a replayable run

  1. Begin

    Start a session when a battle, level or run starts, with its seed, version and tags.

  2. Record

    Call RecordTurn after each command your rules engine applies, and RecordEvent for anything else worth knowing.

  3. Finish

    Pass the game's own outcome to Finish; the file is closed and marked clean.

  4. Analyse

    Flatten sessions into rows and chart, query or train on them offline.

Quick start

Record a session from any .NET app

The same calls are available in Unity through TelemetryUnity.

The full setup guide lives in the documentation.

csharp
var session = Telemetry.Begin(new TelemetryOptions { AppName = "MyApp", AppVersion = "1.4.0" }, "MyApp");
session.RecordEvent("level.start", new TelemetryData { ["level"] = 3 });
await session.FinishAsync(new { completed = true });

// later, offline:
var rows = TelemetryReader.Flatten(path).ToList();

Part of MindAttic

One piece of a bigger workshop

MindAttic.Telemetry is the family's game-data recorder. GridGame.Unity consumes its Unity package through a local file: path, and its analysis output feeds balance decisions in MindAttic games.

It sits beside MindAttic.Media.Capture as the other half of observing a game: Capture records what the screen showed, Telemetry records what the rules engine did.

Status

Where it stands

Core complete

The core is hardened; the Unity plugin is catching up

Sessions, the NDJSON writer, orphan recovery and the reader and flattener are done and hardened. The last step to 1.0 is refreshing the DLL vendored into the Unity package and proving a GridGame session reads back with TelemetryReader.Flatten.

Current milestone: MindAttic.Telemetry 1.0: the Unity package at parity with the core.

Next step

Start recording real play

Guides, reference and design notes are in the searchable MindAttic documentation. The source, issues and history are on GitHub.