Adding missing guard for telemetry optout to avoid NRE when importing modules (#18949)

This commit is contained in:
Staffan Gustafsson
2023-04-07 11:55:05 -07:00
committed by Dongbo Wang
parent 93fa32222e
commit 142b17e699
@@ -661,6 +661,11 @@ namespace Microsoft.PowerShell.Telemetry
/// <param name="moduleVersion">The module version to report. The default value is the anonymous version '0.0.0.0'.</param>
internal static void SendModuleTelemetryMetric(TelemetryType telemetryType, string moduleName, string moduleVersion = AnonymousVersion)
{
if (!CanSendTelemetry)
{
return;
}
try
{
string allowedModuleName = GetModuleName(moduleName);