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
Installation
Section titled “Installation”dotnet add package Vortex.CSharp.SDKOr search for Vortex.CSharp.SDK in the NuGet Package Manager.
Requirements: .NET Standard 2.0+ or .NET 6+, System.Text.Json
Initialization
Section titled “Initialization”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);Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
tenantId | string | — | Your project identifier from the Vortex dashboard |
url | string | — | Server endpoint, e.g. https://in.vortexanalytics.io |
platform | string | — | Platform string, e.g. Windows, Steam, Android |
appVersion | string | — | Your application version |
autoBatching | bool | false | Queue events and flush on an interval instead of sending immediately |
flushIntervalSec | int | — | Flush interval in seconds (only used when autoBatching is true) |
What happens on initialization
Section titled “What happens on initialization”- Loads or generates a persistent device identifier (stored locally)
- Creates a new session ID
- Starts a background health-check task
- Enables or disables analytics based on server availability
If the server is unreachable, events are safely queued until connectivity is restored.
Tracking events
Section titled “Tracking events”Simple event
Section titled “Simple event”AnalyticsManager.Instance.TrackEvent("app_started");Event with string payload
Section titled “Event with string payload”AnalyticsManager.Instance.TrackEvent("menu_opened", "settings");Event with structured data
Section titled “Event with structured data”AnalyticsManager.Instance.TrackEvent("level_completed", new Dictionary<string, object>{ { "level", 5 }, { "difficulty", "Hard" }, { "time", 123.4f }});Batching
Section titled “Batching”Manual batching
Section titled “Manual batching”Use manual batching when you want explicit control over when events are flushed (e.g. at the end of a match).
// Queue eventsAnalyticsManager.Instance.BatchedTrackEvent("EnemyKilled");
AnalyticsManager.Instance.BatchedTrackEvent( "ItemCrafted", new Dictionary<string, object> { { "item", "MagicSword" }, { "rarity", "Epic" } });
// Send all queued events in a single HTTP requestAnalyticsManager.Instance.FlushManualBatch();Automatic batching
Section titled “Automatic batching”Enable autoBatching: true during Init():
TrackEventcalls are queued automatically- The queue flushes every
flushIntervalSecseconds - If the server is unreachable, events stay queued until connectivity is restored
Custom data
Section titled “Custom data”Attach persistent metadata to every event the manager sends.
// Set custom data — included in all subsequent eventsAnalyticsManager.Instance.SetCustomData(new Dictionary<string, object>{ { "user_id", 123 }, { "tier", "gold" }});
// Remove custom dataAnalyticsManager.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
Lifecycle handling
Section titled “Lifecycle handling”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.
MonoGame (Game1.cs)
Section titled “MonoGame (Game1.cs)”protected override void UnloadContent(){ AnalyticsManager.Instance.Shutdown(); base.UnloadContent();}WPF (App.xaml.cs)
Section titled “WPF (App.xaml.cs)”protected override void OnExit(ExitEventArgs e){ AnalyticsManager.Instance.Shutdown(); base.OnExit(e);}Console app
Section titled “Console app”AppDomain.CurrentDomain.ProcessExit += (s, e) =>{ AnalyticsManager.Instance.Shutdown();};