Skip to content

Add Analytics page name callback support - #2808

Open
Radhika Gupta (rads-1996) wants to merge 1 commit into
microsoft:mainfrom
rads-1996:add-analytics-page-name-callback
Open

Radhika Gupta (rads-1996) wants to merge 1 commit into
microsoft:mainfrom
rads-1996:add-analytics-page-name-callback

Conversation

@rads-1996

Copy link
Copy Markdown
Member

@rads-1996
Radhika Gupta (rads-1996) requested a review from a team as a code owner November 25, 2026 20:59
Copilot AI balanced review requested due to automatic review settings November 25, 2026 20:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the Analytics page-name callback change.

No open issues 🎉

What changed in this PR

Adds an Analytics page-name callback so applications can derive names for manual and automatic SPA page views without changing the document title, addressing the use case in issue #1986.

Changes:

  • Adds extension-scoped callbacks with explicit-name precedence, document-title fallback, and runtime configuration updates.
  • Exports the callback interface through the Analytics and web SDK packages.
  • Adds usage documentation and tests covering fallback behavior, SPA navigation, performance telemetry, and page-visit metrics.
File Description
RELEASES.md Announces page-name callback support.
extensions/​applicationinsights-analytics-js/​Tests/​Unit/​src/​AnalyticsPlugin.tests.ts Tests callback behavior and telemetry integration.
extensions/​applicationinsights-analytics-js/​src/​JavaScriptSDK/​Interfaces/​IAnalyticsConfig.ts Defines and documents the callback configuration.
extensions/​applicationinsights-analytics-js/​src/​JavaScriptSDK/​AnalyticsPlugin.ts Resolves page names and manages extension-scoped callbacks.
extensions/​applicationinsights-analytics-js/​src/​applicationinsights-analytics-js.ts Exports the callback interface from Analytics.
extensions/​applicationinsights-analytics-js/​README.md Documents configuration and usage.
AISKU/​src/​applicationinsights-web.ts Re-exports the callback interface from the web SDK.

Review effort: Balanced

@rads-1996
Radhika Gupta (rads-1996) force-pushed the add-analytics-page-name-callback branch from 09ec20a to 8a836d0 Compare November 25, 2026 21:02
let callback = _extConfig && _extConfig.callback;
if (callback && isFunction(callback.pageName)) {
try {
let name = callback.pageName();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reproduced this with the callback reading the current route. The new SPA test waits for the first page view before navigating again, so it misses this case. I didn’t find another blocker.

This branch has not been deployed

No deployments
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.

[Feature] Enable a callback to obtain the pageName as part of the analytics

3 participants