private static void AddSourceProperties(TelemetryEvent telemetry, SourceRepository sourceRepository, FeedType feedType)
        {
            telemetry.AddPiiData(PropertyNames.Source.Url, sourceRepository.PackageSource.Source);

            telemetry[PropertyNames.Source.Type] = feedType;

            var msFeed = GetMsFeed(sourceRepository.PackageSource);

            if (msFeed != null)
            {
                telemetry[PropertyNames.Source.MSFeed] = msFeed;
            }
        }
Example #2
0
        internal static TelemetryEvent ToTelemetry(Data data, string source, PackageSource packageSource, string parentId)
        {
            if (data.Metadata.EventTiming.Requests == 0 && data.Nupkg.EventTiming.Requests == 0)
            {
                return(null);
            }

            var telemetry = new TelemetryEvent(EventName,
                                               new Dictionary <string, object>()
            {
                { PropertyNames.ParentId, parentId },
            });

            // source info
            telemetry.AddPiiData(PropertyNames.Source.Url, source);

            if (packageSource == null)
            {
                packageSource = new PackageSource(source);
            }

            if (packageSource.IsHttp)
            {
                telemetry[PropertyNames.Source.Type]     = "http";
                telemetry[PropertyNames.Source.Protocol] = TelemetryUtility.IsHttpV3(packageSource) ? 3 : packageSource.ProtocolVersion;
            }
            else
            {
                telemetry[PropertyNames.Source.Type]     = "local";
                telemetry[PropertyNames.Source.Protocol] = packageSource.ProtocolVersion;
            }

            var msFeed = GetMsFeed(packageSource);

            if (msFeed != null)
            {
                telemetry[PropertyNames.Source.MSFeed] = msFeed;
            }

            AddResourceProperties(telemetry, data.Metadata, PropertyNames.Metadata);
            AddResourceProperties(telemetry, data.Nupkg, PropertyNames.Nupkg);

            ResourceData all = CalculateTotal(data.Metadata, data.Nupkg);

            AddResourceProperties(telemetry, all, PropertyNames.All);

            return(telemetry);
        }