Skip to content

Commit 98a6070

Browse files
authored
Merge pull request #13 from unoplatform/dev/jela/async-flush
feat: Add async flush method
2 parents 9b3eb77 + b8b19cd commit 98a6070

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Uno.DevTools.Telemetry/Telemetry.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ public void Flush()
123123
}
124124
}
125125

126+
public async Task FlushAsync(CancellationToken ct)
127+
{
128+
if (!Enabled || _trackEventTask == null)
129+
{
130+
return;
131+
}
132+
133+
if (!_trackEventTask.IsCompleted)
134+
{
135+
await Task.WhenAny(_trackEventTask, Task.Delay(-1, ct));
136+
}
137+
}
138+
126139
public void Dispose()
127140
{
128141
_persistenceChannel?.Dispose();
@@ -162,7 +175,11 @@ private void InitializeTelemetry()
162175
_commonProperties = new TelemetryCommonProperties(_settingsStorageDirectoryPath, _versionAssembly, _currentDirectoryProvider).GetTelemetryCommonProperties();
163176
_commonMeasurements = new Dictionary<string, double>();
164177

165-
_telemetryConfig = new TelemetryConfiguration { InstrumentationKey = _instrumentationKey };
178+
_telemetryConfig = new TelemetryConfiguration {
179+
InstrumentationKey = _instrumentationKey,
180+
TelemetryChannel = _persistenceChannel
181+
};
182+
166183
_client = new TelemetryClient(_telemetryConfig);
167184
_client.InstrumentationKey = _instrumentationKey;
168185
_client.Context.User.Id = _commonProperties[TelemetryCommonProperties.MachineId];

0 commit comments

Comments
 (0)