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

This commit is contained in:
Staffan Gustafsson 2023-01-31 06:13:55 +01:00 committed by GitHub
parent d29f34b5c2
commit 4e80e7611f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);