Vortex.CSharp.SDK 1.0.0

Suggested Alternatives

Hintway.CSharp.SDK

dotnet add package Vortex.CSharp.SDK --version 1.0.0
                    
NuGet\Install-Package Vortex.CSharp.SDK -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Vortex.CSharp.SDK" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Vortex.CSharp.SDK" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Vortex.CSharp.SDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Vortex.CSharp.SDK --version 1.0.0
                    
#r "nuget: Vortex.CSharp.SDK, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Vortex.CSharp.SDK@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Vortex.CSharp.SDK&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Vortex.CSharp.SDK&version=1.0.0
                    
Install as a Cake Tool

AnalyticsManager Documentation

AnalyticsManager is a pure C# singleton class responsible for sending analytics events to a remote server. It is designed for use in any .NET environment (WPF, Monogame, Godot, Console, ASP.NET, etc.).

It supports:

  • Immediate event tracking
  • Batched event tracking
  • Automatic retry when the server becomes available
  • Local file-based session and device identification
  • Thread-safe queue management

Dependencies

  • .NET Standard 2.0+ or .NET 6+
  • System.Text.Json (Required for JSON serialization)

Initialization

It is a Singleton that must be initialized explicitly in your application's entry point (e.g., Main(), App.xaml.cs, Game1.cs).

Basic Setup

// 1. Configure settings (Optional)
// Set to true to queue events and send them periodically instead of immediately.
// Default is false (immediate send).
bool enableAutoBatching = true; 
int flushIntervalSeconds = 10;

// 2. Initialize the Singleton
AnalyticsManager.Instance.Init(
    tenantId: "mygame_production",
    url: "https://analytics.myserver.com",
    platform: "Windows",
    appVersion: "1.0.0",
    autoBatching: enableAutoBatching,
    flushIntervalSec: flushIntervalSeconds
);

⚠️ Important: Init() must be called before sending any events.

Internal Behavior

On initialization, the system:

  1. Loads or generates a persistent device identifier (stored in a local file).
  2. Creates a new session ID.
  3. Starts a background task to check server health.
  4. Enables or disables analytics based on server availability.

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

Tracking Events

Simple Event

AnalyticsManager.Instance.TrackEvent("app_started");

Event with String Payload

AnalyticsManager.Instance.TrackEvent("menu_opened", "settings");

Event with Structured Data

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

Custom Data

You can attach custom JSON data to all analytics events sent by the system.

Setting Custom Data

AnalyticsManager.Instance.SetCustomData(new Dictionary<string, object>
{
    { "user_id", 123 },
    { "tier", "gold" }
});
  • Pass a Dictionary<string, object> with your custom properties
  • The dictionary is automatically serialized to JSON
  • Once set, the custom data is included in every subsequent event

Resetting Custom Data

// Clear custom data
AnalyticsManager.Instance.ClearCustomData();

// Or pass null/empty dictionary to SetCustomData
AnalyticsManager.Instance.SetCustomData(null);

Behavior

  • Custom data is stored in the custom field of each TrackingData object
  • It persists across multiple event calls until explicitly cleared or changed
  • Empty custom data is not included in the request payload
  • The custom JSON must be valid; invalid JSON is rejected with a log error

Batching

Manual Batching

Manual batching allows you to explicitly control when analytics events are sent (e.g., at the end of a match).

Add Events to Batch

AnalyticsManager.Instance.BatchedTrackEvent("EnemyKilled");

AnalyticsManager.Instance.BatchedTrackEvent(
    "ItemCrafted",
    new Dictionary<string, object>
    {
        { "item", "MagicSword" },
        { "rarity", "Epic" }
    }
);

Send Batched Events

AnalyticsManager.Instance.FlushManualBatch();

This triggers a background task to send all queued events in a single request.

Automatic Batching

When autoBatching is enabled during initialization:

Events tracked via TrackEvent are queued automatically.

The system flushes the queue every flushIntervalSec seconds.

If the server is unreachable, events remain queued until the server responds to a health check.

Lifecycle Handling

Because this is a standard C# class, it cannot automatically detect when your application closes. You must call Shutdown() when your application exits to ensure buffered events are flushed to the network.

Monogame Example (Game1.cs)

protected override void UnloadContent()
{
    AnalyticsManager.Instance.Shutdown();
    base.UnloadContent();
}

WPF Example (App.xaml.cs)

protected override void OnExit(ExitEventArgs e)
{
    AnalyticsManager.Instance.Shutdown();
    base.OnExit(e);
}

Console App Example

AppDomain.CurrentDomain.ProcessExit += (s, e) => 
{
    AnalyticsManager.Instance.Shutdown();
};

Calling Shutdown() performs a blocking wait (max 2 seconds) to attempt a final data flush before the process terminates.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 122 4/19/2026 1.0.0 is deprecated because it is no longer maintained.