Skip to content

Commit

Permalink
DYN-6839 Dynamo Home Analytics (#15218)
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang authored May 16, 2024
1 parent 49a3f7c commit dfa5af6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
32 changes: 23 additions & 9 deletions src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ public HomePage()
InitializeComponent();
InitializeGuideTourItems();

dynWebView = new DynamoWebView2();
dynWebView = new DynamoWebView2
{
Margin = new System.Windows.Thickness(0), // Set margin to zero
ZoomFactor = 1.0 // Set zoom factor (optional)
};

dynWebView.Margin = new System.Windows.Thickness(0); // Set margin to zero
dynWebView.ZoomFactor = 1.0; // Set zoom factor (optional)

HostGrid.Children.Add(dynWebView);

// Bind event handlers
Expand All @@ -82,7 +83,7 @@ public HomePage()
RequestNewCustomNodeWorkspace = NewCustomNodeWorkspace;
RequestShowSampleFilesInFolder = ShowSampleFilesInFolder;
RequestShowBackupFilesInFolder = ShowBackupFilesInFolder;
RequestShowTemplate = ShowTemplate;
RequestShowTemplate = OpenTemplate;
RequestApplicationLoaded = ApplicationLoaded;
RequestSaveSettings = SaveSettings;

Expand Down Expand Up @@ -129,7 +130,7 @@ private void DynamoViewModel_PropertyChanged(object sender, System.ComponentMode
/// This is used before DynamoModel initialization specifically to get user data dir
/// </summary>
/// <returns></returns>
private string GetUserDirectory()
private static string GetUserDirectory()
{
var version = AssemblyHelper.GetDynamoVersion();

Expand Down Expand Up @@ -233,12 +234,14 @@ internal bool ProcessUri(string uri)
if (filePath.EndsWith(".dyn") || filePath.EndsWith(".dyf"))
{
OpenFile(filePath);
Logging.Analytics.TrackEvent(Logging.Actions.Open, Logging.Categories.DynamoHomeOperations, "Workspace");
return true;
}
}
else
{
Process.Start(new ProcessStartInfo(uri) { UseShellExecute = true });
Logging.Analytics.TrackEvent(Logging.Actions.Open, Logging.Categories.DynamoHomeOperations, "Hyper Link: "+ uri);
}

return false;
Expand Down Expand Up @@ -431,6 +434,8 @@ internal void StartGuidedTour(string path)
}

ShowGuidedTour(path);
Logging.Analytics.TrackEvent(Logging.Actions.Start, Logging.Categories.DynamoHomeOperations, "Guided Tour: " + path);

}

internal void SaveSettings(string settingsJson)
Expand Down Expand Up @@ -464,6 +469,7 @@ internal void SaveSettings(string settingsJson)
internal void NewWorkspace()
{
this.startPage?.DynamoViewModel?.NewHomeWorkspaceCommand.Execute(null);
Logging.Analytics.TrackEvent(Logging.Actions.New, Logging.Categories.DynamoHomeOperations, "Workspace");
}

internal void OpenWorkspace()
Expand All @@ -475,6 +481,7 @@ internal void OpenWorkspace()
}

this.startPage?.DynamoViewModel?.ShowOpenDialogAndOpenResultCommand.Execute(null);
Logging.Analytics.TrackEvent(Logging.Actions.Open, Logging.Categories.DynamoHomeOperations, "Workspace");
}

internal void NewCustomNodeWorkspace()
Expand All @@ -486,6 +493,7 @@ internal void NewCustomNodeWorkspace()
}

this.startPage?.DynamoViewModel?.ShowNewFunctionDialogCommand.Execute(null);
Logging.Analytics.TrackEvent(Logging.Actions.New, Logging.Categories.DynamoHomeOperations, "Custom Node Workspace");
}

internal void ShowSampleFilesInFolder()
Expand All @@ -500,6 +508,8 @@ internal void ShowSampleFilesInFolder()
Process.Start(new ProcessStartInfo("explorer.exe", "/select,"
+ this.startPage.SampleFolderPath)
{ UseShellExecute = true });
Logging.Analytics.TrackEvent(Logging.Actions.Show, Logging.Categories.DynamoHomeOperations, "Sample Files");

}

internal void ShowBackupFilesInFolder()
Expand All @@ -513,9 +523,10 @@ internal void ShowBackupFilesInFolder()

Process.Start(new ProcessStartInfo("explorer.exe", this.startPage.DynamoViewModel.Model.PathManager.BackupDirectory)
{ UseShellExecute = true });
Logging.Analytics.TrackEvent(Logging.Actions.Show, Logging.Categories.DynamoHomeOperations, "Backup Files");
}

internal void ShowTemplate()
internal void OpenTemplate()
{
if (DynamoModel.IsTestMode)
{
Expand All @@ -524,12 +535,15 @@ internal void ShowTemplate()
}

// Equivalent to CommandParameter="Template"
this.startPage?.DynamoViewModel?.ShowOpenTemplateDialogCommand.Execute("Template");
this.startPage?.DynamoViewModel?.ShowOpenTemplateDialogCommand.Execute("Template");
Logging.Analytics.TrackEvent(Logging.Actions.Open, Logging.Categories.DynamoHomeOperations, "Template");
}

internal void ApplicationLoaded()
{
LoadingDone();
LoadingDone();
Logging.Analytics.TrackEvent(Logging.Actions.Load, Logging.Categories.DynamoHomeOperations);

}

#endregion
Expand Down
10 changes: 9 additions & 1 deletion src/NodeServices/IAnalyticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ namespace Dynamo.Logging
/// </summary>
public enum Categories
{
/// XXXOperations usually means actions from Dynamo users
/// v.s. XXX usually means actions from the Dynamo component itself

/// <summary>
/// Events Category related to application lifecycle
/// </summary>
Expand Down Expand Up @@ -142,7 +145,12 @@ public enum Categories
/// <summary>
/// Events Category related to DynamoMLDataPipeline
/// </summary>
DynamoMLDataPipelineOperations
DynamoMLDataPipelineOperations,

/// <summary>
/// Events Category related to DynamoHome
/// </summary>
DynamoHomeOperations
}

/// <summary>
Expand Down

0 comments on commit dfa5af6

Please sign in to comment.