Skip to content

Comments

chore (deps): Update Microsoft.ApplicationInsights to v3#1505

Draft
Copilot wants to merge 10 commits intomainfrom
copilot/update-application-insights-sdk
Draft

chore (deps): Update Microsoft.ApplicationInsights to v3#1505
Copilot wants to merge 10 commits intomainfrom
copilot/update-application-insights-sdk

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Summary

Upgrades Microsoft.ApplicationInsights from 2.23.0 to 3.0.0.

Application Insights SDK v3 for .NET removed TrackPageView and PageViewTelemetry with no official replacement. The SDK's supported telemetry types in v3 are: TrackEvent, TrackException, TrackDependency, TrackRequest, TrackAvailability, and TrackTrace.

This PR replaces the removed TrackPageView(name) call with TrackEvent("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

  • No breaking changes to IViewTracking or the constructor. ApplicationInsightsViewTracking still takes a TelemetryClient, same as before.
  • OnViewNavigation(PageViewTelemetry) overload removedPageViewTelemetry no longer exists in the upstream SDK. If you were calling this concrete overload, use the IViewTracking.OnViewNavigation(string) method instead.
  • Page views now appear as custom events in Application Insights (under customEvents) instead of the removed pageViews table.
  • ApplicationInsightsFeatureUsageTrackingSession is unchanged — it already used TrackEvent/TrackException which are still supported in v3.
  • ConnectionString is now required on TelemetryConfiguration in Application Insights v3 (previously optional).

Usage

Constructor and IViewTracking interface usage remain the same — no code changes needed:

var config = new TelemetryConfiguration
{
    ConnectionString = "InstrumentationKey=...",  // required in v3
};
var telemetryClient = new TelemetryClient(config);

var viewTracking = new ApplicationInsightsViewTracking(telemetryClient);
viewTracking.OnViewNavigation("HomePage");

Feature usage tracking is also unchanged:

var session = new ApplicationInsightsFeatureUsageTrackingSession("MyFeature", telemetryClient);
// ... use the feature ...
session.Dispose(); // sends "Feature Usage End" event

Querying page views in Application Insights

Page views previously appeared in the pageViews table. They now appear in customEvents:

// Before (v2 — no longer populated)
pageViews
| where name == "HomePage"

// After (v3)
customEvents
| where name == "PageView"
| extend viewName = tostring(customDimensions.Name)
| where viewName == "HomePage"

Changes

File Change
Directory.Packages.props Microsoft.ApplicationInsights 2.23.0 → 3.0.0
ApplicationInsightsViewTracking.cs Replace TrackPageView(name) with TrackEvent("PageView", {Name}). Remove OnViewNavigation(PageViewTelemetry) overload (type no longer exists).
ApplicationInsightsFeatureUsageTrackingSession.cs Add XML documentation to all undocumented members
ApplicationInsightsViewTrackingTests.cs Add ConnectionString required by v3, add OnViewNavigation tests
ApplicationInsightsFeatureUsageTrackingSessionTests.cs Add ConnectionString required by v3

Test plan

  • dotnet build -c Release -warnaserror — 0 warnings, 0 errors
  • dotnet test for Splat.ApplicationInsights.Tests — 21/21 passing (net8.0, net9.0, net10.0)

Copilot AI and others added 2 commits February 11, 2026 09:36
Co-authored-by: dpvreony <170983+dpvreony@users.noreply.github.com>
Co-authored-by: dpvreony <170983+dpvreony@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Application Insights SDK to version 3.0.0 Migrate ApplicationInsights to v3 with OpenTelemetry Activities Feb 11, 2026
Copilot AI requested a review from dpvreony February 11, 2026 09:42
@dpvreony dpvreony changed the title Migrate ApplicationInsights to v3 with OpenTelemetry Activities WIP: Migrate ApplicationInsights to v3 with OpenTelemetry Activities Feb 11, 2026
@glennawatson
Copy link
Contributor

Might see if I can find out what the issue is with the intermittent results with the raygun tests there.

glennawatson and others added 2 commits February 15, 2026 15:03
…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.
@glennawatson glennawatson changed the title WIP: Migrate ApplicationInsights to v3 with OpenTelemetry Activities Update Microsoft.ApplicationInsights to v3 Feb 15, 2026
@glennawatson glennawatson changed the title Update Microsoft.ApplicationInsights to v3 chore (deps): Update Microsoft.ApplicationInsights to v3 Feb 15, 2026
@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.57%. Comparing base (b3c95f8) to head (5049951).

Files with missing lines Patch % Lines
...icationInsights/ApplicationInsightsViewTracking.cs 88.88% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@glennawatson
Copy link
Contributor

@dpvreony I'll wait for you to review the changes before proceeding. Sorry if I jumped in on your work.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ApplicationInsights from 2.23.0 → 3.0.0 via central package management.
  • Replace TrackPageView(name) with TrackEvent("PageView", ...) in ApplicationInsightsViewTracking and remove the PageViewTelemetry overload.
  • 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.

The name parameter is non-nullable and the v3 TrackEvent signature
accepts IDictionary<string, string>, so Dictionary<string, string?>
was unnecessarily nullable.
@dpvreony
Copy link
Member

dpvreony commented Feb 16, 2026

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.

https://github.com/microsoft/ApplicationInsights-JS/blob/b6de144e27629b2d50e05ceb3885ee51b4fa0e2b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts#L300

### trackPageView

```ts
applicationInsights.trackPageView(pageView: IPageViewTelemetry)

The IPageViewTelemetry interface is below:

Parameter Type Description
name? string Optional
Name of the pageview. Defaults to the document title.
uri? string Optional
A relative or absolute URL that identifies the page or other item. Defaults to the window location.
refUri? string Optional
The URL of the previous page that sent the user to the current page.
pageType? string Optional
Page Type string. Describes how you classify this page, e.g. errorPage, formPage, etc.
isLoggedIn? boolean Optional
Whether or not the user is logged in
properties? dictionary Optional
Map of string to any: Additional data used to filter pages in the portal. Defaults to empty.

Note: To send a custom duration (ms) of your pageview as an argument, it must be included in the properties named field. E.g appInsights.trackPageView({ properties: { duration: 123.45 } });.

https://github.com/microsoft/ApplicationInsights-JS/blob/b6de144e27629b2d50e05ceb3885ee51b4fa0e2b/API-reference.md?plain=1#L150

            var eventTelemetry = new EventTelemetry(name)
            {
                ItemTypeFlag = SamplingTelemetryItemTypes.PageView, 
            };
            telemetryClient.TrackEvent(eventTelemetry);

issue with this is ItemTypeFlag is read only, only a brain dump of the type of bit that needs resolving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants