Skip to content

Commit a66f987

Browse files
authored
Merge pull request #14 from unoplatform/dev/nr/interface
feat: Adding ITelemetry interface
2 parents 98a6070 + 97d3d89 commit a66f987

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
//
4+
// 2019/04/12 (Jerome Laban <[email protected]>):
5+
// - Extracted from dotnet.exe
6+
// 2024/12/05 (Jerome Laban <[email protected]>):
7+
// - Updated for nullability
8+
//
9+
10+
11+
namespace Uno.DevTools.Telemetry
12+
{
13+
public interface ITelemetry
14+
{
15+
bool Enabled { get; }
16+
17+
void Dispose();
18+
void Flush();
19+
Task FlushAsync(CancellationToken ct);
20+
void ThreadBlockingTrackEvent(string eventName, IDictionary<string, string> properties, IDictionary<string, double> measurements);
21+
void TrackEvent(string eventName, (string key, string value)[]? properties, (string key, double value)[]? measurements);
22+
void TrackEvent(string eventName, IDictionary<string, string>? properties, IDictionary<string, double>? measurements);
23+
}
24+
}

src/Uno.DevTools.Telemetry/Telemetry.cs

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,15 @@
77
// - Updated for nullability
88
//
99

10-
using System;
11-
using System.Collections.Generic;
12-
using System.Diagnostics;
13-
using System.IO;
14-
using System.Linq;
15-
using System.Reflection;
16-
using System.Threading.Tasks;
1710
using Microsoft.ApplicationInsights;
1811
using Microsoft.ApplicationInsights.Extensibility;
1912
using Microsoft.DotNet.PlatformAbstractions;
13+
using System.Diagnostics;
14+
using System.Reflection;
2015

2116
namespace Uno.DevTools.Telemetry
2217
{
23-
public class Telemetry
18+
public class Telemetry : ITelemetry
2419
{
2520
private string? _currentSessionId;
2621
private TelemetryClient? _client;
@@ -175,7 +170,8 @@ private void InitializeTelemetry()
175170
_commonProperties = new TelemetryCommonProperties(_settingsStorageDirectoryPath, _versionAssembly, _currentDirectoryProvider).GetTelemetryCommonProperties();
176171
_commonMeasurements = new Dictionary<string, double>();
177172

178-
_telemetryConfig = new TelemetryConfiguration {
173+
_telemetryConfig = new TelemetryConfiguration
174+
{
179175
InstrumentationKey = _instrumentationKey,
180176
TelemetryChannel = _persistenceChannel
181177
};

0 commit comments

Comments
 (0)