This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,28 @@ public UsageTracker(
5555 this . repositoryHosts = repositoryHosts ;
5656 this . userSettings = userSettings ;
5757 this . client = ( IMetricsService ) serviceProvider . GetService ( typeof ( IMetricsService ) ) ;
58+
59+ userSettings . WhenAny ( x => x . CollectMetrics , x => x . Value )
60+ // If SendUsageData is true we'll subscribe to the Run()
61+ // observable (which is a timer) and thus kick off the
62+ // tracker. The Run method will produce on unit per tick
63+ // but we don't care about that at all so we'll ignore
64+ // that and instead send true or false down the chain
65+ // indicating that the tracker is running or not.
66+ . Select ( sendUsageData => sendUsageData
67+ ? Run ( )
68+ . IgnoreElements ( )
69+ . Select ( _ => true )
70+ . StartWith ( true )
71+ : Observable . Return ( false ) )
72+ . Switch ( )
73+ // The first value will be what initially kicks off the
74+ // tracker. The second value (if there is one) will signal
75+ // that the user has opted in or out of usage tracking.
76+ . Skip ( 1 )
77+ . Select ( sendUsageData => sendUsageData ? OptIn ( ) : OptOut ( ) )
78+ . Switch ( )
79+ . Subscribe ( ) ;
5880 }
5981
6082 IBlobCache LocalMachineCache => cache . Value . LocalMachine ;
You can’t perform that action at this time.
0 commit comments