A small dependency-free C# client for sending game telemetry to TerryWatch.
Reference this project from your game or server project:
dotnet add reference path/to/TerryWatch.Client.csprojThen import the namespace:
using TerryWatch.Client;Initialize the client with the credentials shown on the TerryWatch game setup page:
var client = Terrywatch.Init(
apiKey: "your_api_secret",
appId: "your_app_id"
);For a deployed TerryWatch server, pass the base URL:
var client = Terrywatch.Init(
apiKey: "your_api_secret",
appId: "your_app_id",
baseUrl: "https://your-terrywatch-domain.com"
);Start a player session, send events, then end the session:
var session = await client.StartSessionAsync(
steamId: "76561198000000001",
authToken: "sbox_auth_token"
);
await session.SendEventAsync("level_started", new
{
level = 1,
map = "facility"
});
await session.SendEventAsync("level_complete", new
{
level = 1,
score = 1200,
time_seconds = 84
});
var ended = await session.EndAsync();
Console.WriteLine($"Session duration: {ended.DurationSeconds}s");Terrywatch.Init(...)stores your app ID, API key, and server URL.StartSessionAsync(...)callsPOST /api/sessions/startand returns a session token.SendEventAsync(...)callsPOST /api/eventsusing that session token.EndAsync(...)callsPOST /api/sessions/end.
The TerryWatch dashboard unlocks after the first successful session start request.
Failed API responses throw TerryWatchApiException.
try
{
var session = await client.StartSessionAsync(steamId, authToken);
}
catch (TerryWatchApiException exception)
{
Console.WriteLine(exception.StatusCode);
Console.WriteLine(exception.ErrorCode);
Console.WriteLine(exception.ResponseBody);
}Common error codes include:
missing_credentialsinvalid_credentialsinvalid_auth_tokenmissing_tokeninvalid_tokensession_endedsession_idle_closed
If your app already manages an HttpClient, pass it into Init:
var httpClient = new HttpClient
{
Timeout = TimeSpan.FromSeconds(5)
};
var client = Terrywatch.Init(
apiKey: "your_api_secret",
appId: "your_app_id",
baseUrl: "https://your-terrywatch-domain.com",
httpClient: httpClient
);dotnet build TerryWatch.Client.csproj