• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thoughtspot / visual-embed-sdk / #4096

04 Dec 2025 03:40AM UTC coverage: 94.317% (+0.008%) from 94.309%
#4096

push

web-flow
SCAL-285780 Update GitHub workflow to verify package-lock.json is up to date (#367)

1349 of 1517 branches covered (88.93%)

Branch coverage included in aggregate %.

3182 of 3287 relevant lines covered (96.81%)

102.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.36
/src/embed/app.ts
1
/**
2
 * Copyright (c) 2022
3
 *
4
 * Full application embedding
5
 * https://developers.thoughtspot.com/docs/?pageid=full-embed
6
 * @summary Full app embed
7
 * @module
8
 * @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
9
 */
10

11
import { logger } from '../utils/logger';
14✔
12
import { calculateVisibleElementData, getQueryParamString, isUndefined } from '../utils';
14✔
13
import {
14✔
14
    Param,
15
    DOMSelector,
16
    HostEvent,
17
    EmbedEvent,
18
    MessagePayload,
19
    AllEmbedViewConfig,
20
} from '../types';
21
import { V1Embed } from './ts-embed';
14✔
22

23
/**
24
 * Pages within the ThoughtSpot app that can be embedded.
25
 */
26

27
export enum Page {
14✔
28
    /**
29
     * Home page
30
     */
31
    Home = 'home',
14✔
32
    /**
33
     * Search page
34
     */
35
    Search = 'search',
14✔
36
    /**
37
     * Saved answers listing page
38
     */
39
    Answers = 'answers',
14✔
40
    /**
41
     * Liveboards listing page
42
     */
43
    Liveboards = 'liveboards',
14✔
44
    /**
45
     * @hidden
46
     */
47
    Pinboards = 'pinboards',
14✔
48
    /**
49
     * Data management page
50
     */
51
    Data = 'data',
14✔
52
    /**
53
     * SpotIQ listing page
54
     */
55
    SpotIQ = 'insights',
14✔
56
    /**
57
     *  Monitor Alerts Page
58
     */
59
    Monitor = 'monitor'
14✔
60
}
61

62
/**
63
 * Define the initial state os column custom group accordions
64
 * in data panel v2.
65
 */
66
export enum DataPanelCustomColumnGroupsAccordionState {
14✔
67
    /**
68
     * Expand all the accordion initially in data panel v2.
69
     */
70
    EXPAND_ALL = 'EXPAND_ALL',
14✔
71
    /**
72
     * Collapse all the accordions initially in data panel v2.
73
     */
74
    COLLAPSE_ALL = 'COLLAPSE_ALL',
14✔
75
    /**
76
     * Expand the first accordion and collapse the rest.
77
     */
78
    EXPAND_FIRST = 'EXPAND_FIRST',
14✔
79
}
80

81
export enum HomePageSearchBarMode {
14✔
82
    OBJECT_SEARCH = 'objectSearch',
14✔
83
    AI_ANSWER = 'aiAnswer',
14✔
84
    NONE = 'none'
14✔
85
}
86

87
/**
88
 * Define the version of the primary navbar
89
 * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
90
 */
91
export enum PrimaryNavbarVersion {
14✔
92
    /**
93
     * Sliding (v3) introduces a new left-side navigation hub featuring a tab switcher,
94
     * along with updates to the top navigation bar.
95
     * It serves as the foundational version of the PrimaryNavBar.
96
     */
97
    Sliding = 'v3',
14✔
98
}
99

100
/**
101
 * Define the version of the home page
102
 * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
103
 */
104
export enum HomePage {
14✔
105
    /**
106
     * Modular (v2) introduces the updated Modular Home Experience.
107
     * It serves as the foundational version of the home page.
108
     */
109
    Modular = 'v2',
14✔
110
    /**
111
     * ModularWithStylingChanges (v3) introduces Modular Home Experience
112
     * with styling changes.
113
     */
114
    ModularWithStylingChanges = 'v3',
14✔
115
}
116

117
/**
118
 * Define the version of the list page
119
 * @version SDK: 1.40.0 | ThoughtSpot: 10.12.0.cl
120
 */
121
export enum ListPage {
14✔
122
    /**
123
     * List (v2) is the traditional List Experience.
124
     * It serves as the foundational version of the list page.
125
     */
126
    List = 'v2',
14✔
127
    /**
128
     * ListWithUXChanges (v3) introduces the new updated list page with UX changes.
129
     */
130
    ListWithUXChanges = 'v3',
14✔
131
}
132

133
/**
134
 * Define the discovery experience
135
 * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
136
 */
137
export interface DiscoveryExperience {
138
    /**
139
     * primaryNavbarVersion determines the version of the navigation version.
140
     */
141
    primaryNavbarVersion?: PrimaryNavbarVersion;
142
    /**
143
     * homePage determines the version of the home page.
144
     */
145
    homePage?: HomePage;
146
    /**
147
     * listPageVersion determines the version of the list page.
148
     */
149
    listPageVersion?: ListPage;
150
}
151

152
/**
153
 * The view configuration for full app embedding.
154
 * @group Embed components
155
 */
156
export interface AppViewConfig extends AllEmbedViewConfig {
157
    /**
158
     * If true, the top navigation bar within the ThoughtSpot app
159
     * is displayed. By default, the navigation bar is hidden.
160
     * This flag also controls the homepage left navigation bar.
161
     *
162
     * Supported embed types: `AppEmbed`
163
     * @default true
164
     * @version SDK: 1.2.0 | ThoughtSpot: 8.4.0.cl
165
     * @example
166
     * ```js
167
     * const embed = new AppEmbed('#tsEmbed', {
168
     *    ... // other embed view config
169
     *    showPrimaryNavbar:true,
170
     * })
171
     * ```
172
     */
173
    showPrimaryNavbar?: boolean;
174
    /**
175
     * Control the visibility of the left navigation bar on the Homepage.
176
     * If showPrimaryNavbar is true, that is, if the Global and Homepage
177
     * nav-bars are visible, this flag will only hide the homepage left nav-bar.
178
     * The showPrimaryNavbar flag takes precedence over the hideHomepageLeftNav.
179
     *
180
     * **Note**: This option does not apply to the classic homepage.
181
     * To access the updated modular homepage, set
182
     * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
183
     *
184
     * Supported embed types: `AppEmbed`
185
     * @default false
186
     * @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl
187
     * @example
188
     * ```js
189
     * const embed = new AppEmbed('#tsEmbed', {
190
     *    ... // other embed view config
191
     *    hideHomepageLeftNav : true,
192
     * })
193
     * ```
194
     */
195
    hideHomepageLeftNav?: boolean;
196
    /**
197
     * Control the visibility of the help (?) and profile buttons on the
198
     * Global nav-bar. By default, these buttons are visible on the nav-bar.
199
     *
200
     * Supported embed types: `AppEmbed`
201
     * @default false
202
     * @version SDK: 1.2.0 | ThoughtSpot: 8.4.0.cl
203
     * @example
204
     * ```js
205
     * const embed = new AppEmbed('#tsEmbed', {
206
     *    ... // other embed view config
207
     *    disableProfileAndHelp: true,
208
     * })
209
     * ```
210
     */
211
    disableProfileAndHelp?: boolean;
212
    /**
213
     * @version SDK: 1.36.3 | ThoughtSpot: 10.1.0.cl
214
     * @default true
215
     * Whether the help menu in the top nav bar should be served
216
     * from Pendo or ThoughtSpot's internal help items.
217
     *
218
     * Supported embed types: `AppEmbed`
219
     * @example
220
     * ```js
221
     * const embed = new AppEmbed('#tsEmbed', {
222
     *   ... // other embed view config
223
     *  enablePendoHelp: false,
224
     * });
225
     * ```
226
     */
227
    enablePendoHelp?: boolean
228
    /**
229
     * Control the visibility of the hamburger icon on the top nav bar
230
     * available when new navigation V3 is enabled.
231
     *
232
     * Supported embed types: `AppEmbed`
233
     * @default false
234
     * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
235
     * @example
236
     * ```js
237
     * const embed = new AppEmbed('#tsEmbed', {
238
     *    ... // other embed view config
239
     *    hideHamburger : true,
240
     * })
241
     * ```
242
     */
243
    hideHamburger?: boolean;
244
    /**
245
     * Control the visibility of the Eureka search on the top nav bar
246
     * this will control for both new V2 and new navigation V3.
247
     *
248
     * Supported embed types: `AppEmbed`
249
     * @default true
250
     * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
251
     * @example
252
     * ```js
253
     * const embed = new AppEmbed('#tsEmbed', {
254
     *    ... // other embed view config
255
     *    hideObjectSearch: false,
256
     * })
257
     * ```
258
     */
259
    hideObjectSearch?: boolean;
260
    /**
261
     * Control the visibility of the notification on the top nav bar V3,
262
     * available when new navigation V3 is enabled.
263
     *
264
     * Supported embed types: `AppEmbed`
265
     * @default true
266
     * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
267
     * @example
268
     * ```js
269
     * const embed = new AppEmbed('#tsEmbed', {
270
     *    ... // other embed view config
271
     *    hideNotification: false,
272
     * })
273
     * ```
274
     */
275
    hideNotification?: boolean;
276
    /**
277
     * Control the visibility of the application switcher button on the nav-bar.
278
     * By default, the application switcher is shown.
279
     *
280
     * **Note**: This option does not apply to the classic homepage.
281
     * To access the updated modular homepage, set
282
     * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
283
     *
284
     * Supported embed types: `AppEmbed`
285
     * @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl
286
     * @default false
287
     * @example
288
     * ```js
289
     * const embed = new AppEmbed('#tsEmbed', {
290
     *    ... // other embed view config
291
     *    hideApplicationSwitcher : true,
292
     * })
293
     * ```
294
     */
295
    hideApplicationSwitcher?: boolean;
296
    /**
297
     * Control the visibility of the Org switcher button on the nav-bar.
298
     * By default, the Org switcher button is shown.
299
     *
300
     * **Note**: This option does not apply to the classic homepage.
301
     * To access the updated modular homepage, set
302
     * `modularHomeExperience` to `true` (available as Early Access feature in 9.12.5.cl).
303
     *
304
     * Supported embed types: `AppEmbed`
305
     * @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl
306
     * @default true
307
     * @example
308
     * ```js
309
     * const embed = new AppEmbed('#tsEmbed', {
310
     *    ... // other embed view config
311
     *    hideOrgSwitcher : true,
312
     * })
313
     * ```
314
     */
315
    hideOrgSwitcher?: boolean;
316
    /**
317
     * A URL path to the embedded application page
318
     * If both path and pageId attributes are defined, the path definition
319
     * takes precedence. This is the path post the `#/` in the URL of the standalone
320
     * ThoughtSpot app. Use this to open the embedded view to a specific path.
321
     *
322
     * For eg, if you want the component to open to a specific Liveboard
323
     * you could set the path to `pinboard/<liveboardId>/tab/<tabId>`.
324
     *
325
     * Supported embed types: `AppEmbed`
326
     * @version SDK: 1.1.0 | ThoughtSpot: 9.4.0.cl
327
     * @example
328
     * ```js
329
     * const embed = new AppEmbed('#tsEmbed', {
330
     *    ... // other embed view config
331
     *    path:"pinboard/1234/tab/7464",
332
     * })
333
     * ```
334
     */
335
    path?: string;
336
    /**
337
     * The application page to set as the start page
338
     * in the embedded view.
339
     *
340
     * Use this to open to particular page in the app. To open to a specific
341
     * path within the app, use the `path` attribute which is more flexible.
342
     *
343
     * Supported embed types: `AppEmbed`
344
     * @version SDK: 1.1.0 | ThoughtSpot: 9.4.0.cl
345
     * @example
346
     * ```js
347
     * const embed = new AppEmbed('#tsEmbed', {
348
     *    ... // other embed view config
349
     *    pageId : Page.Answers | Page.Data,
350
     * })
351
     * ```
352
     */
353
    pageId?: Page;
354
    /**
355
     * This puts a filter tag on the application. All metadata lists in the
356
     * application, such as Liveboards and answers, would be filtered by this
357
     * tag.
358
     *
359
     * Supported embed types: `AppEmbed`
360
     * @version SDK: 1.1.0 | ThoughtSpot: 9.4.0.cl
361
     * @example
362
     * ```js
363
     * const embed = new AppEmbed('#tsEmbed', {
364
     *    ... // other embed view config
365
     *    tag:'value',
366
     * })
367
     * ```
368
     */
369
    tag?: string;
370
    /**
371
     * Hide tag filter chips that appear when content is filtered by tags.
372
     * When enabled, this automatically:
373
     * - Hides tag filter indicators/chips from the UI
374
     *
375
     * This provides a clean interface without tag-related UI elements.
376
     *
377
     * Supported embed types: `AppEmbed`
378
     * @version SDK: 1.44.0 | ThoughtSpot: 10.15.0.cl
379
     * @example
380
     * ```js
381
     * // Simple usage - automatically hides all tag-related UI
382
     * const embed = new AppEmbed('#tsEmbed', {
383
     *    ... // other embed view config
384
     *    tag: 'Some Tag',
385
     *    hideTagFilterChips: true, // This is all you need!
386
     * });
387
     * ```
388
     */
389
    hideTagFilterChips?: boolean;
390
    /**
391
     * The array of GUIDs to be hidden
392
     *
393
     * Supported embed types: `AppEmbed`
394
     * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
395
     * @example
396
     * ```js
397
     * const embed = new AppEmbed('#tsEmbed', {
398
     *    ... // other embed view config
399
     *    hideObjects: [
400
     *       '430496d6-6903-4601-937e-2c691821af3c',
401
     *       'f547ec54-2a37-4516-a222-2b06719af726'
402
     *     ]
403
     * })
404
     * ```
405
     */
406
    hideObjects?: string[];
407
    /**
408
     * Render liveboards using the new v2 rendering mode
409
     * This is a transient flag which is primarily meant for internal use
410
     *
411
     * Supported embed types: `AppEmbed`
412
     * @version SDK: 1.11.0 | ThoughtSpot: 8.3.0.cl, 8.4.1-sw
413
     * @hidden
414
     */
415
    liveboardV2?: boolean;
416
    /**
417
     * If set to true, the Search Assist feature is enabled.
418
     *
419
     * Supported embed types: `AppEmbed`
420
     * @default true
421
     * @version SDK: 1.13.0 | ThoughtSpot: 8.5.0.cl, 8.8.1-sw
422
     * @example
423
     * ```js
424
     * const embed = new AppEmbed('#tsEmbed', {
425
     *    ... // other embed view config
426
     *    enableSearchAssist: true,
427
     * })
428
     * ```
429
     */
430
    enableSearchAssist?: boolean;
431
    /**
432
     * If set to true, the Liveboard container dynamically resizes
433
     * according to the height of the Liveboard.
434
     *
435
     * **Note**: Using fullHeight loads all visualizations
436
     * on the Liveboard simultaneously, which results in
437
     * multiple warehouse queries and potentially a
438
     * longer wait for the topmost visualizations to
439
     * display on the screen. Setting fullHeight to
440
     * `false` fetches visualizations incrementally as
441
     * users scroll the page to view the charts and tables.
442
     *
443
     * Supported embed types: `AppEmbed`
444
     * @version SDK: 1.21.0 | ThoughtSpot: 9.4.0.cl, 9.4.0-sw
445
     * @example
446
     * ```js
447
     * const embed = new AppEmbed('#tsEmbed', {
448
     *    ... // other embed view config
449
     *    fullHeight: true,
450
     * })
451
     * ```
452
     */
453
    fullHeight?: boolean;
454
    /**
455
     * Flag to control new Modular Home experience.
456
     *
457
     * Supported embed types: `AppEmbed`
458
     * @default false
459
     * @version SDK: 1.28.0 | ThoughtSpot: 9.12.5.cl
460
     * @example
461
     * ```js
462
     * const embed = new AppEmbed('#tsEmbed', {
463
     *    ... // other embed view config
464
     *    modularHomeExperience : true,
465
     * })
466
     * ```
467
     */
468
    modularHomeExperience?: boolean;
469
    /**
470
     * To configure the top-left navigation and home page experience
471
     *
472
     * Supported embed types: `AppEmbed`
473
     * @default false
474
     * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
475
     * @example
476
     * ```js
477
     * const embed = new AppEmbed('#tsEmbed', {
478
     *    ... // other embed view config
479
     *    discoveryExperience : {
480
     *      primaryNavbarVersion: PrimaryNavbarVersion.Sliding,
481
     *      homePage: HomePage.Modular,
482
     *    },
483
     * })
484
     * ```
485
     */
486
    discoveryExperience?: DiscoveryExperience;
487
    /**
488
     * To set the initial state of the search bar in case of saved-answers.
489
     * @version SDK: 1.32.0 | ThoughtSpot: 10.0.0.cl
490
     * @default false
491
     * @deprecated Use {@link collapseSearchBar} instead
492
     */
493
    collapseSearchBarInitially?: boolean;
494
    /**
495
     * This controls the initial behaviour of custom column groups accordion.
496
     * It takes DataPanelCustomColumnGroupsAccordionState enum values as input.
497
     * List of different enum values:-
498
     * - EXPAND_ALL: Expand all the accordion initially in data panel v2.
499
     * - COLLAPSE_ALL: Collapse all the accordions initially in data panel v2.
500
     * - EXPAND_FIRST: Expand the first accordion and collapse the rest.
501
     *
502
     * Supported embed types: `AppEmbed`
503
     * @version SDK: 1.32.0 | ThoughtSpot: 10.0.0.cl
504
     * @default DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL
505
     * @example
506
     * ```js
507
     * const embed = new AppEmbed('#embed', {
508
     *   ... // other app view config
509
     *   dataPanelCustomGroupsAccordionInitialState:
510
     *      DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL,
511
     * });
512
     * ```
513
     */
514
    dataPanelCustomGroupsAccordionInitialState?: DataPanelCustomColumnGroupsAccordionState;
515
    /**
516
     * Flag to use home page search bar mode
517
     *
518
     * Supported embed types: `AppEmbed`
519
     * @version SDK : 1.33.0 | ThoughtSpot: 10.3.0.cl
520
     */
521
    homePageSearchBarMode?: HomePageSearchBarMode;
522
    /**
523
     * This flag is used to enable unified search experience for full app embed.
524
     *
525
     * Supported embed types: `AppEmbed`
526
     * @version SDK: 1.34.0 | ThoughtSpot:10.5.0.cl
527
     * @default true
528
     * @example
529
     * ```js
530
     * const embed = new AppEmbed('#tsEmbed', {
531
     *    ... // other embed view config
532
     *    isUnifiedSearchExperienceEnabled: true,
533
     * })
534
     * ```
535
     */
536
    isUnifiedSearchExperienceEnabled?: boolean;
537

538
    /**
539
     * This flag is used to enable/disable the styling and grouping in a Liveboard
540
     *
541
     * Supported embed types: `AppEmbed`, `LiveboardEmbed`
542
     * @type {boolean}
543
     * @version SDK: 1.40.0 | ThoughtSpot: 10.11.0.cl
544
     * @example
545
     * ```js
546
     * // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
547
     * const embed = new <EmbedComponent>('#tsEmbed', {
548
     *    ... // other embed view config
549
     *    isLiveboardStylingAndGroupingEnabled: true,
550
     * })
551
     * ```
552
     */
553
    isLiveboardStylingAndGroupingEnabled?: boolean;
554

555
    /**
556
     * This flag is used to enable/disable the png embedding of liveboard in scheduled mails
557
     *
558
     * Supported embed types: `AppEmbed`, `LiveboardEmbed`
559
     * @type {boolean}
560
     * @version SDK: 1.42.0 | ThoughtSpot: 10.14.0.cl
561
     * @example
562
     * ```js
563
     * // Replace <EmbedComponent> with embed component name. For example, AppEmbed or LiveboardEmbed
564
     * const embed = new <EmbedComponent>('#tsEmbed', {
565
     *    ... // other embed view config
566
     *    isPNGInScheduledEmailsEnabled: true,
567
     * })
568
     * ```
569
     */
570
    isPNGInScheduledEmailsEnabled?: boolean;
571

572
    /**
573
     * This flag is used to enable the full height lazy load data.
574
     *
575
     * @example
576
     * ```js
577
     * const embed = new AppEmbed('#embed-container', {
578
     *    // ...other options
579
     *    fullHeight: true,
580
     *    lazyLoadingForFullHeight: true,
581
     * })
582
     * ```
583
     *
584
     * @type {boolean}
585
     * @default false
586
     * @version SDK: 1.40.0 | ThoughtSpot:10.12.0.cl
587
     */
588
    lazyLoadingForFullHeight?: boolean;
589

590
    /**
591
     * The margin to be used for lazy loading.
592
     *
593
     * For example, if the margin is set to '10px',
594
     * the visualization will be loaded 10px before the its top edge is visible in the
595
     * viewport.
596
     *
597
     * The format is similar to CSS margin.
598
     *
599
     * @example
600
     * ```js
601
     * const embed = new AppEmbed('#embed-container', {
602
     *    // ...other options
603
     *    fullHeight: true,
604
     *    lazyLoadingForFullHeight: true,
605
     *   // Using 0px, the visualization will be only loaded when its visible in the viewport.
606
     *    lazyLoadingMargin: '0px',
607
     * })
608
     * ```
609
     * @type {string}
610
     * @version SDK: 1.40.0 | ThoughtSpot:10.12.0.cl
611
     */
612
    lazyLoadingMargin?: string;
613

614
    /**
615
     * updatedSpotterChatPrompt : Controls the updated spotter chat prompt.
616
     *
617
     * Supported embed types: `AppEmbed`
618
     * @default false
619
     * @example
620
     * ```js
621
     * const embed = new AppEmbed('#tsEmbed', {
622
     *    ... //other embed view config
623
     *    updatedSpotterChatPrompt : true,
624
     * })
625
     * ```
626
     * @version SDK: 1.45.0 | ThoughtSpot: 26.2.0.cl
627
     */
628
    updatedSpotterChatPrompt?: boolean;
629
}
630

631
/**
632
 * Embeds full ThoughtSpot experience in a host application.
633
 * @group Embed components
634
 */
635
export class AppEmbed extends V1Embed {
636
    protected viewConfig: AppViewConfig;
637

638
    private defaultHeight = '100%';
639

640

641
    constructor(domSelector: DOMSelector, viewConfig: AppViewConfig) {
642
        viewConfig.embedComponentType = 'AppEmbed';
643
        super(domSelector, viewConfig);
644
        if (this.viewConfig.fullHeight === true) {
645
            this.on(EmbedEvent.RouteChange, this.setIframeHeightForNonEmbedLiveboard);
646
            this.on(EmbedEvent.EmbedHeight, this.updateIFrameHeight);
647
            this.on(EmbedEvent.EmbedIframeCenter, this.embedIframeCenter);
648
            this.on(EmbedEvent.RequestVisibleEmbedCoordinates, this.requestVisibleEmbedCoordinatesHandler);
649
        }
650
    }
651

652
    /**
653
     * Constructs a map of parameters to be passed on to the
14✔
654
     * embedded Liveboard or visualization.
655
     */
656
    protected getEmbedParams() {
137✔
657
        const {
658
            tag,
659
            hideTagFilterChips,
660
            hideObjects,
137✔
661
            liveboardV2,
137✔
662
            showPrimaryNavbar,
137✔
663
            disableProfileAndHelp,
15✔
664
            hideHamburger,
15✔
665
            hideObjectSearch,
15✔
666
            hideNotification,
15✔
667
            hideApplicationSwitcher,
668
            hideOrgSwitcher,
669
            enableSearchAssist,
670
            fullHeight,
671
            dataPanelV2 = true,
672
            hideLiveboardHeader = false,
673
            showLiveboardTitle = true,
674
            showLiveboardDescription = true,
675
            hideHomepageLeftNav = false,
676
            modularHomeExperience = false,
677
            isLiveboardHeaderSticky = true,
678
            enableAskSage,
679
            collapseSearchBarInitially = false,
680
            enable2ColumnLayout,
681
            enableCustomColumnGroups = false,
682
            dataPanelCustomGroupsAccordionInitialState = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL,
683
            collapseSearchBar = true,
684
            isLiveboardCompactHeaderEnabled = false,
685
            showLiveboardVerifiedBadge = true,
686
            showLiveboardReverifyBanner = true,
687
            hideIrrelevantChipsInLiveboardTabs = false,
688
            isEnhancedFilterInteractivityEnabled = false,
689
            homePageSearchBarMode,
135✔
690
            isUnifiedSearchExperienceEnabled = true,
136✔
691
            enablePendoHelp = true,
136✔
692
            discoveryExperience,
136✔
693
            coverAndFilterOptionInPDF = false,
135✔
694
            liveboardXLSXCSVDownload,
127✔
695
            isLiveboardStylingAndGroupingEnabled,
135✔
696
            isPNGInScheduledEmailsEnabled = false,
697
            isCentralizedLiveboardFilterUXEnabled = false,
136✔
698
            isLinkParametersEnabled,
699
            updatedSpotterChatPrompt,
136✔
700
        } = this.viewConfig;
135✔
701

136✔
702
        let params: any = {};
135✔
703
        params[Param.PrimaryNavHidden] = !showPrimaryNavbar;
135✔
704
        params[Param.HideProfleAndHelp] = !!disableProfileAndHelp;
135✔
705
        params[Param.HideApplicationSwitcher] = !!hideApplicationSwitcher;
135✔
706
        params[Param.HideOrgSwitcher] = !!hideOrgSwitcher;
135✔
707
        params[Param.HideLiveboardHeader] = hideLiveboardHeader;
708
        params[Param.ShowLiveboardTitle] = showLiveboardTitle;
135✔
709
        params[Param.ShowLiveboardDescription] = !!showLiveboardDescription;
135✔
710
        params[Param.LiveboardHeaderSticky] = isLiveboardHeaderSticky;
711
        params[Param.IsFullAppEmbed] = true;
135✔
712
        params[Param.LiveboardHeaderV2] = isLiveboardCompactHeaderEnabled;
713
        params[Param.IsEnhancedFilterInteractivityEnabled] = isEnhancedFilterInteractivityEnabled;
714
        params[Param.ShowLiveboardVerifiedBadge] = showLiveboardVerifiedBadge;
135✔
715
        params[Param.ShowLiveboardReverifyBanner] = showLiveboardReverifyBanner;
134✔
716
        params[Param.HideIrrelevantFiltersInTab] = hideIrrelevantChipsInLiveboardTabs;
717
        params[Param.IsUnifiedSearchExperienceEnabled] = isUnifiedSearchExperienceEnabled;
718
        params[Param.CoverAndFilterOptionInPDF] = !!coverAndFilterOptionInPDF;
719

136✔
720
        params = this.getBaseQueryParams(params);
721

136✔
722
        if (!isUndefined(updatedSpotterChatPrompt)) {
136✔
723
            params[Param.UpdatedSpotterChatPrompt] = !!updatedSpotterChatPrompt;
136✔
724
        }
136✔
725

136✔
726
        if (hideObjectSearch) {
136✔
727
            params[Param.HideObjectSearch] = !!hideObjectSearch;
136✔
728
        }
136✔
729

136✔
730
        if (hideHamburger) {
136✔
731
            params[Param.HideHamburger] = !!hideHamburger;
136✔
732
        }
136✔
733

136✔
734
        if (hideNotification) {
136✔
735
            params[Param.HideNotification] = !!hideNotification;
136✔
736
        }
136✔
737

136✔
738
        if (fullHeight === true) {
739
            params[Param.fullHeight] = true;
136✔
740
            if (this.viewConfig.lazyLoadingForFullHeight) {
741
                params[Param.IsLazyLoadingForEmbedEnabled] = true;
136✔
742
                params[Param.RootMarginForLazyLoad] = this.viewConfig.lazyLoadingMargin;
2✔
743
            }
744
        }
745

136✔
746
        if (tag) {
2✔
747
            params[Param.Tag] = tag;
748
        }
749
        if (hideObjects && hideObjects.length) {
136✔
750
            params[Param.HideObjects] = JSON.stringify(hideObjects);
1✔
751
        }
752
        if (liveboardV2 !== undefined) {
753
            params[Param.LiveboardV2Enabled] = liveboardV2;
136✔
754
        }
1✔
755

756
        if (enableSearchAssist !== undefined) {
757
            params[Param.EnableSearchAssist] = enableSearchAssist;
136✔
758
        }
1✔
759

760
        if (enable2ColumnLayout !== undefined) {
761
            params[Param.Enable2ColumnLayout] = enable2ColumnLayout;
136✔
762
        }
16✔
763

16✔
764
        if (enableAskSage) {
9✔
765
            params[Param.enableAskSage] = enableAskSage;
9✔
766
        }
767

768
        if (homePageSearchBarMode) {
769
            params[Param.HomePageSearchBarMode] = homePageSearchBarMode;
136✔
770
        }
1✔
771

772
        if (enablePendoHelp !== undefined) {
136!
773
            params[Param.EnablePendoHelp] = enablePendoHelp;
×
774
        }
775

136!
776
        if (isLiveboardStylingAndGroupingEnabled !== undefined) {
×
777
            params[Param.IsLiveboardStylingAndGroupingEnabled] = isLiveboardStylingAndGroupingEnabled;
778
        }
779

136✔
780
        if (liveboardXLSXCSVDownload !== undefined) {
1✔
781
            params[Param.LiveboardXLSXCSVDownload] = !!liveboardXLSXCSVDownload;
782
        }
783

136✔
784
        if (isPNGInScheduledEmailsEnabled !== undefined) {
1✔
785
            params[Param.isPNGInScheduledEmailsEnabled] = isPNGInScheduledEmailsEnabled;
786
        }
787

136✔
788
        if (hideTagFilterChips !== undefined) {
1✔
789
            params[Param.HideTagFilterChips] = hideTagFilterChips;
790
        }
791

136✔
792
        if (isLinkParametersEnabled !== undefined) {
3✔
793
            params[Param.isLinkParametersEnabled] = isLinkParametersEnabled;
794
        }
795

136✔
796
        if (isCentralizedLiveboardFilterUXEnabled != undefined) {
136✔
797
            params[
798
                Param.isCentralizedLiveboardFilterUXEnabled
799
            ] = isCentralizedLiveboardFilterUXEnabled;
136✔
800
        }
1✔
801

802
        params[Param.DataPanelV2Enabled] = dataPanelV2;
803
        params[Param.HideHomepageLeftNav] = hideHomepageLeftNav;
136✔
804
        params[Param.ModularHomeExperienceEnabled] = modularHomeExperience;
2✔
805
        params[Param.CollapseSearchBarInitially] = collapseSearchBarInitially || collapseSearchBar;
806
        params[Param.EnableCustomColumnGroups] = enableCustomColumnGroups;
807
        if (dataPanelCustomGroupsAccordionInitialState
136✔
808
            === DataPanelCustomColumnGroupsAccordionState.COLLAPSE_ALL
136✔
809
            || dataPanelCustomGroupsAccordionInitialState
810
            === DataPanelCustomColumnGroupsAccordionState.EXPAND_FIRST
811
        ) {
136✔
812

2✔
813
            params[
814
                Param.DataPanelCustomGroupsAccordionInitialState
815
            ] = dataPanelCustomGroupsAccordionInitialState;
136✔
816
        } else {
2✔
817

818
            params[Param.DataPanelCustomGroupsAccordionInitialState] = DataPanelCustomColumnGroupsAccordionState.EXPAND_ALL;
819
        }
136✔
820

136✔
821
        // Set navigation to v2 by default to avoid problems like the app
822
        // switcher (9-dot menu) not showing when v3 navigation is turned on
823
        // at the cluster level.
824
        // To use v3 navigation, we must manually set the discoveryExperience
825
        // settings.
136✔
826
        params[Param.NavigationVersion] = 'v2';
136✔
827
        // Set homePageVersion to v2 by default to reset the LD flag value
136✔
828
        // for the homepageVersion.
136✔
829
        params[Param.HomepageVersion] = 'v2';
136✔
830
        // Set listpageVersion to v2 by default to reset the LD flag value
136✔
831
        // for the listpageVersion.
832
        params[Param.ListPageVersion] = ListPage.List;
833
        if (discoveryExperience) {
834
            // primaryNavbarVersion v3 will enabled the new left navigation
835
            if (discoveryExperience.primaryNavbarVersion === PrimaryNavbarVersion.Sliding) {
836
                params[Param.NavigationVersion] = discoveryExperience.primaryNavbarVersion;
1✔
837
                // Enable the modularHomeExperience when Sliding is enabled.
838
                params[Param.ModularHomeExperienceEnabled] = true;
839
            }
840

841
            // homePage v2 will enable the modular home page
135✔
842
            // and it will override the modularHomeExperience value
843
            if (discoveryExperience.homePage === HomePage.Modular) {
844
                params[Param.ModularHomeExperienceEnabled] = true;
845
            }
846

847
            // ModularWithStylingChanges (v3) introduces the styling changes
848
            // to the Modular Homepage.
849
            // v3 will be the base version of homePageVersion.
136✔
850
            if (discoveryExperience.homePage === HomePage.ModularWithStylingChanges) {
851
                params[Param.HomepageVersion] = HomePage.ModularWithStylingChanges;
852
            }
136✔
853

854
            // listPageVersion v3 will enable the new list page
855
            if (discoveryExperience.listPageVersion === ListPage.ListWithUXChanges) {
136✔
856
                params[Param.ListPageVersion] = discoveryExperience.listPageVersion;
136✔
857
            }
858
        }
8✔
859

5✔
860
        const queryParams = getQueryParamString(params, true);
861

5✔
862
        return queryParams;
863
    }
864

865
    private sendFullHeightLazyLoadData = () => {
866
        const data = calculateVisibleElementData(this.iFrame);
8✔
867
        this.trigger(HostEvent.VisibleEmbedCoordinates, data);
4✔
868
    }
869

870
    /**
871
     * This is a handler for the RequestVisibleEmbedCoordinates event.
872
     * It is used to send the visible coordinates data to the host application.
873
     * @param data The event payload
8✔
874
     * @param responder The responder function
2✔
875
     */
876
    private requestVisibleEmbedCoordinatesHandler = (data: MessagePayload, responder: any) => {
877
        logger.info('Sending RequestVisibleEmbedCoordinates', data);
878
        const visibleCoordinatesData = calculateVisibleElementData(this.iFrame);
8✔
879
        responder({ type: EmbedEvent.RequestVisibleEmbedCoordinates, data: visibleCoordinatesData });
2✔
880
    }
881

882
    /**
883
     * Constructs the URL of the ThoughtSpot app page to be rendered.
136✔
884
     * @param pageId The ID of the page to be embedded.
885
     */
136✔
886
    public getIFrameSrc(): string {
887
        const { pageId, path, modularHomeExperience } = this.viewConfig;
888
        const pageRoute = this.formatPath(path) || this.getPageRoute(pageId, modularHomeExperience);
137✔
889
        let url = `${this.getRootIframeSrc()}/${pageRoute}`;
5✔
890

5✔
891
        const tsPostHashParams = this.getThoughtSpotPostUrlParams();
892
        url = `${url}${tsPostHashParams}`;
893

894
        return url;
895
    }
896

897
    /**
898
     * Set the iframe height as per the computed height received
899
     * from the ThoughtSpot app.
137✔
900
     * @param data The event payload
1✔
901
     */
1✔
902
    protected updateIFrameHeight = (data: MessagePayload) => {
1✔
903
        this.setIFrameHeight(Math.max(data.data, this.iFrame?.scrollHeight));
904
        this.sendFullHeightLazyLoadData();
905
    };
906

907
    private embedIframeCenter = (data: MessagePayload, responder: any) => {
908
        const obj = this.getIframeCenter();
909
        responder({ type: EmbedEvent.EmbedIframeCenter, data: obj });
910
    };
136✔
911

136✔
912
    private setIframeHeightForNonEmbedLiveboard = (data: MessagePayload) => {
136✔
913
        const { height: frameHeight } = this.viewConfig.frameParams || {};
914

136✔
915
        const liveboardRelatedRoutes = [
136✔
916
            '/pinboard/',
917
            '/insights/pinboard/',
136✔
918
            '/schedules/',
919
            '/embed/viz/',
920
            '/embed/insights/viz/',
921
            '/liveboard/',
922
            '/insights/liveboard/',
923
            '/tsl-editor/PINBOARD_ANSWER_BOOK/',
924
            '/import-tsl/PINBOARD_ANSWER_BOOK/',
925
        ];
137✔
926

3!
927
        if (liveboardRelatedRoutes.some((path) => data.data.currentPath.startsWith(path))) {
3✔
928
            // Ignore the height reset of the frame, if the navigation is
929
            // only within the liveboard page.
930
            return;
137✔
931
        }
2✔
932
        this.setIFrameHeight(frameHeight || this.defaultHeight);
2✔
933
    };
934

935
    /**
137✔
936
     * Gets the ThoughtSpot route of the page for a particular page ID.
5!
937
     * @param pageId The identifier for a page in the ThoughtSpot app.
938
     * @param modularHomeExperience
5✔
939
     */
940
    private getPageRoute(pageId: Page, modularHomeExperience = false) {
941
        switch (pageId) {
942
            case Page.Search:
943
                return 'answer';
944
            case Page.Answers:
945
                return modularHomeExperience ? 'home/answers' : 'answers';
946
            case Page.Liveboards:
947
                return modularHomeExperience ? 'home/liveboards' : 'pinboards';
948
            case Page.Pinboards:
949
                return modularHomeExperience ? 'home/liveboards' : 'pinboards';
950
            case Page.Data:
36✔
951
                return 'data/tables';
952
            case Page.SpotIQ:
953
                return modularHomeExperience ? 'home/spotiq-analysis' : 'insights/results';
2✔
954
            case Page.Monitor:
955
                return modularHomeExperience ? 'home/monitor-alerts' : 'insights/monitor-alerts';
3!
956
            case Page.Home:
957
            default:
958
                return 'home';
959
        }
960
    }
961

962
    /**
963
     * Formats the path provided by the user.
126✔
964
     * @param path The URL path.
135✔
965
     * @returns The URL path that the embedded app understands.
966
     */
2✔
967
    private formatPath(path: string) {
968
        if (!path) {
2✔
969
            return null;
970
        }
2✔
971

972
        // remove leading slash
2✔
973
        if (path.indexOf('/') === 0) {
974
            return path.substring(1);
2✔
975
        }
976

2✔
977
        return path;
978
    }
2✔
979

980
    /**
981
     * Navigate to particular page for app embed. eg:answers/pinboards/home
121✔
982
     * This is used for embedding answers, pinboards, visualizations and full application
983
     * only.
984
     * @param path string | number The string, set to iframe src and navigate to new page
985
     * eg: appEmbed.navigateToPage('pinboards')
986
     * When used with `noReload` (default: true) this can also be a number
987
     * like 1/-1 to go forward/back.
988
     * @param noReload boolean Trigger the navigation without reloading the page
989
     * @version SDK: 1.12.0 | ThoughtSpot: 8.4.0.cl, 8.4.1-sw
990
     */
991
    public navigateToPage(path: string | number, noReload = false): void {
136✔
992
        if (!this.iFrame) {
135✔
993
            logger.log('Please call render before invoking this method');
994
            return;
995
        }
996
        if (noReload) {
1!
997
            this.trigger(HostEvent.Navigate, path);
×
998
        } else {
999
            if (typeof path !== 'string') {
1000
                logger.warn('Path can only by a string when triggered without noReload');
1✔
1001
                return;
1002
            }
1003
            const iframeSrc = this.iFrame.src;
1004
            const embedPath = '#/embed';
1005
            const currentPath = iframeSrc.includes(embedPath) ? embedPath : '#';
1006
            this.iFrame.src = `${iframeSrc.split(currentPath)[0]}${currentPath}/${path.replace(
1007
                /^\/?#?\//,
1008
                '',
1009
            )}`;
1010
        }
1011
    }
1012

1013
    /**
1014
     * Destroys the ThoughtSpot embed, and remove any nodes from the DOM.
3✔
1015
     * @version SDK: 1.39.0 | ThoughtSpot: 10.10.0.cl
8✔
1016
     */
2✔
1017
    public destroy() {
2✔
1018
        super.destroy();
1019
        this.unregisterLazyLoadEvents();
6✔
1020
    }
2✔
1021

1022
    private postRender() {
4✔
1023
        this.registerLazyLoadEvents();
1✔
1024
    }
1✔
1025

1026
    private registerLazyLoadEvents() {
3✔
1027
        if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
3✔
1028
            // TODO: Use passive: true, install modernizr to check for passive
3!
1029
            window.addEventListener('resize', this.sendFullHeightLazyLoadData);
3✔
1030
            window.addEventListener('scroll', this.sendFullHeightLazyLoadData, true);
1031
        }
1032
    }
1033

1034
    private unregisterLazyLoadEvents() {
1035
        if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) {
1036
            window.removeEventListener('resize', this.sendFullHeightLazyLoadData);
1037
            window.removeEventListener('scroll', this.sendFullHeightLazyLoadData);
1038
        }
1039
    }
1040

1041
    /**
10✔
1042
     * Renders the embedded application pages in the ThoughtSpot app.
10✔
1043
     * @param renderOptions An object containing the page ID
1044
     * to be embedded.
1045
     */
1046
    public async render(): Promise<AppEmbed> {
135✔
1047
        await super.render();
1048

1049
        const src = this.getIFrameSrc();
1050
        await this.renderV1Embed(src);
135✔
1051

1052
        this.postRender();
8✔
1053
        return this;
8✔
1054
    }
1055
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc