2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import type { GitHubTelemetryNotification } from '@github/copilot-sdk';
7
>
import { multiplexProperties, type IAgentHostRestrictedTelemetry, type IAgentHostRestrictedTelemetryContext, type TelemetryProps } from './agentHostRestrictedTelemetry.js';
8
>
9
>
const enum TelemetryDestination {
10
>
EnhancedGH = 1,
11
>
InternalMSFT = 2,
12
>
}
13
>
14
>
const targetDestinations = new Map<string, TelemetryDestination>([
15
>
['engine.messages', TelemetryDestination.EnhancedGH],
16
>
['engine.messages.length', TelemetryDestination.EnhancedGH | TelemetryDestination.InternalMSFT],
17
>
['model.message.added', TelemetryDestination.InternalMSFT],
18
>
['model.modelCall.input', TelemetryDestination.InternalMSFT],
19
>
['model.modelCall.output', TelemetryDestination.InternalMSFT],
20
>
['model.request.added', TelemetryDestination.InternalMSFT],
21
>
['model.request.options.added', TelemetryDestination.InternalMSFT],
22
>
]);
23
>
24
>
export class AgentHostGitHubTelemetryRouter {
25
>
26
>
constructor(private readonly _telemetryService: IAgentHostRestrictedTelemetry) { }
27
>
28
>
isTarget(notification: GitHubTelemetryNotification): boolean {
29
return targetDestinations.has(notification.event.kind);
30
}
32
>
route(notification: GitHubTelemetryNotification, context?: IAgentHostRestrictedTelemetryContext): boolean {
33
const { event } = notification;
34
const eventName = event.kind;