Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit c72e618

Browse files
committed
Use constants for settings keys
1 parent 085c485 commit c72e618

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

src/GitHub.Api/ApplicationManagerBase.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected void Initialize()
3535
LocalSettings.Initialize();
3636
SystemSettings.Initialize();
3737

38-
Logging.TracingEnabled = UserSettings.Get("EnableTraceLogging", false);
38+
Logging.TracingEnabled = UserSettings.Get(Constants.TraceLoggingKey, false);
3939
ProcessManager = new ProcessManager(Environment, Platform.GitEnvironment, CancellationToken);
4040
Platform.Initialize(ProcessManager, TaskManager);
4141
GitClient = new GitClient(Environment, ProcessManager, Platform.CredentialManager, TaskManager);
@@ -134,7 +134,7 @@ private async Task SetupAndRestart(ProgressReport progress)
134134
private async Task<NPath> LookForGitInstallationPath()
135135
{
136136
NPath cachedGitInstallPath = null;
137-
var path = SystemSettings.Get("GitInstallPath");
137+
var path = SystemSettings.Get(Constants.GitInstallPathKey);
138138
if (!String.IsNullOrEmpty(path))
139139
cachedGitInstallPath = path.ToNPath();
140140

@@ -150,21 +150,22 @@ protected void SetupMetrics(string unityVersion, bool firstRun)
150150
{
151151
Logger.Trace("Setup metrics");
152152

153-
var usagePath = Environment.UserCachePath.Combine("usage.json");
153+
var usagePath = Environment.UserCachePath.Combine(Constants.UsageFile);
154154

155-
string id;
156-
if (!UserSettings.Exists("Id"))
155+
string id = null;
156+
if (UserSettings.Exists(Constants.GuidKey))
157157
{
158-
id = Guid.NewGuid().ToString();
159-
UserSettings.Set("Id", id);
158+
id = UserSettings.Get(Constants.GuidKey);
160159
}
161-
else
160+
161+
if (String.IsNullOrEmpty(id))
162162
{
163-
id = UserSettings.Get("Id");
163+
id = Guid.NewGuid().ToString();
164+
UserSettings.Set(Constants.GuidKey, id);
164165
}
165166

166167
UsageTracker = new UsageTracker(usagePath, id, unityVersion);
167-
UsageTracker.Enabled = UserSettings.Get("MetricsEnabled", true);
168+
UsageTracker.Enabled = UserSettings.Get(Constants.MetricsKey, true);
168169

169170
if (firstRun)
170171
{

src/GitHub.Api/Constants.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace GitHub.Unity
2+
{
3+
static class Constants
4+
{
5+
public const string GuidKey = "Guid";
6+
public const string MetricsKey = "MetricsEnabled";
7+
public const string UsageFile = "usage.json";
8+
public const string GitInstallPathKey = "GitInstallPath";
9+
public const string TraceLoggingKey = "EnableTraceLogging";
10+
}
11+
}

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
<Compile Include="Authentication\LoginManager.cs" />
103103
<Compile Include="Authentication\ILoginManager.cs" />
104104
<Compile Include="ApplicationManagerBase.cs" />
105+
<Compile Include="Constants.cs" />
105106
<Compile Include="DefaultEnvironment.cs" />
106107
<Compile Include="Extensions\EnvironmentExtensions.cs" />
107108
<Compile Include="Extensions\FileEventExtensions.cs" />

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ private void OnPrivacyGui()
668668
if (EditorGUI.EndChangeCheck())
669669
{
670670
EntryPoint.UsageTracker.Enabled = metricsEnabled;
671-
Manager.UserSettings.Set("MetricsEnabled", metricsEnabled);
671+
Manager.UserSettings.Set(Constants.MetricsKey, metricsEnabled);
672672

673673
GUI.FocusControl(null);
674674
}
@@ -691,7 +691,7 @@ private void OnLoggingSettingsGui()
691691
if (EditorGUI.EndChangeCheck())
692692
{
693693
Logging.TracingEnabled = traceLogging;
694-
Manager.UserSettings.Set("EnableTraceLogging", traceLogging);
694+
Manager.UserSettings.Set(Constants.TraceLoggingKey, traceLogging);
695695

696696
GUI.FocusControl(null);
697697
}

0 commit comments

Comments
 (0)