-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #549 from WildernessLabs/feature/analytics
Add telemetry support
- Loading branch information
Showing
21 changed files
with
762 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root = true | ||
|
||
[*.csproj] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using CliFx.Attributes; | ||
using CliFx.Extensibility; | ||
using Meadow.Telemetry; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Meadow.CLI.Commands.DeviceManagement; | ||
|
||
[Command("telemetry", Description = "Manage participation in telemetry sharing")] | ||
public class TelemetryCommand : BaseCommand<TelemetryCommand> | ||
{ | ||
public TelemetryCommand( | ||
ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
throw new CommandException("Specify one of the telemetry commands", true); | ||
} | ||
} | ||
|
||
[Command("telemetry enable", Description = "Enable and opt in to telemetry sharing")] | ||
public class TelemetryEnableCommand : BaseCommand<TelemetryCommand> | ||
{ | ||
private readonly ISettingsManager _settingsManager; | ||
|
||
public TelemetryEnableCommand( | ||
ISettingsManager settingsManager, | ||
ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
_settingsManager.SaveSetting(MeadowTelemetry.TelemetryEnabledSettingName, "true"); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} | ||
|
||
[Command("telemetry disable", Description = "Disable and opt out of telemetry sharing")] | ||
public class TelemetryDisableCommand : BaseCommand<TelemetryCommand> | ||
{ | ||
private readonly ISettingsManager _settingsManager; | ||
|
||
public TelemetryDisableCommand( | ||
ISettingsManager settingsManager, | ||
ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
_settingsManager.SaveSetting(MeadowTelemetry.TelemetryEnabledSettingName, "false"); | ||
_settingsManager.DeleteSetting(MeadowTelemetry.MachineIdSettingName); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.