chore (deps): Update Microsoft.ApplicationInsights to v3#1505
chore (deps): Update Microsoft.ApplicationInsights to v3#1505
Conversation
Co-authored-by: dpvreony <170983+dpvreony@users.noreply.github.com>
Co-authored-by: dpvreony <170983+dpvreony@users.noreply.github.com>
src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs
Outdated
Show resolved
Hide resolved
|
Might see if I can find out what the issue is with the intermittent results with the raygun tests there. |
…for AppInsights v3
ApplicationInsights v3 removed TrackPageView/PageViewTelemetry with no
official replacement. The prior commit used ActivitySource which introduced
fake HTTP semantics, silent null activities, zero-duration telemetry, and a
breaking constructor change from TelemetryClient to ActivitySource.
Replace with TelemetryClient.TrackEvent("PageView", {Name: viewName}) which:
- Preserves the existing TelemetryClient constructor (non-breaking)
- Stays consistent with how feature tracking already uses TelemetryClient
- Matches the AppCenter and Exceptionless view tracking patterns
- Records reliably without requiring ActivityListener configuration
Also adds XML documentation to all undocumented members in the
ApplicationInsights project.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1505 +/- ##
==========================================
- Coverage 79.58% 79.57% -0.01%
==========================================
Files 116 116
Lines 7170 7174 +4
Branches 1132 1133 +1
==========================================
+ Hits 5706 5709 +3
+ Misses 1159 1157 -2
- Partials 305 308 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Test that TrackEvent("PageView") is called without throwing for various
inputs: normal view names, multiple consecutive navigations, empty names,
and names with special characters.
AppInsights v3 has no ITelemetryClient interface, no ITelemetryChannel,
and TrackEvent does not emit interceptable OpenTelemetry Activities, so
behavioral verification of the SDK call is not feasible. Tests verify the
integration does not throw under expected usage patterns.
|
@dpvreony I'll wait for you to review the changes before proceeding. Sorry if I jumped in on your work. |
There was a problem hiding this comment.
Pull request overview
This PR upgrades the Splat Application Insights integration to Microsoft.ApplicationInsights v3 and adapts view tracking to account for the removal of TrackPageView / PageViewTelemetry, while updating tests to satisfy v3’s TelemetryConfiguration.ConnectionString requirement.
Changes:
- Bump
Microsoft.ApplicationInsightsfrom 2.23.0 → 3.0.0 via central package management. - Replace
TrackPageView(name)withTrackEvent("PageView", ...)inApplicationInsightsViewTrackingand remove thePageViewTelemetryoverload. - Update Application Insights test setup to include
TelemetryConfiguration.ConnectionString.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Directory.Packages.props | Updates Application Insights dependency to v3. |
| src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs | Migrates view tracking from pageView telemetry to custom event telemetry. |
| src/Splat.ApplicationInsights/ApplicationInsightsFeatureUsageTrackingSession.cs | Adds/expands XML documentation (no functional change). |
| src/tests/Splat.ApplicationInsights.Tests/ApplicationInsightsViewTrackingTests.cs | Adds v3-required ConnectionString and introduces OnViewNavigation tests. |
| src/tests/Splat.ApplicationInsights.Tests/ApplicationInsightsFeatureUsageTrackingSessionTests.cs | Adds v3-required ConnectionString in test setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Splat.ApplicationInsights/ApplicationInsightsViewTracking.cs
Outdated
Show resolved
Hide resolved
src/tests/Splat.ApplicationInsights.Tests/ApplicationInsightsViewTrackingTests.cs
Show resolved
Hide resolved
The name parameter is non-nullable and the v3 TrackEvent signature accepts IDictionary<string, string>, so Dictionary<string, string?> was unnecessarily nullable.
|
this is going to need quite a bit of hacking about. the JS version has drifted from the C# version that was removed. would need a custom type from ITelemetry to get around the issue. away for a few days will have a think. at this point V3 is unusable for Desktop and Blazor. The
issue with this is ItemTypeFlag is read only, only a brain dump of the type of bit that needs resolving. |
Summary
Upgrades
Microsoft.ApplicationInsightsfrom 2.23.0 to 3.0.0.Application Insights SDK v3 for .NET removed
TrackPageViewandPageViewTelemetrywith no official replacement. The SDK's supported telemetry types in v3 are:TrackEvent,TrackException,TrackDependency,TrackRequest,TrackAvailability, andTrackTrace.This PR replaces the removed
TrackPageView(name)call withTrackEvent("PageView", ...), which is the closest semantic match and aligns with how the AppCenter and Exceptionless Splat adapters already track page views.What changes for consumers
IViewTrackingor the constructor.ApplicationInsightsViewTrackingstill takes aTelemetryClient, same as before.OnViewNavigation(PageViewTelemetry)overload removed —PageViewTelemetryno longer exists in the upstream SDK. If you were calling this concrete overload, use theIViewTracking.OnViewNavigation(string)method instead.customEvents) instead of the removedpageViewstable.ApplicationInsightsFeatureUsageTrackingSessionis unchanged — it already usedTrackEvent/TrackExceptionwhich are still supported in v3.ConnectionStringis now required onTelemetryConfigurationin Application Insights v3 (previously optional).Usage
Constructor and
IViewTrackinginterface usage remain the same — no code changes needed:Feature usage tracking is also unchanged:
Querying page views in Application Insights
Page views previously appeared in the
pageViewstable. They now appear incustomEvents:Changes
Directory.Packages.propsMicrosoft.ApplicationInsights2.23.0 → 3.0.0ApplicationInsightsViewTracking.csTrackPageView(name)withTrackEvent("PageView", {Name}). RemoveOnViewNavigation(PageViewTelemetry)overload (type no longer exists).ApplicationInsightsFeatureUsageTrackingSession.csApplicationInsightsViewTrackingTests.csConnectionStringrequired by v3, addOnViewNavigationtestsApplicationInsightsFeatureUsageTrackingSessionTests.csConnectionStringrequired by v3Test plan
dotnet build -c Release -warnaserror— 0 warnings, 0 errorsdotnet testforSplat.ApplicationInsights.Tests— 21/21 passing (net8.0, net9.0, net10.0)