forked from Azure/bicep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BicepTelemetryHandler.cs
35 lines (31 loc) · 1.37 KB
/
BicepTelemetryHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Threading;
using System.Threading.Tasks;
using Bicep.LanguageServer.Telemetry;
using MediatR;
using OmniSharp.Extensions.JsonRpc;
using OmniSharp.Extensions.LanguageServer.Protocol.Workspace;
namespace Bicep.LanguageServer.Handlers
{
// This handler is used to send a request from the client to the server(E.g. command sent as part
// of completion item of top level declaration snippet) which in turn triggers a request from server to client,
// asking the client to log a telemetry event
// Flow of events:
// 1. workspace/executeCommand request is sent from the client to the server
// 2. The above triggers telemetry/event from server to client
public class BicepTelemetryHandler : ExecuteTypedCommandHandlerBase<BicepTelemetryEvent>
{
private readonly ITelemetryProvider TelemetryProvider;
public BicepTelemetryHandler(ITelemetryProvider telemetryProvider, ISerializer serializer)
: base(TelemetryConstants.CommandName, serializer)
{
TelemetryProvider = telemetryProvider;
}
public override Task<Unit> Handle(BicepTelemetryEvent bicepTelemetryEvent, CancellationToken cancellationToken)
{
TelemetryProvider.PostEvent(bicepTelemetryEvent);
return Unit.Task;
}
}
}