Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.19.1 disable network traffic #14393

Merged
merged 8 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/DynamoApplications/StartupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,20 +398,21 @@ private static DynamoModel StartDynamoWithDefaultConfig(bool CLImode,
HostAnalyticsInfo info = new HostAnalyticsInfo(),
bool isServiceMode = false)
{

var config = new DynamoModel.DefaultStartConfiguration
{
GeometryFactoryPath = geometryFactoryPath,
ProcessMode = CLImode ? TaskProcessMode.Synchronous : TaskProcessMode.Asynchronous,
HostAnalyticsInfo = info,
CLIMode = CLImode,
AuthProvider = CLImode ? null : new Core.IDSDKManager(),
//TODO we currently use this like a no network comms flags - work on introducing a new flag or renaming this flag.
AuthProvider = CLImode || Dynamo.Logging.Analytics.DisableAnalytics ? null : new Core.IDSDKManager(),
UpdateManager = CLImode ? null : OSHelper.IsWindows() ? InitializeUpdateManager() : null,
StartInTestMode = CLImode,
PathResolver = CreatePathResolver(CLImode, preloaderLocation, userDataFolder, commonDataFolder),
IsServiceMode = isServiceMode,
Preferences = PreferenceSettings.Instance
};

var model = DynamoModel.Start(config);
return model;
}
Expand Down
6 changes: 6 additions & 0 deletions src/DynamoCore/Logging/AnalyticsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ internal static bool IsADPOptedIn

internal static bool IsADPAvailable()
{
if (Analytics.DisableAnalytics ||
adpAnalyticsUI == null)
{
return false;
}

return adpAnalyticsUI.IsProviderAvailable();
}

Expand Down
30 changes: 0 additions & 30 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,6 @@ protected DynamoModel(IStartConfiguration config)
}
catch (Exception e) { Logger.LogError($"could not start feature flags manager {e}"); };
});

//TODO just a test of feature flag event, safe to remove at any time.
DynamoUtilities.DynamoFeatureFlagsManager.FlagsRetrieved += CheckFeatureFlagTest;

}

// TBD: Do we need settings migrator for service mode? If we config the docker correctly, this could be skipped I think
Expand Down Expand Up @@ -1107,31 +1103,6 @@ private IPreferences CreateOrLoadPreferences(IPreferences preferences)
return new PreferenceSettings();
}

private void CheckFeatureFlagTest()
{
if (!DynamoModel.IsTestMode)
{
if (DynamoModel.FeatureFlags.CheckFeatureFlag<bool>("EasterEggIcon1", false))
{
this.Logger.Log("EasterEggIcon1 is true FROM MODEL");

}
else
{
this.Logger.Log("EasterEggIcon1 is false FROM MODEL");
}

if (DynamoModel.FeatureFlags.CheckFeatureFlag<string>("EasterEggMessage1", "NA") is var s && s != "NA")
{
this.Logger.Log("EasterEggMessage1 is enabled FROM MODEL");
}
else
{
this.Logger.Log("EasterEggMessage1 is disabled FROM MODEL");
}
}
}

private void SetDefaultPythonTemplate()
{
// First check if the default python template is overridden by a PythonTemplate.py file in AppData
Expand Down Expand Up @@ -1475,7 +1446,6 @@ public void Dispose()
{
FeatureFlags.MessageLogged -= LogMessageWrapper;
}
DynamoUtilities.DynamoFeatureFlagsManager.FlagsRetrieved -= CheckFeatureFlagTest;
}

private void InitializeCustomNodeManager()
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCore/Scheduler/UpdateRenderPackageAsyncTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private void GetTessellationDataFromGraphicItem(Guid outputPortId, IGraphicItem
var previousMeshVertexCount = package.MeshVertexCount;

//Todo Plane tessellation needs to be handled here vs in LibG currently
bool instancingEnabled = DynamoModel.FeatureFlags.CheckFeatureFlag<bool>("graphics-primitive-instancing", false);
bool instancingEnabled = DynamoModel.FeatureFlags?.CheckFeatureFlag<bool>("graphics-primitive-instancing", false) ?? false;
if (graphicItem is Plane plane)
{
CreatePlaneTessellation(package, plane);
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ public bool NodeAutocompleteMachineLearningIsBeta
{
get
{
return DynamoModel.FeatureFlags.CheckFeatureFlag("NodeAutocompleteMachineLearningIsBeta", false);
return DynamoModel.FeatureFlags?.CheckFeatureFlag("NodeAutocompleteMachineLearningIsBeta", false) ?? false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ internal virtual void AggregateRenderPackages(IEnumerable<HelixRenderPackage> pa
//If we have any line geometry that was not associated with an instance,
//remove the previously added line data from the render package so the remaining lines can be added to the scene.
if (rp.LineVertexRangesAssociatedWithInstancing.Any()
&& DynamoModel.FeatureFlags.CheckFeatureFlag<bool>("graphics-primitive-instancing", false))
&& DynamoModel.FeatureFlags?.CheckFeatureFlag<bool>("graphics-primitive-instancing", false) == true)
{
//For each range of line vertices add the line data and instances to the scene
var j = 0;
Expand Down Expand Up @@ -1946,7 +1946,7 @@ internal virtual void AggregateRenderPackages(IEnumerable<HelixRenderPackage> pa
//If we have any mesh geometry that was not associated with an instance, remove the previously added
//mesh data from the render package so the remaining mesh can be added to the scene.
if (rp.MeshVertexRangesAssociatedWithInstancing.Any()
&& DynamoModel.FeatureFlags.CheckFeatureFlag<bool>("graphics-primitive-instancing", false))
&& DynamoModel.FeatureFlags?.CheckFeatureFlag<bool>("graphics-primitive-instancing", false) == true)
{
//For each range of mesh vertices add the mesh data and instances to the scene
var j = 0;
Expand Down
45 changes: 0 additions & 45 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,19 +1307,6 @@ private void DynamoView_Loaded(object sender, EventArgs e)
this.Deactivated += (s, args) => { HidePopupWhenWindowDeactivated(null); };
}
loaded = true;


//The following code illustrates use of FeatureFlagsManager.
//safe to remove.
if (DynamoModel.FeatureFlags != null)
{
CheckTestFlags();
}
//if feature flags is not yet initialized, subscribe to the event and wait.
else
{
DynamoUtilities.DynamoFeatureFlagsManager.FlagsRetrieved += CheckTestFlags;
}
}

private void GuideFlowEvents_GuidedTourStart(GuidedTourStateEventArgs args)
Expand All @@ -1333,42 +1320,12 @@ private void GuideFlowEvents_GuidedTourStart(GuidedTourStateEventArgs args)
/// <summary>
/// Close Popup when the Dynamo window is not in the foreground.
/// </summary>

private void HidePopupWhenWindowDeactivated(object obj)
{
var workspace = this.ChildOfType<WorkspaceView>();
if (workspace != null)
workspace.HideAllPopUp(obj);
}
/// <summary>
/// check some test flags from launch darkly.
/// code is safe to remove at any time.
/// </summary>
private void CheckTestFlags()
{
if (!DynamoModel.IsTestMode)
{
//feature flag test.
if (DynamoModel.FeatureFlags?.CheckFeatureFlag<bool>("EasterEggIcon1", false) == true)
{
dynamoViewModel.Model.Logger.Log("EasterEggIcon1 is true from view");
}
else
{
dynamoViewModel.Model.Logger.Log("EasterEggIcon1 is false from view");
}

if (DynamoModel.FeatureFlags?.CheckFeatureFlag<string>("EasterEggMessage1", "NA") is string ffs && ffs != "NA")
{
dynamoViewModel.Model.Logger.Log("EasterEggMessage1 is enabled from view");
MessageBoxService.Show(this, ffs, "EasterEggMessage1", MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
else
{
dynamoViewModel.Model.Logger.Log("EasterEggMessage1 is disabled from view");
}
}
}

private void TrackStartupAnalytics()
{
Expand Down Expand Up @@ -1968,8 +1925,6 @@ private void WindowClosed(object sender, EventArgs e)
this.dynamoViewModel.RequestReturnFocusToView -= OnRequestReturnFocusToView;
this.dynamoViewModel.Model.WorkspaceSaving -= OnWorkspaceSaving;
this.dynamoViewModel.Model.WorkspaceOpened -= OnWorkspaceOpened;
DynamoUtilities.DynamoFeatureFlagsManager.FlagsRetrieved -= CheckTestFlags;

this.dynamoViewModel.RequestEnableShortcutBarItems -= DynamoViewModel_RequestEnableShortcutBarItems;
this.dynamoViewModel.RequestExportWorkSpaceAsImage -= OnRequestExportWorkSpaceAsImage;

Expand Down
13 changes: 10 additions & 3 deletions src/DynamoPackages/PackageManagerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,16 @@ internal bool CheckIfPackagesTargetOtherHosts(IEnumerable<PackageVersion> newPac
{
// determine if any of the packages are targeting other hosts
var containsPackagesThatTargetOtherHosts = false;

// Known hosts
var knownHosts = PackageManagerClient.GetKnownHosts();
//fallback list of hosts as of 9/8/23
IEnumerable<string> knownHosts = new List<string> { "Revit", "Civil 3D", "Alias", "Advance Steel", "FormIt" };
//if analytics is disabled, treat this as network black out
//and don't ask dpm for known hosts.
//TODO we currently use this like a no network comms flags - work on introducing a new flag or renaming this flag.
if (!Dynamo.Logging.Analytics.DisableAnalytics)
{
// Known hosts
knownHosts = PackageManagerClient.GetKnownHosts();
}

// Sandbox, special case: Warn if any package targets only one known host
if (String.IsNullOrEmpty(Host))
Expand Down
1 change: 0 additions & 1 deletion src/DynamoPackagesWPF/PackageManagerViewExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ private void RaisePackageHostNotifications(IEnumerable<Package> packages)
Resources.TitlePackageTargetOtherHost));
}
}

}

private void RequestLoadLayoutSpecs(IEnumerable<Package> packages)
Expand Down
3 changes: 2 additions & 1 deletion src/NodeServices/Analytics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace Dynamo.Logging
{
Expand All @@ -7,6 +7,7 @@ namespace Dynamo.Logging
/// </summary>
public static class Analytics
{
//TODO we currently use this like a no network comms flags - work on introducing a new flag or renaming this flag.
/// <summary>
/// Disables all analytics collection for the lifetime of the process.
/// To ensure that no analytics get through, please set set this flag to false before the DynamoModel is constructed.
Expand Down
5 changes: 3 additions & 2 deletions src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ internal NotificationCenterController(DynamoView view, DynamoLogger dynLogger)
VerticalOffset = notificationPopupVerticalOffset
};
logger = dynLogger;

// If user turns on the feature, they will need to restart Dynamo to see the count
// This ensures no network traffic when Notification center feature is turned off
if (dynamoViewModel.PreferenceSettings.EnableNotificationCenter)
//TODO we currently use DisableAnalytics like a no network comms flags - work on introducing a new flag or renaming this flag.
if (dynamoViewModel.PreferenceSettings.EnableNotificationCenter && !Dynamo.Logging.Analytics.DisableAnalytics )
{
InitializeBrowserAsync();
RequestNotifications();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ void PackageManagerViewExtensionTests_NotificationLogged(NotificationMessage obj
count = count + 1;
}
}

[Test]
public void PackageManagerViewExtesion_SendsNotificationForPackagesThatTargetDifferentHost_AtLatePackageLoad()
{
Expand Down