Skip to main content

AltaAnalyticsDispatcher

A class in Root.Township, ATT.Analytics.

Analytics dispatcher that posts each analytics event to the Alta API as a generic event with the logged-in user's ID. Runs off the main thread.

Constructors​

MemberWhat it is
AltaAnalyticsDispatcher(IAnalyticsService analyticsService)Built by the game's dependency injection (VContainer), which passes the services in.

Fields​

3 private and internal fields
MemberWhat it is
private static readonly Logger loggerNLog logger for this class.
private static readonly StringBuilder stringBuilderShared builder used by LogPretty.
private static int userIdCached user ID, -1 until read.

Properties​

1 private and internal property
MemberWhat it is
private static int UserId { get; }Logged-in user's ID, cached after the first read until logout.

Methods​

MemberWhat it is
protected override void OnAnalyticsEvent(IReadonlyAnalyticsData data)Sends the event on a background task.
3 private and internal methods
MemberWhat it is
private static void LoggedOut()Clears the cached user ID when the user logs out.
private static void LogPretty(string dataName, Dictionary<string, object> props)Logs the sent event name and its properties at debug level.
private static async Task SendData(IReadonlyAnalyticsData data)Turns the event's properties into a dictionary and posts it with PostGenericEventAsync. Errors are logged.