diff --git a/src/Libraries/DSCPython/CPythonEvaluator.cs b/src/Libraries/DSCPython/CPythonEvaluator.cs
index 353e6a698f0..c997a066958 100644
--- a/src/Libraries/DSCPython/CPythonEvaluator.cs
+++ b/src/Libraries/DSCPython/CPythonEvaluator.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
using System.Reflection;
using Autodesk.DesignScript.Runtime;
@@ -262,7 +261,7 @@ private static void InstallPython()
}
///
- /// Creates and initializaes the global Python scope.
+ /// Creates and initializes the global Python scope.
///
private static PyScope CreateGlobalScope()
{
@@ -553,6 +552,10 @@ private static void OnEvaluationBegin(PyScope scope,
if (EvaluationBegin != null)
{
EvaluationBegin(EvaluationState.Begin, scope, code, bindingValues);
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Start,
+ Dynamo.Logging.Categories.PythonOperations,
+ "CPythonEvaluation");
}
}
@@ -572,6 +575,10 @@ private static void OnEvaluationEnd(bool isSuccessful,
{
EvaluationEnd(isSuccessful ? EvaluationState.Success : EvaluationState.Failed,
scope, code, bindingValues);
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.End,
+ Dynamo.Logging.Categories.PythonOperations,
+ "CPythonEvaluation");
}
}
diff --git a/src/Libraries/DSIronPython/IronPythonEvaluator.cs b/src/Libraries/DSIronPython/IronPythonEvaluator.cs
index 45ca2f1886b..b4567a4b908 100644
--- a/src/Libraries/DSIronPython/IronPythonEvaluator.cs
+++ b/src/Libraries/DSIronPython/IronPythonEvaluator.cs
@@ -294,6 +294,10 @@ private static void OnEvaluationBegin( ScriptEngine engine,
if (EvaluationBegin != null)
{
EvaluationBegin(EvaluationState.Begin, engine, scope, code, bindingValues);
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.End,
+ Dynamo.Logging.Categories.PythonOperations,
+ "IronPythonEvaluation");
}
}
@@ -315,6 +319,10 @@ private static void OnEvaluationEnd( bool isSuccessful,
{
EvaluationEnd( isSuccessful ? EvaluationState.Success : EvaluationState.Failed,
engine, scope, code, bindingValues);
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.End,
+ Dynamo.Logging.Categories.PythonOperations,
+ "IronPythonEvaluation");
}
}
diff --git a/src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml.cs b/src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml.cs
index 84a8c7cc278..8b0bd30dde7 100644
--- a/src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml.cs
+++ b/src/Libraries/PythonNodeModelsWpf/ScriptEditorWindow.xaml.cs
@@ -160,6 +160,9 @@ private void OnSaveClicked(object sender, RoutedEventArgs e)
originalScript = editText.Text;
nodeModel.Engine = CachedEngine;
UpdateScript(editText.Text);
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Save,
+ Dynamo.Logging.Categories.PythonOperations);
}
private void OnRevertClicked(object sender, RoutedEventArgs e)
@@ -191,6 +194,9 @@ private void OnRunClicked(object sender, RoutedEventArgs e)
{
dynamoViewModel.HomeSpace.Run();
}
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Run,
+ Dynamo.Logging.Categories.PythonOperations);
}
private void OnMigrationAssistantClicked(object sender, RoutedEventArgs e)
@@ -199,6 +205,9 @@ private void OnMigrationAssistantClicked(object sender, RoutedEventArgs e)
throw new NullReferenceException(nameof(nodeModel));
UpdateScript(editText.Text);
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Migration,
+ Dynamo.Logging.Categories.PythonOperations);
nodeModel.RequestCodeMigration(e);
}
@@ -209,7 +218,15 @@ private void OnMoreInfoClicked(object sender, RoutedEventArgs e)
private void OnEngineChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
- if (CachedEngine != nodeModel.Engine || originalScript != editText.Text) { nodeWasModified = true; }
+ if (CachedEngine != nodeModel.Engine)
+ {
+ nodeWasModified = true;
+ // Cover what switch did user make. Only track when the new engine option is different with the previous one.
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Switch,
+ Dynamo.Logging.Categories.PythonOperations,
+ CachedEngine.ToString());
+ }
editText.Options.ConvertTabsToSpaces = CachedEngine != PythonEngineVersion.IronPython2;
}
@@ -217,6 +234,9 @@ private void OnScriptEditorWindowClosed(object sender, EventArgs e)
{
nodeModel.CodeMigrated -= OnNodeModelCodeMigrated;
this.Closed -= OnScriptEditorWindowClosed;
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Close,
+ Dynamo.Logging.Categories.PythonOperations);
}
#endregion
diff --git a/src/NodeServices/IAnalyticsClient.cs b/src/NodeServices/IAnalyticsClient.cs
index 20ee8dffb4c..24a259b92ac 100644
--- a/src/NodeServices/IAnalyticsClient.cs
+++ b/src/NodeServices/IAnalyticsClient.cs
@@ -65,7 +65,12 @@ public enum Categories
///
/// Events Category related to In-Canvas search
///
- InCanvasSearchOperations
+ InCanvasSearchOperations,
+
+ ///
+ /// Events Category related to Python operations
+ ///
+ PythonOperations,
}
///
@@ -109,7 +114,7 @@ public enum Actions
Open,
///
- /// Close Event, such as Close workspace
+ /// Close Event, such as Close workspace, Close Python Editor
///
Close,
@@ -124,7 +129,7 @@ public enum Actions
Write,
///
- /// Save Event, such as Save workspace
+ /// Save Event, such as Save workspace and save Python code
///
Save,
@@ -162,11 +167,26 @@ public enum Actions
/// Update Installed event
///
Installed,
-
+
///
/// Select event, such as node auto-complete suggestion selection or in-canvas search selection
///
Select,
+
+ ///
+ /// Migration event, such as Python migration or DYN migration
+ ///
+ Migration,
+
+ ///
+ /// Switch event, such as Python engine switch, dropdown node switch
+ ///
+ Switch,
+
+ ///
+ /// Run event, such as Python node run clicked, Graph run Clicked
+ ///
+ Run,
}
///
diff --git a/src/PythonMigrationViewExtension/Controls/BaseDiffViewer.xaml.cs b/src/PythonMigrationViewExtension/Controls/BaseDiffViewer.xaml.cs
index 0b064bd608b..d0d342f6f69 100644
--- a/src/PythonMigrationViewExtension/Controls/BaseDiffViewer.xaml.cs
+++ b/src/PythonMigrationViewExtension/Controls/BaseDiffViewer.xaml.cs
@@ -1,4 +1,6 @@
-using Dynamo.PythonMigration.MigrationAssistant;
+using Dynamo.Logging;
+using Dynamo.PythonMigration.MigrationAssistant;
+using System;
using System.Windows;
namespace Dynamo.PythonMigration.Controls
@@ -52,11 +54,22 @@ private void OnAcceptButtonClicked(object sender, RoutedEventArgs e)
{
ViewModel.ChangeCode();
this.Close();
+ // Record if changes are accepted and if there are proposed changes
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Migration,
+ Dynamo.Logging.Categories.PythonOperations,
+ "Accept",
+ Convert.ToInt32(ViewModel.CurrentViewModel.HasChanges));
}
private void OnRejectButtonClicked(object sender, RoutedEventArgs e)
{
this.Close();
+ Analytics.TrackEvent(
+ Dynamo.Logging.Actions.Migration,
+ Dynamo.Logging.Categories.PythonOperations,
+ "Reject",
+ Convert.ToInt32(ViewModel.CurrentViewModel.HasChanges));
}
}
}
diff --git a/src/PythonMigrationViewExtension/Differ/IDiffViewViewModel.cs b/src/PythonMigrationViewExtension/Differ/IDiffViewViewModel.cs
index ee982f22207..0ff495362ab 100644
--- a/src/PythonMigrationViewExtension/Differ/IDiffViewViewModel.cs
+++ b/src/PythonMigrationViewExtension/Differ/IDiffViewViewModel.cs
@@ -11,6 +11,7 @@ public interface IDiffViewViewModel
{
ViewMode ViewMode { get; }
State DiffState { get; set; }
+ bool HasChanges { get; }
}
public enum ViewMode
diff --git a/src/PythonMigrationViewExtension/Differ/InLineViewModel.cs b/src/PythonMigrationViewExtension/Differ/InLineViewModel.cs
index 347041bc596..c9485a41c62 100644
--- a/src/PythonMigrationViewExtension/Differ/InLineViewModel.cs
+++ b/src/PythonMigrationViewExtension/Differ/InLineViewModel.cs
@@ -8,7 +8,7 @@ public class InLineViewModel : IDiffViewViewModel
{
public ViewMode ViewMode { get; set; }
public DiffPaneModel DiffModel { get; set; }
- private bool HasChanges { get { return DiffModel.HasDifferences; } }
+ public bool HasChanges { get { return DiffModel.HasDifferences; } }
private State diffState;
public State DiffState
diff --git a/src/PythonMigrationViewExtension/Differ/SideBySideViewModel.cs b/src/PythonMigrationViewExtension/Differ/SideBySideViewModel.cs
index 0a6b201151d..e4e463e68e0 100644
--- a/src/PythonMigrationViewExtension/Differ/SideBySideViewModel.cs
+++ b/src/PythonMigrationViewExtension/Differ/SideBySideViewModel.cs
@@ -8,7 +8,7 @@ public class SideBySideViewModel : IDiffViewViewModel
public SideBySideDiffModel DiffModel { get; set; }
public DiffPaneModel AfterPane { get { return DiffModel.NewText; } }
public DiffPaneModel BeforePane { get { return DiffModel.OldText; } }
- private bool HasChanges { get { return DiffModel.NewText.HasDifferences | DiffModel.OldText.HasDifferences; } }
+ public bool HasChanges { get { return DiffModel.NewText.HasDifferences | DiffModel.OldText.HasDifferences; } }
private State diffState;
public State DiffState
diff --git a/src/PythonMigrationViewExtension/PythonMigrationViewExtension.csproj b/src/PythonMigrationViewExtension/PythonMigrationViewExtension.csproj
index 0501ce2e838..4b1fdef4a09 100644
--- a/src/PythonMigrationViewExtension/PythonMigrationViewExtension.csproj
+++ b/src/PythonMigrationViewExtension/PythonMigrationViewExtension.csproj
@@ -144,6 +144,7 @@
{ef879a10-041d-4c68-83e7-3192685f1bae}
DynamoServices
+ False
diff --git a/test/DynamoCoreTests/Models/UndoRedoCommandTest.cs b/test/DynamoCoreTests/Models/UndoRedoCommandTest.cs
index ba53d2a4e53..2f0c0ddebc6 100644
--- a/test/DynamoCoreTests/Models/UndoRedoCommandTest.cs
+++ b/test/DynamoCoreTests/Models/UndoRedoCommandTest.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using NUnit.Framework;
+using NUnit.Framework;
using static Dynamo.Models.DynamoModel;
namespace Dynamo.Tests.ModelsTest