@thoughtspot/visual-embed-sdk 1.49.2 → 1.50.0

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 (153) hide show
  1. package/cjs/package.json +4 -10
  2. package/cjs/src/authToken.spec.js +5 -0
  3. package/cjs/src/authToken.spec.js.map +1 -1
  4. package/cjs/src/embed/app.d.ts +7 -1
  5. package/cjs/src/embed/app.d.ts.map +1 -1
  6. package/cjs/src/embed/app.js +6 -0
  7. package/cjs/src/embed/app.js.map +1 -1
  8. package/cjs/src/embed/app.spec.js +11 -2
  9. package/cjs/src/embed/app.spec.js.map +1 -1
  10. package/cjs/src/embed/conversation.d.ts +12 -0
  11. package/cjs/src/embed/conversation.d.ts.map +1 -1
  12. package/cjs/src/embed/conversation.js.map +1 -1
  13. package/cjs/src/embed/conversation.spec.js +30 -0
  14. package/cjs/src/embed/conversation.spec.js.map +1 -1
  15. package/cjs/src/embed/embedConfig.spec.d.ts +2 -0
  16. package/cjs/src/embed/embedConfig.spec.d.ts.map +1 -0
  17. package/cjs/src/embed/embedConfig.spec.js +74 -0
  18. package/cjs/src/embed/embedConfig.spec.js.map +1 -0
  19. package/cjs/src/embed/host-events.spec.d.ts +2 -0
  20. package/cjs/src/embed/host-events.spec.d.ts.map +1 -0
  21. package/cjs/src/embed/host-events.spec.js +1219 -0
  22. package/cjs/src/embed/host-events.spec.js.map +1 -0
  23. package/cjs/src/embed/liveboard.d.ts +6 -0
  24. package/cjs/src/embed/liveboard.d.ts.map +1 -1
  25. package/cjs/src/embed/liveboard.js.map +1 -1
  26. package/cjs/src/embed/spotter-viz-utils.d.ts +29 -0
  27. package/cjs/src/embed/spotter-viz-utils.d.ts.map +1 -1
  28. package/cjs/src/embed/spotter-viz-utils.js.map +1 -1
  29. package/cjs/src/index.d.ts +2 -2
  30. package/cjs/src/index.d.ts.map +1 -1
  31. package/cjs/src/index.js.map +1 -1
  32. package/cjs/src/mixpanel-service.spec.js +14 -0
  33. package/cjs/src/mixpanel-service.spec.js.map +1 -1
  34. package/cjs/src/types.d.ts +93 -6
  35. package/cjs/src/types.d.ts.map +1 -1
  36. package/cjs/src/types.js +88 -3
  37. package/cjs/src/types.js.map +1 -1
  38. package/cjs/src/utils/custom-actions.spec.js +26 -0
  39. package/cjs/src/utils/custom-actions.spec.js.map +1 -1
  40. package/cjs/src/utils/graphql/answerService/answerService.spec.js +15 -0
  41. package/cjs/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  42. package/cjs/src/utils/processData.spec.js +30 -0
  43. package/cjs/src/utils/processData.spec.js.map +1 -1
  44. package/cjs/src/utils/reporting.spec.js +21 -0
  45. package/cjs/src/utils/reporting.spec.js.map +1 -1
  46. package/cjs/src/utils/sessionInfoService.spec.d.ts +2 -0
  47. package/cjs/src/utils/sessionInfoService.spec.d.ts.map +1 -0
  48. package/cjs/src/utils/sessionInfoService.spec.js +130 -0
  49. package/cjs/src/utils/sessionInfoService.spec.js.map +1 -0
  50. package/cjs/src/utils.js +2 -3
  51. package/cjs/src/utils.js.map +1 -1
  52. package/cjs/src/utils.spec.js +158 -0
  53. package/cjs/src/utils.spec.js.map +1 -1
  54. package/dist/{index-CS7yJ2Jj.js → index-B5xoN6Cp.js} +303 -187
  55. package/dist/src/embed/app.d.ts +7 -1
  56. package/dist/src/embed/app.d.ts.map +1 -1
  57. package/dist/src/embed/conversation.d.ts +12 -0
  58. package/dist/src/embed/conversation.d.ts.map +1 -1
  59. package/dist/src/embed/embedConfig.spec.d.ts +2 -0
  60. package/dist/src/embed/embedConfig.spec.d.ts.map +1 -0
  61. package/dist/src/embed/host-events.spec.d.ts +2 -0
  62. package/dist/src/embed/host-events.spec.d.ts.map +1 -0
  63. package/dist/src/embed/liveboard.d.ts +6 -0
  64. package/dist/src/embed/liveboard.d.ts.map +1 -1
  65. package/dist/src/embed/spotter-viz-utils.d.ts +29 -0
  66. package/dist/src/embed/spotter-viz-utils.d.ts.map +1 -1
  67. package/dist/src/index.d.ts +2 -2
  68. package/dist/src/index.d.ts.map +1 -1
  69. package/dist/src/types.d.ts +93 -6
  70. package/dist/src/types.d.ts.map +1 -1
  71. package/dist/src/utils/sessionInfoService.spec.d.ts +2 -0
  72. package/dist/src/utils/sessionInfoService.spec.d.ts.map +1 -0
  73. package/dist/tsembed-react.es.js +126 -18
  74. package/dist/tsembed-react.js +427 -203
  75. package/dist/tsembed.es.js +126 -18
  76. package/dist/tsembed.js +427 -203
  77. package/dist/visual-embed-sdk-react-full.d.ts +147 -7
  78. package/dist/visual-embed-sdk-react.d.ts +147 -7
  79. package/dist/visual-embed-sdk.d.ts +147 -7
  80. package/lib/package.json +4 -10
  81. package/lib/src/authToken.spec.js +5 -0
  82. package/lib/src/authToken.spec.js.map +1 -1
  83. package/lib/src/embed/app.d.ts +7 -1
  84. package/lib/src/embed/app.d.ts.map +1 -1
  85. package/lib/src/embed/app.js +6 -0
  86. package/lib/src/embed/app.js.map +1 -1
  87. package/lib/src/embed/app.spec.js +11 -2
  88. package/lib/src/embed/app.spec.js.map +1 -1
  89. package/lib/src/embed/conversation.d.ts +12 -0
  90. package/lib/src/embed/conversation.d.ts.map +1 -1
  91. package/lib/src/embed/conversation.js.map +1 -1
  92. package/lib/src/embed/conversation.spec.js +30 -0
  93. package/lib/src/embed/conversation.spec.js.map +1 -1
  94. package/lib/src/embed/embedConfig.spec.d.ts +2 -0
  95. package/lib/src/embed/embedConfig.spec.d.ts.map +1 -0
  96. package/lib/src/embed/embedConfig.spec.js +72 -0
  97. package/lib/src/embed/embedConfig.spec.js.map +1 -0
  98. package/lib/src/embed/host-events.spec.d.ts +2 -0
  99. package/lib/src/embed/host-events.spec.d.ts.map +1 -0
  100. package/lib/src/embed/host-events.spec.js +1216 -0
  101. package/lib/src/embed/host-events.spec.js.map +1 -0
  102. package/lib/src/embed/liveboard.d.ts +6 -0
  103. package/lib/src/embed/liveboard.d.ts.map +1 -1
  104. package/lib/src/embed/liveboard.js.map +1 -1
  105. package/lib/src/embed/spotter-viz-utils.d.ts +29 -0
  106. package/lib/src/embed/spotter-viz-utils.d.ts.map +1 -1
  107. package/lib/src/embed/spotter-viz-utils.js.map +1 -1
  108. package/lib/src/index.d.ts +2 -2
  109. package/lib/src/index.d.ts.map +1 -1
  110. package/lib/src/index.js.map +1 -1
  111. package/lib/src/mixpanel-service.spec.js +14 -0
  112. package/lib/src/mixpanel-service.spec.js.map +1 -1
  113. package/lib/src/types.d.ts +93 -6
  114. package/lib/src/types.d.ts.map +1 -1
  115. package/lib/src/types.js +88 -3
  116. package/lib/src/types.js.map +1 -1
  117. package/lib/src/utils/custom-actions.spec.js +26 -0
  118. package/lib/src/utils/custom-actions.spec.js.map +1 -1
  119. package/lib/src/utils/graphql/answerService/answerService.spec.js +15 -0
  120. package/lib/src/utils/graphql/answerService/answerService.spec.js.map +1 -1
  121. package/lib/src/utils/processData.spec.js +30 -0
  122. package/lib/src/utils/processData.spec.js.map +1 -1
  123. package/lib/src/utils/reporting.spec.js +21 -0
  124. package/lib/src/utils/reporting.spec.js.map +1 -1
  125. package/lib/src/utils/sessionInfoService.spec.d.ts +2 -0
  126. package/lib/src/utils/sessionInfoService.spec.d.ts.map +1 -0
  127. package/lib/src/utils/sessionInfoService.spec.js +127 -0
  128. package/lib/src/utils/sessionInfoService.spec.js.map +1 -0
  129. package/lib/src/utils.js +1 -1
  130. package/lib/src/utils.js.map +1 -1
  131. package/lib/src/utils.spec.js +159 -1
  132. package/lib/src/utils.spec.js.map +1 -1
  133. package/lib/src/visual-embed-sdk.d.ts +147 -7
  134. package/package.json +4 -10
  135. package/src/authToken.spec.ts +6 -0
  136. package/src/embed/app.spec.ts +15 -2
  137. package/src/embed/app.ts +13 -1
  138. package/src/embed/conversation.spec.ts +32 -0
  139. package/src/embed/conversation.ts +12 -0
  140. package/src/embed/embedConfig.spec.ts +79 -0
  141. package/src/embed/host-events.spec.ts +1635 -0
  142. package/src/embed/liveboard.ts +6 -0
  143. package/src/embed/spotter-viz-utils.ts +30 -0
  144. package/src/index.ts +2 -1
  145. package/src/mixpanel-service.spec.ts +15 -0
  146. package/src/types.ts +96 -6
  147. package/src/utils/custom-actions.spec.ts +28 -0
  148. package/src/utils/graphql/answerService/answerService.spec.ts +18 -0
  149. package/src/utils/processData.spec.ts +32 -0
  150. package/src/utils/reporting.spec.ts +27 -0
  151. package/src/utils/sessionInfoService.spec.ts +151 -0
  152. package/src/utils.spec.ts +195 -0
  153. package/src/utils.ts +1 -1
@@ -522,7 +522,7 @@ describe('App embed tests', () => {
522
522
  });
523
523
  });
524
524
 
525
- test('Should add homepageVersion=v4 when homePage is Focused to the iframe src', async () => {
525
+ test('Should add homepageVersion=v4 and updatedSpotterChatPrompt=true when homePage is Focused to the iframe src', async () => {
526
526
  await testUrlParams(
527
527
  {
528
528
  ...defaultViewConfig,
@@ -530,7 +530,20 @@ describe('App embed tests', () => {
530
530
  homePage: HomePage.Focused,
531
531
  },
532
532
  } as AppViewConfig,
533
- `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&homepageVersion=v4${defaultParams}${defaultParamsPost}#/home`,
533
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&homepageVersion=v4&updatedSpotterChatPrompt=true${defaultParams}${defaultParamsPost}#/home`,
534
+ );
535
+ });
536
+
537
+ test('Should respect explicit updatedSpotterChatPrompt=false even when homePage is Focused', async () => {
538
+ await testUrlParams(
539
+ {
540
+ ...defaultViewConfig,
541
+ discoveryExperience: {
542
+ homePage: HomePage.Focused,
543
+ },
544
+ updatedSpotterChatPrompt: false,
545
+ } as AppViewConfig,
546
+ `http://${thoughtSpotHost}/?embedApp=true&primaryNavHidden=true&profileAndHelpInNavBarHidden=false&modularHomeExperience=false&navigationVersion=v2&homepageVersion=v4&updatedSpotterChatPrompt=false${defaultParams}${defaultParamsPost}#/home`,
534
547
  );
535
548
  });
536
549
 
package/src/embed/app.ts CHANGED
@@ -798,7 +798,13 @@ export interface AppViewConfig extends AllEmbedViewConfig {
798
798
  * description: 'Ask questions about your data',
799
799
  * inputChatPlaceholder: 'Ask a question...',
800
800
  * hideStarterPrompts: false,
801
- * customStarterPrompts: [{ id: '1', displayText: 'Top products', fullPrompt: 'What are the top products by revenue?' }]
801
+ * customStarterPrompts: [{ id: '1', displayText: 'Top products', fullPrompt: 'What are the top products by revenue?' }],
802
+ * // loaderHeadline and loaderTips require SDK: 1.51.0 | ThoughtSpot Cloud: 26.8.0.cl
803
+ * loaderHeadline: 'Crunching the numbers...',
804
+ * loaderTips: [
805
+ * { label: 'Tip', text: 'try asking about revenue by region' },
806
+ * { label: 'Tip', text: 'use natural language' },
807
+ * ],
802
808
  * },
803
809
  * })
804
810
  * ```
@@ -1212,6 +1218,12 @@ export class AppEmbed extends V1Embed {
1212
1218
 
1213
1219
  if (discoveryExperience.homePage === HomePage.Focused) {
1214
1220
  params[Param.HomepageVersion] = HomePage.Focused;
1221
+ // The Focused (V4) homepage experience requires the updated
1222
+ // Spotter chat prompt. Enable it automatically unless the
1223
+ // developer has explicitly set updatedSpotterChatPrompt.
1224
+ if (isUndefined(updatedSpotterChatPrompt)) {
1225
+ params[Param.UpdatedSpotterChatPrompt] = true;
1226
+ }
1215
1227
  }
1216
1228
  }
1217
1229
 
@@ -465,6 +465,12 @@ describe('ConversationEmbed', () => {
465
465
  ['SpotterChatConnectorResources', Action.SpotterChatConnectorResources],
466
466
  ['SpotterChatConnectors', Action.SpotterChatConnectors],
467
467
  ['SpotterChatModeSwitcher', Action.SpotterChatModeSwitcher],
468
+ ['SpotterAnalystShare', Action.SpotterAnalystShare],
469
+ ['SpotterAnalystEdit', Action.SpotterAnalystEdit],
470
+ ['SpotterAnalystCreate', Action.SpotterAnalystCreate],
471
+ ['SpotterAnalystDelete', Action.SpotterAnalystDelete],
472
+ ['SpotterAnalystMakeACopy', Action.SpotterAnalystMakeACopy],
473
+ ['SpotterAnalystSidebar', Action.SpotterAnalystSidebar],
468
474
  ])('should render with hiddenActions for %s', async (_, action) => {
469
475
  const viewConfig: SpotterEmbedViewConfig = {
470
476
  worksheetId: 'worksheetId',
@@ -503,6 +509,12 @@ describe('ConversationEmbed', () => {
503
509
  ['SpotterChatConnectorResources', Action.SpotterChatConnectorResources],
504
510
  ['SpotterChatConnectors', Action.SpotterChatConnectors],
505
511
  ['SpotterChatModeSwitcher', Action.SpotterChatModeSwitcher],
512
+ ['SpotterAnalystShare', Action.SpotterAnalystShare],
513
+ ['SpotterAnalystEdit', Action.SpotterAnalystEdit],
514
+ ['SpotterAnalystCreate', Action.SpotterAnalystCreate],
515
+ ['SpotterAnalystDelete', Action.SpotterAnalystDelete],
516
+ ['SpotterAnalystMakeACopy', Action.SpotterAnalystMakeACopy],
517
+ ['SpotterAnalystSidebar', Action.SpotterAnalystSidebar],
506
518
  ])('should render with disabledActions for %s', async (_, action) => {
507
519
  const disabledReason = 'testing disabled reason';
508
520
  const viewConfig: SpotterEmbedViewConfig = {
@@ -612,6 +624,26 @@ describe('SpotterEmbed APP_INIT embedParams', () => {
612
624
  expect(response.data.embedParams).toBeUndefined();
613
625
  });
614
626
 
627
+ it('should include spotterAnalystLabel in embedParams.spotterSidebarConfig when set', async () => {
628
+ const response = await getAppInitResponse({
629
+ worksheetId: 'ws1',
630
+ spotterSidebarConfig: {
631
+ spotterAnalystLabel: 'My Analyst',
632
+ },
633
+ });
634
+ expect(response.data.embedParams.spotterSidebarConfig.spotterAnalystLabel).toBe('My Analyst');
635
+ });
636
+
637
+ it('should include spotterAnalystsLabel in embedParams.spotterSidebarConfig when set', async () => {
638
+ const response = await getAppInitResponse({
639
+ worksheetId: 'ws1',
640
+ spotterSidebarConfig: {
641
+ spotterAnalystsLabel: 'My Analysts',
642
+ },
643
+ });
644
+ expect(response.data.embedParams.spotterSidebarConfig.spotterAnalystsLabel).toBe('My Analysts');
645
+ });
646
+
615
647
  it('should call handleError and exclude spotterDocumentationUrl from embedParams when URL is invalid', async () => {
616
648
  const embed = new SpotterEmbed(getRootEl(), {
617
649
  worksheetId: 'ws1',
@@ -89,6 +89,18 @@ export interface SpotterSidebarViewConfig {
89
89
  * @version SDK: 1.47.0 | ThoughtSpot: 26.4.0.cl
90
90
  */
91
91
  spotterNewChatButtonTitle?: string;
92
+ /**
93
+ * Custom label text for the Spotter Analyst section in the sidebar.
94
+ * @version SDK: 1.51.0 | ThoughtSpot: 26.8.0.cl
95
+ * @default Analyst
96
+ */
97
+ spotterAnalystLabel?: string;
98
+ /**
99
+ * Custom label text for the Spotter Analysts section in the sidebar.
100
+ * @version SDK: 1.51.0 | ThoughtSpot: 26.8.0.cl
101
+ * @default Analysts
102
+ */
103
+ spotterAnalystsLabel?: string;
92
104
  }
93
105
 
94
106
  /**
@@ -0,0 +1,79 @@
1
+ import { getEmbedConfig, setEmbedConfig } from './embedConfig';
2
+ import { storeValueInWindow, resetValueFromWindow } from '../utils';
3
+
4
+ describe('embedConfig', () => {
5
+ beforeEach(() => {
6
+ // Ensure the SDK window namespace exists before resetting individual keys
7
+ storeValueInWindow('embedConfig', undefined);
8
+ resetValueFromWindow('embedConfig');
9
+ });
10
+
11
+ describe('getEmbedConfig', () => {
12
+ test('returns empty object when no config has been set', () => {
13
+ expect(getEmbedConfig()).toEqual({});
14
+ });
15
+
16
+ test('returns the config that was previously set', () => {
17
+ const config: any = {
18
+ thoughtSpotHost: 'https://myhost.thoughtspot.com',
19
+ authType: 'None' as any,
20
+ };
21
+ setEmbedConfig(config);
22
+ expect(getEmbedConfig()).toEqual(config);
23
+ });
24
+
25
+ test('returns the full config object including nested properties', () => {
26
+ const config: any = {
27
+ thoughtSpotHost: 'https://myhost.thoughtspot.com',
28
+ authType: 'None' as any,
29
+ customizations: {
30
+ style: {
31
+ customCSS: {
32
+ variables: { '--ts-var-root-background': '#fff' },
33
+ },
34
+ },
35
+ },
36
+ };
37
+ setEmbedConfig(config);
38
+ expect(getEmbedConfig()).toEqual(config);
39
+ });
40
+ });
41
+
42
+ describe('setEmbedConfig', () => {
43
+ test('stores the config and returns it', () => {
44
+ const config: any = {
45
+ thoughtSpotHost: 'https://myhost.thoughtspot.com',
46
+ authType: 'None' as any,
47
+ };
48
+ const result = setEmbedConfig(config);
49
+ expect(result).toEqual(config);
50
+ });
51
+
52
+ test('getEmbedConfig reflects the config after setEmbedConfig', () => {
53
+ const config: any = {
54
+ thoughtSpotHost: 'https://updated.thoughtspot.com',
55
+ authType: 'TrustedAuthToken' as any,
56
+ };
57
+ setEmbedConfig(config);
58
+ expect(getEmbedConfig()).toEqual(config);
59
+ });
60
+
61
+ test('overwrites a previously stored config', () => {
62
+ const first: any = { thoughtSpotHost: 'https://first.com', authType: 'None' as any };
63
+ const second: any = { thoughtSpotHost: 'https://second.com', authType: 'TrustedAuthToken' as any };
64
+ setEmbedConfig(first);
65
+ setEmbedConfig(second);
66
+ expect(getEmbedConfig()).toEqual(second);
67
+ });
68
+
69
+ test('handles config with disableFullscreenPresentation flag', () => {
70
+ const config: any = {
71
+ thoughtSpotHost: 'https://myhost.thoughtspot.com',
72
+ authType: 'None' as any,
73
+ disableFullscreenPresentation: true,
74
+ };
75
+ setEmbedConfig(config);
76
+ expect(getEmbedConfig().disableFullscreenPresentation).toBe(true);
77
+ });
78
+ });
79
+ });