Exemplo n.º 1
0
        public async Task Jupyter_with_verbose_option_sends_telemetry_just_for_juptyer_command()
        {
            await _parser.InvokeAsync($"--verbose jupyter  {_connectionFile}", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties["verb"] == Sha256Hasher.Hash("JUPYTER") &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("CSHARP"));
        }
Exemplo n.º 2
0
        public async Task Jupyter_install_command_does_not_send_frontend_telemetry()
        {
            await _parser.InvokeAsync($"jupyter install", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties["verb"] == Sha256Hasher.Hash("JUPYTER") &&
                x.Properties["subcommand"] == Sha256Hasher.Hash("INSTALL"));
        }
Exemplo n.º 3
0
        public async Task Jupyter_default_kernel_fsharp_sends_telemetry()
        {
            await _parser.InvokeAsync($"jupyter --default-kernel fsharp {_connectionFile}", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties["verb"] == Sha256Hasher.Hash("JUPYTER") &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("FSHARP"));
        }
Exemplo n.º 4
0
        public void TopLevelCommandNameShouldBeSentToTelemetry()
        {
            string[] args = { "help" };
            Cli.Program.ProcessArgs(args);

            _fakeTelemetry.LogEntries.Should().Contain(e => e.EventName == "toplevelparser/command" &&
                                                       e.Properties.ContainsKey("verb") &&
                                                       e.Properties["verb"] == Sha256Hasher.Hash("HELP"));
        }
Exemplo n.º 5
0
        public async Task Jupyter_default_kernel_csharp_ignore_connection_file_sends_telemetry()
        {
            var tmp = Path.GetTempFileName();
            await _parser.InvokeAsync($"jupyter --default-kernel csharp {_connectionFile}", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties["verb"] == Sha256Hasher.Hash("JUPYTER") &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("CSHARP"));
        }
Exemplo n.º 6
0
        public async Task Jupyter_ignore_connection_file_sends_telemetry()
        {
            // Do not capture connection file
            await _parser.InvokeAsync($"jupyter  {_connectionFile}", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties["verb"] == Sha256Hasher.Hash("JUPYTER") &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("CSHARP"));
        }
Exemplo n.º 7
0
        private static string SanitizeHeaderName(string headerName)
        {
            if (string.IsNullOrEmpty(headerName) ||
                WellKnownHeaders.CommonHeaders.Contains(headerName, StringComparer.OrdinalIgnoreCase))
            {
                return(headerName);
            }

            return(Sha256Hasher.Hash(headerName));
        }
Exemplo n.º 8
0
        public async Task Kernel_server_default_kernel_fsharp_sends_telemetry()
        {
            await _parser.InvokeAsync("kernel-server --default-kernel fsharp", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties.Count == 2 &&
                x.Properties["verb"] == Sha256Hasher.Hash("KERNEL-SERVER") &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("FSHARP"));
        }
Exemplo n.º 9
0
        public async Task stdio_default_kernel_csharp_sends_telemetry()
        {
            await _parser.InvokeAsync("stdio --default-kernel csharp", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties.Count >= 2 &&
                x.Properties["verb"] == Sha256Hasher.Hash("STDIO") &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("CSHARP"));
        }
Exemplo n.º 10
0
        public async Task Jupyter_standalone_command_sends_telemetry()
        {
            await _parser.InvokeAsync("jupyter", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties.Count == 2 &&
                x.Properties["verb"] == Sha256Hasher.Hash("JUPYTER") &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("CSHARP"));
        }
Exemplo n.º 11
0
        private static string SanitizePreferenceName(string preferenceName)
        {
            if (string.IsNullOrEmpty(preferenceName) ||
                WellKnownPreference.Catalog.Names.Contains(preferenceName, StringComparer.OrdinalIgnoreCase))
            {
                return(preferenceName);
            }

            return(Sha256Hasher.Hash(preferenceName));
        }
Exemplo n.º 12
0
        public async Task stdio_command_sends_default_fronted_telemetry()
        {
            await _parser.InvokeAsync("stdio", _console);

            _fakeTelemetry.LogEntries.Should().Contain(
                x => x.EventName == "command" &&
                x.Properties.Count == 3 &&
                x.Properties["verb"] == Sha256Hasher.Hash("STDIO") &&
                x.Properties["frontend"] == "unknown" &&
                x.Properties["default-kernel"] == Sha256Hasher.Hash("CSHARP"));
        }
Exemplo n.º 13
0
        public void TopLevelCommandNameShouldBeSentToTelemetryZeroStartupTime()
        {
            string[] args = { "help" };
            Cli.Program.ProcessArgs(args, new TimeSpan(0));

            _fakeTelemetry.LogEntries.Should().Contain(e => e.EventName == "toplevelparser/command" &&
                                                       e.Properties.ContainsKey("verb") &&
                                                       e.Properties["verb"] == Sha256Hasher.Hash("HELP") &&
                                                       !e.Measurement.ContainsKey("Startup Time") &&
                                                       e.Measurement.ContainsKey("Parse Time") &&
                                                       e.Measurement["Parse Time"] > 0);
        }
Exemplo n.º 14
0
        public void DotnetListCommandFirstArgumentShouldBeSentToTelemetry()
        {
            const string argumentToSend = "reference";

            string[] args = { "list", argumentToSend, "aPackageName" };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" && e.Properties.ContainsKey("argument") &&
                     e.Properties["argument"] == Sha256Hasher.Hash(argumentToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("LIST"));
        }
Exemplo n.º 15
0
        public void TopLevelCommandNameShouldBeSentToTelemetryWithoutPerformanceData()
        {
            var parseResult = Parser.Instance.Parse(new List <string>()
            {
                "build"
            });

            TelemetryEventEntry.SendFiltered(parseResult);
            _fakeTelemetry.LogEntries.Should().Contain(e => e.EventName == "toplevelparser/command" &&
                                                       e.Properties.ContainsKey("verb") &&
                                                       e.Properties["verb"] == Sha256Hasher.Hash("BUILD") &&
                                                       e.Measurement == null);
        }
Exemplo n.º 16
0
        public void InternalreportinstallsuccessCommandCollectExeNameWithEventname()
        {
            FakeRecordEventNameTelemetry fakeTelemetry = new FakeRecordEventNameTelemetry();

            string[] args = { "c:\\mypath\\dotnet-sdk-latest-win-x64.exe" };

            InternalReportinstallsuccess.ProcessInputAndSendTelemetry(args, fakeTelemetry);

            fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "install/reportsuccess" && e.Properties.ContainsKey("exeName") &&
                     e.Properties["exeName"] == Sha256Hasher.Hash("DOTNET-SDK-LATEST-WIN-X64.EXE"));
        }
Exemplo n.º 17
0
        public void DotnetNewCommandLanguageOpinionShouldBeSentToTelemetry()
        {
            const string optionKey         = "language";
            const string optionValueToSend = "c#";

            string[] args = { "new", "console", "--" + optionKey, optionValueToSend };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" && e.Properties.ContainsKey(optionKey) &&
                     e.Properties[optionKey] == Sha256Hasher.Hash(optionValueToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("NEW"));
        }
Exemplo n.º 18
0
        public void DotnetHelpCommandFirstArgumentShouldBeSentToTelemetry()
        {
            const string argumentToSend = "something";

            string[] args = { "help", argumentToSend };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" &&
                     e.Properties.ContainsKey("argument") &&
                     e.Properties["argument"] == Sha256Hasher.Hash(argumentToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("HELP"));
        }
Exemplo n.º 19
0
        public void DotnetBuildAndPublishCommandOpinionsShouldBeSentToTelemetry()
        {
            const string optionKey         = "configuration";
            const string optionValueToSend = "Debug";

            string[] args = { "build", "--" + optionKey, optionValueToSend };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" &&
                     e.Properties.ContainsKey(optionKey) &&
                     e.Properties[optionKey] == Sha256Hasher.Hash(optionValueToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("BUILD"));
        }
Exemplo n.º 20
0
        public void DotnetPublishCommandRuntimeOpinionsShouldBeSentToTelemetry()
        {
            const string optionKey         = "runtime";
            const string optionValueToSend = "win10-x64";

            string[] args = { "publish", "--" + optionKey, optionValueToSend };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" &&
                     e.Properties.ContainsKey(optionKey) &&
                     e.Properties[optionKey] == Sha256Hasher.Hash(optionValueToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("PUBLISH"));
        }
Exemplo n.º 21
0
        public void AnyDotnetCommandVerbosityOpinionShouldBeSentToTelemetry()
        {
            const string optionKey         = "verbosity";
            const string optionValueToSend = "minimal";

            string[] args = { "restore", "--" + optionKey, optionValueToSend };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" &&
                     e.Properties.ContainsKey(optionKey) &&
                     e.Properties[optionKey] == Sha256Hasher.Hash(optionValueToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("RESTORE"));
        }
Exemplo n.º 22
0
        public void TopLevelCommandNameShouldBeSentToTelemetryWithZeroPerformanceData()
        {
            var parseResult = Parser.Instance.Parse(new List <string>()
            {
                "build"
            });

            TelemetryEventEntry.SendFiltered(Tuple.Create(parseResult, new Dictionary <string, double>()
            {
                { "Startup Time", 0 }
            }));
            _fakeTelemetry.LogEntries.Should().Contain(e => e.EventName == "toplevelparser/command" &&
                                                       e.Properties.ContainsKey("verb") &&
                                                       e.Properties["verb"] == Sha256Hasher.Hash("BUILD") &&
                                                       e.Measurement == null);
        }
Exemplo n.º 23
0
        public void SubLevelCommandNameShouldBeSentToTelemetryWithoutPerformanceData()
        {
            var parseResult = Parser.Instance.Parse(new List <string>()
            {
                "new", "console"
            });

            TelemetryEventEntry.SendFiltered(parseResult);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" &&
                     e.Properties.ContainsKey("argument") &&
                     e.Properties["argument"] == Sha256Hasher.Hash("CONSOLE") &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("NEW") &&
                     e.Measurement == null);
        }
Exemplo n.º 24
0
        public void DotnetRunCleanTestCommandOpinionsShouldBeSentToTelemetryWhenThereIsMultipleOption()
        {
            string[] args = { "clean", "--configuration", "Debug", "--framework", "netcoreapp1.0" };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" && e.Properties.ContainsKey("configuration") &&
                     e.Properties["configuration"] == Sha256Hasher.Hash("DEBUG") &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("CLEAN"));

            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" && e.Properties.ContainsKey("framework") &&
                     e.Properties["framework"] == Sha256Hasher.Hash("NETCOREAPP1.0") &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("CLEAN"));
        }
Exemplo n.º 25
0
        public void DotnetBuildAndPublishCommandOpinionsShouldBeSentToTelemetryWhenThereIsMultipleOption()
        {
            string[] args = { "build", "--configuration", "Debug", "--runtime", "osx.10.11-x64" };
            Cli.Program.ProcessArgs(args);
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" && e.Properties.ContainsKey("configuration") &&
                     e.Properties["configuration"] == Sha256Hasher.Hash("DEBUG") &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("BUILD"));

            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" && e.Properties.ContainsKey("runtime") &&
                     e.Properties["runtime"] == Sha256Hasher.Hash("OSX.10.11-X64") &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("BUILD"));
        }
Exemplo n.º 26
0
        public void DotnetNewCommandFirstArgumentShouldBeSentToTelemetryWithPerformanceData()
        {
            const string argumentToSend = "console";

            string[] args = { "new", argumentToSend };
            Cli.Program.ProcessArgs(args, new TimeSpan(23456));
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" &&
                     e.Properties.ContainsKey("argument") &&
                     e.Properties["argument"] == Sha256Hasher.Hash(argumentToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("NEW") &&
                     e.Measurement.ContainsKey("Startup Time") &&
                     e.Measurement["Startup Time"] == 2.3456 &&
                     e.Measurement.ContainsKey("Parse Time") &&
                     e.Measurement["Parse Time"] > 0);
        }
Exemplo n.º 27
0
        public async Task ExecuteAsync_WithUnknownHeader_SendsTelemetryWithHashedHeaderName()
        {
            ArrangeInputs(parseResultSections: "set header name value",
                          out MockedShellState shellState,
                          out HttpState httpState,
                          out ICoreParseResult parseResult);

            TelemetryCollector telemetry = new TelemetryCollector();

            SetHeaderCommand setHeaderCommand = new SetHeaderCommand(telemetry);
            await setHeaderCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None);

            Assert.Single(telemetry.Telemetry);
            TelemetryCollector.CollectedTelemetry collectedTelemetry = telemetry.Telemetry[0];
            Assert.Equal("SetHeader", collectedTelemetry.EventName);
            Assert.Equal(Sha256Hasher.Hash("name"), collectedTelemetry.Properties["HeaderName"]);
            Assert.Equal("False", collectedTelemetry.Properties["IsValueEmpty"]);
        }
Exemplo n.º 28
0
        public void SubLevelCommandNameShouldBeSentToTelemetryWithPerformanceData()
        {
            var parseResult = Parser.Instance.Parse(new List <string>()
            {
                "new", "console"
            });

            TelemetryEventEntry.SendFiltered(Tuple.Create(parseResult, new Dictionary <string, double>()
            {
                { "Startup Time", 34567 }
            }));
            _fakeTelemetry.LogEntries.Should().Contain(e => e.EventName == "sublevelparser/command" &&
                                                       e.Properties.ContainsKey("argument") &&
                                                       e.Properties["argument"] == Sha256Hasher.Hash("CONSOLE") &&
                                                       e.Properties.ContainsKey("verb") &&
                                                       e.Properties["verb"] == Sha256Hasher.Hash("NEW") &&
                                                       e.Measurement.ContainsKey("Startup Time") &&
                                                       e.Measurement["Startup Time"] == 34567);
        }
Exemplo n.º 29
0
        public void WhenCalledWithMissingArgumentWorkloadSubLevelCommandNameAndArgumentShouldBeSentToTelemetry()
        {
            var parseResult =
                Parser.Instance.Parse(new List <string>()
            {
                "-d", "workload", "install"
            });

            TelemetryEventEntry.SendFiltered(Tuple.Create(parseResult,
                                                          new Dictionary <string, double>()
            {
                { "Startup Time", 0 }, { "Parse Time", 23456 }
            }));
            _fakeTelemetry.LogEntries.Should().Contain(e => e.EventName == "sublevelparser/command" &&
                                                       e.Properties.ContainsKey("verb") &&
                                                       e.Properties["verb"] == Sha256Hasher.Hash("WORKLOAD") &&
                                                       e.Properties["subcommand"] ==
                                                       Sha256Hasher.Hash("INSTALL"));
        }
Exemplo n.º 30
0
        public void AnyDotnetCommandVerbosityOpinionShouldBeSentToTelemetryWithPerformanceData()
        {
            const string optionKey         = "verbosity";
            const string optionValueToSend = "minimal";

            string[] args = { "restore", "--" + optionKey, optionValueToSend };
            Cli.Program.ProcessArgs(args, new TimeSpan(34567));
            _fakeTelemetry
            .LogEntries.Should()
            .Contain(e => e.EventName == "sublevelparser/command" &&
                     e.Properties.ContainsKey(optionKey) &&
                     e.Properties[optionKey] == Sha256Hasher.Hash(optionValueToSend.ToUpper()) &&
                     e.Properties.ContainsKey("verb") &&
                     e.Properties["verb"] == Sha256Hasher.Hash("RESTORE") &&
                     e.Measurement.ContainsKey("Startup Time") &&
                     e.Measurement["Startup Time"] == 3.4567 &&
                     e.Measurement.ContainsKey("Parse Time") &&
                     e.Measurement["Parse Time"] > 0);
        }