BlazorApplicationInsights icon indicating copy to clipboard operation
BlazorApplicationInsights copied to clipboard

Disable telemetry in Development environment

Open sergey-tihon opened this issue 2 years ago • 2 comments

Is there an official and easy way to disable AppInsights telemetry in Development environment?

sergey-tihon avatar Apr 07 '22 21:04 sergey-tihon

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.

IvanJosipovic avatar Apr 07 '22 21:04 IvanJosipovic

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 or void. 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

sergey-tihon avatar Apr 08 '22 08:04 sergey-tihon

This is now supported in v3.

IvanJosipovic avatar Nov 25 '23 03:11 IvanJosipovic