Skip to content

WIP Start implementing feature flags for toy feature #12790

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

Closed
wants to merge 8 commits into from

Conversation

mjkkirschner
Copy link
Member

@mjkkirschner mjkkirschner commented Apr 8, 2022

Purpose

This PR onboards Dynamo onto launch darkly, it controls a popup at startup. The feature flag is enabled for debug builds, and disabled for production (release) builds.

PR does the following:

  • adds a new project DynamoFeatureFlags that references the newest launch darkly client side dot net sdk nuget package.
  • updates compiler unsafe to avoid conflict at build time ... latest changes revert this as LD is resolving the same version with Tibi's suggestion.
  • Starts the launch darkly client if - analytics is not disabled by the configuration file, or the DisableAnalytics flag - otherwise LD will start, so it's not controllable via any UI setting, only by commandline, config file etc.
  • We use the stable instrumentation id that is generated for analytics, if this cannot be created or loaded, we use a shared key. Shared key will also be used during testing etc.
  • All users are logged as anonymous, which means that we cannot see them on the LD dashboard, but we can do targeted role outs / AB testing as long as the shared key is not used.
  • mobile sdk keys are embedded into the config file for the new project - according to LD docs, this is safe with no risk, these keys are not full sdk keys, they're more like a url for our dev/prod environments.
  • To avoid a slow startup the LD client is started async, so you can't immediately check feature flags unless you want to block - I have not implemented that, but it should be possible to add to the CheckFeatureFlag<T> method.

New Binaries:

  • LaunchDarkly.ClientSdk.dll - manual netstandard2.0
  • LaunchDarkly.CommonSdk.dll - manual netstandard2.0
  • LaunchDarkly.EventSource.dll - manual netstandard2.0
  • LaunchDarkly.InternalSdk.dll - manual netstandard2.0
  • LaunchDarkly.JsonStream.dll - manual netstandard2.0
  • LaunchDarkly.Logging.dll - manual netstandard2.0
  • Microsoft.Bcl.AsyncInterfaces.dll
  • System.Buffers.dll - automatic net461
  • System.Memory.dll - automatic net461
  • System.Numerics.Vectors.dll - automatic net461
  • System.Runtime.CompilerServices.Unsafe.dll - automatic net461
  • System.Text.Encodings.Web.dll
  • System.Text.Json.dll
  • System.Threading.Tasks.Extensions.dll
  • System.ValueTuple.dll

package refs for the DynamoFeatureFlags Project:

'DynamoFeatureFlags' has the following package references
   [netstandard2.0]: 
   Top-level Package                Requested   Resolved
   > LaunchDarkly.ClientSdk         2.0.1       2.0.1   
   > NETStandard.Library      (A)   [2.0.3, )   2.0.3   

   Transitive Package                            Resolved
   > LaunchDarkly.CommonSdk                      5.5.0   
   > LaunchDarkly.EventSource                    4.1.3   
   > LaunchDarkly.InternalSdk                    2.3.2   
   > LaunchDarkly.JsonStream                     1.0.3   
   > LaunchDarkly.Logging                        1.0.1   
   > Microsoft.NETCore.Platforms                 1.1.0   
   > System.Buffers                              4.5.1   
   > System.Collections.Immutable                1.7.1   
   > System.Memory                               4.5.4   
   > System.Numerics.Vectors                     4.5.0   
   > System.Runtime.CompilerServices.Unsafe      4.5.3   

Screen Shot 2022-04-12 at 7 10 09 PM

TODO:

  • tests
  • in a host like Revit where Dynamo is stopped and restarted, need to test if disposal/restarting of the LD client is smooth.
  • if LD deps are missing, ensure that DynamoCore still starts fine.
  • satisfied with new binaries this PR pulls in.
  • compiler.unsafe version alignment?
  • reference to system.configuration.dll in new csproj looks very wrong. (hint path)
  • if the user is logged in, we might want to add more attributes like email - so we can target specific emails for some features - we should add the private attribute flag if so to avoid storing any PII in LD.

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Release Notes

Add initial feature flags controls in Dynamo.

Reviewers

(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)

(FILL ME IN, optional) Any additional notes to reviewers or testers.

FYIs

(FILL ME IN, Optional) Names of anyone else you wish to be notified of

instantiate feature flags manager in core
test message box in view
add feature flags man project with config file
update compiler unsafe to v 5
wrap startup in try catch
unsub logger handler
add prod key
use shared key
add try catch and logging around LD api methods
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LaunchDarkly.ClientSdk" Version="2.0.1" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we OK with bringing in a bunch of extra dependencies to the dynamo build ?
(I know we tried to avoid this in the past)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, do you think it's worth exploring wrapping up the launch darkly client in a separate process the same way we do for the markdown2htmlCLI tool? This would isolate the dependencies from DynamoCore / the host process.

Performance might be a bit worse, but flags shouldn't be getting evaluated very frequently anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my point of view, LD in a separate process would make sense only if extra dll dependencies are deal breaker.
Some of the extra dependencies will be brought in by the move to dotnet6 anyway.

I did also see a more lightweight REST API client https://www.nuget.org/packages/LaunchDarkly.Api/
Not sure if this would a better alternative ...The API does look more difficult to use ...

@mjkkirschner
Copy link
Member Author

mjkkirschner commented Apr 12, 2022 via email

object output = default(T);
switch (default(T))
{
case bool _:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we testing for type here? If so, can we also use typeof as in:

switch (typeof(T))
{
    case typeof(bool):
...
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2022-04-18 at 11 58 27 AM

also fails on dotnet 6 unfortunately, mixing generic and switch case is not a great idea I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants