Conversation
src/DesktopAnalytics/Analytics.cs
Outdated
| public static void FlushClient() | ||
| { | ||
| s_singleton.Client.Flush(); | ||
| s_singleton._client.Flush(); |
There was a problem hiding this comment.
🚩 FlushClient and Statistics don't guard against uninitialized client
FlushClient() (Analytics.cs:1079) and the Statistics property (Analytics.cs:1022) access _client without checking AllowTracking. For SegmentClient, Flush() calls _analytics.Flush() directly (SegmentClient.cs:67) — if Initialize was never called (tracking disabled), _analytics is null and this throws NullReferenceException. Statistics happens to be safe because it reads from the static StatMonitor. This is a pre-existing issue, but the new ability to toggle tracking makes it easier to encounter: a caller might reasonably call FlushClient() without realizing the client was never initialized.
Was this helpful? React with 👍 or 👎 to provide feedback.
tombogle
left a comment
There was a problem hiding this comment.
@tombogle resolved 1 discussion.
Reviewable status: 0 of 5 files reviewed, all discussions resolved (waiting on andrew-polk and nabalone).
andrew-polk
left a comment
There was a problem hiding this comment.
@andrew-polk reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on nabalone and tombogle).
src/DesktopAnalytics/Analytics.cs line 275 at r3 (raw file):
s_locationInfo = new JsonObject(); UpdateServerInformationOnThisUser(true);
This is more of a preference thing, but I think it is helpful to do UpdateServerInformationOnThisUser(initializing: true);
This change is