Skip to content

Commit 27fcde7

Browse files
committed
UseDependencyTrackingModule
1 parent 10603d5 commit 27fcde7

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

TinyInsights.TestApp/MainPage.xaml.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ namespace TinyInsights.TestApp;
66
public partial class MainPage : ContentPage
77
{
88
private readonly IInsights insights;
9-
private readonly InsightsMessageHandler insightsMessageHandler;
109
private readonly ILogger logger;
1110

12-
public MainPage(IInsights insights, InsightsMessageHandler insightsMessageHandler, ILogger logger)
11+
public MainPage(IInsights insights, ILogger logger)
1312
{
1413
this.insights = insights;
15-
this.insightsMessageHandler = insightsMessageHandler;
1614
this.logger = logger;
1715
BindingContext = this;
1816
insights.OverrideAnonymousUserId("TestUser");
@@ -80,7 +78,7 @@ private async void ExceptionButton_OnClicked(object? sender, EventArgs e)
8078

8179
private async void TrackHttpButton_OnClicked(object? sender, EventArgs e)
8280
{
83-
var client = new HttpClient(insightsMessageHandler);
81+
var client = new HttpClient();
8482

8583
for (int i = 0; i < 10; i++)
8684
{

TinyInsights/ApplicationInsightsProvider.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.ApplicationInsights;
22
using Microsoft.ApplicationInsights.DataContracts;
3+
using Microsoft.ApplicationInsights.DependencyCollector;
34
using Microsoft.ApplicationInsights.Extensibility;
45
using Microsoft.Extensions.Logging;
56
using System.Diagnostics;
@@ -27,6 +28,7 @@ public class ApplicationInsightsProvider : IInsightsProvider, ILogger
2728
public bool IsTrackEventsEnabled { get; set; } = true;
2829
public bool IsTrackDependencyEnabled { get; set; } = true;
2930
public bool EnableConsoleLogging { get; set; }
31+
public bool UseDependencyTrackingModule { get; set; } = false;
3032

3133
private static ICrashHandler CreateDefaultCrashHandlerType() => new CrashToJsonFileStorageHandler();
3234

@@ -76,7 +78,7 @@ public ApplicationInsightsProvider(MauiWinUIApplication app, string? connectionS
7678
{
7779
ConnectionString = connectionString;
7880
provider = this;
79-
81+
8082
this.crashHandler = crashHandler ?? CreateDefaultCrashHandlerType();
8183

8284
app.UnhandledException += App_UnhandledException;
@@ -190,6 +192,13 @@ private static void OnDisappearing(object? sender, Page e)
190192
ConnectionString = ConnectionString
191193
};
192194

195+
196+
if (UseDependencyTrackingModule)
197+
{
198+
var dependencyModule = new DependencyTrackingTelemetryModule();
199+
dependencyModule.Initialize(configuration);
200+
}
201+
193202
client = new TelemetryClient(configuration);
194203

195204
client.Context.Device.OperatingSystem = DeviceInfo.Platform.ToString();

TinyInsights/TinyInsights.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
30+
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.23.0" />
31+
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.23.0" />
3132
</ItemGroup>
3233

3334
<ItemGroup Condition=" $(TargetFramework.StartsWith('net8')) ">

0 commit comments

Comments
 (0)