microsoft / microsoft/applicationinsights-react-js

Custom page view names for SPAs

Open
#20 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
47
Forks
18
Avg merge
1d 2h
Merged PRs (30d)
8

Description

When I use the plugin as documented for a React SPA with router v6, the name for all page views is the page title ("React App" by default). This makes it difficult to track user progress through the application. I was able to solve this using the following telemetry initializer but this doesn't seem very elegant.

appInsights.addTelemetryInitializer((env) => { if(env.baseType === "PageviewData" || env.baseType === "PageviewPerformanceData") { env.baseData.name = window.location.pathname; } });

It would be great for developers to be able to specify how to obtain the page name rather than having to modify it after the fact with a telemetry initializer. Alternatively, if the above approach is the recommended method, adding it to the official documentation would be helpful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the React plugin creates PageviewData and PageviewPerformanceData for SPA navigation, then compare that path with the telemetry initializer shown in the issue. Done means either a supported way to derive custom page-view names is available or the recommended initializer approach is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.