private void SendTelemetryOnBicepFileOpen(SemanticModel semanticModel, DocumentUri documentUri, RootConfiguration configuration, ImmutableHashSet <ISourceFile> sourceFiles, IEnumerable <Diagnostic> diagnostics) { // Telemetry on linter state on bicep file open var telemetryEvent = GetLinterStateTelemetryOnBicepFileOpen(configuration); TelemetryProvider.PostEvent(telemetryEvent); // Telemetry on open bicep file and the referenced modules telemetryEvent = GetTelemetryAboutSourceFiles(semanticModel, documentUri.ToUri(), sourceFiles, diagnostics); if (telemetryEvent is not null) { TelemetryProvider.PostEvent(telemetryEvent); } }
public static void SendTelemetryOnBicepConfigChange(RootConfiguration prevConfiguration, RootConfiguration curConfiguration, ILinterRulesProvider linterRulesProvider, ITelemetryProvider telemetryProvider) { foreach (var telemetryEvent in GetTelemetryEventsForBicepConfigChange(prevConfiguration, curConfiguration, linterRulesProvider)) { telemetryProvider.PostEvent(telemetryEvent); } }
private void PostDeployResultTelemetryEvent(string deployId, bool isSuccess) { var telemetryEvent = BicepTelemetryEvent.CreateDeployStartOrWaitForCompletionResult( TelemetryConstants.EventNames.DeployResult, deployId, isSuccess); telemetryProvider.PostEvent(telemetryEvent); }
public override async Task <Unit> Handle(DocumentUri documentUri, string ruleCode, string bicepConfigFilePath, CancellationToken cancellationToken) { string?error = "unknown"; bool newConfigFile = false; bool newRuleAdded = false; try { // bicepConfigFilePath will be empty string if no current configuration file was found if (string.IsNullOrEmpty(bicepConfigFilePath)) { // There is no configuration file currently - create one in the default location var targetFolder = await BicepGetRecommendedConfigLocationHandler.GetRecommendedConfigFileLocation(this.server, documentUri.GetFileSystemPath()); bicepConfigFilePath = Path.Combine(targetFolder, LanguageConstants.BicepConfigurationFileName); } try { if (!File.Exists(bicepConfigFilePath)) { newConfigFile = true; File.WriteAllText(bicepConfigFilePath, DefaultBicepConfig); } } catch (Exception ex) { error = ex.GetType().Name; server.Window.ShowError($"Unable to create configuration file \"{bicepConfigFilePath}\": {ex.Message}"); return(Unit.Value); } newRuleAdded = await AddAndSelectRuleLevel(bicepConfigFilePath, ruleCode); error = null; return(Unit.Value); } catch (Exception ex) { error = ex.GetType().Name; server.Window.ShowError(ex.Message); return(Unit.Value); } finally { telemetryProvider.PostEvent(BicepTelemetryEvent.EditLinterRule(ruleCode, newConfigFile, newRuleAdded, error)); } }
public override Task <Unit> Handle(BicepTelemetryEvent bicepTelemetryEvent, CancellationToken cancellationToken) { TelemetryProvider.PostEvent(bicepTelemetryEvent); return(Unit.Task); }