diff --git a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj index 4e83825b9b8..70a2a009e54 100644 --- a/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj +++ b/vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj @@ -28,6 +28,7 @@ + diff --git a/vsintegration/src/FSharp.Editor/Hints/Hints.fs b/vsintegration/src/FSharp.Editor/Hints/Hints.fs index 9e6bab5c297..99bc26409e2 100644 --- a/vsintegration/src/FSharp.Editor/Hints/Hints.fs +++ b/vsintegration/src/FSharp.Editor/Hints/Hints.fs @@ -15,4 +15,9 @@ module Hints = Kind: HintKind Range: range Parts: TaggedText list - } \ No newline at end of file + } + + let serialize kind = + match kind with + | TypeHint -> "type" + | ParameterNameHint -> "parameterName" \ No newline at end of file diff --git a/vsintegration/src/FSharp.Editor/Hints/RoslynAdapter.fs b/vsintegration/src/FSharp.Editor/Hints/RoslynAdapter.fs index f79e1dba1fa..668cd3cb2fd 100644 --- a/vsintegration/src/FSharp.Editor/Hints/RoslynAdapter.fs +++ b/vsintegration/src/FSharp.Editor/Hints/RoslynAdapter.fs @@ -6,6 +6,7 @@ open System.Collections.Immutable open System.ComponentModel.Composition open Microsoft.CodeAnalysis.ExternalAccess.FSharp.InlineHints open Microsoft.VisualStudio.FSharp.Editor +open Microsoft.VisualStudio.FSharp.Editor.Telemetry // So the Roslyn interface is called IFSharpInlineHintsService // but our implementation is called just HintsService. @@ -27,6 +28,9 @@ type internal RoslynAdapter if hintKinds.IsEmpty then return ImmutableArray.Empty else + let hintKindsSerialized = hintKinds |> Set.map Hints.serialize |> String.concat "," + TelemetryReporter.reportEvent "hints" [("hints.kinds", hintKindsSerialized)] + let! sourceText = document.GetTextAsync cancellationToken |> Async.AwaitTask let! nativeHints = HintService.getHintsForDocument diff --git a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs index 821a0ab8aad..f43894370db 100644 --- a/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs +++ b/vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs @@ -27,6 +27,7 @@ open Microsoft.CodeAnalysis.ExternalAccess.FSharp open Microsoft.CodeAnalysis.Host open Microsoft.CodeAnalysis.Host.Mef open Microsoft.VisualStudio.FSharp.Editor.WorkspaceExtensions +open Microsoft.VisualStudio.FSharp.Editor.Telemetry open System.Threading.Tasks #nowarn "9" // NativePtr.toNativeInt @@ -104,6 +105,8 @@ type internal FSharpWorkspaceServiceFactory | _ -> let checker = lazy + TelemetryReporter.reportEvent "languageservicestarted" [] + let editorOptions = let editorOptions = workspace.Services.GetService() diff --git a/vsintegration/src/FSharp.Editor/Telemetry/TelemetryReporter.fs b/vsintegration/src/FSharp.Editor/Telemetry/TelemetryReporter.fs new file mode 100644 index 00000000000..f4f91d7f7d0 --- /dev/null +++ b/vsintegration/src/FSharp.Editor/Telemetry/TelemetryReporter.fs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Microsoft.VisualStudio.FSharp.Editor.Telemetry + +open Microsoft.VisualStudio.Telemetry + +module TelemetryReporter = + + let eventPrefix = "dotnet/fsharp/" + let propPrefix = "dotnet.fsharp." + + let getFullEventName name = eventPrefix + name + let getFullPropName name = propPrefix + name + + let createEvent name (props: (string * obj) list) = + let event = TelemetryEvent (getFullEventName name) + + props + |> List.map (fun (k, v) -> getFullPropName k, v) + |> List.iter event.Properties.Add + + event + + let reportEvent name props = + let session = TelemetryService.DefaultSession + let event = createEvent name props + session.PostEvent event +