Skip to content

Commit bfa039f

Browse files
committed
Added error severity
1 parent 2faabba commit bfa039f

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

TinyInsights/ErrorSeverity.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace TinyInsights;
2+
3+
public enum ErrorSeverity
4+
{
5+
Default,
6+
Warning,
7+
Error
8+
}

TinyInsights/IInsights.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public interface IInsights
1212
Task TrackPageViewAsync(string viewName, Dictionary<string, string>? properties = null);
1313

1414
Task TrackEventAsync(string eventName, Dictionary<string, string>? properties = null);
15+
Task TrackErrorAsync(Exception ex, ErrorSeverity severity, Dictionary<string, string>? properties = null);
1516

1617
Task TrackDependencyAsync(string dependencyType, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, bool success, int resultCode = 0, Exception? exception = null);
1718

TinyInsights/Insights.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,21 @@ public IReadOnlyList<IInsightsProvider> GetProviders()
2323
}
2424

2525
public Task TrackErrorAsync(Exception ex, Dictionary<string, string>? properties = null)
26+
{
27+
return TrackErrorAsync(ex, ErrorSeverity.Default, properties);
28+
}
29+
30+
public Task TrackErrorAsync(Exception ex, ErrorSeverity severity, Dictionary<string, string>? properties = null)
2631
{
2732
var tasks = new List<Task>();
2833

34+
if (properties == null)
35+
{
36+
properties = new Dictionary<string, string>();
37+
}
38+
39+
properties.TryAdd(nameof(ErrorSeverity), severity.ToString());
40+
2941
foreach (var provider in insightsProviders.Where(x => x.IsTrackErrorsEnabled))
3042
{
3143
var task = provider.TrackErrorAsync(ex, properties);

0 commit comments

Comments
 (0)