Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
</EmbeddedText>
<Compile Include="$(MSBuildThisFileDirectory)..\..\..\src\LegacyMSBuildResolver\LegacyMSBuildReferenceResolver.fsi" />
<Compile Include="$(MSBuildThisFileDirectory)..\..\..\src\LegacyMSBuildResolver\LegacyMSBuildReferenceResolver.fs" />
<Compile Include="Telemetry\TelemetryReporter.fs" />
<Compile Include="Common\AssemblyInfo.fs" />
<Compile Include="Common\Logger.fsi" />
<Compile Include="Common\Logger.fs" />
Expand Down
7 changes: 6 additions & 1 deletion vsintegration/src/FSharp.Editor/Hints/Hints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ module Hints =
Kind: HintKind
Range: range
Parts: TaggedText list
}
}

let serialize kind =
match kind with
| TypeHint -> "type"
| ParameterNameHint -> "parameterName"
4 changes: 4 additions & 0 deletions vsintegration/src/FSharp.Editor/Hints/RoslynAdapter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -104,6 +105,8 @@ type internal FSharpWorkspaceServiceFactory
| _ ->
let checker =
lazy
TelemetryReporter.reportEvent "languageservicestarted" []

let editorOptions =
let editorOptions = workspace.Services.GetService<EditorOptions>()

Expand Down
28 changes: 28 additions & 0 deletions vsintegration/src/FSharp.Editor/Telemetry/TelemetryReporter.fs
Original file line number Diff line number Diff line change
@@ -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