@thoughtspot/visual-embed-sdk 1.19.0-alpha.2 → 1.19.0-alpha.3

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 (82) hide show
  1. package/dist/src/auth.d.ts +21 -1
  2. package/dist/src/auth.d.ts.map +1 -1
  3. package/dist/src/embed/base.d.ts +2 -5
  4. package/dist/src/embed/base.d.ts.map +1 -1
  5. package/dist/src/embed/search.d.ts +6 -0
  6. package/dist/src/embed/search.d.ts.map +1 -1
  7. package/dist/src/embed/ts-embed.d.ts +1 -0
  8. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/mixpanel-service.d.ts +3 -1
  11. package/dist/src/mixpanel-service.d.ts.map +1 -1
  12. package/dist/src/react/index.d.ts.map +1 -1
  13. package/dist/src/react/util.d.ts +1 -1
  14. package/dist/src/react/util.d.ts.map +1 -1
  15. package/dist/src/test/test-utils.d.ts +1 -1
  16. package/dist/src/test/test-utils.d.ts.map +1 -1
  17. package/dist/src/types.d.ts +19 -8
  18. package/dist/src/types.d.ts.map +1 -1
  19. package/dist/src/utils.d.ts +1 -0
  20. package/dist/src/utils.d.ts.map +1 -1
  21. package/dist/tsembed.es.js +113 -67
  22. package/dist/tsembed.js +113 -67
  23. package/lib/package.json +1 -1
  24. package/lib/src/auth.d.ts +21 -1
  25. package/lib/src/auth.d.ts.map +1 -1
  26. package/lib/src/auth.js +66 -12
  27. package/lib/src/auth.js.map +1 -1
  28. package/lib/src/embed/base.d.ts +2 -5
  29. package/lib/src/embed/base.d.ts.map +1 -1
  30. package/lib/src/embed/base.js +8 -36
  31. package/lib/src/embed/base.js.map +1 -1
  32. package/lib/src/embed/base.spec.js +0 -9
  33. package/lib/src/embed/base.spec.js.map +1 -1
  34. package/lib/src/embed/search.d.ts +6 -0
  35. package/lib/src/embed/search.d.ts.map +1 -1
  36. package/lib/src/embed/search.js.map +1 -1
  37. package/lib/src/embed/ts-embed.d.ts +1 -0
  38. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  39. package/lib/src/embed/ts-embed.js +23 -5
  40. package/lib/src/embed/ts-embed.js.map +1 -1
  41. package/lib/src/embed/ts-embed.spec.js +15 -1
  42. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  43. package/lib/src/index.d.ts.map +1 -1
  44. package/lib/src/index.js.map +1 -1
  45. package/lib/src/mixpanel-service.d.ts +3 -1
  46. package/lib/src/mixpanel-service.d.ts.map +1 -1
  47. package/lib/src/mixpanel-service.js +18 -15
  48. package/lib/src/mixpanel-service.js.map +1 -1
  49. package/lib/src/mixpanel-service.spec.js +20 -4
  50. package/lib/src/mixpanel-service.spec.js.map +1 -1
  51. package/lib/src/react/index.d.ts.map +1 -1
  52. package/lib/src/react/index.js +8 -4
  53. package/lib/src/react/index.js.map +1 -1
  54. package/lib/src/react/index.spec.js +3 -3
  55. package/lib/src/react/index.spec.js.map +1 -1
  56. package/lib/src/react/util.d.ts +1 -1
  57. package/lib/src/react/util.d.ts.map +1 -1
  58. package/lib/src/test/test-utils.d.ts +1 -1
  59. package/lib/src/test/test-utils.d.ts.map +1 -1
  60. package/lib/src/types.d.ts +19 -8
  61. package/lib/src/types.d.ts.map +1 -1
  62. package/lib/src/types.js +7 -0
  63. package/lib/src/types.js.map +1 -1
  64. package/lib/src/utils.d.ts +1 -0
  65. package/lib/src/utils.d.ts.map +1 -1
  66. package/lib/src/utils.js +11 -0
  67. package/lib/src/utils.js.map +1 -1
  68. package/lib/src/visual-embed-sdk.d.ts +42 -7
  69. package/package.json +1 -1
  70. package/src/auth.ts +78 -19
  71. package/src/embed/base.spec.ts +0 -10
  72. package/src/embed/base.ts +18 -37
  73. package/src/embed/search.ts +6 -0
  74. package/src/embed/ts-embed.spec.ts +15 -0
  75. package/src/embed/ts-embed.ts +22 -5
  76. package/src/index.ts +1 -1
  77. package/src/mixpanel-service.spec.ts +26 -5
  78. package/src/mixpanel-service.ts +19 -20
  79. package/src/react/index.spec.tsx +3 -7
  80. package/src/react/index.tsx +16 -6
  81. package/src/types.ts +11 -0
  82. package/src/utils.ts +13 -0
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,cAA+B,EAAU,EAAE;IACtE,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,EAAE;QACzC,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;YACtD,MAAM,KAAK,GAAG,UAAU,GAAG,CAAC,CAAC;YAC7B,MAAM,UAAU,GAAG,EAAE,CAAC;YACtB,UAAU,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;YACpD,UAAU,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjD,UAAU,CAAC,IAAI,CACX,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACjE,CAAC;YAEF,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;KACjC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,KAAU,EAAE,EAAE;IAClC,mCAAmC;IACnC,IACI,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS,EAC5B;QACE,OAAO,KAAK,CAAC;KACh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;gBAClD,2BAA2B;SAClC;QACD,OAAO,EAAE;YACL,GAAG,6BAA6B,aAA7B,6BAA6B,uBAA7B,6BAA6B,CAAE,OAAO;YACzC,GAAG,4BAA4B,aAA5B,4BAA4B,uBAA5B,4BAA4B,CAAE,OAAO;SAC3C;KACJ,CAAC;IACF,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,WAAwB;IAC/C,OAAO,OAAO,WAAW,KAAK,QAAQ;QAClC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC;QACrC,CAAC,CAAC,WAAW,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAW,EAAE,MAAW,EAAE,EAAE;IAClD,mHAAmH;IACnH,gDAAgD;IAChD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACnC,IAAI,MAAM,CAAC,GAAG,CAAC,YAAY,MAAM;YAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;KACvE;IAED,sCAAsC;IACtC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
@@ -153,14 +153,11 @@ declare module '@thoughtspot/visual-embed-sdk/embed/base' {
153
153
  */
154
154
  import EventEmitter from 'eventemitter3';
155
155
  import { EmbedConfig, PrefetchFeatures } from '@thoughtspot/visual-embed-sdk/types';
156
- import { AuthFailureType } from '@thoughtspot/visual-embed-sdk/auth';
156
+ import { notifyAuthFailure, notifyAuthSDKSuccess, notifyAuthSuccess, notifyLogout } from '@thoughtspot/visual-embed-sdk/auth';
157
157
  export let authPromise: Promise<boolean>;
158
158
  export const getEmbedConfig: () => EmbedConfig;
159
159
  export const getAuthPromise: () => Promise<boolean>;
160
- export function notifyAuthSDKSuccess(): void;
161
- export function notifyAuthSuccess(): void;
162
- export function notifyAuthFailure(failureType: AuthFailureType): void;
163
- export function notifyLogout(): void;
160
+ export { notifyAuthFailure, notifyAuthSDKSuccess, notifyAuthSuccess, notifyLogout, };
164
161
  /**
165
162
  * Perform authentication on the ThoughtSpot app as applicable.
166
163
  */
@@ -392,6 +389,12 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
392
389
  * The GUID of a saved answer to load initially.
393
390
  */
394
391
  answerId?: string;
392
+ /**
393
+ * If set to true, search page will render without the Search Bar
394
+ * The chart/table should still be visible.
395
+ * @version SDK: 1.18.1 | ThoughtSpot: 9.2.0.cl (TBD)
396
+ */
397
+ hideSearchBar?: boolean;
395
398
  }
396
399
  export const HiddenActionItemByDefaultForSearchEmbed: Action[];
397
400
  /**
@@ -453,6 +456,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search-bar' {
453
456
  }
454
457
 
455
458
  declare module '@thoughtspot/visual-embed-sdk/auth' {
459
+ import EventEmitter from 'eventemitter3';
456
460
  import { EmbedConfig } from '@thoughtspot/visual-embed-sdk/types';
457
461
  export let loggedInStatus: boolean;
458
462
  export let samlAuthWindow: Window;
@@ -488,8 +492,27 @@ declare module '@thoughtspot/visual-embed-sdk/auth' {
488
492
  /**
489
493
  * Emits when a user logs out
490
494
  */
491
- LOGOUT = "LOGOUT"
495
+ LOGOUT = "LOGOUT",
496
+ /**
497
+ * Emitted when inPopup: true in the SAMLRedirect flow.
498
+ * And, we are waiting for popup to be triggered either programatically
499
+ * or by the trigger button.
500
+ * @version SDK: 1.19.0
501
+ */
502
+ WAITING_FOR_POPUP = "WAITING_FOR_POPUP"
503
+ }
504
+ export enum AuthEvent {
505
+ /**
506
+ * Manually trigger the SSO popup.
507
+ */
508
+ TRIGGER_SSO_POPUP = "TRIGGER_SSO_POPUP"
492
509
  }
510
+ export function getAuthEE(): EventEmitter;
511
+ export function setAuthEE(eventEmitter: EventEmitter): void;
512
+ export function notifyAuthSDKSuccess(): void;
513
+ export function notifyAuthSuccess(): void;
514
+ export function notifyAuthFailure(failureType: AuthFailureType): void;
515
+ export function notifyLogout(): void;
493
516
  /**
494
517
  * Return releaseVersion if available
495
518
  */
@@ -869,6 +892,10 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
869
892
  * @default ''
870
893
  */
871
894
  customizations?: CustomisationsInterface;
895
+ /**
896
+ * Insert as a sibling of the target container, instead of appending to a child inside it.
897
+ */
898
+ insertAsSibling?: boolean;
872
899
  }
873
900
  /**
874
901
  * MessagePayload: Embed event payload: message type, data and status (start/end)
@@ -1622,7 +1649,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
1622
1649
  * vizEmbed.trigger(HostEvent.ManagePipelines)
1623
1650
  * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
1624
1651
  */
1625
- ManagePipelines = "manage-pipeline"
1652
+ ManagePipelines = "manage-pipeline",
1653
+ /**
1654
+ * Triggers the Reset search in answer
1655
+ * @example
1656
+ * searchEmbed.trigger(HostEvent.SearchReset
1657
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.2.0.cl, 9.0.1-sw
1658
+ */
1659
+ ResetSearch = "resetSearch"
1626
1660
  }
1627
1661
  /**
1628
1662
  * The different visual modes that the data sources panel within
@@ -1924,6 +1958,7 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
1924
1958
  * @param frameOptions
1925
1959
  */
1926
1960
  protected renderIFrame(url: string, frameOptions?: FrameParams): Promise<any>;
1961
+ protected insertIntoDOM(child: string | Node): void;
1927
1962
  /**
1928
1963
  * Sets the height of the iframe
1929
1964
  * @param height The height in pixels
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thoughtspot/visual-embed-sdk",
3
- "version": "1.19.0-alpha.2",
3
+ "version": "1.19.0-alpha.3",
4
4
  "description": "ThoughtSpot Embed SDK",
5
5
  "module": "lib/src/index.js",
6
6
  "main": "dist/tsembed.js",
package/src/auth.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import EventEmitter from 'eventemitter3';
1
2
  import { initMixpanel } from './mixpanel-service';
2
3
  import { AuthType, DOMSelector, EmbedConfig, EmbedEvent, Param } from './types';
3
4
  import { getDOMNode, getRedirectUrl } from './utils';
@@ -58,6 +59,62 @@ export enum AuthStatus {
58
59
  * Emits when a user logs out
59
60
  */
60
61
  LOGOUT = 'LOGOUT',
62
+ /**
63
+ * Emitted when inPopup: true in the SAMLRedirect flow.
64
+ * And, we are waiting for popup to be triggered either programatically
65
+ * or by the trigger button.
66
+ * @version SDK: 1.19.0
67
+ */
68
+ WAITING_FOR_POPUP = 'WAITING_FOR_POPUP',
69
+ }
70
+
71
+ export enum AuthEvent {
72
+ /**
73
+ * Manually trigger the SSO popup.
74
+ */
75
+ TRIGGER_SSO_POPUP = 'TRIGGER_SSO_POPUP',
76
+ }
77
+
78
+ let authEE: EventEmitter;
79
+
80
+ export function getAuthEE(): EventEmitter {
81
+ return authEE;
82
+ }
83
+
84
+ export function setAuthEE(eventEmitter: EventEmitter): void {
85
+ authEE = eventEmitter;
86
+ }
87
+
88
+ export function notifyAuthSDKSuccess(): void {
89
+ if (!authEE) {
90
+ console.error('SDK not initialized');
91
+ return;
92
+ }
93
+ authEE.emit(AuthStatus.SDK_SUCCESS);
94
+ }
95
+
96
+ export function notifyAuthSuccess(): void {
97
+ if (!authEE) {
98
+ console.error('SDK not initialized');
99
+ return;
100
+ }
101
+ authEE.emit(AuthStatus.SUCCESS);
102
+ }
103
+
104
+ export function notifyAuthFailure(failureType: AuthFailureType): void {
105
+ if (!authEE) {
106
+ console.error('SDK not initialized');
107
+ return;
108
+ }
109
+ authEE.emit(AuthStatus.FAILURE, failureType);
110
+ }
111
+
112
+ export function notifyLogout(): void {
113
+ if (!authEE) {
114
+ console.error('SDK not initialized');
115
+ return;
116
+ }
117
+ authEE.emit(AuthStatus.LOGOUT);
61
118
  }
62
119
 
63
120
  /**
@@ -213,11 +270,26 @@ async function samlPopupFlow(
213
270
  triggerContainer: DOMSelector,
214
271
  triggerText: string,
215
272
  ) {
273
+ const openPopup = () => {
274
+ if (samlAuthWindow === null || samlAuthWindow.closed) {
275
+ samlAuthWindow = window.open(
276
+ ssoURL,
277
+ '_blank',
278
+ 'location=no,height=570,width=520,scrollbars=yes,status=yes',
279
+ );
280
+ } else {
281
+ samlAuthWindow.focus();
282
+ }
283
+ };
284
+ authEE?.emit(AuthStatus.WAITING_FOR_POPUP);
216
285
  const containerEl = getDOMNode(triggerContainer);
217
- containerEl.innerHTML =
218
- '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
219
- const authElem = document.getElementById('ts-auth-btn');
220
- authElem.textContent = triggerText;
286
+ if (containerEl) {
287
+ containerEl.innerHTML =
288
+ '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
289
+ const authElem = document.getElementById('ts-auth-btn');
290
+ authElem.textContent = triggerText;
291
+ authElem.addEventListener('click', openPopup, { once: true });
292
+ }
221
293
  samlCompletionPromise =
222
294
  samlCompletionPromise ||
223
295
  new Promise<void>((resolve, reject) => {
@@ -228,21 +300,8 @@ async function samlPopupFlow(
228
300
  }
229
301
  });
230
302
  });
231
- authElem.addEventListener(
232
- 'click',
233
- () => {
234
- if (samlAuthWindow === null || samlAuthWindow.closed) {
235
- samlAuthWindow = window.open(
236
- ssoURL,
237
- '_blank',
238
- 'location=no,height=570,width=520,scrollbars=yes,status=yes',
239
- );
240
- } else {
241
- samlAuthWindow.focus();
242
- }
243
- },
244
- { once: true },
245
- );
303
+
304
+ authEE?.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
246
305
  return samlCompletionPromise;
247
306
  }
248
307
 
@@ -204,16 +204,6 @@ describe('Base TS Embed', () => {
204
204
  });
205
205
  }).toThrowError();
206
206
  });
207
-
208
- test('config sanity, pass triggerContainer with noRedirect', () => {
209
- expect(() => {
210
- index.init({
211
- thoughtSpotHost,
212
- authType: index.AuthType.SAMLRedirect,
213
- noRedirect: true,
214
- });
215
- }).toThrowError();
216
- });
217
207
  });
218
208
 
219
209
  describe('Base without init', () => {
package/src/embed/base.ts CHANGED
@@ -16,6 +16,11 @@ import {
16
16
  logout as _logout,
17
17
  AuthFailureType,
18
18
  AuthStatus,
19
+ notifyAuthFailure,
20
+ notifyAuthSDKSuccess,
21
+ notifyAuthSuccess,
22
+ notifyLogout,
23
+ setAuthEE,
19
24
  } from '../auth';
20
25
  import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
21
26
 
@@ -32,39 +37,13 @@ export const getEmbedConfig = (): EmbedConfig => config;
32
37
 
33
38
  export const getAuthPromise = (): Promise<boolean> => authPromise;
34
39
 
35
- let authEE: EventEmitter;
36
-
37
- export function notifyAuthSDKSuccess(): void {
38
- if (!authEE) {
39
- console.error('SDK not initialized');
40
- return;
41
- }
42
- authEE.emit(AuthStatus.SDK_SUCCESS);
43
- }
44
-
45
- export function notifyAuthSuccess(): void {
46
- if (!authEE) {
47
- console.error('SDK not initialized');
48
- return;
49
- }
50
- authEE.emit(AuthStatus.SUCCESS);
51
- }
52
-
53
- export function notifyAuthFailure(failureType: AuthFailureType): void {
54
- if (!authEE) {
55
- console.error('SDK not initialized');
56
- return;
57
- }
58
- authEE.emit(AuthStatus.FAILURE, failureType);
59
- }
40
+ export {
41
+ notifyAuthFailure,
42
+ notifyAuthSDKSuccess,
43
+ notifyAuthSuccess,
44
+ notifyLogout,
45
+ };
60
46
 
61
- export function notifyLogout(): void {
62
- if (!authEE) {
63
- console.error('SDK not initialized');
64
- return;
65
- }
66
- authEE.emit(AuthStatus.LOGOUT);
67
- }
68
47
  /**
69
48
  * Perform authentication on the ThoughtSpot app as applicable.
70
49
  */
@@ -142,9 +121,6 @@ function sanity(embedConfig: EmbedConfig) {
142
121
  );
143
122
  }
144
123
  }
145
- if (embedConfig.noRedirect && !embedConfig.authTriggerContainer) {
146
- throw new Error('authTriggerContainer not provided with noRedirect');
147
- }
148
124
  }
149
125
 
150
126
  /**
@@ -164,7 +140,8 @@ export const init = (embedConfig: EmbedConfig): EventEmitter => {
164
140
  ...embedConfig,
165
141
  thoughtSpotHost: getThoughtSpotHost(embedConfig),
166
142
  };
167
- authEE = new EventEmitter();
143
+ const authEE = new EventEmitter();
144
+ setAuthEE(authEE);
168
145
  handleAuth();
169
146
 
170
147
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
@@ -177,6 +154,10 @@ export const init = (embedConfig: EmbedConfig): EventEmitter => {
177
154
  usedCustomizationRules:
178
155
  embedConfig.customizations?.style?.customCSS?.rules_UNSTABLE !=
179
156
  null,
157
+ usedCustomizationStrings: !!embedConfig.customizations?.content
158
+ ?.strings,
159
+ usedCustomizationIconSprite: !!embedConfig.customizations
160
+ ?.iconSpriteUrl,
180
161
  });
181
162
 
182
163
  if (config.callPrefetch) {
@@ -231,6 +212,6 @@ export const renderInQueue = (
231
212
  // For testing purposes only
232
213
  export function reset(): void {
233
214
  config = {} as any;
234
- authEE = null;
215
+ setAuthEE(null);
235
216
  authPromise = null;
236
217
  }
@@ -97,6 +97,12 @@ export interface SearchViewConfig extends ViewConfig {
97
97
  * The GUID of a saved answer to load initially.
98
98
  */
99
99
  answerId?: string;
100
+ /**
101
+ * If set to true, search page will render without the Search Bar
102
+ * The chart/table should still be visible.
103
+ * @version SDK: 1.18.1 | ThoughtSpot: 9.2.0.cl (TBD)
104
+ */
105
+ hideSearchBar?: boolean;
100
106
  }
101
107
 
102
108
  export const HiddenActionItemByDefaultForSearchEmbed = [
@@ -325,6 +325,7 @@ describe('Unit test case for ts embed', () => {
325
325
  const iFrame: any = document.createElement('div');
326
326
  iFrame.contentWindow = null;
327
327
  jest.spyOn(document, 'createElement').mockReturnValueOnce(iFrame);
328
+ spyOn(console, 'error');
328
329
  tsEmbed.render();
329
330
  });
330
331
 
@@ -334,6 +335,9 @@ describe('Unit test case for ts embed', () => {
334
335
  );
335
336
  expect(mockMixPanelEvent).toBeCalledWith(
336
337
  MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED,
338
+ {
339
+ error: 'false',
340
+ },
337
341
  );
338
342
  });
339
343
  });
@@ -651,6 +655,17 @@ describe('Unit test case for ts embed', () => {
651
655
  `&iconSprite=iconSprite.com${defaultParamsPost}#/home`,
652
656
  );
653
657
  });
658
+ it('inserts as sibling of root node if configured', async () => {
659
+ const appEmbed = new AppEmbed(getRootEl(), {
660
+ frameParams: {
661
+ width: '100%',
662
+ height: '100%',
663
+ },
664
+ insertAsSibling: true,
665
+ });
666
+ await appEmbed.render();
667
+ expect(getRootEl().nextSibling).toBe(getIFrameEl());
668
+ });
654
669
  xit('Sets the forceSAMLAutoRedirect param', async (done) => {
655
670
  jest.spyOn(baseInstance, 'getAuthPromise').mockResolvedValue(true);
656
671
  init({
@@ -417,7 +417,7 @@ export class TsEmbed {
417
417
  return getAuthPromise()
418
418
  ?.then((isLoggedIn: boolean) => {
419
419
  if (!isLoggedIn) {
420
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
420
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
421
421
  return;
422
422
  }
423
423
 
@@ -478,8 +478,7 @@ export class TsEmbed {
478
478
  this.iFrame.addEventListener('error', () => {
479
479
  nextInQueue();
480
480
  });
481
- this.el.innerHTML = '';
482
- this.el.appendChild(this.iFrame);
481
+ this.insertIntoDOM(this.iFrame);
483
482
  const prefetchIframe = document.querySelectorAll(
484
483
  '.prefetchIframe',
485
484
  );
@@ -494,13 +493,31 @@ export class TsEmbed {
494
493
  nextInQueue();
495
494
  uploadMixpanelEvent(
496
495
  MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED,
496
+ { error: JSON.stringify(error) },
497
497
  );
498
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
498
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
499
499
  this.handleError(error);
500
500
  });
501
501
  });
502
502
  }
503
503
 
504
+ protected insertIntoDOM(child: string | Node): void {
505
+ if (this.viewConfig.insertAsSibling) {
506
+ if (typeof child === 'string') {
507
+ const div = document.createElement('div');
508
+ div.innerHTML = child;
509
+ // eslint-disable-next-line no-param-reassign
510
+ child = div;
511
+ }
512
+ this.el.parentElement.insertBefore(child, this.el.nextSibling);
513
+ } else if (typeof child === 'string') {
514
+ this.el.innerHTML = child;
515
+ } else {
516
+ this.el.innerHTML = '';
517
+ this.el.appendChild(child);
518
+ }
519
+ }
520
+
504
521
  /**
505
522
  * Sets the height of the iframe
506
523
  * @param height The height in pixels
@@ -730,7 +747,7 @@ export class V1Embed extends TsEmbed {
730
747
  options: MessageOptions = { start: false },
731
748
  ): typeof TsEmbed.prototype {
732
749
  const eventType = this.getCompatibleEventType(messageType);
733
-
750
+ uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_ON}-${messageType}`);
734
751
  return super.on(eventType, callback, options);
735
752
  }
736
753
  }
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  } from './embed/liveboard';
18
18
  import { SearchEmbed, SearchViewConfig } from './embed/search';
19
19
  import { SearchBarEmbed, SearchBarViewConfig } from './embed/search-bar';
20
- import { AuthFailureType, AuthStatus } from './auth';
20
+ import { AuthFailureType, AuthStatus, AuthEvent } from './auth';
21
21
  import {
22
22
  AuthType,
23
23
  RuntimeFilter,
@@ -1,5 +1,10 @@
1
1
  import * as mixpanel from 'mixpanel-browser';
2
- import { initMixpanel, uploadMixpanelEvent } from './mixpanel-service';
2
+ import {
3
+ initMixpanel,
4
+ uploadMixpanelEvent,
5
+ MIXPANEL_EVENT,
6
+ testResetMixpanel,
7
+ } from './mixpanel-service';
3
8
  import { AuthType } from './types';
4
9
 
5
10
  const config = {
@@ -7,10 +12,6 @@ const config = {
7
12
  authType: AuthType.None,
8
13
  };
9
14
 
10
- const MIXPANEL_EVENT = {
11
- VISUAL_SDK_CALLED_INIT: 'visual-sdk-called-init',
12
- };
13
-
14
15
  jest.mock('mixpanel-browser', () => ({
15
16
  __esModule: true,
16
17
  init: jest.fn(),
@@ -19,6 +20,9 @@ jest.mock('mixpanel-browser', () => ({
19
20
  }));
20
21
 
21
22
  describe('Unit test for mixpanel', () => {
23
+ afterEach(() => {
24
+ jest.clearAllMocks();
25
+ });
22
26
  test('initMixpanel and test upload event', () => {
23
27
  const sessionInfo = {
24
28
  mixpanelToken: 'abc123',
@@ -49,4 +53,21 @@ describe('Unit test for mixpanel', () => {
49
53
  sessionInfo.userGUID,
50
54
  );
51
55
  });
56
+
57
+ test('when not init, should queue events and flush on init', () => {
58
+ testResetMixpanel();
59
+ uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
60
+ authType: config.authType,
61
+ host: config.thoughtSpotHost,
62
+ });
63
+ uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_TRIGGER);
64
+ expect(mixpanel.track).not.toHaveBeenCalled();
65
+ const sessionInfo = {
66
+ mixpanelToken: 'abc123',
67
+ userGUID: '12345',
68
+ isPublicUser: false,
69
+ };
70
+ initMixpanel(sessionInfo);
71
+ expect(mixpanel.track).toHaveBeenCalledTimes(2);
72
+ });
52
73
  });
@@ -10,40 +10,34 @@ export const MIXPANEL_EVENT = {
10
10
  VISUAL_SDK_RENDER_COMPLETE: 'visual-sdk-render-complete',
11
11
  VISUAL_SDK_RENDER_FAILED: 'visual-sdk-render-failed',
12
12
  VISUAL_SDK_TRIGGER: 'visual-sdk-trigger',
13
+ VISUAL_SDK_ON: 'visual-sdk-on',
13
14
  VISUAL_SDK_IFRAME_LOAD_PERFORMANCE: 'visual-sdk-iframe-load-performance',
14
15
  };
15
16
 
16
- let isEventCollectorOn = false;
17
- const eventCollectorQueue: { eventId: string; eventProps: any }[] = [];
18
-
19
- function setEventCollectorOn() {
20
- isEventCollectorOn = true;
21
- }
22
-
23
- function getEventCollectorOnValue() {
24
- return isEventCollectorOn;
25
- }
17
+ let isMixpanelInitialized = false;
18
+ let eventQueue: { eventId: string; eventProps: any }[] = [];
26
19
 
27
20
  /**
28
21
  * Pushes the event with its Property key-value map to mixpanel.
29
22
  * @param eventId
30
23
  * @param eventProps
31
24
  */
32
- export async function uploadMixpanelEvent(
33
- eventId: string,
34
- eventProps = {},
35
- ): Promise<any> {
36
- if (!getEventCollectorOnValue()) {
37
- eventCollectorQueue.push({ eventId, eventProps });
38
- return Promise.resolve();
25
+ export function uploadMixpanelEvent(eventId: string, eventProps = {}): void {
26
+ if (!isMixpanelInitialized) {
27
+ eventQueue.push({ eventId, eventProps });
28
+ return;
39
29
  }
40
- return new Promise(() => mixpanel.track(eventId, eventProps));
30
+ mixpanel.track(eventId, eventProps);
41
31
  }
42
32
 
43
33
  function emptyQueue() {
44
- eventCollectorQueue.forEach((event) => {
34
+ if (!isMixpanelInitialized) {
35
+ return;
36
+ }
37
+ eventQueue.forEach((event) => {
45
38
  uploadMixpanelEvent(event.eventId, event.eventProps);
46
39
  });
40
+ eventQueue = [];
47
41
  }
48
42
 
49
43
  export function initMixpanel(sessionInfo: any): void {
@@ -58,7 +52,12 @@ export function initMixpanel(sessionInfo: any): void {
58
52
  if (!isPublicCluster) {
59
53
  mixpanel.identify(sessionInfo.userGUID);
60
54
  }
61
- setEventCollectorOn();
55
+ isMixpanelInitialized = true;
62
56
  emptyQueue();
63
57
  }
64
58
  }
59
+
60
+ export function testResetMixpanel() {
61
+ isMixpanelInitialized = false;
62
+ eventQueue = [];
63
+ }
@@ -41,9 +41,7 @@ describe('React Components', () => {
41
41
  await waitFor(() => getIFrameEl(container));
42
42
 
43
43
  expect(
44
- getIFrameEl(container).parentElement.classList.contains(
45
- 'embedClass',
46
- ),
44
+ getIFrameEl(container).classList.contains('embedClass'),
47
45
  ).toBe(true);
48
46
  expect(getIFrameSrc(container)).toBe(
49
47
  `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22,%22editACopy%22,%22saveAsView%22,%22updateTSL%22,%22editTSL%22,%22onDeleteAnswer%22]&dataSourceMode=hide&useLastSelectedSources=false&isSearchEmbed=true#/embed/answer`,
@@ -130,7 +128,7 @@ describe('React Components', () => {
130
128
  const { container } = render(
131
129
  <SearchBarEmbed
132
130
  className="embedClass"
133
- dataSources={['test']}
131
+ dataSource={'test'}
134
132
  searchOptions={{
135
133
  searchTokenString: '[revenue]',
136
134
  executeSearch: true,
@@ -141,9 +139,7 @@ describe('React Components', () => {
141
139
  await waitFor(() => getIFrameEl(container));
142
140
 
143
141
  expect(
144
- getIFrameEl(container).parentElement.classList.contains(
145
- 'embedClass',
146
- ),
142
+ getIFrameEl(container).classList.contains('embedClass'),
147
143
  ).toBe(true);
148
144
  expect(getIFrameSrc(container)).toBe(
149
145
  `http://${thoughtSpotHost}/?hostAppUrl=local-host&viewPortHeight=768&viewPortWidth=1024&sdkVersion=${version}&authType=None&hideAction=[%22${Action.ReportError}%22]&dataSources=[%22test%22]&searchTokenString=%5Brevenue%5D&executeSearch=true&useLastSelectedSources=false&isSearchEmbed=true#/embed/search-bar-embed`,