diff --git a/extern/Analytics.NET/AdpSDKCSharpWrapper.dll b/extern/Analytics.NET/AdpSDKCSharpWrapper.dll
index a1f6d85445c..6dbbbf75b1c 100644
Binary files a/extern/Analytics.NET/AdpSDKCSharpWrapper.dll and b/extern/Analytics.NET/AdpSDKCSharpWrapper.dll differ
diff --git a/extern/Analytics.NET/Analytics.Net.ADP.dll b/extern/Analytics.NET/Analytics.Net.ADP.dll
index 5f805ed0bcc..f4cd2700a7e 100644
Binary files a/extern/Analytics.NET/Analytics.Net.ADP.dll and b/extern/Analytics.NET/Analytics.Net.ADP.dll differ
diff --git a/src/DynamoCore/Logging/AnalyticsService.cs b/src/DynamoCore/Logging/AnalyticsService.cs
index 4f519f9be71..d5042b72440 100644
--- a/src/DynamoCore/Logging/AnalyticsService.cs
+++ b/src/DynamoCore/Logging/AnalyticsService.cs
@@ -10,15 +10,43 @@ namespace Dynamo.Logging
///
class AnalyticsService
{
- private static IAnalyticsUI adpAnalyticsUI = new ADPAnalyticsUI();
+ private static ADPAnalyticsUI adpAnalyticsUI = new ADPAnalyticsUI();
///
/// Starts the client when DynamoModel is created. This method initializes
/// the Analytics service and application life cycle start is tracked.
///
/// DynamoModel
- internal static void Start(DynamoModel model)
+ /// Pass true to disable ADP for the lifetime of the Dynamo or host process
+ /// Analytics won't be started if IsHeadless, but ADP may be loaded to be disabled.
+ /// Analytics won't be started if isTestMode, ADP will not be loaded.
+ internal static void Start(DynamoModel model, bool disableADP, bool isHeadless, bool isTestMode)
{
+ if (isTestMode)
+ {
+ if (disableADP)
+ {
+ model.Logger.Log("Incompatible configuration: [IsTestMode] and [ADP disabled] ");
+ }
+ return;
+ }
+ if (disableADP)
+ {
+ //if this returns false something has gone wrong.
+ //the client requested ADP be disabled, but we cannot disable it.
+ if (!adpAnalyticsUI.DisableADPForProcessLifetime())
+ {
+ model.Logger.LogNotification("Dynamo",
+ "Dynamo Startup Error",
+ "Analytics could not be disabled",
+ "Dynamo was started with configuration requesting ADP be disabled - but ADP could not be disabled.");
+ }
+ }
+
+ if (isHeadless)
+ {
+ return;
+ }
var client = new DynamoAnalyticsClient(model);
Analytics.Start(client);
model.WorkspaceAdded += OnWorkspaceAdded;
@@ -35,7 +63,7 @@ static void OnWorkspaceAdded(WorkspaceModel obj)
///
/// Indicates whether the user has opted-in to ADP analytics.
///
- internal static bool IsADPOptedIn
+ internal static bool IsADPOptedIn
{
get
{
diff --git a/src/DynamoCore/Models/DynamoModel.cs b/src/DynamoCore/Models/DynamoModel.cs
index e1c6dd4b1e7..a17ff264a23 100644
--- a/src/DynamoCore/Models/DynamoModel.cs
+++ b/src/DynamoCore/Models/DynamoModel.cs
@@ -451,7 +451,7 @@ public IEnumerable Workspaces
public AuthenticationManager AuthenticationManager { get; set; }
internal static string DefaultPythonEngine { get; private set; }
-
+ private bool disableADP;
#endregion
#region initialization and disposal
@@ -555,6 +555,10 @@ public struct DefaultStartConfiguration : IStartConfiguration
/// Default Python script engine
///
public string DefaultPythonEngine { get; set; }
+ ///
+ /// Disables ADP for the entire process for the lifetime of the process.
+ ///
+ public bool DisableADP { get; set; }
}
///
@@ -586,11 +590,13 @@ public static DynamoModel Start(IStartConfiguration configuration)
/// Start configuration
protected DynamoModel(IStartConfiguration config)
{
- if (config is DefaultStartConfiguration)
+ if (config is DefaultStartConfiguration defaultStartConfig)
{
// This is not exposed in IStartConfiguration to avoid a breaking change.
// TODO: This fact should probably be revisited in 3.0.
- DefaultPythonEngine = ((DefaultStartConfiguration)config).DefaultPythonEngine;
+ DefaultPythonEngine = defaultStartConfig.DefaultPythonEngine;
+ disableADP = defaultStartConfig.DisableADP;
+
}
ClipBoard = new ObservableCollection();
@@ -668,6 +674,15 @@ protected DynamoModel(IStartConfiguration config)
{
// Do nothing for now
}
+
+ // these configuration options are incompatible, one requires loading ADP binaries
+ // the other depends on not loading those same binaries.
+
+ if (areAnalyticsDisabledFromConfig && disableADP)
+ {
+ throw new ConfigurationErrorsException("Incompatible configuration: could not start Dynamo with both [Analytics disabled] and [ADP disabled] config options enabled");
+ }
+
// If user skipped analytics from assembly config, do not try to launch the analytics client
if (!areAnalyticsDisabledFromConfig)
{
@@ -1407,10 +1422,7 @@ private void LoadNodeModels(List nodes, bool isPackageMember)
private void InitializeAnalyticsService()
{
- if (!IsTestMode && !IsHeadless)
- {
- AnalyticsService.Start(this);
- }
+ AnalyticsService.Start(this,disableADP, IsHeadless, IsTestMode);
}
private IPreferences CreateOrLoadPreferences(IPreferences preferences)