public static IEnumerable <BicepTelemetryEvent> GetTelemetryEventsForBicepConfigChange(RootConfiguration prevConfiguration, RootConfiguration curConfiguration, ILinterRulesProvider linterRulesProvider) { bool prevLinterEnabledSettingValue = prevConfiguration.Analyzers.GetValue(LinterEnabledSetting, true); bool curLinterEnabledSettingValue = curConfiguration.Analyzers.GetValue(LinterEnabledSetting, true); if (!prevLinterEnabledSettingValue && !curLinterEnabledSettingValue) { return(Enumerable.Empty <BicepTelemetryEvent>()); } List <BicepTelemetryEvent> telemetryEvents = new(); if (prevLinterEnabledSettingValue != curLinterEnabledSettingValue) { var telemetryEvent = BicepTelemetryEvent.CreateOverallLinterStateChangeInBicepConfig(prevLinterEnabledSettingValue.ToString().ToLowerInvariant(), curLinterEnabledSettingValue.ToString().ToLowerInvariant()); telemetryEvents.Add(telemetryEvent); } else { foreach (var kvp in linterRulesProvider.GetLinterRules()) { string prevLinterRuleDiagnosticLevelValue = prevConfiguration.Analyzers.GetValue(kvp.Value, "warning"); string curLinterRuleDiagnosticLevelValue = curConfiguration.Analyzers.GetValue(kvp.Value, "warning"); if (prevLinterRuleDiagnosticLevelValue != curLinterRuleDiagnosticLevelValue) { var telemetryEvent = BicepTelemetryEvent.CreateLinterRuleStateChangeInBicepConfig(kvp.Key, prevLinterRuleDiagnosticLevelValue, curLinterRuleDiagnosticLevelValue); telemetryEvents.Add(telemetryEvent); } } } return(telemetryEvents); }
public BicepTelemetryEvent GetLinterStateTelemetryOnBicepFileOpen(RootConfiguration configuration) { bool linterEnabledSettingValue = configuration.Analyzers.GetValue(LinterEnabledSetting, true); Dictionary <string, string> properties = new(); properties.Add("enabled", linterEnabledSettingValue.ToString().ToLowerInvariant()); if (linterEnabledSettingValue) { foreach (var kvp in LinterRulesProvider.GetLinterRules()) { string linterRuleDiagnosticLevelValue = configuration.Analyzers.GetValue(kvp.Value, "warning"); properties.Add(kvp.Key, linterRuleDiagnosticLevelValue); } } return(BicepTelemetryEvent.CreateLinterStateOnBicepFileOpen(properties)); }