예제 #1
0
        public async Task TrackNewItemAsync(TemplateType templateType, UserSelectionContext context, Guid vsProjectId, GenItemsTelemetryData genItemsTelemetryData = null, double?timeSpent = null, CreationResultStatus genStatus = CreationResultStatus.Success, string message = "")
        {
            var itemType       = templateType.GetNewItemType();
            var itemTypeString = itemType != null?itemType.ToString() : string.Empty;

            // TODO: Remove TelemetryProperties.Framework and use TelemetryProperties.FrontendFramework
            var properties = new Dictionary <string, string>()
            {
                { TelemetryProperties.ProjectType, context.ProjectType },
                { TelemetryProperties.Framework, context.FrontEndFramework },
                { TelemetryProperties.FrontendFramework, context.FrontEndFramework },
                { TelemetryProperties.BackendFramework, context.BackEndFramework },
                { TelemetryProperties.GenEngineStatus, genStatus.ToString() },
                { TelemetryProperties.GenEngineMessage, message },
                { TelemetryProperties.EventName, TelemetryEvents.NewItemGen },
                { TelemetryProperties.VisualStudioActiveProjectGuid, vsProjectId.ToString() },
                { TelemetryProperties.Language, context.Language },
                { TelemetryProperties.VsProjectCategory, context.Platform },
                { TelemetryProperties.NewItemType, itemTypeString },
            };

            AddPropertiesFromPropertyBag(context, properties);

            var metrics = new Dictionary <string, double>();

            if (genItemsTelemetryData.PagesCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.PagesCount, genItemsTelemetryData.PagesCount.Value);
            }

            if (timeSpent.HasValue)
            {
                metrics.Add(TelemetryMetrics.TimeSpent, timeSpent.Value);
            }

            if (genItemsTelemetryData.FeaturesCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.FeaturesCount, genItemsTelemetryData.FeaturesCount.Value);
            }

            if (genItemsTelemetryData.ServicesCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.ServicesCount, genItemsTelemetryData.ServicesCount.Value);
            }

            if (genItemsTelemetryData.TestingCount.HasValue)
            {
                metrics.Add(TelemetryMetrics.TestingCount, genItemsTelemetryData.TestingCount.Value);
            }

            GenContext.ToolBox.Shell.SafeTrackNewItemVsTelemetry(properties, genItemsTelemetryData.PageIdentities, genItemsTelemetryData.FeatureIdentities, genItemsTelemetryData.ServiceIdentities, genItemsTelemetryData.TestingIdentities, metrics);

            await TelemetryService.Current.TrackEventAsync(TelemetryEvents.NewItemGen, properties, metrics).ConfigureAwait(false);
        }