0
votes

I have a single page application written with JavaScript. I am currently logging events to Azure Application Insights using the JavaScript API. I notice that Application Insights is automatically writing all page views to Application Insights. However, I'm only interested in writing custom events to Application Insights.

Is there a way to disable logging page views? In other words, can I log only custom events, custom metrics, and exceptions with Application Insights?

I don't see anything in the API documentation. Thank you.

1

1 Answers

1
votes

You can restrict the type of telemetry you want by inspecting type and returning true/false in a Telemetry Initializer while creating client as below.

import { ApplicationInsights } from '@microsoft/applicationinsights-web'
const appInsights = new ApplicationInsights({ config: {
  instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE'  
} });
appInsights.addTelemetryInitializer(t => {
  // Update criteria as per your need.
  if (t.baseType == 'PageView') // or anything else
    return false; // disable
  return true; // enable everything else
});