DynamoVisualProgramming.DynamoServices by Autodesk

<PackageReference Include="DynamoVisualProgramming.DynamoServices" Version="2.5.0-beta6607" />

 Analytics

public static class Analytics
Utility class to support analytics tracking.
using System; using System.Text; namespace Dynamo.Logging { public static class Analytics { private class Dummy : IDisposable { public void Dispose() { } } private static IAnalyticsClient client; internal static bool IsEnabled => client != null; public static bool ReportingAnalytics { get { if (client != null) return client.ReportingAnalytics; return false; } } internal static void Start(IAnalyticsClient client) { Analytics.client = client; client.Start(); } internal static void ShutDown() { if (client != null) client.ShutDown(); (client as IDisposable)?.Dispose(); client = null; } public static void TrackStartupTime(string productName, TimeSpan time, string description = "") { if (client != null) { string description2 = string.IsNullOrEmpty(description) ? productName : $"{productName}""{description}"; client.TrackTimedEvent(Categories.Performance, "Startup", time, description2); } } public static void TrackEvent(Actions action, Categories category, string description = "", int? value = default(int?)) { if (client != null) client.TrackEvent(action, category, description, value); } public static void TrackPreference(string name, string stringValue, int? metricValue) { if (client != null) client.TrackPreference(name, stringValue, metricValue); } public static void TrackTimedEvent(Categories category, string variable, TimeSpan time, string description = "") { if (client != null) client.TrackTimedEvent(category, variable, time, description); } public static void TrackScreenView(string viewName) { if (client != null) client.TrackScreenView(viewName); } public static void TrackException(Exception ex, bool isFatal) { if (client != null) client.TrackException(ex, isFatal); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Type: " + ex.GetType()); stringBuilder.AppendLine("Fatal: " + isFatal.ToString()); stringBuilder.AppendLine("Message: " + ex.Message); stringBuilder.AppendLine("StackTrace: " + ex.StackTrace); LogPiiInfo("Analytics.TrackException", stringBuilder.ToString()); } public static IDisposable CreateTimedEvent(Categories category, string variable, string description = "", int? value = default(int?)) { if (client == null) return new Dummy(); return client.CreateTimedEvent(category, variable, description, value); } public static IDisposable TrackCommandEvent(string name, string description = "", int? value = default(int?)) { if (client == null) return new Dummy(); return client.CreateCommandEvent(name, description, value); } public static IDisposable TrackFileOperationEvent(string filepath, Actions operation, int size, string description = "") { if (client == null) return new Dummy(); return client.TrackFileOperationEvent(filepath, operation, size, description); } public static void LogPiiInfo(string tag, string data) { if (client != null) client.LogPiiInfo(tag, data); } } }