@thoughtspot/visual-embed-sdk 1.35.5 → 1.35.6

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.
@@ -96,6 +96,11 @@ const customisationsView = {
96
96
  },
97
97
  };
98
98
 
99
+ const customVariablesForThirdPartyTools = {
100
+ key1: '!@#',
101
+ key2: '*%^',
102
+ };
103
+
99
104
  describe('Unit test case for ts embed', () => {
100
105
  const mockMixPanelEvent = jest.spyOn(mixpanelInstance, 'uploadMixpanelEvent');
101
106
  beforeEach(() => {
@@ -227,6 +232,7 @@ describe('Unit test case for ts embed', () => {
227
232
  thoughtSpotHost: 'tshost',
228
233
  authType: AuthType.None,
229
234
  customizations: customisations,
235
+ customVariablesForThirdPartyTools,
230
236
  });
231
237
  });
232
238
 
@@ -255,6 +261,7 @@ describe('Unit test case for ts embed', () => {
255
261
  hiddenHomepageModules: [],
256
262
  hostConfig: undefined,
257
263
  reorderedHomepageModules: [],
264
+ customVariablesForThirdPartyTools,
258
265
  },
259
266
  });
260
267
  });
@@ -287,6 +294,7 @@ describe('Unit test case for ts embed', () => {
287
294
  hiddenHomepageModules: [],
288
295
  hostConfig: undefined,
289
296
  reorderedHomepageModules: [],
297
+ customVariablesForThirdPartyTools,
290
298
  },
291
299
  });
292
300
  });
@@ -324,6 +332,43 @@ describe('Unit test case for ts embed', () => {
324
332
  hiddenHomeLeftNavItems: [],
325
333
  hiddenHomepageModules: [HomepageModule.MyLibrary, HomepageModule.Learning],
326
334
  reorderedHomepageModules: [],
335
+ customVariablesForThirdPartyTools,
336
+ },
337
+ });
338
+ });
339
+
340
+ test('customVariablesForThirdPartyTools should be part of the app_init payload', async () => {
341
+ const mockEmbedEventPayload = {
342
+ type: EmbedEvent.APP_INIT,
343
+ data: {},
344
+ };
345
+
346
+ const searchEmbed = new AppEmbed(getRootEl(), {
347
+ ...defaultViewConfig,
348
+ });
349
+ searchEmbed.render();
350
+
351
+ const mockPort: any = {
352
+ postMessage: jest.fn(),
353
+ };
354
+
355
+ await executeAfterWait(() => {
356
+ const iframe = getIFrameEl();
357
+ postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
358
+ });
359
+
360
+ expect(mockPort.postMessage).toHaveBeenCalledWith({
361
+ type: EmbedEvent.APP_INIT,
362
+ data: {
363
+ customisations,
364
+ authToken: '',
365
+ hostConfig: undefined,
366
+ runtimeFilterParams: null,
367
+ runtimeParameterParams: null,
368
+ hiddenHomeLeftNavItems: [],
369
+ hiddenHomepageModules: [],
370
+ reorderedHomepageModules: [],
371
+ customVariablesForThirdPartyTools,
327
372
  },
328
373
  });
329
374
  });
@@ -361,6 +406,7 @@ describe('Unit test case for ts embed', () => {
361
406
  hiddenHomeLeftNavItems: [],
362
407
  hiddenHomepageModules: [],
363
408
  reorderedHomepageModules: [HomepageModule.MyLibrary, HomepageModule.Watchlist],
409
+ customVariablesForThirdPartyTools,
364
410
  },
365
411
  });
366
412
  });
@@ -401,6 +447,7 @@ describe('Unit test case for ts embed', () => {
401
447
  hiddenHomepageModules: [],
402
448
  hostConfig: undefined,
403
449
  reorderedHomepageModules: [],
450
+ customVariablesForThirdPartyTools,
404
451
  },
405
452
  });
406
453
  });
@@ -442,6 +489,7 @@ describe('Unit test case for ts embed', () => {
442
489
  hiddenHomepageModules: [],
443
490
  hostConfig: undefined,
444
491
  reorderedHomepageModules: [],
492
+ customVariablesForThirdPartyTools,
445
493
  },
446
494
  });
447
495
  });
@@ -482,6 +530,7 @@ describe('Unit test case for ts embed', () => {
482
530
  hiddenHomepageModules: [],
483
531
  hostConfig: undefined,
484
532
  reorderedHomepageModules: [],
533
+ customVariablesForThirdPartyTools,
485
534
  },
486
535
  });
487
536
  });
@@ -523,6 +572,7 @@ describe('Unit test case for ts embed', () => {
523
572
  hiddenHomepageModules: [],
524
573
  hostConfig: undefined,
525
574
  reorderedHomepageModules: [],
575
+ customVariablesForThirdPartyTools,
526
576
  },
527
577
  });
528
578
  });
@@ -561,6 +611,7 @@ describe('Unit test case for ts embed', () => {
561
611
  [HomeLeftNavItem.Home, HomeLeftNavItem.MonitorSubscription],
562
612
  hiddenHomepageModules: [],
563
613
  reorderedHomepageModules: [],
614
+ customVariablesForThirdPartyTools,
564
615
  },
565
616
  });
566
617
  });
@@ -727,6 +778,7 @@ describe('Unit test case for ts embed', () => {
727
778
  hiddenHomepageModules: [],
728
779
  hostConfig: undefined,
729
780
  reorderedHomepageModules: [],
781
+ customVariablesForThirdPartyTools: {},
730
782
  },
731
783
  });
732
784
  });
@@ -352,6 +352,8 @@ export class TsEmbed {
352
352
  hiddenHomeLeftNavItems: this.viewConfig?.hiddenHomeLeftNavItems
353
353
  ? this.viewConfig?.hiddenHomeLeftNavItems
354
354
  : [],
355
+ customVariablesForThirdPartyTools:
356
+ this.embedConfig.customVariablesForThirdPartyTools || {},
355
357
  },
356
358
  });
357
359
  };
package/src/types.ts CHANGED
@@ -608,6 +608,22 @@ export interface EmbedConfig {
608
608
  * @version SDK: 1.33.5 | ThoughtSpot: *
609
609
  */
610
610
  additionalFlags?: { [key: string]: string | number | boolean };
611
+ /**
612
+ * This is an object (key/val) for customVariables being
613
+ * used by the third party tool's script.
614
+ * @example
615
+ * ```js
616
+ * const embed = new LiveboardEmbed('#embed', {
617
+ * ... // other liveboard view config
618
+ * customVariablesForThirdPartyTools: {
619
+ * key1: 'value1',
620
+ * key2: 'value2'
621
+ * }
622
+ * });
623
+ * ```
624
+ * @version SDK 1.37.0 | Thoughtspot: 10.7.0.cl
625
+ */
626
+ customVariablesForThirdPartyTools?: Record< string, any >;
611
627
  }
612
628
 
613
629
  // eslint-disable-next-line @typescript-eslint/no-empty-interface