mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-12-06 06:14:22 +00:00
Fix the TelemetryClient
Fix the TelemetryClient
This commit is contained in:
parent
2db2e7b91a
commit
3188317bf6
|
|
@ -47,15 +47,33 @@ namespace WelsonJS.Launcher
|
||||||
);
|
);
|
||||||
|
|
||||||
// telemetry
|
// telemetry
|
||||||
string telemetryProvider = GetAppConfig("TelemetryProvider");
|
try
|
||||||
var telemetryOptions = new TelemetryOptions
|
|
||||||
{
|
{
|
||||||
ApiKey = GetAppConfig("TelemetryApiKey"),
|
var telemetryProvider = GetAppConfig("TelemetryProvider");
|
||||||
BaseUrl = GetAppConfig("TelemetryBaseUrl"),
|
var telemetryOptions = new TelemetryOptions
|
||||||
DistinctId = TelemetryIdentity.GetDistinctId(),
|
{
|
||||||
Disabled = !string.Equals(GetAppConfig("TelemetryEnabled"), "true", StringComparison.OrdinalIgnoreCase)
|
ApiKey = GetAppConfig("TelemetryApiKey"),
|
||||||
};
|
BaseUrl = GetAppConfig("TelemetryBaseUrl"),
|
||||||
_telemetryClient = new TelemetryClient(telemetryProvider, telemetryOptions, _logger);
|
DistinctId = TelemetryIdentity.GetDistinctId(),
|
||||||
|
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]
|
[STAThread]
|
||||||
|
|
@ -84,7 +102,10 @@ namespace WelsonJS.Launcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// send event to the telemetry server
|
// 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
|
// draw the main form
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
|
|
|
||||||
|
|
@ -66,11 +66,11 @@ namespace WelsonJS.Launcher.Telemetry
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _httpClient.PostAsync(
|
using (var response = await _httpClient.PostAsync(
|
||||||
url,
|
url,
|
||||||
new StringContent(json, Encoding.UTF8, "application/json"),
|
new StringContent(json, Encoding.UTF8, "application/json"),
|
||||||
cancellationToken
|
cancellationToken
|
||||||
);
|
)) { /* disposed automatically */ }
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user