none
Application insights client side page-view URL customization RRS feed

  • Question

  • We have URL like below 

    https://ABC.com/V2/#/Enquiry/Enquiry/EnquiryList

    The client side appinsights is logging the opertaion name as "/V1/"

    but we want like this - "Enquiry/Enquiry/EnquiryList"

    We are using the below script in our layout page. please provide the information to customize the 

       <script type="text/javascript">
        var instrumentkey = "";
        var sdkInstance = "appInsightsSDK"; window[sdkInstance] = "appInsights"var aiName = window[sdkInstance], aisdk = window[aiName] || function (e) { function n(e) { t[e] = function () { var n = arguments; t.queue.push(function () { t[e].apply(t, n) }) } } var t = { config: e }; t.initialize = !0var i = document, a = window; setTimeout(function () { var n = i.createElement("script"); n.src = e.url || "https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js", i.getElementsByTagName("script")[0].parentNode.appendChild(n) }); try { t.cookie = i.cookie } catch (e) { } t.queue = [], t.version = 2for (var r = ["Event""PageView""Exception""Trace""DependencyData""Metric""PageViewPerformance"]; r.length;) n("track" + r.pop()); n("startTrackPage"), n("stopTrackPage"); var s = "Track" + r[0]; if (n("start" + s), n("stop" + s), n("setAuthenticatedUserContext"), n("clearAuthenticatedUserContext"), n("flush"), !(!0 === e.disableExceptionTracking || e.extensionConfig && e.extensionConfig.ApplicationInsightsAnalytics && !0 === e.extensionConfig.ApplicationInsightsAnalytics.disableExceptionTracking)) { n("_" + (r = "onerror")); var o = a[r]; a[r] = function (e, n, i, a, s) { var c = o && o(e, n, i, a, s); return !0 !== c && t["_" + r]({ message: e, url: n, lineNumber: i, columnNumber: a, error: s }), c }, e.autoExceptionInstrumented = !0 } return t }(
        {
            instrumentationKey: instrumentkey
        }
        ); window[aiName] = aisdk, aisdk.queue && 0 === aisdk.queue.length && aisdk.trackPageView({});
        </script>

    Tuesday, November 19, 2019 1:00 PM

All replies

  • You can change the url logged by creating a TelemtryInitializer to modify the data and modifying the snippet slightly to make use of it.

            <script type="text/javascript">
                var sdkInstance="appInsightsSDK";window[sdkInstance]="appInsights";v...({message:e,url:n,lineNumber:i,columnNumber:a,error:s}),c},e.autoExceptionInstrumented=!0}return t}(
                    {
                    instrumentationKey:"key"
                    }
                );
    
                //remove the call to trackPageView()
                window[aiName]=aisdk,aisdk.queue&&0===aisdk.queue.length;
    
                
                var telemetryInitializer = (envelope) => {
                    envelope.baseData.uri = 'Enquiry/Enquiry/EnquiryList'
                };
    
                window.appInsights.addTelemetryInitializer(telemetryInitializer);
    
                //now that the initializer is in the pipeline, go ahead and send the page view
                window.appInsights.trackPageView()
            </script>
    You can read more about how to use the TelemetryInitailizer in the docs to modify other properties as you need or to filter what data is sent: https://github.com/microsoft/ApplicationInsights-JS

    Tuesday, November 26, 2019 6:56 PM
    Moderator