Skip to content

Commit 5d27865

Browse files
authored
SCAL-208508 : Update desc (#189)
1 parent 4219caf commit 5d27865

File tree

2 files changed

+48
-15
lines changed

2 files changed

+48
-15
lines changed

src/types.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,15 +3349,28 @@ export enum HostEvent {
33493349
/**
33503350
* Get the Answer session for a Search or
33513351
* Liveboard visualization.
3352+
*
3353+
* Note: This event is not typically used directly. Instead, use the
3354+
* `getAnswerService()` method on the embed instance to get an AnswerService
3355+
* object that provides a more convenient interface for working with answers.
3356+
*
33523357
* @example
33533358
* ```js
3359+
* // Preferred way to get an AnswerService
3360+
* const service = await embed.getAnswerService();
3361+
*
3362+
* // Alternative direct usage (not recommended)
33543363
* const {session} = await embed.trigger(
33553364
* HostEvent.GetAnswerSession, {
33563365
* vizId: '123', // For Liveboard Visualization.
33573366
* })
33583367
* ```
33593368
* @example
33603369
* ```js
3370+
* // Preferred way to get an AnswerService
3371+
* const service = await embed.getAnswerService();
3372+
*
3373+
* // Alternative direct usage (not recommended)
33613374
* const {session} = await embed.trigger( HostEvent.GetAnswerSession )
33623375
* ```
33633376
* @version SDK: 1.26.0 | ThoughtSpot: 9.10.0.cl, 10.1.0.sw

src/utils/graphql/answerService/answerService.ts

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,49 @@ export interface UnderlyingDataPoint {
2626
}
2727

2828
/**
29-
* Class representing the answer service provided with the
30-
* custom action payload. This service could be used to run
31-
* graphql queries in the context of the answer on which the
32-
* custom action was triggered.
29+
* AnswerService provides a simple way to work with ThoughtSpot Answers.
30+
*
31+
* This service allows you to interact with ThoughtSpot Answers programmatically,
32+
* making it easy to customize visualizations, filter data, and extract insights
33+
* directly from your application.
34+
*
35+
* You can use this service to:
36+
* - Add or remove columns from Answers (`addColumns`, `removeColumns`, `addColumnsByName`)
37+
* - Apply filters to Answers (`addFilter`)
38+
* - Get data from Answers in different formats (JSON, CSV, PNG) (`fetchData`, `fetchCSVBlob`, `fetchPNGBlob`)
39+
* - Get data for specific points in visualizations (`getUnderlyingDataForPoint`)
40+
* - Run custom queries (`executeQuery`)
41+
* - Add visualizations to liveboards (`addDisplayedVizToLiveboard`)
42+
*
3343
* @example
3444
* ```js
35-
* embed.on(EmbedEvent.CustomAction, e => {
36-
* const underlying = await e.answerService.getUnderlyingDataForPoint([
37-
* 'col name 1'
38-
* ]);
39-
* const data = await underlying.fetchData(0, 100);
40-
* })
45+
* // Get the answer service
46+
* embed.on(EmbedEvent.Data, async (e) => {
47+
* const service = await embed.getAnswerService();
48+
*
49+
* // Add columns to the answer
50+
* await service.addColumnsByName(["Sales", "Region"]);
51+
*
52+
* // Get the data
53+
* const data = await service.fetchData();
54+
* console.log(data);
55+
* });
4156
* ```
57+
*
4258
* @example
4359
* ```js
44-
* embed.on(EmbedEvent.Data, async (e) => {
45-
* const service = await embed.getAnswerService();
46-
* await service.addColumns([
47-
* "<column guid>"
60+
* // Get data for a point in a visualization
61+
* embed.on(EmbedEvent.CustomAction, async (e) => {
62+
* const underlying = await e.answerService.getUnderlyingDataForPoint([
63+
* 'Product Name',
64+
* 'Sales Amount'
4865
* ]);
49-
* console.log(await service.fetchData());
66+
*
67+
* const data = await underlying.fetchData(0, 100);
68+
* console.log(data);
5069
* });
5170
* ```
71+
*
5272
* @version SDK: 1.25.0| ThoughtSpot: 9.10.0.cl
5373
* @group Events
5474
*/

0 commit comments

Comments
 (0)