@thoughtspot/visual-embed-sdk 1.42.1-alpha.6 → 1.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/cjs/package.json +3 -2
  2. package/cjs/src/embed/app.d.ts +20 -0
  3. package/cjs/src/embed/app.d.ts.map +1 -1
  4. package/cjs/src/embed/app.js +5 -4
  5. package/cjs/src/embed/app.js.map +1 -1
  6. package/cjs/src/embed/app.spec.js +32 -0
  7. package/cjs/src/embed/app.spec.js.map +1 -1
  8. package/cjs/src/embed/hostEventClient/contracts.d.ts +1 -11
  9. package/cjs/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  10. package/cjs/src/embed/hostEventClient/contracts.js +0 -1
  11. package/cjs/src/embed/hostEventClient/contracts.js.map +1 -1
  12. package/cjs/src/embed/hostEventClient/host-event-client.d.ts +3 -3
  13. package/cjs/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  14. package/cjs/src/embed/hostEventClient/host-event-client.js +6 -6
  15. package/cjs/src/embed/hostEventClient/host-event-client.js.map +1 -1
  16. package/cjs/src/embed/search.d.ts.map +1 -1
  17. package/cjs/src/embed/search.js +1 -3
  18. package/cjs/src/embed/search.js.map +1 -1
  19. package/cjs/src/embed/ts-embed.d.ts +1 -3
  20. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  21. package/cjs/src/embed/ts-embed.js +16 -44
  22. package/cjs/src/embed/ts-embed.js.map +1 -1
  23. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  24. package/cjs/src/index.d.ts +2 -2
  25. package/cjs/src/index.d.ts.map +1 -1
  26. package/cjs/src/index.js +1 -2
  27. package/cjs/src/index.js.map +1 -1
  28. package/cjs/src/react/all-types-export.d.ts +1 -1
  29. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  30. package/cjs/src/react/all-types-export.js +1 -2
  31. package/cjs/src/react/all-types-export.js.map +1 -1
  32. package/cjs/src/react/util.d.ts +1 -0
  33. package/cjs/src/react/util.d.ts.map +1 -1
  34. package/cjs/src/types.d.ts +105 -143
  35. package/cjs/src/types.d.ts.map +1 -1
  36. package/cjs/src/types.js +103 -98
  37. package/cjs/src/types.js.map +1 -1
  38. package/cjs/src/utils/processData.d.ts +1 -1
  39. package/cjs/src/utils/processData.d.ts.map +1 -1
  40. package/cjs/src/utils/processData.js +8 -8
  41. package/cjs/src/utils/processData.js.map +1 -1
  42. package/cjs/src/utils/processData.spec.js.map +1 -1
  43. package/cjs/src/utils/processTrigger.d.ts +2 -1
  44. package/cjs/src/utils/processTrigger.d.ts.map +1 -1
  45. package/cjs/src/utils/processTrigger.js +4 -2
  46. package/cjs/src/utils/processTrigger.js.map +1 -1
  47. package/dist/{index-DvNA626T.js → index-CWQnMX2L.js} +1 -1
  48. package/dist/src/embed/app.d.ts +20 -0
  49. package/dist/src/embed/app.d.ts.map +1 -1
  50. package/dist/src/embed/hostEventClient/contracts.d.ts +1 -11
  51. package/dist/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  52. package/dist/src/embed/hostEventClient/host-event-client.d.ts +3 -3
  53. package/dist/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  54. package/dist/src/embed/search.d.ts.map +1 -1
  55. package/dist/src/embed/ts-embed.d.ts +1 -3
  56. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  57. package/dist/src/index.d.ts +2 -2
  58. package/dist/src/index.d.ts.map +1 -1
  59. package/dist/src/react/all-types-export.d.ts +1 -1
  60. package/dist/src/react/all-types-export.d.ts.map +1 -1
  61. package/dist/src/react/util.d.ts +1 -0
  62. package/dist/src/react/util.d.ts.map +1 -1
  63. package/dist/src/types.d.ts +105 -143
  64. package/dist/src/types.d.ts.map +1 -1
  65. package/dist/src/utils/processData.d.ts +1 -1
  66. package/dist/src/utils/processData.d.ts.map +1 -1
  67. package/dist/src/utils/processTrigger.d.ts +2 -1
  68. package/dist/src/utils/processTrigger.d.ts.map +1 -1
  69. package/dist/tsembed-react.es.js +155 -277
  70. package/dist/tsembed-react.js +299 -497
  71. package/dist/tsembed.es.js +156 -278
  72. package/dist/tsembed.js +299 -497
  73. package/dist/visual-embed-sdk-react-full.d.ts +129 -160
  74. package/dist/visual-embed-sdk-react.d.ts +129 -157
  75. package/dist/visual-embed-sdk.d.ts +129 -160
  76. package/lib/package.json +3 -2
  77. package/lib/src/embed/app.d.ts +20 -0
  78. package/lib/src/embed/app.d.ts.map +1 -1
  79. package/lib/src/embed/app.js +5 -4
  80. package/lib/src/embed/app.js.map +1 -1
  81. package/lib/src/embed/app.spec.js +32 -0
  82. package/lib/src/embed/app.spec.js.map +1 -1
  83. package/lib/src/embed/hostEventClient/contracts.d.ts +1 -11
  84. package/lib/src/embed/hostEventClient/contracts.d.ts.map +1 -1
  85. package/lib/src/embed/hostEventClient/contracts.js +0 -1
  86. package/lib/src/embed/hostEventClient/contracts.js.map +1 -1
  87. package/lib/src/embed/hostEventClient/host-event-client.d.ts +3 -3
  88. package/lib/src/embed/hostEventClient/host-event-client.d.ts.map +1 -1
  89. package/lib/src/embed/hostEventClient/host-event-client.js +6 -6
  90. package/lib/src/embed/hostEventClient/host-event-client.js.map +1 -1
  91. package/lib/src/embed/search.d.ts.map +1 -1
  92. package/lib/src/embed/search.js +1 -3
  93. package/lib/src/embed/search.js.map +1 -1
  94. package/lib/src/embed/ts-embed.d.ts +1 -3
  95. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  96. package/lib/src/embed/ts-embed.js +16 -44
  97. package/lib/src/embed/ts-embed.js.map +1 -1
  98. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  99. package/lib/src/index.d.ts +2 -2
  100. package/lib/src/index.d.ts.map +1 -1
  101. package/lib/src/index.js +2 -2
  102. package/lib/src/index.js.map +1 -1
  103. package/lib/src/react/all-types-export.d.ts +1 -1
  104. package/lib/src/react/all-types-export.d.ts.map +1 -1
  105. package/lib/src/react/all-types-export.js +1 -1
  106. package/lib/src/react/all-types-export.js.map +1 -1
  107. package/lib/src/react/util.d.ts +1 -0
  108. package/lib/src/react/util.d.ts.map +1 -1
  109. package/lib/src/types.d.ts +105 -143
  110. package/lib/src/types.d.ts.map +1 -1
  111. package/lib/src/types.js +102 -97
  112. package/lib/src/types.js.map +1 -1
  113. package/lib/src/utils/processData.d.ts +1 -1
  114. package/lib/src/utils/processData.d.ts.map +1 -1
  115. package/lib/src/utils/processData.js +8 -8
  116. package/lib/src/utils/processData.js.map +1 -1
  117. package/lib/src/utils/processData.spec.js.map +1 -1
  118. package/lib/src/utils/processTrigger.d.ts +2 -1
  119. package/lib/src/utils/processTrigger.d.ts.map +1 -1
  120. package/lib/src/utils/processTrigger.js +4 -2
  121. package/lib/src/utils/processTrigger.js.map +1 -1
  122. package/package.json +3 -2
  123. package/src/embed/app.spec.ts +45 -0
  124. package/src/embed/app.ts +26 -4
  125. package/src/embed/hostEventClient/contracts.ts +0 -10
  126. package/src/embed/hostEventClient/host-event-client.ts +7 -3
  127. package/src/embed/search.ts +1 -3
  128. package/src/embed/ts-embed.spec.ts +7 -7
  129. package/src/embed/ts-embed.ts +33 -68
  130. package/src/index.ts +0 -2
  131. package/src/react/all-types-export.ts +0 -1
  132. package/src/types.ts +104 -145
  133. package/src/utils/processData.spec.ts +1 -0
  134. package/src/utils/processData.ts +11 -11
  135. package/src/utils/processTrigger.ts +5 -2
  136. package/cjs/src/api-intercept.d.ts +0 -31
  137. package/cjs/src/api-intercept.d.ts.map +0 -1
  138. package/cjs/src/api-intercept.js +0 -117
  139. package/cjs/src/api-intercept.js.map +0 -1
  140. package/cjs/src/api-intercept.spec.d.ts +0 -2
  141. package/cjs/src/api-intercept.spec.d.ts.map +0 -1
  142. package/cjs/src/api-intercept.spec.js +0 -122
  143. package/cjs/src/api-intercept.spec.js.map +0 -1
  144. package/dist/index-BCC3Z072.js +0 -7371
  145. package/dist/index-BEzW4MDA.js +0 -7371
  146. package/dist/index-BaESA9rq.js +0 -7371
  147. package/dist/index-CFNZIcKr.js +0 -7447
  148. package/dist/index-DFnPKcjZ.js +0 -7447
  149. package/dist/index-DhFH7b7U.js +0 -7447
  150. package/dist/src/api-intercept.d.ts +0 -31
  151. package/dist/src/api-intercept.d.ts.map +0 -1
  152. package/dist/src/api-intercept.spec.d.ts +0 -2
  153. package/dist/src/api-intercept.spec.d.ts.map +0 -1
  154. package/lib/src/api-intercept.d.ts +0 -31
  155. package/lib/src/api-intercept.d.ts.map +0 -1
  156. package/lib/src/api-intercept.js +0 -110
  157. package/lib/src/api-intercept.js.map +0 -1
  158. package/lib/src/api-intercept.spec.d.ts +0 -2
  159. package/lib/src/api-intercept.spec.d.ts.map +0 -1
  160. package/lib/src/api-intercept.spec.js +0 -119
  161. package/lib/src/api-intercept.spec.js.map +0 -1
  162. package/src/api-intercept.ts +0 -136
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.42.1-alpha.6",
3
+ "version": "1.42.1",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
@@ -57,7 +57,7 @@
57
57
  "test": "npm run test-sdk",
58
58
  "posttest": "cat ./coverage/sdk/lcov.info | npx coveralls-next",
59
59
  "is-publish-allowed": "node scripts/is-publish-allowed.js",
60
- "prepublishOnly": "npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build",
60
+ "prepublishOnly": "npm run is-publish-allowed && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build",
61
61
  "check-size": "npm run build && size-limit",
62
62
  "publish-dev": "npm publish --tag dev",
63
63
  "publish-prod": "npm publish --tag latest",
@@ -92,6 +92,7 @@
92
92
  "@testing-library/user-event": "^13.1.8",
93
93
  "@types/jest": "^22.2.3",
94
94
  "@types/lodash": "^4.17.0",
95
+ "@types/mixpanel-browser": "^2.35.6",
95
96
  "@types/react-test-renderer": "^17.0.1",
96
97
  "@typescript-eslint/eslint-plugin": "^8.28.0",
97
98
  "@typescript-eslint/parser": "^8.28.0",
@@ -430,6 +430,51 @@ describe('App embed tests', () => {
430
430
  });
431
431
  });
432
432
 
433
+ test('Should add the hideTagFilterChips true to the iframe src', async () => {
434
+ const appEmbed = new AppEmbed(getRootEl(), {
435
+ ...defaultViewConfig,
436
+ showPrimaryNavbar: false,
437
+ hideTagFilterChips: true,
438
+ } as AppViewConfig);
439
+
440
+ appEmbed.render();
441
+ await executeAfterWait(() => {
442
+ expectUrlMatchesWithParams(
443
+ getIFrameSrc(),
444
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}&hideTagFilterChips=true${defaultParamsPost}#/home`,
445
+ );
446
+ });
447
+ });
448
+
449
+ test('Should add the hideTagFilterChips false to the iframe src', async () => {
450
+ const appEmbed = new AppEmbed(getRootEl(), {
451
+ ...defaultViewConfig,
452
+ showPrimaryNavbar: false,
453
+ hideTagFilterChips: false,
454
+ } as AppViewConfig);
455
+ appEmbed.render();
456
+ await executeAfterWait(() => {
457
+ expectUrlMatchesWithParams(
458
+ getIFrameSrc(),
459
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}&hideTagFilterChips=false${defaultParamsPost}#/home`,
460
+ );
461
+ });
462
+ });
463
+
464
+ test('Should not add hideTagFilterChips if it is undefined', async () => {
465
+ const appEmbed = new AppEmbed(getRootEl(), {
466
+ ...defaultViewConfig,
467
+ showPrimaryNavbar: false,
468
+ } as AppViewConfig);
469
+ appEmbed.render();
470
+ await executeAfterWait(() => {
471
+ expectUrlMatchesWithParams(
472
+ getIFrameSrc(),
473
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false${defaultParams}${defaultParamsPost}#/home`,
474
+ );
475
+ });
476
+ });
477
+
433
478
  test('Should add enableSearchAssist flagto the iframe src', async () => {
434
479
  const appEmbed = new AppEmbed(getRootEl(), {
435
480
  ...defaultViewConfig,
package/src/embed/app.ts CHANGED
@@ -19,7 +19,6 @@ import {
19
19
  AllEmbedViewConfig,
20
20
  } from '../types';
21
21
  import { V1Embed } from './ts-embed';
22
- import { getInterceptInitData } from '../api-intercept';
23
22
 
24
23
  /**
25
24
  * Pages within the ThoughtSpot app that can be embedded.
@@ -368,6 +367,26 @@ export interface AppViewConfig extends AllEmbedViewConfig {
368
367
  * ```
369
368
  */
370
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;
371
390
  /**
372
391
  * The array of GUIDs to be hidden
373
392
  *
@@ -626,6 +645,7 @@ export class AppEmbed extends V1Embed {
626
645
  protected getEmbedParams() {
627
646
  const {
628
647
  tag,
648
+ hideTagFilterChips,
629
649
  hideObjects,
630
650
  liveboardV2,
631
651
  showPrimaryNavbar,
@@ -729,9 +749,7 @@ export class AppEmbed extends V1Embed {
729
749
  params[Param.enableAskSage] = enableAskSage;
730
750
  }
731
751
 
732
- const { enableApiIntercept } = getInterceptInitData(this.embedConfig, this.viewConfig);
733
-
734
- if (isOnBeforeGetVizDataInterceptEnabled && !enableApiIntercept) {
752
+ if (isOnBeforeGetVizDataInterceptEnabled) {
735
753
 
736
754
  params[
737
755
  Param.IsOnBeforeGetVizDataInterceptEnabled
@@ -753,6 +771,10 @@ export class AppEmbed extends V1Embed {
753
771
  if (isPNGInScheduledEmailsEnabled !== undefined) {
754
772
  params[Param.isPNGInScheduledEmailsEnabled] = isPNGInScheduledEmailsEnabled;
755
773
  }
774
+
775
+ if (hideTagFilterChips !== undefined) {
776
+ params[Param.HideTagFilterChips] = hideTagFilterChips;
777
+ }
756
778
 
757
779
  if (isLinkParametersEnabled !== undefined) {
758
780
  params[Param.isLinkParametersEnabled] = isLinkParametersEnabled;
@@ -7,7 +7,6 @@ export enum UIPassthroughEvent {
7
7
  GetAvailableUIPassthroughs = 'getAvailableUiPassthroughs',
8
8
  GetAnswerConfig = 'getAnswerPageConfig',
9
9
  GetLiveboardConfig = 'getPinboardPageConfig',
10
- GetUnsavedAnswerTML = 'getUnsavedAnswerTML',
11
10
  }
12
11
 
13
12
  // UI Passthrough Contract
@@ -64,15 +63,6 @@ export type UIPassthroughContractBase = {
64
63
  request: any;
65
64
  response: any;
66
65
  };
67
- [UIPassthroughEvent.GetUnsavedAnswerTML]: {
68
- request: {
69
- sessionId?: string;
70
- vizId?: string;
71
- };
72
- response: {
73
- tml: string;
74
- };
75
- };
76
66
  };
77
67
 
78
68
  // UI Passthrough Request and Response
@@ -23,7 +23,7 @@ export class HostEventClient {
23
23
  * @param {any} data Data to send with the host event
24
24
  * @returns {Promise<any>} - the response from the process trigger
25
25
  */
26
- protected async processTrigger(message: HostEvent, data: any): Promise<any> {
26
+ protected async processTrigger(message: HostEvent, data: any, context?: any): Promise<any> {
27
27
  if (!this.iFrame) {
28
28
  throw new Error('Iframe element is not set');
29
29
  }
@@ -34,6 +34,7 @@ export class HostEventClient {
34
34
  message,
35
35
  thoughtspotHost,
36
36
  data,
37
+ context,
37
38
  );
38
39
  }
39
40
 
@@ -65,8 +66,9 @@ export class HostEventClient {
65
66
  public async hostEventFallback(
66
67
  hostEvent: HostEvent,
67
68
  data: any,
69
+ context?: any,
68
70
  ): Promise<any> {
69
- return this.processTrigger(hostEvent, data);
71
+ return this.processTrigger(hostEvent, data, context);
70
72
  }
71
73
 
72
74
  /**
@@ -132,9 +134,11 @@ export class HostEventClient {
132
134
  public async triggerHostEvent<
133
135
  HostEventT extends HostEvent,
134
136
  PayloadT,
137
+ ContextT,
135
138
  >(
136
139
  hostEvent: HostEventT,
137
140
  payload?: TriggerPayload<PayloadT, HostEventT>,
141
+ context?: ContextT,
138
142
  ): Promise<TriggerResponse<PayloadT, HostEventT>> {
139
143
  switch (hostEvent) {
140
144
  case HostEvent.Pin:
@@ -144,7 +148,7 @@ export class HostEventClient {
144
148
  payload as HostEventRequest<HostEvent.SaveAnswer>,
145
149
  ) as any;
146
150
  default:
147
- return this.hostEventFallback(hostEvent, payload);
151
+ return this.hostEventFallback(hostEvent, payload, context as any);
148
152
  }
149
153
  }
150
154
  }
@@ -26,7 +26,6 @@ import { ERROR_MESSAGE } from '../errors';
26
26
  import { getAuthPromise } from './base';
27
27
  import { getReleaseVersion } from '../auth';
28
28
  import { getEmbedConfig } from './embedConfig';
29
- import { getInterceptInitData } from '../api-intercept';
30
29
 
31
30
  /**
32
31
  * Configuration for search options.
@@ -443,8 +442,7 @@ export class SearchEmbed extends TsEmbed {
443
442
  queryParams[Param.HideSearchBar] = true;
444
443
  }
445
444
 
446
- const { enableApiIntercept } = getInterceptInitData(this.embedConfig, this.viewConfig);
447
- if (isOnBeforeGetVizDataInterceptEnabled && !enableApiIntercept) {
445
+ if (isOnBeforeGetVizDataInterceptEnabled) {
448
446
 
449
447
  queryParams[Param.IsOnBeforeGetVizDataInterceptEnabled] = isOnBeforeGetVizDataInterceptEnabled;
450
448
  }
@@ -1045,7 +1045,7 @@ describe('Unit test case for ts embed', () => {
1045
1045
  type: EmbedEvent.APP_INIT,
1046
1046
  data: {},
1047
1047
  };
1048
-
1048
+
1049
1049
  // Create a SearchEmbed with valid custom actions to test
1050
1050
  // CustomActionsValidationResult
1051
1051
  const searchEmbed = new SearchEmbed(getRootEl(), {
@@ -1067,7 +1067,7 @@ describe('Unit test case for ts embed', () => {
1067
1067
  }
1068
1068
  ]
1069
1069
  });
1070
-
1070
+
1071
1071
  searchEmbed.render();
1072
1072
  const mockPort: any = {
1073
1073
  postMessage: jest.fn(),
@@ -1116,7 +1116,7 @@ describe('Unit test case for ts embed', () => {
1116
1116
  customVariablesForThirdPartyTools: {},
1117
1117
  },
1118
1118
  });
1119
-
1119
+
1120
1120
  // Verify that CustomActionsValidationResult structure is
1121
1121
  // correct
1122
1122
  const appInitData = mockPort.postMessage.mock.calls[0][0].data;
@@ -1137,7 +1137,7 @@ describe('Unit test case for ts embed', () => {
1137
1137
  })
1138
1138
  ])
1139
1139
  );
1140
-
1140
+
1141
1141
  // Verify actions are sorted by name (alphabetically)
1142
1142
  expect(appInitData.customActions[0].name).toBe('Another Valid Action');
1143
1143
  expect(appInitData.customActions[1].name).toBe('Valid Action');
@@ -2488,7 +2488,7 @@ describe('Unit test case for ts embed', () => {
2488
2488
  });
2489
2489
 
2490
2490
  afterAll((): void => {
2491
- (window.location as any) = location;
2491
+ window.location = location as any;
2492
2492
  });
2493
2493
 
2494
2494
  it('get url params for TS', () => {
@@ -3406,7 +3406,7 @@ describe('Unit test case for ts embed', () => {
3406
3406
  new Error('Auth failed'),
3407
3407
  );
3408
3408
  const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
3409
- const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => { });
3409
+ const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
3410
3410
  await searchEmbed.render();
3411
3411
  await executeAfterWait(() => {
3412
3412
  expect(getRootEl().innerHTML).toContain('Not logged in');
@@ -3415,7 +3415,7 @@ describe('Unit test case for ts embed', () => {
3415
3415
  window.dispatchEvent(onlineEvent);
3416
3416
  }).not.toThrow();
3417
3417
  });
3418
-
3418
+
3419
3419
  errorSpy.mockReset();
3420
3420
  });
3421
3421
 
@@ -71,7 +71,6 @@ import { getEmbedConfig } from './embedConfig';
71
71
  import { ERROR_MESSAGE } from '../errors';
72
72
  import { getPreauthInfo } from '../utils/sessionInfoService';
73
73
  import { HostEventClient } from './hostEventClient/host-event-client';
74
- import { getInterceptInitData, handleInterceptEvent, processLegacyInterceptResponse } from '../api-intercept';
75
74
 
76
75
  const { version } = pkgInfo;
77
76
 
@@ -202,7 +201,7 @@ export class TsEmbed {
202
201
  });
203
202
  const embedConfig = getEmbedConfig();
204
203
  this.embedConfig = embedConfig;
205
-
204
+
206
205
  this.hostEventClient = new HostEventClient(this.iFrame);
207
206
  this.isReadyForRenderPromise = getInitPromise().then(async () => {
208
207
  if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
@@ -337,50 +336,33 @@ export class TsEmbed {
337
336
  this.subscribedListeners.offline = offlineEventListener;
338
337
  }
339
338
 
340
- private messageEventListener = async (event: MessageEvent<any>) => {
341
- const eventType = this.getEventType(event);
342
- const eventPort = this.getEventPort(event);
343
- const eventData = this.formatEventData(event, eventType);
344
- if (event.source === this.iFrame.contentWindow) {
345
- const processedEventData = await processEventData(
346
- eventType,
347
- eventData,
348
- this.thoughtSpotHost,
349
- this.isPreRendered ? this.preRenderWrapper : this.el,
350
- );
351
-
352
- const executeEvent = (_eventType: EmbedEvent, data: any) => {
353
- this.executeCallbacks(_eventType, data, eventPort);
354
- }
355
-
356
- if (eventType === EmbedEvent.ApiIntercept && this.viewConfig.enableApiIntercept) {
357
- const getUnsavedAnswerTml = async (props: { sessionId?: string, vizId?: string }) => {
358
- const response = await this.triggerUIPassThrough(UIPassthroughEvent.GetUnsavedAnswerTML, props);
359
- return response[0]?.value;
360
- }
361
- handleInterceptEvent({ eventData: processedEventData, executeEvent, embedConfig: this.embedConfig, viewConfig: this.viewConfig, getUnsavedAnswerTml });
362
- return;
363
- }
364
-
365
- this.executeCallbacks(
366
- eventType,
367
- processedEventData,
368
- eventPort,
369
- );
370
- }
371
- };
372
339
  /**
373
340
  * Subscribe to message events that depend on successful iframe setup
374
341
  */
375
342
  private subscribeToMessageEvents() {
376
343
  this.unsubscribeToMessageEvents();
377
344
 
378
- window.addEventListener('message', this.messageEventListener);
345
+ const messageEventListener = (event: MessageEvent<any>) => {
346
+ const eventType = this.getEventType(event);
347
+ const eventPort = this.getEventPort(event);
348
+ const eventData = this.formatEventData(event, eventType);
349
+ if (event.source === this.iFrame.contentWindow) {
350
+ this.executeCallbacks(
351
+ eventType,
352
+ processEventData(
353
+ eventType,
354
+ eventData,
355
+ this.thoughtSpotHost,
356
+ this.isPreRendered ? this.preRenderWrapper : this.el,
357
+ ),
358
+ eventPort,
359
+ );
360
+ }
361
+ };
362
+ window.addEventListener('message', messageEventListener);
379
363
 
380
- this.subscribedListeners.message = this.messageEventListener;
364
+ this.subscribedListeners.message = messageEventListener;
381
365
  }
382
-
383
-
384
366
  /**
385
367
  * Adds event listeners for both network and message events.
386
368
  * This maintains backward compatibility with the existing method.
@@ -394,7 +376,6 @@ export class TsEmbed {
394
376
  this.subscribeToMessageEvents();
395
377
  }
396
378
 
397
-
398
379
  private unsubscribeToNetworkEvents() {
399
380
  if (this.subscribedListeners.online) {
400
381
  window.removeEventListener('online', this.subscribedListeners.online);
@@ -445,7 +426,7 @@ export class TsEmbed {
445
426
  message: customActionsResult.errors,
446
427
  });
447
428
  }
448
- const baseInitData = {
429
+ return {
449
430
  customisations: getCustomisations(this.embedConfig, this.viewConfig),
450
431
  authToken,
451
432
  runtimeFilterParams: this.viewConfig.excludeRuntimeFiltersfromURL
@@ -464,10 +445,7 @@ export class TsEmbed {
464
445
  this.embedConfig.customVariablesForThirdPartyTools || {},
465
446
  hiddenListColumns: this.viewConfig.hiddenListColumns || [],
466
447
  customActions: customActionsResult.actions,
467
- ...getInterceptInitData(this.embedConfig, this.viewConfig),
468
448
  };
469
-
470
- return baseInitData;
471
449
  }
472
450
 
473
451
  protected async getAppInitData() {
@@ -1045,21 +1023,6 @@ export class TsEmbed {
1045
1023
  this.iFrame.style.height = getCssDimension(height);
1046
1024
  }
1047
1025
 
1048
- protected createEmbedEventResponder = (eventPort: MessagePort | void, eventType: EmbedEvent) => {
1049
-
1050
- const { enableApiIntercept } = getInterceptInitData(this.embedConfig, this.viewConfig);
1051
- if (eventType === EmbedEvent.OnBeforeGetVizDataIntercept && enableApiIntercept) {
1052
- return (payload: any) => {
1053
- const payloadToSend = processLegacyInterceptResponse(payload);
1054
- this.triggerEventOnPort(eventPort, payloadToSend);
1055
- }
1056
- }
1057
-
1058
- return (payload: any) => {
1059
- this.triggerEventOnPort(eventPort, payload);
1060
- }
1061
- }
1062
-
1063
1026
  /**
1064
1027
  * Executes all registered event handlers for a particular event type
1065
1028
  * @param eventType The event type
@@ -1084,8 +1047,9 @@ export class TsEmbed {
1084
1047
  // payload
1085
1048
  || (!callbackObj.options.start && dataStatus === embedEventStatus.END)
1086
1049
  ) {
1087
- const responder = this.createEmbedEventResponder(eventPort, eventType);
1088
- callbackObj.callback(data, responder);
1050
+ callbackObj.callback(data, (payload) => {
1051
+ this.triggerEventOnPort(eventPort, payload);
1052
+ });
1089
1053
  }
1090
1054
  });
1091
1055
  }
@@ -1227,12 +1191,12 @@ export class TsEmbed {
1227
1191
  }
1228
1192
  }
1229
1193
 
1230
- /**
1231
- * @hidden
1232
- * Internal state to track if the embed container is loaded.
1233
- * This is used to trigger events after the embed container is loaded.
1234
- */
1235
- public isEmbedContainerLoaded = false;
1194
+ /**
1195
+ * @hidden
1196
+ * Internal state to track if the embed container is loaded.
1197
+ * This is used to trigger events after the embed container is loaded.
1198
+ */
1199
+ public isEmbedContainerLoaded = false;
1236
1200
 
1237
1201
  /**
1238
1202
  * @hidden
@@ -1307,6 +1271,7 @@ export class TsEmbed {
1307
1271
  public async trigger<HostEventT extends HostEvent, PayloadT>(
1308
1272
  messageType: HostEventT,
1309
1273
  data: TriggerPayload<PayloadT, HostEventT> = {} as any,
1274
+ context: any = {},
1310
1275
  ): Promise<TriggerResponse<PayloadT, HostEventT>> {
1311
1276
  uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_TRIGGER}-${messageType}`);
1312
1277
 
@@ -1330,7 +1295,7 @@ export class TsEmbed {
1330
1295
  }
1331
1296
 
1332
1297
  // send an empty object, this is needed for liveboard default handlers
1333
- return this.hostEventClient.triggerHostEvent(messageType, data);
1298
+ return this.hostEventClient.triggerHostEvent(messageType, data, context);
1334
1299
  }
1335
1300
 
1336
1301
  /**
@@ -1384,7 +1349,7 @@ export class TsEmbed {
1384
1349
  }
1385
1350
  this.isPreRendered = true;
1386
1351
  this.showPreRenderByDefault = showPreRenderByDefault;
1387
-
1352
+
1388
1353
  const isAlreadyRendered = this.connectPreRendered();
1389
1354
  if (isAlreadyRendered && !replaceExistingPreRender) {
1390
1355
  return this;
package/src/index.ts CHANGED
@@ -64,7 +64,6 @@ import {
64
64
  ListPageColumns,
65
65
  CustomActionsPosition,
66
66
  CustomActionTarget,
67
- InterceptedApiType,
68
67
  } from './types';
69
68
  import { CustomCssVariables } from './css-variables';
70
69
  import { SageEmbed, SageViewConfig } from './embed/sage';
@@ -153,7 +152,6 @@ export {
153
152
  DataPanelCustomColumnGroupsAccordionState,
154
153
  CustomActionsPosition,
155
154
  CustomActionTarget,
156
- InterceptedApiType,
157
155
  };
158
156
 
159
157
  export { resetCachedAuthToken } from './authToken';
@@ -59,5 +59,4 @@ export {
59
59
  resetCachedAuthToken,
60
60
  UIPassthroughEvent,
61
61
  DataPanelCustomColumnGroupsAccordionState,
62
- InterceptedApiType,
63
62
  } from '../index';