@thoughtspot/visual-embed-sdk 1.27.0-alpha.0 → 1.27.0-loggers
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.
- package/cjs/package.json +1 -1
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +5 -4
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/embed/app.d.ts +1 -1
- package/cjs/src/embed/app.d.ts.map +1 -1
- package/cjs/src/embed/app.js +3 -2
- package/cjs/src/embed/app.js.map +1 -1
- package/cjs/src/embed/app.spec.js +5 -4
- package/cjs/src/embed/app.spec.js.map +1 -1
- package/cjs/src/embed/base.d.ts.map +1 -1
- package/cjs/src/embed/base.js +5 -2
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +3 -2
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +2 -1
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/embedConfig.d.ts +2 -1
- package/cjs/src/embed/embedConfig.d.ts.map +1 -1
- package/cjs/src/embed/embedConfig.js +2 -0
- package/cjs/src/embed/embedConfig.js.map +1 -1
- package/cjs/src/embed/events.spec.js +3 -2
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.d.ts.map +1 -1
- package/cjs/src/embed/liveboard.js.map +1 -1
- package/cjs/src/embed/sage.d.ts +1 -1
- package/cjs/src/embed/sage.d.ts.map +1 -1
- package/cjs/src/embed/sage.js.map +1 -1
- package/cjs/src/embed/search.d.ts +1 -1
- package/cjs/src/embed/search.d.ts.map +1 -1
- package/cjs/src/embed/search.js +2 -3
- package/cjs/src/embed/search.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts +0 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +13 -13
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +27 -26
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/mixpanel-service.d.ts.map +1 -1
- package/cjs/src/mixpanel-service.js +2 -1
- package/cjs/src/mixpanel-service.js.map +1 -1
- package/cjs/src/react/index.spec.js +2 -2
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +25 -1
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +12 -1
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/authService.d.ts.map +1 -1
- package/cjs/src/utils/authService/authService.js +3 -2
- package/cjs/src/utils/authService/authService.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +3 -2
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.js +2 -1
- package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/cjs/src/utils/logger.d.ts +18 -0
- package/cjs/src/utils/logger.d.ts.map +1 -0
- package/cjs/src/utils/logger.js +78 -0
- package/cjs/src/utils/logger.js.map +1 -0
- package/cjs/src/utils/logger.spec.d.ts +25 -0
- package/cjs/src/utils/logger.spec.d.ts.map +1 -0
- package/cjs/src/utils/logger.spec.js +80 -0
- package/cjs/src/utils/logger.spec.js.map +1 -0
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/embed/app.d.ts +1 -1
- package/dist/src/embed/app.d.ts.map +1 -1
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/embedConfig.d.ts +2 -1
- package/dist/src/embed/embedConfig.d.ts.map +1 -1
- package/dist/src/embed/liveboard.d.ts.map +1 -1
- package/dist/src/embed/sage.d.ts +1 -1
- package/dist/src/embed/sage.d.ts.map +1 -1
- package/dist/src/embed/search.d.ts +1 -1
- package/dist/src/embed/search.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts +0 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/types.d.ts +25 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/authService/authService.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/dist/src/utils/logger.d.ts +18 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.spec.d.ts +25 -0
- package/dist/src/utils/logger.spec.d.ts.map +1 -0
- package/dist/tsembed-react.es.js +17309 -33
- package/dist/tsembed-react.js +17309 -33
- package/dist/tsembed.es.js +17635 -353
- package/dist/tsembed.js +32458 -15176
- package/dist/visual-embed-sdk-react-full.d.ts +27 -24
- package/dist/visual-embed-sdk-react.d.ts +27 -24
- package/dist/visual-embed-sdk.d.ts +27 -24
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +5 -4
- package/lib/src/auth.js.map +1 -1
- package/lib/src/embed/app.d.ts +1 -1
- package/lib/src/embed/app.d.ts.map +1 -1
- package/lib/src/embed/app.js +3 -2
- package/lib/src/embed/app.js.map +1 -1
- package/lib/src/embed/app.spec.js +5 -4
- package/lib/src/embed/app.spec.js.map +1 -1
- package/lib/src/embed/base.d.ts.map +1 -1
- package/lib/src/embed/base.js +6 -3
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +3 -2
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +2 -1
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/embedConfig.d.ts +2 -1
- package/lib/src/embed/embedConfig.d.ts.map +1 -1
- package/lib/src/embed/embedConfig.js +2 -0
- package/lib/src/embed/embedConfig.js.map +1 -1
- package/lib/src/embed/events.spec.js +3 -2
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/liveboard.d.ts.map +1 -1
- package/lib/src/embed/liveboard.js.map +1 -1
- package/lib/src/embed/sage.d.ts +1 -1
- package/lib/src/embed/sage.d.ts.map +1 -1
- package/lib/src/embed/sage.js.map +1 -1
- package/lib/src/embed/search.d.ts +1 -1
- package/lib/src/embed/search.d.ts.map +1 -1
- package/lib/src/embed/search.js +2 -3
- package/lib/src/embed/search.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts +0 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +13 -13
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +27 -26
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +2 -1
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/react/index.spec.js +2 -2
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +25 -1
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +11 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.d.ts.map +1 -1
- package/lib/src/utils/authService/authService.js +3 -2
- package/lib/src/utils/authService/authService.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +3 -2
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.js +2 -1
- package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/lib/src/utils/logger.d.ts +18 -0
- package/lib/src/utils/logger.d.ts.map +1 -0
- package/lib/src/utils/logger.js +73 -0
- package/lib/src/utils/logger.js.map +1 -0
- package/lib/src/utils/logger.spec.d.ts +25 -0
- package/lib/src/utils/logger.spec.d.ts.map +1 -0
- package/lib/src/utils/logger.spec.js +57 -0
- package/lib/src/utils/logger.spec.js.map +1 -0
- package/lib/src/visual-embed-sdk.d.ts +27 -24
- package/package.json +1 -1
- package/src/auth.ts +5 -4
- package/src/embed/app.spec.ts +5 -4
- package/src/embed/app.ts +4 -3
- package/src/embed/base.spec.ts +3 -2
- package/src/embed/base.ts +10 -3
- package/src/embed/embed.spec.ts +2 -1
- package/src/embed/embedConfig.ts +2 -0
- package/src/embed/events.spec.ts +3 -2
- package/src/embed/liveboard.ts +4 -4
- package/src/embed/sage.ts +1 -1
- package/src/embed/search.ts +3 -4
- package/src/embed/ts-embed.spec.ts +27 -26
- package/src/embed/ts-embed.ts +19 -19
- package/src/mixpanel-service.ts +2 -1
- package/src/react/index.spec.tsx +2 -2
- package/src/types.ts +26 -0
- package/src/utils/authService/authService.spec.ts +3 -2
- package/src/utils/authService/authService.ts +4 -2
- package/src/utils/authService/tokenizedAuthService.ts +2 -1
- package/src/utils/logger.spec.ts +67 -0
- package/src/utils/logger.ts +87 -0
|
@@ -227,12 +227,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/app' {
|
|
|
227
227
|
* embedded Liveboard or visualization.
|
|
228
228
|
*/
|
|
229
229
|
protected getEmbedParams(): string;
|
|
230
|
-
/**
|
|
231
|
-
* Constructs the URL of the ThoughtSpot app page to be rendered.
|
|
232
|
-
*
|
|
233
|
-
* @param pageId The ID of the page to be embedded.
|
|
234
|
-
*/
|
|
235
|
-
getIFrameSrc(): string;
|
|
236
230
|
/**
|
|
237
231
|
* Set the iframe height as per the computed height received
|
|
238
232
|
* from the ThoughtSpot app.
|
|
@@ -729,14 +723,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/search' {
|
|
|
729
723
|
protected embedComponentType: string;
|
|
730
724
|
constructor(domSelector: DOMSelector, viewConfig: SearchViewConfig);
|
|
731
725
|
protected getEmbedParams(): string;
|
|
732
|
-
/**
|
|
733
|
-
* Construct the URL of the embedded ThoughtSpot search to be
|
|
734
|
-
* loaded in the iframe
|
|
735
|
-
*
|
|
736
|
-
* @param answerId The GUID of a saved answer
|
|
737
|
-
* @param dataSources A list of data source GUIDs
|
|
738
|
-
*/
|
|
739
|
-
getIFrameSrc(): string;
|
|
740
726
|
/**
|
|
741
727
|
* Render the embedded ThoughtSpot search
|
|
742
728
|
*/
|
|
@@ -1512,6 +1498,20 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
1512
1498
|
* @version SDK: 1.26.2 | ThoughtSpot: *
|
|
1513
1499
|
*/
|
|
1514
1500
|
suppressErrorAlerts?: boolean;
|
|
1501
|
+
/**
|
|
1502
|
+
* Log level for the SDK.
|
|
1503
|
+
* @default LogLevel.ERROR
|
|
1504
|
+
*
|
|
1505
|
+
* @example
|
|
1506
|
+
* ```js
|
|
1507
|
+
* init({
|
|
1508
|
+
* ...embedConfig,
|
|
1509
|
+
* logLevel: LogLevel.SILENT
|
|
1510
|
+
* })
|
|
1511
|
+
* ```
|
|
1512
|
+
* @version SDK: 1.26.3 | ThoughtSpot: 9.10.0.cl
|
|
1513
|
+
*/
|
|
1514
|
+
logLevel?: LogLevel;
|
|
1515
1515
|
}
|
|
1516
1516
|
export interface LayoutConfig {
|
|
1517
1517
|
}
|
|
@@ -3755,7 +3755,9 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
3755
3755
|
IsProductTour = "isProductTour",
|
|
3756
3756
|
HideSearchBarTitle = "hideSearchBarTitle",
|
|
3757
3757
|
HideSageAnswerHeader = "hideSageAnswerHeader",
|
|
3758
|
-
HideSearchBar = "hideSearchBar"
|
|
3758
|
+
HideSearchBar = "hideSearchBar",
|
|
3759
|
+
ClientLogLevel = "clientLogLevel",
|
|
3760
|
+
OverrideNativeConsole = "overrideConsoleLogs"
|
|
3759
3761
|
}
|
|
3760
3762
|
/**
|
|
3761
3763
|
* ThoughtSpot application pages include actions and menu commands
|
|
@@ -4670,6 +4672,14 @@ declare module '@thoughtspot/visual-embed-sdk/types' {
|
|
|
4670
4672
|
session: SessionInterface;
|
|
4671
4673
|
vizId?: string;
|
|
4672
4674
|
}
|
|
4675
|
+
export enum LogLevel {
|
|
4676
|
+
SILENT = "SILENT",
|
|
4677
|
+
ERROR = "ERROR",
|
|
4678
|
+
WARN = "WARN",
|
|
4679
|
+
INFO = "INFO",
|
|
4680
|
+
DEBUG = "DEBUG",
|
|
4681
|
+
TRACE = "TRACE"
|
|
4682
|
+
}
|
|
4673
4683
|
}
|
|
4674
4684
|
|
|
4675
4685
|
declare module '@thoughtspot/visual-embed-sdk/css-variables' {
|
|
@@ -5166,13 +5176,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/sage' {
|
|
|
5166
5176
|
* @returns {string} query string
|
|
5167
5177
|
*/
|
|
5168
5178
|
protected getEmbedParams(): string;
|
|
5169
|
-
/**
|
|
5170
|
-
* Construct the URL of the embedded ThoughtSpot sage to be
|
|
5171
|
-
* loaded in the iframe
|
|
5172
|
-
*
|
|
5173
|
-
* @returns {string} iframe url
|
|
5174
|
-
*/
|
|
5175
|
-
getIFrameSrc(): string;
|
|
5176
5179
|
/**
|
|
5177
5180
|
* Render the embedded ThoughtSpot Sage
|
|
5178
5181
|
*
|
|
@@ -5270,12 +5273,13 @@ declare module '@thoughtspot/visual-embed-sdk/embed/embedConfig' {
|
|
|
5270
5273
|
export const getEmbedConfig: () => EmbedConfig;
|
|
5271
5274
|
/**
|
|
5272
5275
|
* Sets the configuration embed was initialized with.
|
|
5276
|
+
* And returns the new configuration.
|
|
5273
5277
|
*
|
|
5274
5278
|
* @param newConfig The configuration to set.
|
|
5275
5279
|
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
5276
5280
|
* @group Global methods
|
|
5277
5281
|
*/
|
|
5278
|
-
export const setEmbedConfig: (newConfig: EmbedConfig) =>
|
|
5282
|
+
export const setEmbedConfig: (newConfig: EmbedConfig) => EmbedConfig;
|
|
5279
5283
|
}
|
|
5280
5284
|
|
|
5281
5285
|
declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
@@ -5475,7 +5479,6 @@ declare module '@thoughtspot/visual-embed-sdk/embed/ts-embed' {
|
|
|
5475
5479
|
* @param args
|
|
5476
5480
|
*/
|
|
5477
5481
|
render(): TsEmbed;
|
|
5478
|
-
getIframeSrc(): string;
|
|
5479
5482
|
protected handleRenderForPrerender(): void;
|
|
5480
5483
|
/**
|
|
5481
5484
|
* Creates the preRender shell
|
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
EndPoints,
|
|
14
14
|
} from './utils/authService';
|
|
15
15
|
import { getAuthenticationToken, resetCachedAuthToken } from './authToken';
|
|
16
|
+
import { logger } from './utils/logger';
|
|
16
17
|
|
|
17
18
|
// eslint-disable-next-line import/no-mutable-exports
|
|
18
19
|
export let loggedInStatus = false;
|
|
@@ -154,7 +155,7 @@ export function setAuthEE(eventEmitter: EventEmitter<AuthStatus | AuthEvent>): v
|
|
|
154
155
|
*/
|
|
155
156
|
export function notifyAuthSDKSuccess(): void {
|
|
156
157
|
if (!authEE) {
|
|
157
|
-
|
|
158
|
+
logger.error('SDK not initialized');
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
161
|
authEE.emit(AuthStatus.SDK_SUCCESS);
|
|
@@ -165,7 +166,7 @@ export function notifyAuthSDKSuccess(): void {
|
|
|
165
166
|
*/
|
|
166
167
|
export function notifyAuthSuccess(): void {
|
|
167
168
|
if (!authEE) {
|
|
168
|
-
|
|
169
|
+
logger.error('SDK not initialized');
|
|
169
170
|
return;
|
|
170
171
|
}
|
|
171
172
|
authEE.emit(AuthStatus.SUCCESS, sessionInfo);
|
|
@@ -177,7 +178,7 @@ export function notifyAuthSuccess(): void {
|
|
|
177
178
|
*/
|
|
178
179
|
export function notifyAuthFailure(failureType: AuthFailureType): void {
|
|
179
180
|
if (!authEE) {
|
|
180
|
-
|
|
181
|
+
logger.error('SDK not initialized');
|
|
181
182
|
return;
|
|
182
183
|
}
|
|
183
184
|
authEE.emit(AuthStatus.FAILURE, failureType);
|
|
@@ -188,7 +189,7 @@ export function notifyAuthFailure(failureType: AuthFailureType): void {
|
|
|
188
189
|
*/
|
|
189
190
|
export function notifyLogout(): void {
|
|
190
191
|
if (!authEE) {
|
|
191
|
-
|
|
192
|
+
logger.error('SDK not initialized');
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
195
|
authEE.emit(AuthStatus.LOGOUT);
|
package/src/embed/app.spec.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { version } from '../../package.json';
|
|
19
19
|
import * as config from '../config';
|
|
20
20
|
import { TsEmbed, V1Embed } from './ts-embed';
|
|
21
|
+
import { logger } from '../utils/logger';
|
|
21
22
|
|
|
22
23
|
const defaultViewConfig = {
|
|
23
24
|
frameParams: {
|
|
@@ -463,15 +464,15 @@ describe('App embed tests', () => {
|
|
|
463
464
|
},
|
|
464
465
|
});
|
|
465
466
|
await appEmbed.render();
|
|
466
|
-
spyOn(
|
|
467
|
+
spyOn(logger, 'warn');
|
|
467
468
|
appEmbed.navigateToPage(-1);
|
|
468
|
-
expect(
|
|
469
|
+
expect(logger.warn).toHaveBeenCalledWith(
|
|
469
470
|
'Path can only by a string when triggered without noReload',
|
|
470
471
|
);
|
|
471
472
|
});
|
|
472
473
|
|
|
473
474
|
test('navigateToPage function use before render', async () => {
|
|
474
|
-
spyOn(
|
|
475
|
+
spyOn(logger, 'log');
|
|
475
476
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
476
477
|
frameParams: {
|
|
477
478
|
width: '100%',
|
|
@@ -480,7 +481,7 @@ describe('App embed tests', () => {
|
|
|
480
481
|
});
|
|
481
482
|
appEmbed.navigateToPage(path);
|
|
482
483
|
await appEmbed.render();
|
|
483
|
-
expect(
|
|
484
|
+
expect(logger.log).toHaveBeenCalledWith(
|
|
484
485
|
'Please call render before invoking this method',
|
|
485
486
|
);
|
|
486
487
|
});
|
package/src/embed/app.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @author Ayon Ghosh <ayon.ghosh@thoughtspot.com>
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import { logger } from '../utils/logger';
|
|
12
13
|
import { getQueryParamString } from '../utils';
|
|
13
14
|
import {
|
|
14
15
|
Param, DOMSelector, HostEvent, ViewConfig, EmbedEvent, MessagePayload,
|
|
@@ -282,7 +283,7 @@ export class AppEmbed extends V1Embed {
|
|
|
282
283
|
*
|
|
283
284
|
* @param pageId The ID of the page to be embedded.
|
|
284
285
|
*/
|
|
285
|
-
|
|
286
|
+
private getIFrameSrc() {
|
|
286
287
|
const {
|
|
287
288
|
pageId, path, modularHomeExperience,
|
|
288
289
|
} = this.viewConfig;
|
|
@@ -376,14 +377,14 @@ export class AppEmbed extends V1Embed {
|
|
|
376
377
|
*/
|
|
377
378
|
public navigateToPage(path: string | number, noReload = false): void {
|
|
378
379
|
if (!this.iFrame) {
|
|
379
|
-
|
|
380
|
+
logger.log('Please call render before invoking this method');
|
|
380
381
|
return;
|
|
381
382
|
}
|
|
382
383
|
if (noReload) {
|
|
383
384
|
this.trigger(HostEvent.Navigate, path);
|
|
384
385
|
} else {
|
|
385
386
|
if (typeof path !== 'string') {
|
|
386
|
-
|
|
387
|
+
logger.warn('Path can only by a string when triggered without noReload');
|
|
387
388
|
return;
|
|
388
389
|
}
|
|
389
390
|
const iframeSrc = this.iFrame.src;
|
package/src/embed/base.spec.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
getIFrameSrc,
|
|
18
18
|
} from '../test/test-utils';
|
|
19
19
|
import * as tokenizedFetchInstance from '../tokenizedFetch';
|
|
20
|
+
import { logger } from '../utils/logger';
|
|
20
21
|
|
|
21
22
|
const thoughtSpotHost = 'tshost';
|
|
22
23
|
let authEE: EventEmitter;
|
|
@@ -412,11 +413,11 @@ describe('Base TS Embed', () => {
|
|
|
412
413
|
describe('Base without init', () => {
|
|
413
414
|
test('notify should error when called without init', () => {
|
|
414
415
|
base.reset();
|
|
415
|
-
jest.spyOn(
|
|
416
|
+
jest.spyOn(logger, 'error').mockImplementation(() => undefined);
|
|
416
417
|
base.notifyAuthSuccess();
|
|
417
418
|
base.notifyAuthFailure(auth.AuthFailureType.SDK);
|
|
418
419
|
base.notifyLogout();
|
|
419
420
|
base.notifyAuthSDKSuccess();
|
|
420
|
-
expect(
|
|
421
|
+
expect(logger.error).toHaveBeenCalledTimes(4);
|
|
421
422
|
});
|
|
422
423
|
});
|
package/src/embed/base.ts
CHANGED
|
@@ -10,10 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import EventEmitter from 'eventemitter3';
|
|
12
12
|
import uniq from 'lodash/uniq';
|
|
13
|
+
import { logger, setGlobalLogLevelOverride } from '../utils/logger';
|
|
13
14
|
import { tokenizedFetch } from '../tokenizedFetch';
|
|
14
15
|
import { EndPoints } from '../utils/authService/authService';
|
|
15
16
|
import { getThoughtSpotHost } from '../config';
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
AuthType, EmbedConfig, LogLevel, PrefetchFeatures,
|
|
19
|
+
} from '../types';
|
|
17
20
|
import {
|
|
18
21
|
authenticate,
|
|
19
22
|
logout as _logout,
|
|
@@ -34,6 +37,7 @@ const CONFIG_DEFAULTS: Partial<EmbedConfig> = {
|
|
|
34
37
|
loginFailedMessage: 'Not logged in',
|
|
35
38
|
authTriggerText: 'Authorize',
|
|
36
39
|
authType: AuthType.None,
|
|
40
|
+
logLevel: LogLevel.ERROR,
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
export interface executeTMLInput {
|
|
@@ -100,7 +104,7 @@ const hostUrlToFeatureUrl = {
|
|
|
100
104
|
export const prefetch = (url?: string, prefetchFeatures?: PrefetchFeatures[]): void => {
|
|
101
105
|
if (url === '') {
|
|
102
106
|
// eslint-disable-next-line no-console
|
|
103
|
-
|
|
107
|
+
logger.warn('The prefetch method does not have a valid URL');
|
|
104
108
|
} else {
|
|
105
109
|
const features = prefetchFeatures || [PrefetchFeatures.FullApp];
|
|
106
110
|
let hostUrl = url || getEmbedConfig().thoughtSpotHost;
|
|
@@ -174,13 +178,16 @@ function backwardCompat(embedConfig: EmbedConfig): EmbedConfig {
|
|
|
174
178
|
*/
|
|
175
179
|
export const init = (embedConfig: EmbedConfig): AuthEventEmitter => {
|
|
176
180
|
sanity(embedConfig);
|
|
177
|
-
setEmbedConfig(
|
|
181
|
+
embedConfig = setEmbedConfig(
|
|
178
182
|
backwardCompat({
|
|
179
183
|
...CONFIG_DEFAULTS,
|
|
180
184
|
...embedConfig,
|
|
181
185
|
thoughtSpotHost: getThoughtSpotHost(embedConfig),
|
|
182
186
|
}),
|
|
183
187
|
);
|
|
188
|
+
|
|
189
|
+
setGlobalLogLevelOverride(embedConfig.logLevel);
|
|
190
|
+
|
|
184
191
|
const authEE = new EventEmitter<AuthStatus | AuthEvent>();
|
|
185
192
|
setAuthEE(authEE);
|
|
186
193
|
handleAuth();
|
package/src/embed/embed.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from '../utils/logger';
|
|
1
2
|
import {
|
|
2
3
|
init, AuthType, SearchEmbed, EmbedEvent,
|
|
3
4
|
} from '../index';
|
|
@@ -51,7 +52,7 @@ describe('test view config', () => {
|
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
test('trying to register event handler after render should throw error', async () => {
|
|
54
|
-
spyOn(
|
|
55
|
+
spyOn(logger, 'error');
|
|
55
56
|
const onErrorSpy = jest.fn();
|
|
56
57
|
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
57
58
|
searchEmbed
|
package/src/embed/embedConfig.ts
CHANGED
|
@@ -13,6 +13,7 @@ export const getEmbedConfig = (): EmbedConfig => config;
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Sets the configuration embed was initialized with.
|
|
16
|
+
* And returns the new configuration.
|
|
16
17
|
*
|
|
17
18
|
* @param newConfig The configuration to set.
|
|
18
19
|
* @version SDK: 1.27.0 | ThoughtSpot: *
|
|
@@ -20,4 +21,5 @@ export const getEmbedConfig = (): EmbedConfig => config;
|
|
|
20
21
|
*/
|
|
21
22
|
export const setEmbedConfig = (newConfig: EmbedConfig) => {
|
|
22
23
|
config = newConfig;
|
|
24
|
+
return newConfig;
|
|
23
25
|
};
|
package/src/embed/events.spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from '../utils/logger';
|
|
1
2
|
import {
|
|
2
3
|
init,
|
|
3
4
|
AuthType,
|
|
@@ -155,7 +156,7 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
155
156
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
156
157
|
} as LiveboardViewConfig);
|
|
157
158
|
liveboardEmbed.render();
|
|
158
|
-
const spy1 = jest.spyOn(
|
|
159
|
+
const spy1 = jest.spyOn(logger, 'log');
|
|
159
160
|
|
|
160
161
|
await executeAfterWait(() => {
|
|
161
162
|
const iframe = getIFrameEl();
|
|
@@ -173,7 +174,7 @@ describe('test communication between host app and ThoughtSpot', () => {
|
|
|
173
174
|
pinboardId: 'eca215d4-0d2c-4a55-90e3-d81ef6848ae0',
|
|
174
175
|
} as LiveboardViewConfig);
|
|
175
176
|
pinboardEmbed.render();
|
|
176
|
-
const spy1 = jest.spyOn(
|
|
177
|
+
const spy1 = jest.spyOn(logger, 'log');
|
|
177
178
|
|
|
178
179
|
await executeAfterWait(() => {
|
|
179
180
|
const iframe = getIFrameEl();
|
package/src/embed/liveboard.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { V1Embed } from './ts-embed';
|
|
|
28
28
|
*
|
|
29
29
|
* @group Embed components
|
|
30
30
|
*/
|
|
31
|
-
export interface LiveboardViewConfig extends Omit<ViewConfig, 'hiddenHomepageModules' | 'hiddenHomeLeftNavItems'
|
|
31
|
+
export interface LiveboardViewConfig extends Omit<ViewConfig, 'hiddenHomepageModules' | 'hiddenHomeLeftNavItems'| 'reorderedHomepageModules'> {
|
|
32
32
|
/**
|
|
33
33
|
* If set to true, the embedded object container dynamically resizes
|
|
34
34
|
* according to the height of the Liveboard.
|
|
@@ -263,7 +263,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
263
263
|
* Construct the URL of the embedded ThoughtSpot Liveboard or visualization
|
|
264
264
|
* to be loaded within the iFrame.
|
|
265
265
|
*/
|
|
266
|
-
private getIFrameSrc()
|
|
266
|
+
private getIFrameSrc() {
|
|
267
267
|
const { vizId, activeTabId } = this.viewConfig;
|
|
268
268
|
const liveboardId = this.viewConfig.liveboardId ?? this.viewConfig.pinboardId;
|
|
269
269
|
|
|
@@ -312,7 +312,7 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
312
312
|
if (isUndefined(embedObj)) return;
|
|
313
313
|
|
|
314
314
|
const showDifferentLib = this.viewConfig.liveboardId
|
|
315
|
-
|
|
315
|
+
&& embedObj.viewConfig.liveboardId !== this.viewConfig.liveboardId;
|
|
316
316
|
|
|
317
317
|
if (showDifferentLib) {
|
|
318
318
|
const libId = this.viewConfig.liveboardId;
|
|
@@ -379,4 +379,4 @@ export class LiveboardEmbed extends V1Embed {
|
|
|
379
379
|
/**
|
|
380
380
|
* @hidden
|
|
381
381
|
*/
|
|
382
|
-
export class PinboardEmbed extends LiveboardEmbed {
|
|
382
|
+
export class PinboardEmbed extends LiveboardEmbed {}
|
package/src/embed/sage.ts
CHANGED
|
@@ -212,7 +212,7 @@ export class SageEmbed extends V1Embed {
|
|
|
212
212
|
*
|
|
213
213
|
* @returns {string} iframe url
|
|
214
214
|
*/
|
|
215
|
-
|
|
215
|
+
private getIFrameSrc() {
|
|
216
216
|
const path = 'eureka';
|
|
217
217
|
const postHashObj = {};
|
|
218
218
|
const tsPostHashParams = this.getThoughtSpotPostUrlParams();
|
package/src/embed/search.ts
CHANGED
|
@@ -272,8 +272,7 @@ export class SearchEmbed extends TsEmbed {
|
|
|
272
272
|
* @param answerId The GUID of a saved answer
|
|
273
273
|
* @param dataSources A list of data source GUIDs
|
|
274
274
|
*/
|
|
275
|
-
|
|
276
|
-
const { answerId } = this.viewConfig;
|
|
275
|
+
private getIFrameSrc(answerId: string) {
|
|
277
276
|
const answerPath = answerId ? `saved-answer/${answerId}` : 'answer';
|
|
278
277
|
const tsPostHashParams = this.getThoughtSpotPostUrlParams();
|
|
279
278
|
|
|
@@ -287,14 +286,14 @@ export class SearchEmbed extends TsEmbed {
|
|
|
287
286
|
super.render();
|
|
288
287
|
const { answerId } = this.viewConfig;
|
|
289
288
|
|
|
290
|
-
const src = this.getIFrameSrc();
|
|
289
|
+
const src = this.getIFrameSrc(answerId);
|
|
291
290
|
this.renderIFrame(src);
|
|
292
291
|
getAuthPromise().then(() => {
|
|
293
292
|
if (
|
|
294
293
|
checkReleaseVersionInBeta(
|
|
295
294
|
getReleaseVersion(),
|
|
296
295
|
getEmbedConfig().suppressSearchEmbedBetaWarning
|
|
297
|
-
|
|
296
|
+
|| getEmbedConfig().suppressErrorAlerts,
|
|
298
297
|
)
|
|
299
298
|
) {
|
|
300
299
|
alert(ERROR_MESSAGE.SEARCHEMBED_BETA_WRANING_MESSAGE);
|
|
@@ -32,6 +32,7 @@ import * as authInstance from '../auth';
|
|
|
32
32
|
import * as baseInstance from './base';
|
|
33
33
|
import { MIXPANEL_EVENT } from '../mixpanel-service';
|
|
34
34
|
import * as authService from '../utils/authService/authService';
|
|
35
|
+
import { logger } from '../utils/logger';
|
|
35
36
|
|
|
36
37
|
const defaultViewConfig = {
|
|
37
38
|
frameParams: {
|
|
@@ -425,7 +426,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
425
426
|
const searchEmbed = new SearchEmbed(getRootEl(), defaultViewConfig);
|
|
426
427
|
searchEmbed
|
|
427
428
|
.on(EmbedEvent.Save, () => {
|
|
428
|
-
|
|
429
|
+
logger.log('non callable');
|
|
429
430
|
})
|
|
430
431
|
.render();
|
|
431
432
|
|
|
@@ -468,7 +469,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
468
469
|
.on(
|
|
469
470
|
EmbedEvent.Save,
|
|
470
471
|
() => {
|
|
471
|
-
|
|
472
|
+
logger.log('non callable');
|
|
472
473
|
},
|
|
473
474
|
{ start: true },
|
|
474
475
|
)
|
|
@@ -830,7 +831,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
830
831
|
const iFrame: any = document.createElement('div');
|
|
831
832
|
iFrame.contentWindow = null;
|
|
832
833
|
jest.spyOn(document, 'createElement').mockReturnValueOnce(iFrame);
|
|
833
|
-
spyOn(
|
|
834
|
+
spyOn(logger, 'error');
|
|
834
835
|
tsEmbed.render();
|
|
835
836
|
});
|
|
836
837
|
|
|
@@ -844,7 +845,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
844
845
|
|
|
845
846
|
describe('when visible actions are set', () => {
|
|
846
847
|
test('should throw error when there are both visible and hidden actions - pinboard', async () => {
|
|
847
|
-
spyOn(
|
|
848
|
+
spyOn(logger, 'error');
|
|
848
849
|
const pinboardEmbed = new PinboardEmbed(getRootEl(), {
|
|
849
850
|
hiddenActions: [Action.DownloadAsCsv],
|
|
850
851
|
visibleActions: [Action.DownloadAsCsv],
|
|
@@ -853,7 +854,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
853
854
|
} as LiveboardViewConfig);
|
|
854
855
|
await pinboardEmbed.render();
|
|
855
856
|
expect(pinboardEmbed['isError']).toBe(true);
|
|
856
|
-
expect(
|
|
857
|
+
expect(logger.error).toHaveBeenCalledWith(
|
|
857
858
|
'You cannot have both hidden actions and visible actions',
|
|
858
859
|
);
|
|
859
860
|
});
|
|
@@ -876,7 +877,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
876
877
|
hiddenActions: Array<Action>,
|
|
877
878
|
visibleActions: Array<Action>,
|
|
878
879
|
) {
|
|
879
|
-
spyOn(
|
|
880
|
+
spyOn(logger, 'error');
|
|
880
881
|
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
881
882
|
hiddenActions,
|
|
882
883
|
visibleActions,
|
|
@@ -885,7 +886,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
885
886
|
} as LiveboardViewConfig);
|
|
886
887
|
await liveboardEmbed.render();
|
|
887
888
|
expect(liveboardEmbed['isError']).toBe(true);
|
|
888
|
-
expect(
|
|
889
|
+
expect(logger.error).toHaveBeenCalledWith(
|
|
889
890
|
'You cannot have both hidden actions and visible actions',
|
|
890
891
|
);
|
|
891
892
|
}
|
|
@@ -921,7 +922,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
921
922
|
|
|
922
923
|
describe('when visible Tabs are set', () => {
|
|
923
924
|
test('should throw error when there are both visible and hidden Tabs - pinboard', async () => {
|
|
924
|
-
spyOn(
|
|
925
|
+
spyOn(logger, 'error');
|
|
925
926
|
const pinboardEmbed = new PinboardEmbed(getRootEl(), {
|
|
926
927
|
visibleTabs: [tabId1],
|
|
927
928
|
hiddenTabs: [tabId2],
|
|
@@ -930,7 +931,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
930
931
|
} as LiveboardViewConfig);
|
|
931
932
|
await pinboardEmbed.render();
|
|
932
933
|
expect(pinboardEmbed['isError']).toBe(true);
|
|
933
|
-
expect(
|
|
934
|
+
expect(logger.error).toHaveBeenCalledWith(
|
|
934
935
|
'You cannot have both hidden Tabs and visible Tabs',
|
|
935
936
|
);
|
|
936
937
|
});
|
|
@@ -953,7 +954,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
953
954
|
hiddenTabs: Array<string>,
|
|
954
955
|
visibleTabs: Array<string>,
|
|
955
956
|
) {
|
|
956
|
-
spyOn(
|
|
957
|
+
spyOn(logger, 'error');
|
|
957
958
|
const liveboardEmbed = new LiveboardEmbed(getRootEl(), {
|
|
958
959
|
hiddenTabs,
|
|
959
960
|
visibleTabs,
|
|
@@ -962,7 +963,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
962
963
|
} as LiveboardViewConfig);
|
|
963
964
|
await liveboardEmbed.render();
|
|
964
965
|
expect(liveboardEmbed['isError']).toBe(true);
|
|
965
|
-
expect(
|
|
966
|
+
expect(logger.error).toHaveBeenCalledWith(
|
|
966
967
|
'You cannot have both hidden Tabs and visible Tabs',
|
|
967
968
|
);
|
|
968
969
|
}
|
|
@@ -1006,11 +1007,11 @@ describe('Unit test case for ts embed', () => {
|
|
|
1006
1007
|
});
|
|
1007
1008
|
|
|
1008
1009
|
test('Error should be true', async () => {
|
|
1009
|
-
spyOn(
|
|
1010
|
+
spyOn(logger, 'error');
|
|
1010
1011
|
const tsEmbed = new SearchEmbed(getRootEl(), {});
|
|
1011
1012
|
tsEmbed.render();
|
|
1012
1013
|
expect(tsEmbed['isError']).toBe(true);
|
|
1013
|
-
expect(
|
|
1014
|
+
expect(logger.error).toHaveBeenCalledWith(
|
|
1014
1015
|
'You need to init the ThoughtSpot SDK module first',
|
|
1015
1016
|
);
|
|
1016
1017
|
});
|
|
@@ -1018,13 +1019,13 @@ describe('Unit test case for ts embed', () => {
|
|
|
1018
1019
|
|
|
1019
1020
|
describe('V1Embed ', () => {
|
|
1020
1021
|
test('when isRendered is true than isError will be true', () => {
|
|
1021
|
-
spyOn(
|
|
1022
|
+
spyOn(logger, 'error');
|
|
1022
1023
|
const viEmbedIns = new tsEmbedInstance.V1Embed(getRootEl(), defaultViewConfig);
|
|
1023
1024
|
expect(viEmbedIns['isError']).toBe(false);
|
|
1024
1025
|
viEmbedIns.render();
|
|
1025
1026
|
viEmbedIns.on(EmbedEvent.CustomAction, jest.fn()).render();
|
|
1026
1027
|
expect(viEmbedIns['isError']).toBe(true);
|
|
1027
|
-
expect(
|
|
1028
|
+
expect(logger.error).toHaveBeenCalledWith(
|
|
1028
1029
|
'Please register event handlers before calling render',
|
|
1029
1030
|
);
|
|
1030
1031
|
});
|
|
@@ -1065,7 +1066,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1065
1066
|
});
|
|
1066
1067
|
|
|
1067
1068
|
test('navigateToPage function use before render', async () => {
|
|
1068
|
-
spyOn(
|
|
1069
|
+
spyOn(logger, 'log');
|
|
1069
1070
|
const appEmbed = new AppEmbed(getRootEl(), {
|
|
1070
1071
|
frameParams: {
|
|
1071
1072
|
width: '100%',
|
|
@@ -1074,7 +1075,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1074
1075
|
});
|
|
1075
1076
|
appEmbed.navigateToPage(path, false);
|
|
1076
1077
|
await appEmbed.render();
|
|
1077
|
-
expect(
|
|
1078
|
+
expect(logger.log).toHaveBeenCalledWith(
|
|
1078
1079
|
'Please call render before invoking this method',
|
|
1079
1080
|
);
|
|
1080
1081
|
});
|
|
@@ -1462,7 +1463,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1462
1463
|
});
|
|
1463
1464
|
|
|
1464
1465
|
// show preRender
|
|
1465
|
-
const warnSpy = spyOn(
|
|
1466
|
+
const warnSpy = spyOn(logger, 'warn');
|
|
1466
1467
|
libEmbed.showPreRender();
|
|
1467
1468
|
expect(warnSpy).toHaveBeenCalledTimes(0);
|
|
1468
1469
|
|
|
@@ -1492,13 +1493,13 @@ describe('Unit test case for ts embed', () => {
|
|
|
1492
1493
|
it('preRender called without preRenderId should log error ', () => {
|
|
1493
1494
|
createRootEleForEmbed();
|
|
1494
1495
|
|
|
1495
|
-
spyOn(
|
|
1496
|
+
spyOn(logger, 'error');
|
|
1496
1497
|
const libEmbed = new LiveboardEmbed('#tsEmbedDiv', {
|
|
1497
1498
|
liveboardId: 'myLiveboardId',
|
|
1498
1499
|
});
|
|
1499
1500
|
libEmbed.preRender();
|
|
1500
1501
|
|
|
1501
|
-
expect(
|
|
1502
|
+
expect(logger.error).toHaveBeenCalledWith('PreRender id is required for preRender');
|
|
1502
1503
|
});
|
|
1503
1504
|
|
|
1504
1505
|
it('showPreRender should preRender if not available', async () => {
|
|
@@ -1546,7 +1547,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
1546
1547
|
|
|
1547
1548
|
libEmbed.preRender();
|
|
1548
1549
|
await waitFor(() => !!getIFrameEl());
|
|
1549
|
-
const warnSpy = jest.spyOn(
|
|
1550
|
+
const warnSpy = jest.spyOn(logger, 'warn');
|
|
1550
1551
|
const newEmbed = new LiveboardEmbed('#tsEmbedDiv', {
|
|
1551
1552
|
preRenderId: 'i-am-preRendered',
|
|
1552
1553
|
liveboardId: 'awdawda',
|
|
@@ -1565,10 +1566,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
1565
1566
|
liveboardId: 'myLiveboardId',
|
|
1566
1567
|
});
|
|
1567
1568
|
spyOn(libEmbed, 'preRender');
|
|
1568
|
-
spyOn(
|
|
1569
|
+
spyOn(logger, 'error');
|
|
1569
1570
|
libEmbed.showPreRender();
|
|
1570
1571
|
expect(libEmbed.preRender).toHaveBeenCalledTimes(0);
|
|
1571
|
-
expect(
|
|
1572
|
+
expect(logger.error).toHaveBeenCalledTimes(1);
|
|
1572
1573
|
});
|
|
1573
1574
|
|
|
1574
1575
|
it('should get underlying iframe', async () => {
|
|
@@ -1596,16 +1597,16 @@ describe('Unit test case for ts embed', () => {
|
|
|
1596
1597
|
);
|
|
1597
1598
|
});
|
|
1598
1599
|
it('should log error if sync is called before preRender', async () => {
|
|
1599
|
-
jest.spyOn(
|
|
1600
|
+
jest.spyOn(logger, 'error').mockImplementation(jest.fn());
|
|
1600
1601
|
const libEmbed = new LiveboardEmbed('#tsEmbedDiv', {
|
|
1601
1602
|
liveboardId: 'myLiveboardId',
|
|
1602
1603
|
preRenderId: 'test',
|
|
1603
1604
|
});
|
|
1604
1605
|
await libEmbed.syncPreRenderStyle();
|
|
1605
|
-
expect(
|
|
1606
|
+
expect(logger.error).toBeCalledWith(
|
|
1606
1607
|
'PreRender should be called before using syncPreRenderStyle',
|
|
1607
1608
|
);
|
|
1608
|
-
(
|
|
1609
|
+
(logger.error as any).mockClear();
|
|
1609
1610
|
});
|
|
1610
1611
|
});
|
|
1611
1612
|
});
|