azure-application-insights

how to log into browserTimings custom http requests made by SPA - Application Insights / JS


I want to log into browserTimings table inside Azure Application Insights custom data my performance service collects via PerformanceObserver - it basically logs timing of all http calls made by spa - (more into here https://w3c.github.io/navigation-timing/#dom-performancenavigationtiming)

enter image description here

I was using .trackPageViewPerformance(logObj) method for some time only to realize the log method actually overwrites some of the data with telemetry from the page load event. Which is not desirable. My coleague pointed out I can do Object.freeze to prevent that, or craft a class which will not accept changes to certain properties after its set. (And still allow for "enrichers" to add more props). However this seems like a workaround albaight clever one. I'm still wondering if there is some high or low level method I can use which is suited better for this usecase. Or what is a correct way to do this.

this is the repo of the JS package https://github.com/microsoft/ApplicationInsights-JS


Solution

  • Linking to the Issue in the repo where we have talked about possible solutions to this. https://github.com/microsoft/ApplicationInsights-JS/issues/2477