mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-12-05 22:04:43 +00:00
Fix the TelemetryClient
Fix the TelemetryClient
This commit is contained in:
parent
2db2e7b91a
commit
3188317bf6
|
|
@ -47,16 +47,34 @@ namespace WelsonJS.Launcher
|
|||
);
|
||||
|
||||
// telemetry
|
||||
string telemetryProvider = GetAppConfig("TelemetryProvider");
|
||||
try
|
||||
{
|
||||
var telemetryProvider = GetAppConfig("TelemetryProvider");
|
||||
var telemetryOptions = new TelemetryOptions
|
||||
{
|
||||
ApiKey = GetAppConfig("TelemetryApiKey"),
|
||||
BaseUrl = GetAppConfig("TelemetryBaseUrl"),
|
||||
DistinctId = TelemetryIdentity.GetDistinctId(),
|
||||
Disabled = !string.Equals(GetAppConfig("TelemetryEnabled"), "true", StringComparison.OrdinalIgnoreCase)
|
||||
Disabled = !string.Equals(
|
||||
GetAppConfig("TelemetryEnabled"),
|
||||
"true",
|
||||
StringComparison.OrdinalIgnoreCase)
|
||||
};
|
||||
|
||||
if (!telemetryOptions.Disabled &&
|
||||
!string.IsNullOrWhiteSpace(telemetryProvider) &&
|
||||
!string.IsNullOrWhiteSpace(telemetryOptions.ApiKey) &&
|
||||
!string.IsNullOrWhiteSpace(telemetryOptions.BaseUrl))
|
||||
{
|
||||
_telemetryClient = new TelemetryClient(telemetryProvider, telemetryOptions, _logger);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error($"Telemetry initialization failed: {ex}");
|
||||
_telemetryClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
|
|
@ -84,7 +102,10 @@ namespace WelsonJS.Launcher
|
|||
}
|
||||
|
||||
// send event to the telemetry server
|
||||
_telemetryClient.TrackAppStartedAsync("WelsonJS.Launcher", "0.2.7.57");
|
||||
if (_telemetryClient != null)
|
||||
{
|
||||
_ = _telemetryClient.TrackAppStartedAsync("WelsonJS.Launcher", "0.2.7.57");
|
||||
}
|
||||
|
||||
// draw the main form
|
||||
Application.EnableVisualStyles();
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ namespace WelsonJS.Launcher.Telemetry
|
|||
|
||||
try
|
||||
{
|
||||
await _httpClient.PostAsync(
|
||||
using (var response = await _httpClient.PostAsync(
|
||||
url,
|
||||
new StringContent(json, Encoding.UTF8, "application/json"),
|
||||
cancellationToken
|
||||
);
|
||||
)) { /* disposed automatically */ }
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user