|
@@ -9,19 +9,19 @@ namespace PixiEditor.Models.AnalyticsAPI;
|
|
|
|
|
|
public static class Analytics
|
|
|
{
|
|
|
- public static AnalyticEvent SendStartup(StartupPerformance startup) =>
|
|
|
+ public static AnalyticEvent? SendStartup(StartupPerformance startup) =>
|
|
|
SendEvent(AnalyticEventTypes.Startup, startup.GetData());
|
|
|
|
|
|
- public static AnalyticEvent SendCreateDocument(int width, int height) =>
|
|
|
+ public static AnalyticEvent? SendCreateDocument(int width, int height) =>
|
|
|
SendEvent(AnalyticEventTypes.CreateDocument, ("Width", width), ("Height", height));
|
|
|
|
|
|
- internal static AnalyticEvent SendOpenFile(IoFileType fileType, long fileSize, VecI size) =>
|
|
|
+ internal static AnalyticEvent? SendOpenFile(IoFileType fileType, long fileSize, VecI size) =>
|
|
|
SendEvent(AnalyticEventTypes.OpenFile, ("FileType", fileType.PrimaryExtension), ("FileSize", fileSize), ("Width", size.X), ("Height", size.Y));
|
|
|
|
|
|
- internal static AnalyticEvent SendCreateNode(Type nodeType) =>
|
|
|
+ internal static AnalyticEvent? SendCreateNode(Type nodeType) =>
|
|
|
SendEvent(AnalyticEventTypes.CreateNode, ("NodeType", nodeType.GetCustomAttribute<NodeInfoAttribute>()?.UniqueName));
|
|
|
|
|
|
- internal static AnalyticEvent SendCreateKeyframe(int position, string type, int fps, int duration, int totalKeyframes) =>
|
|
|
+ internal static AnalyticEvent? SendCreateKeyframe(int position, string type, int fps, int duration, int totalKeyframes) =>
|
|
|
SendEvent(
|
|
|
AnalyticEventTypes.CreateKeyframe,
|
|
|
("Position", position),
|
|
@@ -30,24 +30,31 @@ public static class Analytics
|
|
|
("Duration", duration),
|
|
|
("TotalKeyframes", totalKeyframes));
|
|
|
|
|
|
- internal static AnalyticEvent SendCloseDocument() => SendEvent(AnalyticEventTypes.CloseDocument);
|
|
|
+ internal static AnalyticEvent? SendCloseDocument() => SendEvent(AnalyticEventTypes.CloseDocument);
|
|
|
|
|
|
- internal static AnalyticEvent SendOpenExample(string fileName) => SendEvent(AnalyticEventTypes.OpenExample, ("FileName", fileName));
|
|
|
+ internal static AnalyticEvent? SendOpenExample(string fileName) => SendEvent(AnalyticEventTypes.OpenExample, ("FileName", fileName));
|
|
|
|
|
|
- internal static AnalyticEvent SendUseTool(IToolHandler? tool, VecD positionOnCanvas, VecD documentSize) =>
|
|
|
+ internal static AnalyticEvent? SendUseTool(IToolHandler? tool, VecD positionOnCanvas, VecD documentSize) =>
|
|
|
SendEvent(AnalyticEventTypes.UseTool, ("Tool", tool?.ToolName), ("Position", new VecD(documentSize.X / positionOnCanvas.X, documentSize.Y / positionOnCanvas.Y)));
|
|
|
|
|
|
- internal static AnalyticEvent SendSwitchToTool(IToolHandler? newTool, IToolHandler? oldTool, ICommandExecutionSourceInfo? sourceInfo) =>
|
|
|
+ internal static AnalyticEvent? SendSwitchToTool(IToolHandler? newTool, IToolHandler? oldTool, ICommandExecutionSourceInfo? sourceInfo) =>
|
|
|
SendEvent(AnalyticEventTypes.SwitchTool, ("NewTool", newTool?.ToolName), ("OldTool", oldTool?.ToolName), ("Source", sourceInfo));
|
|
|
|
|
|
- internal static AnalyticEvent SendCommand(string commandName, ICommandExecutionSourceInfo? source) =>
|
|
|
+ internal static AnalyticEvent? SendCommand(string commandName, ICommandExecutionSourceInfo? source) =>
|
|
|
SendEvent(AnalyticEventTypes.GeneralCommand, ("CommandName", commandName), ("Source", source));
|
|
|
|
|
|
- private static AnalyticEvent SendEvent(string name, params (string, object)[] data) =>
|
|
|
+ private static AnalyticEvent? SendEvent(string name, params (string, object)[] data) =>
|
|
|
SendEvent(name, data.ToDictionary());
|
|
|
|
|
|
- private static AnalyticEvent SendEvent(string name, Dictionary<string, object> data)
|
|
|
+ private static AnalyticEvent? SendEvent(string name, Dictionary<string, object> data)
|
|
|
{
|
|
|
+ var reporter = AnalyticsPeriodicReporter.Instance;
|
|
|
+
|
|
|
+ if (reporter == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
var e = new AnalyticEvent
|
|
|
{
|
|
|
EventType = name,
|
|
@@ -55,8 +62,6 @@ public static class Analytics
|
|
|
Data = data
|
|
|
};
|
|
|
|
|
|
- var reporter = AnalyticsPeriodicReporter.Instance;
|
|
|
-
|
|
|
reporter.AddEvent(e);
|
|
|
|
|
|
return e;
|