Skip to content

Commit

Permalink
remove workspace events handling
Browse files Browse the repository at this point in the history
  • Loading branch information
zavub committed Nov 21, 2023
1 parent 0d6e0ff commit f01e409
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
21 changes: 5 additions & 16 deletions src/DynamoCore/Logging/AnalyticsService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Dynamo.Graph.Workspaces;
using Dynamo.Models;
using Autodesk.Analytics.ADP;
using Autodesk.Analytics.Core;
Expand All @@ -24,27 +23,14 @@ internal class AnalyticsService
/// Starts the Analytics client. This method initializes
/// the Analytics service and application life cycle start is tracked.
/// </summary>
internal static void Start(DynamoModel model)
internal static void Start()
{
// Initialize the concrete class only when we initialize the Service.
// This will also load the Analytics.Net.ADP assembly
// We must initialize the ADPAnalyticsUI instance before the Analytics.Start call.
adpAnalyticsUI = new ADPAnalyticsUI();

Analytics.Start(new DynamoAnalyticsClient(DynamoModel.HostAnalyticsInfo));

if(model != null)
{
model.WorkspaceAdded += OnWorkspaceAdded;
}
}

static void OnWorkspaceAdded(WorkspaceModel obj)
{
if (obj is CustomNodeWorkspaceModel)
Analytics.TrackScreenView("CustomWorkspace");
else
Analytics.TrackScreenView("Workspace");
}

/// <summary>
Expand Down Expand Up @@ -92,7 +78,10 @@ internal static bool IsADPAvailable()
/// </summary>
internal static void ShutDown()
{
Analytics.ShutDown();
if (!KeepAlive)
{
Analytics.ShutDown();
}
}

/// <summary>
Expand Down
9 changes: 3 additions & 6 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,7 @@ public void ShutDown(bool shutdownHost)
ShutDownCore(shutdownHost);
PostShutdownCore(shutdownHost);

if (!AnalyticsService.KeepAlive)
{
AnalyticsService.ShutDown();
}
AnalyticsService.ShutDown();

State = DynamoModelState.NotStarted;
OnShutdownCompleted(); // Notify possible event handlers.
Expand Down Expand Up @@ -1042,13 +1039,13 @@ private void HandleAnalytics()
// So we don't want to start it when splash screen or dynamo window is launched again.
if (Analytics.client == null)
{
AnalyticsService.Start(this);
AnalyticsService.Start();
}
else if (Analytics.client is DynamoAnalyticsClient dac)
{
if (dac.Session == null)
{
AnalyticsService.Start(this);
AnalyticsService.Start();
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/DynamoCore/Models/DynamoModelEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using Dynamo.Graph;
using Dynamo.Extensions;
using Dynamo.Logging;

namespace Dynamo.Models
{
Expand Down Expand Up @@ -158,6 +159,11 @@ protected virtual void OnWorkspaceAdded(WorkspaceModel obj)
var handler = WorkspaceAdded;
if (handler != null) handler(obj);

if (obj is CustomNodeWorkspaceModel)
Analytics.TrackScreenView("CustomWorkspace");
else
Analytics.TrackScreenView("Workspace");

WorkspaceEvents.OnWorkspaceAdded(obj.Guid, obj.Name, obj.GetType());
}

Expand Down

0 comments on commit f01e409

Please sign in to comment.