@thoughtspot/visual-embed-sdk 1.36.2 → 1.36.4

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 (271) hide show
  1. package/cjs/package.json +1 -1
  2. package/cjs/src/authToken.d.ts.map +1 -1
  3. package/cjs/src/authToken.js +10 -3
  4. package/cjs/src/authToken.js.map +1 -1
  5. package/cjs/src/embed/app.d.ts +14 -0
  6. package/cjs/src/embed/app.d.ts.map +1 -1
  7. package/cjs/src/embed/app.js +5 -2
  8. package/cjs/src/embed/app.js.map +1 -1
  9. package/cjs/src/embed/app.spec.js +17 -0
  10. package/cjs/src/embed/app.spec.js.map +1 -1
  11. package/cjs/src/embed/base.d.ts +4 -0
  12. package/cjs/src/embed/base.d.ts.map +1 -1
  13. package/cjs/src/embed/base.js +27 -1
  14. package/cjs/src/embed/base.js.map +1 -1
  15. package/cjs/src/embed/bodyless-conversation.d.ts.map +1 -1
  16. package/cjs/src/embed/bodyless-conversation.js +1 -1
  17. package/cjs/src/embed/bodyless-conversation.js.map +1 -1
  18. package/cjs/src/embed/conversation.d.ts.map +1 -1
  19. package/cjs/src/embed/conversation.js +1 -1
  20. package/cjs/src/embed/conversation.js.map +1 -1
  21. package/cjs/src/embed/embedConfig.d.ts +1 -1
  22. package/cjs/src/embed/embedConfig.d.ts.map +1 -1
  23. package/cjs/src/embed/embedConfig.js +5 -4
  24. package/cjs/src/embed/embedConfig.js.map +1 -1
  25. package/cjs/src/embed/liveboard.d.ts +6 -3
  26. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  27. package/cjs/src/embed/liveboard.js +4 -5
  28. package/cjs/src/embed/liveboard.js.map +1 -1
  29. package/cjs/src/embed/liveboard.spec.js +11 -11
  30. package/cjs/src/embed/liveboard.spec.js.map +1 -1
  31. package/cjs/src/embed/sage.d.ts.map +1 -1
  32. package/cjs/src/embed/sage.js +1 -1
  33. package/cjs/src/embed/sage.js.map +1 -1
  34. package/cjs/src/embed/search-bar.d.ts.map +1 -1
  35. package/cjs/src/embed/search-bar.js +1 -1
  36. package/cjs/src/embed/search-bar.js.map +1 -1
  37. package/cjs/src/embed/search.d.ts.map +1 -1
  38. package/cjs/src/embed/search.js +1 -1
  39. package/cjs/src/embed/search.js.map +1 -1
  40. package/cjs/src/embed/ts-embed.d.ts +4 -3
  41. package/cjs/src/embed/ts-embed.d.ts.map +1 -1
  42. package/cjs/src/embed/ts-embed.js +25 -16
  43. package/cjs/src/embed/ts-embed.js.map +1 -1
  44. package/cjs/src/embed/ts-embed.spec.d.ts.map +1 -1
  45. package/cjs/src/embed/ts-embed.spec.js +71 -5
  46. package/cjs/src/embed/ts-embed.spec.js.map +1 -1
  47. package/cjs/src/errors.d.ts +1 -0
  48. package/cjs/src/errors.d.ts.map +1 -1
  49. package/cjs/src/errors.js +1 -0
  50. package/cjs/src/errors.js.map +1 -1
  51. package/cjs/src/react/all-types-export.d.ts +1 -1
  52. package/cjs/src/react/all-types-export.d.ts.map +1 -1
  53. package/cjs/src/react/all-types-export.js +2 -1
  54. package/cjs/src/react/all-types-export.js.map +1 -1
  55. package/cjs/src/react/index.d.ts +16 -0
  56. package/cjs/src/react/index.d.ts.map +1 -1
  57. package/cjs/src/react/index.js +25 -2
  58. package/cjs/src/react/index.js.map +1 -1
  59. package/cjs/src/types.d.ts +85 -66
  60. package/cjs/src/types.d.ts.map +1 -1
  61. package/cjs/src/types.js +78 -59
  62. package/cjs/src/types.js.map +1 -1
  63. package/cjs/src/utils/with-resolvers-polyfill.d.ts +1 -0
  64. package/cjs/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  65. package/cjs/src/utils/with-resolvers-polyfill.js +12 -0
  66. package/cjs/src/utils/with-resolvers-polyfill.js.map +1 -0
  67. package/cjs/src/utils.d.ts +27 -0
  68. package/cjs/src/utils.d.ts.map +1 -1
  69. package/cjs/src/utils.js +45 -1
  70. package/cjs/src/utils.js.map +1 -1
  71. package/cjs/src/utils.spec.js +15 -0
  72. package/cjs/src/utils.spec.js.map +1 -1
  73. package/dist/{index-B3hd6DTM.js → index-NZYq1Tu3.js} +1 -1
  74. package/dist/src/authToken.d.ts.map +1 -1
  75. package/dist/src/embed/app.d.ts +14 -0
  76. package/dist/src/embed/app.d.ts.map +1 -1
  77. package/dist/src/embed/base.d.ts +4 -0
  78. package/dist/src/embed/base.d.ts.map +1 -1
  79. package/dist/src/embed/bodyless-conversation.d.ts.map +1 -1
  80. package/dist/src/embed/conversation.d.ts.map +1 -1
  81. package/dist/src/embed/embedConfig.d.ts +1 -1
  82. package/dist/src/embed/embedConfig.d.ts.map +1 -1
  83. package/dist/src/embed/liveboard.d.ts +6 -3
  84. package/dist/src/embed/liveboard.d.ts.map +1 -1
  85. package/dist/src/embed/sage.d.ts.map +1 -1
  86. package/dist/src/embed/search-bar.d.ts.map +1 -1
  87. package/dist/src/embed/search.d.ts.map +1 -1
  88. package/dist/src/embed/ts-embed.d.ts +4 -3
  89. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  90. package/dist/src/embed/ts-embed.spec.d.ts.map +1 -1
  91. package/dist/src/errors.d.ts +1 -0
  92. package/dist/src/errors.d.ts.map +1 -1
  93. package/dist/src/react/all-types-export.d.ts +1 -1
  94. package/dist/src/react/all-types-export.d.ts.map +1 -1
  95. package/dist/src/react/index.d.ts +16 -0
  96. package/dist/src/react/index.d.ts.map +1 -1
  97. package/dist/src/types.d.ts +85 -66
  98. package/dist/src/types.d.ts.map +1 -1
  99. package/dist/src/utils/with-resolvers-polyfill.d.ts +1 -0
  100. package/dist/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  101. package/dist/src/utils.d.ts +27 -0
  102. package/dist/src/utils.d.ts.map +1 -1
  103. package/dist/tsembed-react.es.js +458 -108
  104. package/dist/tsembed-react.js +456 -105
  105. package/dist/tsembed.es.js +197 -98
  106. package/dist/tsembed.js +196 -97
  107. package/dist/visual-embed-sdk-react-full.d.ts +1324 -1269
  108. package/dist/visual-embed-sdk-react.d.ts +814 -759
  109. package/dist/visual-embed-sdk.d.ts +113 -72
  110. package/lib/package.json +1 -1
  111. package/lib/src/authToken.d.ts.map +1 -1
  112. package/lib/src/authToken.js +10 -3
  113. package/lib/src/authToken.js.map +1 -1
  114. package/lib/src/embed/app.d.ts +14 -0
  115. package/lib/src/embed/app.d.ts.map +1 -1
  116. package/lib/src/embed/app.js +5 -2
  117. package/lib/src/embed/app.js.map +1 -1
  118. package/lib/src/embed/app.spec.js +17 -0
  119. package/lib/src/embed/app.spec.js.map +1 -1
  120. package/lib/src/embed/base.d.ts +4 -0
  121. package/lib/src/embed/base.d.ts.map +1 -1
  122. package/lib/src/embed/base.js +24 -1
  123. package/lib/src/embed/base.js.map +1 -1
  124. package/lib/src/embed/bodyless-conversation.d.ts.map +1 -1
  125. package/lib/src/embed/bodyless-conversation.js +1 -1
  126. package/lib/src/embed/bodyless-conversation.js.map +1 -1
  127. package/lib/src/embed/conversation.d.ts.map +1 -1
  128. package/lib/src/embed/conversation.js +1 -1
  129. package/lib/src/embed/conversation.js.map +1 -1
  130. package/lib/src/embed/embedConfig.d.ts +1 -1
  131. package/lib/src/embed/embedConfig.d.ts.map +1 -1
  132. package/lib/src/embed/embedConfig.js +5 -4
  133. package/lib/src/embed/embedConfig.js.map +1 -1
  134. package/lib/src/embed/liveboard.d.ts +6 -3
  135. package/lib/src/embed/liveboard.d.ts.map +1 -1
  136. package/lib/src/embed/liveboard.js +4 -5
  137. package/lib/src/embed/liveboard.js.map +1 -1
  138. package/lib/src/embed/liveboard.spec.js +11 -11
  139. package/lib/src/embed/liveboard.spec.js.map +1 -1
  140. package/lib/src/embed/sage.d.ts.map +1 -1
  141. package/lib/src/embed/sage.js +1 -1
  142. package/lib/src/embed/sage.js.map +1 -1
  143. package/lib/src/embed/search-bar.d.ts.map +1 -1
  144. package/lib/src/embed/search-bar.js +1 -1
  145. package/lib/src/embed/search-bar.js.map +1 -1
  146. package/lib/src/embed/search.d.ts.map +1 -1
  147. package/lib/src/embed/search.js +1 -1
  148. package/lib/src/embed/search.js.map +1 -1
  149. package/lib/src/embed/ts-embed.d.ts +4 -3
  150. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  151. package/lib/src/embed/ts-embed.js +26 -17
  152. package/lib/src/embed/ts-embed.js.map +1 -1
  153. package/lib/src/embed/ts-embed.spec.d.ts.map +1 -1
  154. package/lib/src/embed/ts-embed.spec.js +71 -5
  155. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  156. package/lib/src/errors.d.ts +1 -0
  157. package/lib/src/errors.d.ts.map +1 -1
  158. package/lib/src/errors.js +1 -0
  159. package/lib/src/errors.js.map +1 -1
  160. package/lib/src/react/all-types-export.d.ts +1 -1
  161. package/lib/src/react/all-types-export.d.ts.map +1 -1
  162. package/lib/src/react/all-types-export.js +1 -1
  163. package/lib/src/react/all-types-export.js.map +1 -1
  164. package/lib/src/react/index.d.ts +16 -0
  165. package/lib/src/react/index.d.ts.map +1 -1
  166. package/lib/src/react/index.js +23 -1
  167. package/lib/src/react/index.js.map +1 -1
  168. package/lib/src/types.d.ts +85 -66
  169. package/lib/src/types.d.ts.map +1 -1
  170. package/lib/src/types.js +78 -59
  171. package/lib/src/types.js.map +1 -1
  172. package/lib/src/utils/with-resolvers-polyfill.d.ts +1 -0
  173. package/lib/src/utils/with-resolvers-polyfill.d.ts.map +1 -0
  174. package/lib/src/utils/with-resolvers-polyfill.js +12 -0
  175. package/lib/src/utils/with-resolvers-polyfill.js.map +1 -0
  176. package/lib/src/utils.d.ts +27 -0
  177. package/lib/src/utils.d.ts.map +1 -1
  178. package/lib/src/utils.js +41 -0
  179. package/lib/src/utils.js.map +1 -1
  180. package/lib/src/utils.spec.js +16 -1
  181. package/lib/src/utils.spec.js.map +1 -1
  182. package/lib/src/visual-embed-sdk.d.ts +114 -73
  183. package/package.json +1 -1
  184. package/src/authToken.ts +11 -3
  185. package/src/embed/app.spec.ts +27 -0
  186. package/src/embed/app.ts +21 -1
  187. package/src/embed/base.ts +41 -1
  188. package/src/embed/bodyless-conversation.ts +2 -1
  189. package/src/embed/conversation.ts +2 -1
  190. package/src/embed/embedConfig.ts +5 -4
  191. package/src/embed/liveboard.spec.ts +11 -11
  192. package/src/embed/liveboard.ts +9 -7
  193. package/src/embed/sage.ts +1 -2
  194. package/src/embed/search-bar.tsx +1 -2
  195. package/src/embed/search.ts +1 -2
  196. package/src/embed/ts-embed.spec.ts +83 -5
  197. package/src/embed/ts-embed.ts +33 -17
  198. package/src/errors.ts +1 -0
  199. package/src/react/all-types-export.ts +1 -0
  200. package/src/react/index.tsx +27 -2
  201. package/src/types.ts +89 -70
  202. package/src/utils/with-resolvers-polyfill.ts +11 -0
  203. package/src/utils.spec.ts +21 -0
  204. package/src/utils.ts +52 -0
  205. package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
  206. package/cjs/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
  207. package/cjs/src/embed/searchEmbed-basic-auth.spec.js +0 -104
  208. package/cjs/src/embed/searchEmbed-basic-auth.spec.js.map +0 -1
  209. package/cjs/src/hostEventsTypeMapping.d.ts +0 -2
  210. package/cjs/src/hostEventsTypeMapping.d.ts.map +0 -1
  211. package/cjs/src/hostEventsTypeMapping.js +0 -4
  212. package/cjs/src/hostEventsTypeMapping.js.map +0 -1
  213. package/cjs/src/utils/embedApi/contracts.d.ts +0 -101
  214. package/cjs/src/utils/embedApi/contracts.d.ts.map +0 -1
  215. package/cjs/src/utils/embedApi/contracts.js +0 -17
  216. package/cjs/src/utils/embedApi/contracts.js.map +0 -1
  217. package/cjs/src/utils/embedApi/embedApiClient.d.ts +0 -12
  218. package/cjs/src/utils/embedApi/embedApiClient.d.ts.map +0 -1
  219. package/cjs/src/utils/embedApi/embedApiClient.js +0 -46
  220. package/cjs/src/utils/embedApi/embedApiClient.js.map +0 -1
  221. package/cjs/src/utils/embedApi/processEmbedApi.d.ts +0 -9
  222. package/cjs/src/utils/embedApi/processEmbedApi.d.ts.map +0 -1
  223. package/cjs/src/utils/embedApi/processEmbedApi.js +0 -18
  224. package/cjs/src/utils/embedApi/processEmbedApi.js.map +0 -1
  225. package/dist/index-BBBimG1x.js +0 -7370
  226. package/dist/index-BGnxP5NY.js +0 -7370
  227. package/dist/index-CENLvayL.js +0 -7370
  228. package/dist/index-CR5u7BMC.js +0 -7370
  229. package/dist/index-CbltIawo.js +0 -7370
  230. package/dist/index-CoQfqaHj.js +0 -7370
  231. package/dist/index-CzwzS0P4.js +0 -7370
  232. package/dist/index-D-9WUCUl.js +0 -7370
  233. package/dist/index-DFwi_pV_.js +0 -7370
  234. package/dist/index-DOIjN0N_.js +0 -7370
  235. package/dist/index-DYBx8SuE.js +0 -7370
  236. package/dist/index-DaLHJaLd.js +0 -7370
  237. package/dist/index-DnJX-gN2.js +0 -7370
  238. package/dist/index-DpuhnTj2.js +0 -7370
  239. package/dist/index-IDmSUe93.js +0 -7370
  240. package/dist/index-nWevLycs.js +0 -7370
  241. package/dist/index-vxW97_xb.js +0 -7370
  242. package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
  243. package/dist/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
  244. package/dist/src/hostEventsTypeMapping.d.ts +0 -2
  245. package/dist/src/hostEventsTypeMapping.d.ts.map +0 -1
  246. package/dist/src/utils/embedApi/contracts.d.ts +0 -101
  247. package/dist/src/utils/embedApi/contracts.d.ts.map +0 -1
  248. package/dist/src/utils/embedApi/embedApiClient.d.ts +0 -12
  249. package/dist/src/utils/embedApi/embedApiClient.d.ts.map +0 -1
  250. package/dist/src/utils/embedApi/processEmbedApi.d.ts +0 -9
  251. package/dist/src/utils/embedApi/processEmbedApi.d.ts.map +0 -1
  252. package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts +0 -2
  253. package/lib/src/embed/searchEmbed-basic-auth.spec.d.ts.map +0 -1
  254. package/lib/src/embed/searchEmbed-basic-auth.spec.js +0 -101
  255. package/lib/src/embed/searchEmbed-basic-auth.spec.js.map +0 -1
  256. package/lib/src/hostEventsTypeMapping.d.ts +0 -2
  257. package/lib/src/hostEventsTypeMapping.d.ts.map +0 -1
  258. package/lib/src/hostEventsTypeMapping.js +0 -2
  259. package/lib/src/hostEventsTypeMapping.js.map +0 -1
  260. package/lib/src/utils/embedApi/contracts.d.ts +0 -101
  261. package/lib/src/utils/embedApi/contracts.d.ts.map +0 -1
  262. package/lib/src/utils/embedApi/contracts.js +0 -14
  263. package/lib/src/utils/embedApi/contracts.js.map +0 -1
  264. package/lib/src/utils/embedApi/embedApiClient.d.ts +0 -12
  265. package/lib/src/utils/embedApi/embedApiClient.d.ts.map +0 -1
  266. package/lib/src/utils/embedApi/embedApiClient.js +0 -42
  267. package/lib/src/utils/embedApi/embedApiClient.js.map +0 -1
  268. package/lib/src/utils/embedApi/processEmbedApi.d.ts +0 -9
  269. package/lib/src/utils/embedApi/processEmbedApi.d.ts.map +0 -1
  270. package/lib/src/utils/embedApi/processEmbedApi.js +0 -14
  271. package/lib/src/utils/embedApi/processEmbedApi.js.map +0 -1
package/src/embed/app.ts CHANGED
@@ -137,6 +137,20 @@ export interface AppViewConfig extends Omit<ViewConfig, 'visibleTabs'> {
137
137
  * ```
138
138
  */
139
139
  disableProfileAndHelp?: boolean;
140
+ /**
141
+ * @version SDK: 1.36.3 | ThoughtSpot: 10.1.0.cl
142
+ * @default true
143
+ * Whether the help menu in the top nav bar should be served
144
+ * from Pendo or ThoughtSpot's internal help items.
145
+ * @example
146
+ * ```js
147
+ * const embed = new AppEmbed('#tsEmbed', {
148
+ * ... // other options
149
+ * enablePendoHelp: false,
150
+ * });
151
+ * ```
152
+ */
153
+ enablePendoHelp?: boolean
140
154
  /**
141
155
  * Control the visibility of the application switcher button on the nav-bar.
142
156
  * By default, the application switcher is shown.
@@ -526,6 +540,7 @@ export class AppEmbed extends V1Embed {
526
540
  hideIrrelevantChipsInLiveboardTabs = false,
527
541
  homePageSearchBarMode,
528
542
  isUnifiedSearchExperienceEnabled = true,
543
+ enablePendoHelp = true,
529
544
  } = this.viewConfig;
530
545
 
531
546
  let params = {};
@@ -583,6 +598,10 @@ export class AppEmbed extends V1Embed {
583
598
  params[Param.HomePageSearchBarMode] = homePageSearchBarMode;
584
599
  }
585
600
 
601
+ if (enablePendoHelp !== undefined) {
602
+ params[Param.EnablePendoHelp] = enablePendoHelp;
603
+ }
604
+
586
605
  params[Param.DataPanelV2Enabled] = dataPanelV2;
587
606
  params[Param.HideHomepageLeftNav] = hideHomepageLeftNav;
588
607
  params[Param.ModularHomeExperienceEnabled] = modularHomeExperience;
@@ -742,7 +761,8 @@ export class AppEmbed extends V1Embed {
742
761
  * to be embedded.
743
762
  */
744
763
  public async render(): Promise<AppEmbed> {
745
- super.render();
764
+ await super.render();
765
+
746
766
  const src = this.getIFrameSrc();
747
767
  await this.renderV1Embed(src);
748
768
 
package/src/embed/base.ts CHANGED
@@ -30,9 +30,10 @@ import {
30
30
  AuthEventEmitter,
31
31
  postLoginService,
32
32
  } from '../auth';
33
+ import '../utils/with-resolvers-polyfill';
33
34
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
34
35
  import { getEmbedConfig, setEmbedConfig } from './embedConfig';
35
- import { getQueryParamString } from '../utils';
36
+ import { getQueryParamString, getValueFromWindow, storeValueInWindow } from '../utils';
36
37
  import { resetAllCachedServices } from '../utils/resetServices';
37
38
 
38
39
  const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
@@ -171,6 +172,40 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
171
172
  return newConfig;
172
173
  }
173
174
 
175
+ type InitFlagStore = {
176
+ initPromise: Promise<ReturnType<typeof init>>;
177
+ isInitCalled: boolean;
178
+ initPromiseResolve: (value: ReturnType<typeof init>) => void;
179
+ }
180
+ const initFlagKey = 'initFlagKey';
181
+
182
+ export const createAndSetInitPromise = (): void => {
183
+ const {
184
+ promise: initPromise,
185
+ resolve: initPromiseResolve,
186
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
187
+ // @ts-ignore
188
+ } = Promise.withResolvers<AuthEventEmitter>();
189
+ const initFlagStore: InitFlagStore = {
190
+ initPromise,
191
+ isInitCalled: false,
192
+ initPromiseResolve,
193
+ };
194
+ storeValueInWindow(initFlagKey, initFlagStore, {
195
+ // In case of diff imports the promise might be already set
196
+ ignoreIfAlreadyExists: true,
197
+ });
198
+ };
199
+
200
+ createAndSetInitPromise();
201
+
202
+ export const getInitPromise = ():
203
+ Promise<
204
+ ReturnType<typeof init>
205
+ > => getValueFromWindow<InitFlagStore>(initFlagKey)?.initPromise;
206
+
207
+ export const getIsInitCalled = (): boolean => !!getValueFromWindow(initFlagKey)?.isInitCalled;
208
+
174
209
  /**
175
210
  * Initializes the Visual Embed SDK globally and perform
176
211
  * authentication if applicable. This function needs to be called before any ThoughtSpot
@@ -223,6 +258,11 @@ export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
223
258
  if (getEmbedConfig().callPrefetch) {
224
259
  prefetch(getEmbedConfig().thoughtSpotHost);
225
260
  }
261
+
262
+ // Resolves the promise created in the initPromiseKey
263
+ getValueFromWindow<InitFlagStore>(initFlagKey).initPromiseResolve(authEE);
264
+ getValueFromWindow<InitFlagStore>(initFlagKey).isInitCalled = true;
265
+
226
266
  return authEE as AuthEventEmitter;
227
267
  };
228
268
 
@@ -55,7 +55,8 @@ class ConversationMessage extends TsEmbed {
55
55
  }
56
56
 
57
57
  public async render(): Promise<ConversationMessage> {
58
- super.render();
58
+ await super.render();
59
+
59
60
  const src = this.getIframeSrc();
60
61
  await this.renderIFrame(src);
61
62
  return this;
@@ -164,7 +164,8 @@ export class ConversationEmbed extends TsEmbed {
164
164
  }
165
165
 
166
166
  public async render(): Promise<ConversationEmbed> {
167
- super.render();
167
+ await super.render();
168
+
168
169
  const src = this.getIframeSrc();
169
170
  await this.renderIFrame(src);
170
171
  return this;
@@ -1,6 +1,7 @@
1
+ import { getValueFromWindow, storeValueInWindow } from '../utils';
1
2
  import { EmbedConfig } from '../types';
2
3
 
3
- let config = {} as EmbedConfig;
4
+ const configKey = 'embedConfig';
4
5
 
5
6
  /**
6
7
  * Gets the configuration embed was initialized with.
@@ -8,7 +9,7 @@ let config = {} as EmbedConfig;
8
9
  * @version SDK: 1.19.0 | ThoughtSpot: *
9
10
  * @group Global methods
10
11
  */
11
- export const getEmbedConfig = (): EmbedConfig => config;
12
+ export const getEmbedConfig = (): EmbedConfig => getValueFromWindow(configKey) || ({} as any);
12
13
 
13
14
  /**
14
15
  * Sets the configuration embed was initialized with.
@@ -18,6 +19,6 @@ export const getEmbedConfig = (): EmbedConfig => config;
18
19
  * @group Global methods
19
20
  */
20
21
  export const setEmbedConfig = (newConfig: EmbedConfig) => {
21
- config = newConfig;
22
- return newConfig;
22
+ storeValueInWindow(configKey, newConfig);
23
+ return getValueFromWindow(configKey);
23
24
  };
@@ -553,13 +553,13 @@ describe('Liveboard/viz embed tests', () => {
553
553
  });
554
554
  });
555
555
 
556
- test('navigateToLiveboard should trigger the navigate event with the correct path', (done) => {
556
+ test('navigateToLiveboard should trigger the navigate event with the correct path', async (done) => {
557
557
  mockMessageChannel();
558
558
  const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
559
559
  ...defaultViewConfig,
560
560
  } as LiveboardViewConfig);
561
561
  const onSpy = jest.spyOn(liveboardEmbed, 'trigger');
562
- liveboardEmbed.prerenderGeneric();
562
+ await liveboardEmbed.prerenderGeneric();
563
563
  executeAfterWait(() => {
564
564
  const iframe = getIFrameEl();
565
565
  postMessageToParent(iframe.contentWindow, {
@@ -573,14 +573,14 @@ describe('Liveboard/viz embed tests', () => {
573
573
  });
574
574
  });
575
575
 
576
- test('navigateToLiveboard with preRender', (done) => {
576
+ test('navigateToLiveboard with preRender', async (done) => {
577
577
  mockMessageChannel();
578
578
  const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
579
579
  ...defaultViewConfig,
580
580
  preRenderId: 'test',
581
581
  } as LiveboardViewConfig);
582
582
  const onSpy = jest.spyOn(liveboardEmbed, 'trigger');
583
- liveboardEmbed.prerenderGeneric();
583
+ await liveboardEmbed.prerenderGeneric();
584
584
  executeAfterWait(() => {
585
585
  const iframe = getIFrameEl();
586
586
  postMessageToParent(iframe.contentWindow, {
@@ -604,7 +604,7 @@ describe('Liveboard/viz embed tests', () => {
604
604
  },
605
605
  ],
606
606
  } as LiveboardViewConfig);
607
- liveboardEmbed.render();
607
+ await liveboardEmbed.render();
608
608
  await executeAfterWait(() => {
609
609
  expectUrlMatchesWithParams(
610
610
  getIFrameSrc(),
@@ -637,7 +637,7 @@ describe('Liveboard/viz embed tests', () => {
637
637
  ...defaultViewConfig,
638
638
  liveboardId,
639
639
  } as LiveboardViewConfig);
640
- liveboardEmbed.render();
640
+ await liveboardEmbed.render();
641
641
  await executeAfterWait(() => {
642
642
  const result = liveboardEmbed.trigger(HostEvent.SetActiveTab, {
643
643
  tabId: newActiveTabId,
@@ -650,13 +650,13 @@ describe('Liveboard/viz embed tests', () => {
650
650
  });
651
651
 
652
652
  describe('PreRender flow for liveboard embed', () => {
653
- test('it should preRender generic with liveboard id is not passed', (done) => {
653
+ test('it should preRender generic with liveboard id is not passed', async (done) => {
654
654
  const consoleSpy = jest.spyOn(console, 'error');
655
655
  const libEmbed = new LiveboardEmbed(getRootEl(), {
656
656
  preRenderId: 'testPreRender',
657
657
  });
658
658
  const prerenderGenericSpy = jest.spyOn(libEmbed, 'prerenderGeneric');
659
- libEmbed.preRender();
659
+ await libEmbed.preRender();
660
660
  executeAfterWait(() => {
661
661
  const iFrame = document.getElementById(
662
662
  libEmbed.getPreRenderIds().child,
@@ -735,7 +735,7 @@ describe('Liveboard/viz embed tests', () => {
735
735
  };
736
736
  });
737
737
 
738
- libEmbed.preRender();
738
+ await libEmbed.preRender();
739
739
 
740
740
  await waitFor(() => !!getIFrameEl());
741
741
 
@@ -750,7 +750,7 @@ describe('Liveboard/viz embed tests', () => {
750
750
  liveboardId: testLiveboardId,
751
751
  });
752
752
  const navigateToLiveboardSpy = jest.spyOn(newLibEmbed, 'navigateToLiveboard');
753
- newLibEmbed.showPreRender();
753
+ await newLibEmbed.showPreRender();
754
754
 
755
755
  executeAfterWait(() => {
756
756
  const iFrame = document.getElementById(
@@ -776,7 +776,7 @@ describe('Liveboard/viz embed tests', () => {
776
776
  ...defaultViewConfig,
777
777
  vizId: 'testViz',
778
778
  });
779
- liveboardEmbed.render();
779
+ await liveboardEmbed.render();
780
780
  mockProcessTrigger.mockResolvedValue({ session: 'test' });
781
781
  await executeAfterWait(async () => {
782
782
  await liveboardEmbed.trigger(
@@ -21,7 +21,7 @@ import {
21
21
  } from '../types';
22
22
  import { getQueryParamString, isUndefined } from '../utils';
23
23
  import { getAuthPromise } from './base';
24
- import { V1Embed } from './ts-embed';
24
+ import { TsEmbed, V1Embed } from './ts-embed';
25
25
  import { addPreviewStylesIfNotPresent } from '../utils/global-styles';
26
26
  import { TriggerPayload, TriggerResponse } from './hostEventClient/contracts';
27
27
 
@@ -293,7 +293,10 @@ export interface LiveboardViewConfig
293
293
  */
294
294
  showPreviewLoader?: boolean;
295
295
  /**
296
- * This flag is used to enable the compact header on a Liveboard
296
+ * Enables or disables the compact header feature on a Liveboard.
297
+ * Compact Liveboard header is turned off by default on Liveboards in
298
+ * ThoughtSpot Embedded apps.
299
+ *
297
300
  * @type {boolean}
298
301
  * @default false
299
302
  * @version SDK: 1.35.0 | ThoughtSpot:10.3.0.cl
@@ -632,12 +635,11 @@ export class LiveboardEmbed extends V1Embed {
632
635
  }
633
636
  }
634
637
 
635
- protected handleRenderForPrerender(): void {
638
+ protected async handleRenderForPrerender(): Promise<TsEmbed> {
636
639
  if (isUndefined(this.viewConfig.liveboardId)) {
637
- this.prerenderGeneric();
638
- return;
640
+ return this.prerenderGeneric();
639
641
  }
640
- super.handleRenderForPrerender();
642
+ return super.handleRenderForPrerender();
641
643
  }
642
644
 
643
645
  /**
@@ -667,7 +669,7 @@ export class LiveboardEmbed extends V1Embed {
667
669
  * visualization ID and the runtime filters.
668
670
  */
669
671
  public async render(): Promise<LiveboardEmbed> {
670
- super.render();
672
+ await super.render();
671
673
 
672
674
  const src = this.getIFrameSrc();
673
675
  await this.renderV1Embed(src);
package/src/embed/sage.ts CHANGED
@@ -206,8 +206,7 @@ export class SageEmbed extends V1Embed {
206
206
  * @returns {SageEmbed} Eureka/Sage embed
207
207
  */
208
208
  public async render(): Promise<SageEmbed> {
209
- super.render();
210
-
209
+ await super.render();
211
210
  const src = this.getIFrameSrc();
212
211
  await this.renderV1Embed(src);
213
212
 
@@ -174,8 +174,7 @@ export class SearchBarEmbed extends TsEmbed {
174
174
  * Render the embedded ThoughtSpot search
175
175
  */
176
176
  public async render(): Promise<SearchBarEmbed> {
177
- super.render();
178
-
177
+ await super.render();
179
178
  const src = this.getIFrameSrc();
180
179
  await this.renderIFrame(src);
181
180
  return this;
@@ -482,9 +482,8 @@ export class SearchEmbed extends TsEmbed {
482
482
  * Render the embedded ThoughtSpot search
483
483
  */
484
484
  public async render(): Promise<SearchEmbed> {
485
- super.render();
485
+ await super.render();
486
486
  const { answerId } = this.viewConfig;
487
-
488
487
  const src = this.getIFrameSrc();
489
488
  await this.renderIFrame(src);
490
489
  getAuthPromise().then(() => {
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable dot-notation */
2
+ import { resetValueFromWindow } from '../utils';
3
+ import { ERROR_MESSAGE } from '../errors';
2
4
  import { resetCachedAuthToken } from '../authToken';
3
5
  import {
4
6
  AuthType,
@@ -1249,14 +1251,14 @@ describe('Unit test case for ts embed', () => {
1249
1251
  });
1250
1252
  });
1251
1253
 
1252
- beforeEach(() => {
1254
+ beforeEach(async () => {
1253
1255
  jest.spyOn(baseInstance, 'getAuthPromise').mockRejectedValueOnce(false);
1254
1256
  const tsEmbed = new SearchEmbed(getRootEl(), {});
1255
1257
  const iFrame: any = document.createElement('div');
1256
1258
  iFrame.contentWindow = null;
1257
1259
  jest.spyOn(document, 'createElement').mockReturnValueOnce(iFrame);
1258
1260
  spyOn(logger, 'error');
1259
- tsEmbed.render();
1261
+ await tsEmbed.render();
1260
1262
  });
1261
1263
 
1262
1264
  test('mixpanel should call with VISUAL_SDK_RENDER_FAILED', () => {
@@ -1433,7 +1435,7 @@ describe('Unit test case for ts embed', () => {
1433
1435
  test('Error should be true', async () => {
1434
1436
  spyOn(logger, 'error');
1435
1437
  const tsEmbed = new SearchEmbed(getRootEl(), {});
1436
- tsEmbed.render();
1438
+ await tsEmbed.render();
1437
1439
  expect(tsEmbed['isError']).toBe(true);
1438
1440
  expect(logger.error).toHaveBeenCalledWith(
1439
1441
  'You need to init the ThoughtSpot SDK module first',
@@ -1446,11 +1448,11 @@ describe('Unit test case for ts embed', () => {
1446
1448
  jest.spyOn(config, 'getThoughtSpotHost').mockImplementation(() => 'http://tshost');
1447
1449
  });
1448
1450
 
1449
- test('when isRendered is true than isError will be true', () => {
1451
+ test('when isRendered is true than isError will be true', async () => {
1450
1452
  spyOn(logger, 'warn');
1451
1453
  const viEmbedIns = new tsEmbedInstance.V1Embed(getRootEl(), defaultViewConfig);
1452
1454
  expect(viEmbedIns['isError']).toBe(false);
1453
- viEmbedIns.render();
1455
+ await viEmbedIns.render();
1454
1456
  viEmbedIns.on(EmbedEvent.CustomAction, jest.fn()).render();
1455
1457
  expect(logger.warn).toHaveBeenCalledWith(
1456
1458
  'Please register event handlers before calling render',
@@ -2382,4 +2384,80 @@ describe('Unit test case for ts embed', () => {
2382
2384
  jest.spyOn(baseInstance, 'notifyAuthFailure').mockClear();
2383
2385
  });
2384
2386
  });
2387
+
2388
+ describe('Renders should wait for init to completed', () => {
2389
+ const errorSpy = jest.spyOn(logger, 'error').mockResolvedValue(true);
2390
+ beforeEach(() => {
2391
+ errorSpy.mockClear();
2392
+ resetValueFromWindow('initFlagKey');
2393
+ baseInstance.createAndSetInitPromise();
2394
+ document.body.innerHTML = getDocumentBody();
2395
+ });
2396
+ test('Pre-render should wait for init to complete', async () => {
2397
+ const lib = new LiveboardEmbed(getRootEl(), { preRenderId: 'test', liveboardId: 'test' });
2398
+ lib.preRender();
2399
+ await executeAfterWait(() => {
2400
+ expect(errorSpy).toHaveBeenCalledWith(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
2401
+ expect(getRootEl().innerHTML).toContain('');
2402
+ });
2403
+
2404
+ const iframeBeforeInit = getIFrameEl();
2405
+ expect(iframeBeforeInit).toBe(null);
2406
+
2407
+ init({
2408
+ thoughtSpotHost: 'tshost',
2409
+ authType: AuthType.None,
2410
+ });
2411
+
2412
+ await waitFor(() => !!getIFrameEl());
2413
+ const preRenderId = lib.getPreRenderIds().wrapper;
2414
+ expect(document.getElementById(preRenderId)).not.toBe(null);
2415
+ const iframeAfterInit = getIFrameEl();
2416
+ expect(iframeAfterInit).not.toBe(null);
2417
+ });
2418
+
2419
+ test('Render should wait for init to complete', async () => {
2420
+ const lib = new LiveboardEmbed(getRootEl(), { liveboardId: 'test' });
2421
+ lib.render();
2422
+ await executeAfterWait(() => {
2423
+ expect(errorSpy).toHaveBeenCalledWith(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
2424
+ expect(getRootEl().innerHTML).toContain('');
2425
+ });
2426
+
2427
+ const iframeBeforeInit = getIFrameEl();
2428
+ expect(iframeBeforeInit).toBe(null);
2429
+
2430
+ init({
2431
+ thoughtSpotHost: 'tshost',
2432
+ authType: AuthType.None,
2433
+ });
2434
+
2435
+ await waitFor(() => !!getIFrameEl());
2436
+ expect(getRootEl()).not.toBe(null);
2437
+ const iframeAfterInit = getIFrameEl();
2438
+ expect(iframeAfterInit).not.toBe(null);
2439
+ });
2440
+
2441
+ test('Pre Render Generic should wait for init to complete', async () => {
2442
+ const lib = new LiveboardEmbed(getRootEl(), {});
2443
+ lib.prerenderGeneric();
2444
+ await executeAfterWait(() => {
2445
+ expect(errorSpy).toHaveBeenCalledWith(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
2446
+ expect(getRootEl().innerHTML).toContain('');
2447
+ });
2448
+
2449
+ const iframeBeforeInit = getIFrameEl();
2450
+ expect(iframeBeforeInit).toBe(null);
2451
+
2452
+ init({
2453
+ thoughtSpotHost: 'tshost',
2454
+ authType: AuthType.None,
2455
+ });
2456
+
2457
+ await waitFor(() => !!getIFrameEl());
2458
+ expect(getRootEl()).not.toBe(null);
2459
+ const iframeAfterInit = getIFrameEl();
2460
+ expect(iframeAfterInit).not.toBe(null);
2461
+ });
2462
+ });
2385
2463
  });
@@ -66,6 +66,8 @@ import { processTrigger } from '../utils/processTrigger';
66
66
  import pkgInfo from '../../package.json';
67
67
  import {
68
68
  getAuthPromise, renderInQueue, handleAuth, notifyAuthFailure,
69
+ getInitPromise,
70
+ getIsInitCalled,
69
71
  } from './base';
70
72
  import { AuthFailureType } from '../auth';
71
73
  import { getEmbedConfig } from './embedConfig';
@@ -180,15 +182,10 @@ export class TsEmbed {
180
182
 
181
183
  protected hostEventClient: HostEventClient;
182
184
 
185
+ protected isReadyForRenderPromise;
186
+
183
187
  constructor(domSelector: DOMSelector, viewConfig?: ViewConfig) {
184
188
  this.el = getDOMNode(domSelector);
185
- // TODO: handle error
186
- this.embedConfig = getEmbedConfig();
187
- if (!this.embedConfig.authTriggerContainer && !this.embedConfig.useEventForSAMLPopup) {
188
- this.embedConfig.authTriggerContainer = domSelector;
189
- }
190
- this.thoughtSpotHost = getThoughtSpotHost(this.embedConfig);
191
- this.thoughtSpotV2Base = getV2BasePath(this.embedConfig);
192
189
  this.eventHandlerMap = new Map();
193
190
  this.isError = false;
194
191
  this.viewConfig = {
@@ -196,12 +193,22 @@ export class TsEmbed {
196
193
  excludeRuntimeParametersfromURL: false,
197
194
  ...viewConfig,
198
195
  };
199
- this.shouldEncodeUrlQueryParams = this.embedConfig.shouldEncodeUrlQueryParams;
200
196
  this.registerAppInit();
201
197
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_EMBED_CREATE, {
202
198
  ...viewConfig,
203
199
  });
204
200
  this.hostEventClient = new HostEventClient(this.iFrame);
201
+
202
+ this.isReadyForRenderPromise = getInitPromise().then(async () => {
203
+ const embedConfig = getEmbedConfig();
204
+ this.embedConfig = embedConfig;
205
+ if (!embedConfig.authTriggerContainer && !embedConfig.useEventForSAMLPopup) {
206
+ this.embedConfig.authTriggerContainer = domSelector;
207
+ }
208
+ this.thoughtSpotHost = getThoughtSpotHost(embedConfig);
209
+ this.thoughtSpotV2Base = getV2BasePath(embedConfig);
210
+ this.shouldEncodeUrlQueryParams = embedConfig.shouldEncodeUrlQueryParams;
211
+ });
205
212
  }
206
213
 
207
214
  /**
@@ -723,6 +730,7 @@ export class TsEmbed {
723
730
  });
724
731
 
725
732
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
733
+
726
734
  return getAuthPromise()
727
735
  ?.then((isLoggedIn: boolean) => {
728
736
  if (!isLoggedIn) {
@@ -1119,8 +1127,11 @@ export class TsEmbed {
1119
1127
  * @param args
1120
1128
  */
1121
1129
  public async render(): Promise<TsEmbed> {
1130
+ if (!getIsInitCalled()) {
1131
+ logger.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
1132
+ }
1133
+ await this.isReadyForRenderPromise;
1122
1134
  this.isRendered = true;
1123
-
1124
1135
  return this;
1125
1136
  }
1126
1137
 
@@ -1129,22 +1140,21 @@ export class TsEmbed {
1129
1140
  }
1130
1141
 
1131
1142
  protected handleRenderForPrerender() {
1132
- this.render();
1143
+ return this.render();
1133
1144
  }
1134
1145
 
1135
1146
  /**
1136
1147
  * Creates the preRender shell
1137
1148
  * @param showPreRenderByDefault - Show the preRender after render, hidden by default
1138
1149
  */
1139
- public preRender(showPreRenderByDefault = false): TsEmbed {
1150
+ public async preRender(showPreRenderByDefault = false): Promise<TsEmbed> {
1140
1151
  if (!this.viewConfig.preRenderId) {
1141
1152
  logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
1142
1153
  return this;
1143
1154
  }
1144
1155
  this.isPreRendered = true;
1145
1156
  this.showPreRenderByDefault = showPreRenderByDefault;
1146
- this.handleRenderForPrerender();
1147
- return this;
1157
+ return this.handleRenderForPrerender();
1148
1158
  }
1149
1159
 
1150
1160
  /**
@@ -1204,6 +1214,11 @@ export class TsEmbed {
1204
1214
  * @returns
1205
1215
  */
1206
1216
  public async prerenderGeneric(): Promise<any> {
1217
+ if (!getIsInitCalled()) {
1218
+ logger.error(ERROR_MESSAGE.RENDER_CALLED_BEFORE_INIT);
1219
+ }
1220
+ await this.isReadyForRenderPromise;
1221
+
1207
1222
  const prerenderFrameSrc = this.getRootIframeSrc();
1208
1223
  this.isRendered = true;
1209
1224
  return this.renderIFrame(prerenderFrameSrc);
@@ -1246,18 +1261,17 @@ export class TsEmbed {
1246
1261
  * Also, synchronizes the style of the PreRender component with the embedding
1247
1262
  * element.
1248
1263
  */
1249
- public showPreRender(): void {
1264
+ public async showPreRender(): Promise<TsEmbed> {
1250
1265
  if (!this.viewConfig.preRenderId) {
1251
1266
  logger.error(ERROR_MESSAGE.PRERENDER_ID_MISSING);
1252
- return;
1267
+ return this;
1253
1268
  }
1254
1269
  if (!this.isPreRenderAvailable()) {
1255
1270
  const isAvailable = this.connectPreRendered();
1256
1271
 
1257
1272
  if (!isAvailable) {
1258
1273
  // if the Embed component is not preRendered , Render it now and
1259
- this.preRender(true);
1260
- return;
1274
+ return this.preRender(true);
1261
1275
  }
1262
1276
  this.validatePreRenderViewConfig(this.viewConfig);
1263
1277
  }
@@ -1284,6 +1298,8 @@ export class TsEmbed {
1284
1298
  removeStyleProperties(this.preRenderWrapper, ['z-index', 'opacity', 'pointer-events']);
1285
1299
 
1286
1300
  this.subscribeToEvents();
1301
+
1302
+ return this;
1287
1303
  }
1288
1304
 
1289
1305
  /**
package/src/errors.ts CHANGED
@@ -16,4 +16,5 @@ export const ERROR_MESSAGE = {
16
16
  CSP_VIOLATION_ALERT: 'CSP violation detected. Please check the console errors for more details.',
17
17
  CSP_FRAME_HOST_VIOLATION_LOG_MESSAGE: 'Please set up CSP correctly for the application to start working. For more information, see https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts. \n If the issue persists, refer to https://developers.thoughtspot.com/docs/security-settings#csp-viz-embed-hosts',
18
18
  MISSING_REPORTING_OBSERVER: 'ReportingObserver not supported',
19
+ RENDER_CALLED_BEFORE_INIT: 'Looks like render was called before calling init, the render won\'t start until init is called.\nFor more info check\n1. https://developers.thoughtspot.com/docs/Function_init#_init\n2.https://developers.thoughtspot.com/docs/getting-started#initSdk',
19
20
  };
@@ -12,6 +12,7 @@ export {
12
12
  ConversationEmbed,
13
13
  PreRenderedConversationEmbed,
14
14
  useEmbedRef,
15
+ useInit,
15
16
  } from './index';
16
17
 
17
18
  export {
@@ -1,5 +1,6 @@
1
- import React from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import useDeepCompareEffect from 'use-deep-compare-effect';
3
+ import { AuthEventEmitter } from '../auth';
3
4
  import { deepMerge } from '../utils';
4
5
  import { SearchBarEmbed as _SearchBarEmbed, SearchBarViewConfig } from '../embed/search-bar';
5
6
  import { SageEmbed as _SageEmbed, SageViewConfig } from '../embed/sage';
@@ -8,9 +9,10 @@ import { AppEmbed as _AppEmbed, AppViewConfig } from '../embed/app';
8
9
  import { LiveboardEmbed as _LiveboardEmbed, LiveboardViewConfig } from '../embed/liveboard';
9
10
  import { TsEmbed } from '../embed/ts-embed';
10
11
 
11
- import { EmbedEvent, ViewConfig } from '../types';
12
+ import { EmbedConfig, EmbedEvent, ViewConfig } from '../types';
12
13
  import { EmbedProps, getViewPropsAndListeners } from './util';
13
14
  import { ConversationEmbed as _ConversationEmbed, ConversationViewConfig } from '../embed/conversation';
15
+ import { init } from '../embed/base';
14
16
 
15
17
  const componentFactory = <T extends typeof TsEmbed, U extends EmbedProps, V extends ViewConfig>(
16
18
  EmbedConstructor: T,
@@ -404,6 +406,29 @@ export function useEmbedRef<T extends EmbedComponent>():
404
406
  return React.useRef<React.ComponentRef<T>>(null);
405
407
  }
406
408
 
409
+ /**
410
+ *
411
+ * @param config - EmbedConfig
412
+ * @returns AuthEventEmitter
413
+ * @example
414
+ * ```
415
+ * function Component() {
416
+ * const authEE = useInit({ ...initConfig });
417
+ * return <LiveboardEmbed ref={ref} liveboardId={<id>} />
418
+ * }
419
+ * ```
420
+ * @version SDK: 1.36.2 | ThoughtSpot: *
421
+ */
422
+ export function useInit(config: EmbedConfig) {
423
+ const ref = useRef<AuthEventEmitter | null>(null);
424
+ useDeepCompareEffect(() => {
425
+ const authEE = init(config);
426
+ ref.current = authEE;
427
+ }, [config]);
428
+
429
+ return ref;
430
+ }
431
+
407
432
  export {
408
433
  LiveboardViewConfig,
409
434
  SearchViewConfig,