This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +36
-36
lines changed
UnityExtension/Assets/Editor/GitHub.Unity Expand file tree Collapse file tree 3 files changed +36
-36
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,32 @@ private async Task<NPath> LookForGitInstallationPath()
147
147
return await GitClient . FindGitInstallation ( ) . SafeAwait ( ) ;
148
148
}
149
149
150
+ protected void SetupMetrics ( string unityVersion , bool firstRun )
151
+ {
152
+ Logger . Trace ( "Setup metrics" ) ;
153
+
154
+ var usagePath = Environment . UserCachePath . Combine ( "usage.json" ) ;
155
+
156
+ string id ;
157
+ if ( ! UserSettings . Exists ( "Id" ) )
158
+ {
159
+ id = Guid . NewGuid ( ) . ToString ( ) ;
160
+ UserSettings . Set ( "Id" , id ) ;
161
+ }
162
+ else
163
+ {
164
+ id = UserSettings . Get ( "Id" ) ;
165
+ }
166
+
167
+ UsageTracker = new UsageTracker ( usagePath , id , unityVersion ) ;
168
+ UsageTracker . Enabled = UserSettings . Get ( "MetricsEnabled" , true ) ;
169
+
170
+ if ( firstRun )
171
+ {
172
+ UsageTracker . IncrementLaunchCount ( ) ;
173
+ }
174
+ }
175
+
150
176
private bool disposed = false ;
151
177
protected virtual void Dispose ( bool disposing )
152
178
{
Original file line number Diff line number Diff line change @@ -13,18 +13,19 @@ class UsageTracker : IUsageTracker
13
13
private static IMetricsService metricsService ;
14
14
15
15
private readonly NPath storePath ;
16
- private readonly string userTrackingId ;
16
+ private readonly string id ;
17
+ private readonly string unityVersion ;
17
18
18
19
private bool firstRun = true ;
19
20
private Timer timer ;
20
21
21
- public UsageTracker ( NPath storePath , string userTrackingId )
22
+ public UsageTracker ( NPath storePath , string id , string unityVersion )
22
23
{
23
- this . userTrackingId = userTrackingId ;
24
- Logger . Trace ( "Tracking Id:{0}" , userTrackingId ) ;
25
-
24
+ this . id = id ;
26
25
this . storePath = storePath ;
26
+ this . unityVersion = unityVersion ;
27
27
28
+ Logger . Trace ( "id:{0}" , id ) ;
28
29
RunTimer ( ) ;
29
30
}
30
31
Original file line number Diff line number Diff line change @@ -31,9 +31,6 @@ public override ITask Run()
31
31
Utility . Initialize ( ) ;
32
32
33
33
return base . Run ( )
34
- . Then ( _ => {
35
- SetupUserTracking ( ) ;
36
- } )
37
34
. ThenInUI ( _ =>
38
35
{
39
36
Logger . Debug ( "Run" ) ;
@@ -45,8 +42,10 @@ public override ITask Run()
45
42
if ( view != null )
46
43
view . Initialize ( this ) ;
47
44
48
- //logger.Debug("Application Restarted");
49
- } ) . Start ( ) ;
45
+ return new { Version = Application . unityVersion , FirstRun = ApplicationCache . Instance . FirstRun } ;
46
+ } )
47
+ . Then ( ( s , x ) => SetupMetrics ( x . Version , x . FirstRun ) )
48
+ . Start ( ) ;
50
49
}
51
50
52
51
@@ -142,32 +141,6 @@ protected override void Dispose(bool disposing)
142
141
}
143
142
}
144
143
145
- private void SetupUserTracking ( )
146
- {
147
- Logger . Trace ( "Setup User Tracking" ) ;
148
-
149
- var usagePath = Environment . UserCachePath . Combine ( "github-unity-usage.json" ) ;
150
-
151
- string userTrackingId ;
152
- if ( ! UserSettings . Exists ( "UserTrackingId" ) )
153
- {
154
- userTrackingId = Guid . NewGuid ( ) . ToString ( ) ;
155
- UserSettings . Set ( "UserTrackingId" , userTrackingId ) ;
156
- }
157
- else
158
- {
159
- userTrackingId = UserSettings . Get ( "UserTrackingId" ) ;
160
- }
161
-
162
- UsageTracker = new UsageTracker ( usagePath , userTrackingId ) ;
163
- UsageTracker . Enabled = UserSettings . Get ( "UserTrackingEnabled" , true ) ;
164
-
165
- if ( ApplicationCache . Instance . FirstRun )
166
- {
167
- UsageTracker . IncrementLaunchCount ( ) ;
168
- }
169
- }
170
-
171
144
public override IProcessEnvironment GitEnvironment { get { return Platform . GitEnvironment ; } }
172
145
}
173
146
}
You can’t perform that action at this time.
0 commit comments