Skip to content

Commit

Permalink
Merge pull request #13 from unoplatform/dev/jela/async-flush
Browse files Browse the repository at this point in the history
feat: Add async flush method
  • Loading branch information
jeromelaban authored Dec 19, 2024
2 parents 9b3eb77 + b8b19cd commit 98a6070
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Uno.DevTools.Telemetry/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ public void Flush()
}
}

public async Task FlushAsync(CancellationToken ct)
{
if (!Enabled || _trackEventTask == null)
{
return;
}

if (!_trackEventTask.IsCompleted)
{
await Task.WhenAny(_trackEventTask, Task.Delay(-1, ct));
}
}

public void Dispose()
{
_persistenceChannel?.Dispose();
Expand Down Expand Up @@ -162,7 +175,11 @@ private void InitializeTelemetry()
_commonProperties = new TelemetryCommonProperties(_settingsStorageDirectoryPath, _versionAssembly, _currentDirectoryProvider).GetTelemetryCommonProperties();
_commonMeasurements = new Dictionary<string, double>();

_telemetryConfig = new TelemetryConfiguration { InstrumentationKey = _instrumentationKey };
_telemetryConfig = new TelemetryConfiguration {
InstrumentationKey = _instrumentationKey,
TelemetryChannel = _persistenceChannel
};

_client = new TelemetryClient(_telemetryConfig);
_client.InstrumentationKey = _instrumentationKey;
_client.Context.User.Id = _commonProperties[TelemetryCommonProperties.MachineId];
Expand Down

0 comments on commit 98a6070

Please sign in to comment.