Skip to content

C# / .NET SDK

AnalyticsManager is a pure C# singleton class that sends analytics events to the Vortex platform. It works in any .NET environment and requires no platform-specific dependencies.

NuGet: Vortex.CSharp.SDK
GitHub: Vortex-Analytics-IO/CSharp-SDK

Supported features:

  • Immediate and batched event tracking
  • Automatic retry when the server becomes available
  • Persistent device and session identification
  • Thread-safe queue management

Terminal window
dotnet add package Vortex.CSharp.SDK

Or search for Vortex.CSharp.SDK in the NuGet Package Manager.

Requirements: .NET Standard 2.0+ or .NET 6+, System.Text.Json


Call Init() once in your application’s entry point before sending any events.

AnalyticsManager.Instance.Init(
tenantId: "mygame_production",
url: "https://in.vortexanalytics.io",
platform: "Windows",
appVersion: "1.0.0",
autoBatching: true, // queue events and flush periodically
flushIntervalSec: 10 // flush every 10 seconds
);
ParameterTypeDefaultDescription
tenantIdstringYour project identifier from the Vortex dashboard
urlstringServer endpoint, e.g. https://in.vortexanalytics.io
platformstringPlatform string, e.g. Windows, Steam, Android
appVersionstringYour application version
autoBatchingboolfalseQueue events and flush on an interval instead of sending immediately
flushIntervalSecintFlush interval in seconds (only used when autoBatching is true)
  1. Loads or generates a persistent device identifier (stored locally)
  2. Creates a new session ID
  3. Starts a background health-check task
  4. Enables or disables analytics based on server availability

If the server is unreachable, events are safely queued until connectivity is restored.


AnalyticsManager.Instance.TrackEvent("app_started");
AnalyticsManager.Instance.TrackEvent("menu_opened", "settings");
AnalyticsManager.Instance.TrackEvent("level_completed", new Dictionary<string, object>
{
{ "level", 5 },
{ "difficulty", "Hard" },
{ "time", 123.4f }
});

Use manual batching when you want explicit control over when events are flushed (e.g. at the end of a match).

// Queue events
AnalyticsManager.Instance.BatchedTrackEvent("EnemyKilled");
AnalyticsManager.Instance.BatchedTrackEvent(
"ItemCrafted",
new Dictionary<string, object>
{
{ "item", "MagicSword" },
{ "rarity", "Epic" }
}
);
// Send all queued events in a single HTTP request
AnalyticsManager.Instance.FlushManualBatch();

Enable autoBatching: true during Init():

  • TrackEvent calls are queued automatically
  • The queue flushes every flushIntervalSec seconds
  • If the server is unreachable, events stay queued until connectivity is restored

Attach persistent metadata to every event the manager sends.

// Set custom data — included in all subsequent events
AnalyticsManager.Instance.SetCustomData(new Dictionary<string, object>
{
{ "user_id", 123 },
{ "tier", "gold" }
});
// Remove custom data
AnalyticsManager.Instance.ClearCustomData();
// Or:
AnalyticsManager.Instance.SetCustomData(null);
  • Empty custom data is not included in request payloads
  • The dictionary is automatically serialized to JSON
  • Invalid JSON data is rejected with a log error

AnalyticsManager cannot detect application shutdown automatically. You must call Shutdown() when your app exits to flush any buffered events.

Shutdown() blocks for up to 2 seconds to attempt a final flush before the process terminates.

protected override void UnloadContent()
{
AnalyticsManager.Instance.Shutdown();
base.UnloadContent();
}
protected override void OnExit(ExitEventArgs e)
{
AnalyticsManager.Instance.Shutdown();
base.OnExit(e);
}
AppDomain.CurrentDomain.ProcessExit += (s, e) =>
{
AnalyticsManager.Instance.Shutdown();
};