Skip to content

Commit

Permalink
DEV2-4228: expose capabilities to the chat app (#1359)
Browse files Browse the repository at this point in the history
* DEV2-4228: expose capabilities to the chat app

* Update chat version to v2.20.0

* Update chat version to v2.22.0
  • Loading branch information
yairco1990 authored Nov 15, 2023
1 parent f56694c commit d1330fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .chatversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.21.0
v2.22.0
17 changes: 17 additions & 0 deletions src/tabnineChatWidget/ChatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getState,
getChatCommunicatorAddress,
ChatCommunicationKind,
getCapabilities,
} from "../binary/requests/requests";
import { sendEvent } from "../binary/requests/sendEvent";
import { chatEventRegistry } from "./chatEventRegistry";
Expand Down Expand Up @@ -38,6 +39,10 @@ type GetUserResponse = {
avatarUrl?: string;
};

type GetCapabilitiesResponse = {
enabledFeatures: string[];
};

type SendEventRequest = {
eventName: string;
properties?: { [key: string]: string };
Expand Down Expand Up @@ -125,6 +130,18 @@ export function initChatApi(
serviceLevel: state.service_level,
};
})
.registerEvent<void, GetCapabilitiesResponse>(
"get_capabilities",
async () => {
const capabilitiesResponse = await getCapabilities();
if (!capabilitiesResponse) {
throw new Error("capabilities response is undefined");
}
return {
enabledFeatures: capabilitiesResponse.enabled_features,
};
}
)
.registerEvent<SendEventRequest, void>(
"send_event",
async (req: SendEventRequest) => {
Expand Down

0 comments on commit d1330fe

Please sign in to comment.