BlazorApplicationInsights
BlazorApplicationInsights copied to clipboard
Disable telemetry in Development environment
Is there an official
and easy way to disable AppInsights telemetry in Development environment?
Not that I'm aware of. I keep it on but use a Dev App Insights instance so that alerts don't trigger. Additionally, you could use an adblocker.
Quote from https://docs.microsoft.com/en-us/azure/azure-monitor/app/javascript#telemetry-initializers
The input argument to addTelemetryInitializer is a callback that takes a ITelemetryItem as an argument and returns a
boolean
orvoid
. If returning false, the telemetry item isn't sent, else it proceeds to the next telemetry initializer, if any, or is sent to the telemetry collection endpoint.
Looks like telemetryInitializer may return false
and disable telemetry.
We can add property to TelemetryItem
that will control this behaviour during initialisation.
public bool SendTelemetry {get; set} = true;
or one similar to .net client
public bool DisableTelemetry {get; set} = false;
p.s. solution found on StackOverflow
This is now supported in v3.