@thoughtspot/visual-embed-sdk 1.29.0-alpha.7 → 1.29.0-alpha.SCAL-205893-1
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 +14 -17
- package/cjs/src/auth.d.ts.map +1 -1
- package/cjs/src/auth.js +45 -59
- package/cjs/src/auth.js.map +1 -1
- package/cjs/src/auth.spec.d.ts +12 -0
- package/cjs/src/auth.spec.d.ts.map +1 -1
- package/cjs/src/auth.spec.js +89 -67
- package/cjs/src/auth.spec.js.map +1 -1
- package/cjs/src/authToken.d.ts +1 -1
- package/cjs/src/authToken.d.ts.map +1 -1
- package/cjs/src/authToken.js +18 -5
- package/cjs/src/authToken.js.map +1 -1
- package/cjs/src/authToken.spec.d.ts +2 -0
- package/cjs/src/authToken.spec.d.ts.map +1 -0
- package/cjs/src/authToken.spec.js +29 -0
- package/cjs/src/authToken.spec.js.map +1 -0
- package/cjs/src/embed/app.spec.js +4 -2
- 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 +2 -0
- package/cjs/src/embed/base.js.map +1 -1
- package/cjs/src/embed/base.spec.js +1 -0
- package/cjs/src/embed/base.spec.js.map +1 -1
- package/cjs/src/embed/embed.spec.js +3 -0
- package/cjs/src/embed/embed.spec.js.map +1 -1
- package/cjs/src/embed/events.spec.js +3 -0
- package/cjs/src/embed/events.spec.js.map +1 -1
- package/cjs/src/embed/liveboard.spec.js +2 -0
- package/cjs/src/embed/liveboard.spec.js.map +1 -1
- package/cjs/src/embed/pinboard.spec.js +3 -0
- package/cjs/src/embed/pinboard.spec.js.map +1 -1
- package/cjs/src/embed/sage.spec.js +3 -0
- package/cjs/src/embed/sage.spec.js.map +1 -1
- package/cjs/src/embed/search.spec.js +1 -0
- package/cjs/src/embed/search.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed-trigger.spec.js +3 -0
- package/cjs/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/cjs/src/embed/ts-embed.d.ts.map +1 -1
- package/cjs/src/embed/ts-embed.js +7 -0
- package/cjs/src/embed/ts-embed.js.map +1 -1
- package/cjs/src/embed/ts-embed.spec.js +7 -0
- package/cjs/src/embed/ts-embed.spec.js.map +1 -1
- package/cjs/src/index.d.ts +2 -1
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/index.js +2 -1
- package/cjs/src/index.js.map +1 -1
- package/cjs/src/mixpanel-service.d.ts +2 -1
- package/cjs/src/mixpanel-service.d.ts.map +1 -1
- package/cjs/src/mixpanel-service.js +1 -0
- package/cjs/src/mixpanel-service.js.map +1 -1
- package/cjs/src/mixpanel-service.spec.js +7 -0
- package/cjs/src/mixpanel-service.spec.js.map +1 -1
- package/cjs/src/react/index.d.ts +1 -1
- package/cjs/src/react/index.d.ts.map +1 -1
- package/cjs/src/react/index.js +2 -1
- package/cjs/src/react/index.js.map +1 -1
- package/cjs/src/react/index.spec.js +6 -0
- package/cjs/src/react/index.spec.js.map +1 -1
- package/cjs/src/types.d.ts +79 -47
- package/cjs/src/types.d.ts.map +1 -1
- package/cjs/src/types.js +61 -46
- package/cjs/src/types.js.map +1 -1
- package/cjs/src/utils/authService/authService.d.ts +1 -0
- package/cjs/src/utils/authService/authService.d.ts.map +1 -1
- package/cjs/src/utils/authService/authService.js +1 -0
- package/cjs/src/utils/authService/authService.js.map +1 -1
- package/cjs/src/utils/authService/authService.spec.js +18 -5
- package/cjs/src/utils/authService/authService.spec.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts +15 -2
- package/cjs/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.js +39 -9
- package/cjs/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js +32 -0
- package/cjs/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
- package/cjs/src/utils/graphql/answerService/answerService.d.ts +10 -0
- package/cjs/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/cjs/src/utils/graphql/answerService/answerService.js +10 -0
- package/cjs/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/cjs/src/utils/processData.js +2 -2
- package/cjs/src/utils/processData.js.map +1 -1
- package/cjs/src/utils/processData.spec.js +3 -2
- package/cjs/src/utils/processData.spec.js.map +1 -1
- package/cjs/src/utils/sessionInfoService.d.ts +66 -0
- package/cjs/src/utils/sessionInfoService.d.ts.map +1 -0
- package/cjs/src/utils/sessionInfoService.js +92 -0
- package/cjs/src/utils/sessionInfoService.js.map +1 -0
- package/cjs/src/utils.d.ts +1 -1
- package/cjs/src/utils.d.ts.map +1 -1
- package/cjs/src/utils.js +4 -1
- package/cjs/src/utils.js.map +1 -1
- package/dist/src/auth.d.ts +14 -17
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/auth.spec.d.ts +12 -0
- package/dist/src/auth.spec.d.ts.map +1 -1
- package/dist/src/authToken.d.ts +1 -1
- package/dist/src/authToken.d.ts.map +1 -1
- package/dist/src/authToken.spec.d.ts +2 -0
- package/dist/src/authToken.spec.d.ts.map +1 -0
- package/dist/src/embed/base.d.ts.map +1 -1
- package/dist/src/embed/ts-embed.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/mixpanel-service.d.ts +2 -1
- package/dist/src/mixpanel-service.d.ts.map +1 -1
- package/dist/src/react/index.d.ts +1 -1
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/types.d.ts +79 -47
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/authService/authService.d.ts +1 -0
- package/dist/src/utils/authService/authService.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.d.ts +15 -2
- package/dist/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/dist/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/dist/src/utils/graphql/answerService/answerService.d.ts +10 -0
- package/dist/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/dist/src/utils/sessionInfoService.d.ts +66 -0
- package/dist/src/utils/sessionInfoService.d.ts.map +1 -0
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/tsembed-react.es.js +225 -105
- package/dist/tsembed-react.js +225 -104
- package/dist/tsembed.es.js +233 -116
- package/dist/tsembed.js +233 -116
- package/dist/visual-embed-sdk-react-full.d.ts +171 -66
- package/dist/visual-embed-sdk-react.d.ts +171 -66
- package/dist/visual-embed-sdk.d.ts +171 -66
- package/lib/package.json +1 -1
- package/lib/src/auth.d.ts +14 -17
- package/lib/src/auth.d.ts.map +1 -1
- package/lib/src/auth.js +44 -56
- package/lib/src/auth.js.map +1 -1
- package/lib/src/auth.spec.d.ts +12 -0
- package/lib/src/auth.spec.d.ts.map +1 -1
- package/lib/src/auth.spec.js +88 -66
- package/lib/src/auth.spec.js.map +1 -1
- package/lib/src/authToken.d.ts +1 -1
- package/lib/src/authToken.d.ts.map +1 -1
- package/lib/src/authToken.js +18 -5
- package/lib/src/authToken.js.map +1 -1
- package/lib/src/authToken.spec.d.ts +2 -0
- package/lib/src/authToken.spec.d.ts.map +1 -0
- package/lib/src/authToken.spec.js +26 -0
- package/lib/src/authToken.spec.js.map +1 -0
- package/lib/src/embed/app.spec.js +4 -2
- 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 +3 -1
- package/lib/src/embed/base.js.map +1 -1
- package/lib/src/embed/base.spec.js +1 -0
- package/lib/src/embed/base.spec.js.map +1 -1
- package/lib/src/embed/embed.spec.js +2 -0
- package/lib/src/embed/embed.spec.js.map +1 -1
- package/lib/src/embed/events.spec.js +2 -0
- package/lib/src/embed/events.spec.js.map +1 -1
- package/lib/src/embed/liveboard.spec.js +2 -0
- package/lib/src/embed/liveboard.spec.js.map +1 -1
- package/lib/src/embed/pinboard.spec.js +2 -0
- package/lib/src/embed/pinboard.spec.js.map +1 -1
- package/lib/src/embed/sage.spec.js +2 -0
- package/lib/src/embed/sage.spec.js.map +1 -1
- package/lib/src/embed/search.spec.js +1 -0
- package/lib/src/embed/search.spec.js.map +1 -1
- package/lib/src/embed/ts-embed-trigger.spec.js +2 -0
- package/lib/src/embed/ts-embed-trigger.spec.js.map +1 -1
- package/lib/src/embed/ts-embed.d.ts.map +1 -1
- package/lib/src/embed/ts-embed.js +7 -0
- package/lib/src/embed/ts-embed.js.map +1 -1
- package/lib/src/embed/ts-embed.spec.js +7 -0
- package/lib/src/embed/ts-embed.spec.js.map +1 -1
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.d.ts.map +1 -1
- package/lib/src/index.js +2 -1
- package/lib/src/index.js.map +1 -1
- package/lib/src/mixpanel-service.d.ts +2 -1
- package/lib/src/mixpanel-service.d.ts.map +1 -1
- package/lib/src/mixpanel-service.js +1 -0
- package/lib/src/mixpanel-service.js.map +1 -1
- package/lib/src/mixpanel-service.spec.js +7 -0
- package/lib/src/mixpanel-service.spec.js.map +1 -1
- package/lib/src/react/index.d.ts +1 -1
- package/lib/src/react/index.d.ts.map +1 -1
- package/lib/src/react/index.js +1 -1
- package/lib/src/react/index.js.map +1 -1
- package/lib/src/react/index.spec.js +6 -0
- package/lib/src/react/index.spec.js.map +1 -1
- package/lib/src/types.d.ts +79 -47
- package/lib/src/types.d.ts.map +1 -1
- package/lib/src/types.js +61 -46
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/authService/authService.d.ts +1 -0
- package/lib/src/utils/authService/authService.d.ts.map +1 -1
- package/lib/src/utils/authService/authService.js +1 -0
- package/lib/src/utils/authService/authService.js.map +1 -1
- package/lib/src/utils/authService/authService.spec.js +18 -5
- package/lib/src/utils/authService/authService.spec.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.d.ts +15 -2
- package/lib/src/utils/authService/tokenizedAuthService.d.ts.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.js +37 -8
- package/lib/src/utils/authService/tokenizedAuthService.js.map +1 -1
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts +2 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.d.ts.map +1 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.js +29 -0
- package/lib/src/utils/authService/tokenizedAuthService.spec.js.map +1 -0
- package/lib/src/utils/graphql/answerService/answerService.d.ts +10 -0
- package/lib/src/utils/graphql/answerService/answerService.d.ts.map +1 -1
- package/lib/src/utils/graphql/answerService/answerService.js +10 -0
- package/lib/src/utils/graphql/answerService/answerService.js.map +1 -1
- package/lib/src/utils/processData.js +3 -3
- package/lib/src/utils/processData.js.map +1 -1
- package/lib/src/utils/processData.spec.js +3 -2
- package/lib/src/utils/processData.spec.js.map +1 -1
- package/lib/src/utils/sessionInfoService.d.ts +66 -0
- package/lib/src/utils/sessionInfoService.d.ts.map +1 -0
- package/lib/src/utils/sessionInfoService.js +85 -0
- package/lib/src/utils/sessionInfoService.js.map +1 -0
- package/lib/src/utils.d.ts +1 -1
- package/lib/src/utils.d.ts.map +1 -1
- package/lib/src/utils.js +4 -1
- package/lib/src/utils.js.map +1 -1
- package/lib/src/visual-embed-sdk.d.ts +176 -67
- package/package.json +1 -1
- package/src/auth.spec.ts +92 -72
- package/src/auth.ts +46 -68
- package/src/authToken.spec.ts +31 -0
- package/src/authToken.ts +17 -5
- package/src/embed/app.spec.ts +4 -2
- package/src/embed/base.spec.ts +1 -0
- package/src/embed/base.ts +3 -0
- package/src/embed/embed.spec.ts +2 -0
- package/src/embed/events.spec.ts +2 -0
- package/src/embed/liveboard.spec.ts +2 -0
- package/src/embed/pinboard.spec.ts +2 -0
- package/src/embed/sage.spec.ts +3 -0
- package/src/embed/search.spec.ts +1 -0
- package/src/embed/ts-embed-trigger.spec.ts +3 -0
- package/src/embed/ts-embed.spec.ts +8 -0
- package/src/embed/ts-embed.ts +7 -0
- package/src/index.ts +2 -1
- package/src/mixpanel-service.spec.ts +12 -3
- package/src/mixpanel-service.ts +3 -1
- package/src/react/index.spec.tsx +7 -0
- package/src/react/index.tsx +1 -0
- package/src/types.ts +80 -47
- package/src/utils/authService/authService.spec.ts +18 -5
- package/src/utils/authService/authService.ts +1 -0
- package/src/utils/authService/tokenizedAuthService.spec.ts +36 -0
- package/src/utils/authService/tokenizedAuthService.ts +38 -8
- package/src/utils/graphql/answerService/answerService.ts +10 -0
- package/src/utils/processData.spec.ts +3 -2
- package/src/utils/processData.ts +3 -3
- package/src/utils/sessionInfoService.ts +101 -0
- package/src/utils.ts +7 -2
package/src/embed/base.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
notifyLogout,
|
|
31
31
|
setAuthEE,
|
|
32
32
|
AuthEventEmitter,
|
|
33
|
+
postLoginService,
|
|
33
34
|
} from '../auth';
|
|
34
35
|
import { uploadMixpanelEvent, MIXPANEL_EVENT } from '../mixpanel-service';
|
|
35
36
|
import { getEmbedConfig, setEmbedConfig } from './embedConfig';
|
|
@@ -75,6 +76,8 @@ export const handleAuth = (): Promise<boolean> => {
|
|
|
75
76
|
if (!isLoggedIn) {
|
|
76
77
|
notifyAuthFailure(AuthFailureType.SDK);
|
|
77
78
|
} else {
|
|
79
|
+
// Post login service is called after successful login.
|
|
80
|
+
postLoginService();
|
|
78
81
|
notifyAuthSDKSuccess();
|
|
79
82
|
}
|
|
80
83
|
},
|
package/src/embed/embed.spec.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getIFrameEl,
|
|
10
10
|
getRootEl,
|
|
11
11
|
} from '../test/test-utils';
|
|
12
|
+
import * as authInstance from '../auth';
|
|
12
13
|
|
|
13
14
|
const thoughtSpotHost = 'tshost';
|
|
14
15
|
const defaultViewConfig = {
|
|
@@ -24,6 +25,7 @@ beforeAll(() => {
|
|
|
24
25
|
authType: AuthType.None,
|
|
25
26
|
});
|
|
26
27
|
spyOn(window, 'alert');
|
|
28
|
+
jest.spyOn(authInstance, 'postLoginService').mockResolvedValue(true);
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
describe('test view config', () => {
|
package/src/embed/events.spec.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
postMessageToParent,
|
|
21
21
|
} from '../test/test-utils';
|
|
22
22
|
import { LiveboardViewConfig } from './liveboard';
|
|
23
|
+
import * as authInstance from '../auth';
|
|
23
24
|
|
|
24
25
|
const thoughtSpotHost = 'tshost';
|
|
25
26
|
const defaultViewConfig = {
|
|
@@ -36,6 +37,7 @@ beforeAll(() => {
|
|
|
36
37
|
authType: AuthType.None,
|
|
37
38
|
});
|
|
38
39
|
spyOn(window, 'alert');
|
|
40
|
+
jest.spyOn(authInstance, 'postLoginService').mockReturnValue(true);
|
|
39
41
|
});
|
|
40
42
|
|
|
41
43
|
describe('test communication between host app and ThoughtSpot', () => {
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
} from '../test/test-utils';
|
|
24
24
|
import * as tsEmbed from './ts-embed';
|
|
25
25
|
import * as processTriggerInstance from '../utils/processTrigger';
|
|
26
|
+
import * as auth from '../auth';
|
|
26
27
|
|
|
27
28
|
const defaultViewConfig = {
|
|
28
29
|
frameParams: {
|
|
@@ -43,6 +44,7 @@ beforeAll(() => {
|
|
|
43
44
|
thoughtSpotHost,
|
|
44
45
|
authType: AuthType.None,
|
|
45
46
|
});
|
|
47
|
+
jest.spyOn(auth, 'postLoginService').mockImplementation(() => Promise.resolve({}));
|
|
46
48
|
});
|
|
47
49
|
|
|
48
50
|
describe('Liveboard/viz embed tests', () => {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
expectUrlMatchesWithParams,
|
|
14
14
|
} from '../test/test-utils';
|
|
15
15
|
import { version } from '../../package.json';
|
|
16
|
+
import * as auth from '../auth';
|
|
16
17
|
|
|
17
18
|
const defaultViewConfig = {
|
|
18
19
|
frameParams: {
|
|
@@ -30,6 +31,7 @@ beforeAll(() => {
|
|
|
30
31
|
thoughtSpotHost,
|
|
31
32
|
authType: AuthType.None,
|
|
32
33
|
});
|
|
34
|
+
jest.spyOn(auth, 'postLoginService').mockReturnValue(true);
|
|
33
35
|
});
|
|
34
36
|
|
|
35
37
|
describe('Pinboard/viz embed tests', () => {
|
package/src/embed/sage.spec.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
getRootEl,
|
|
10
10
|
} from '../test/test-utils';
|
|
11
11
|
|
|
12
|
+
import * as authInstance from '../auth';
|
|
13
|
+
|
|
12
14
|
const defaultConfig: SageViewConfig = {
|
|
13
15
|
disableWorksheetChange: false,
|
|
14
16
|
hideWorksheetSelector: false,
|
|
@@ -26,6 +28,7 @@ beforeAll(() => {
|
|
|
26
28
|
authType: AuthType.None,
|
|
27
29
|
});
|
|
28
30
|
spyOn(window, 'alert');
|
|
31
|
+
jest.spyOn(authInstance, 'postLoginService').mockResolvedValue(true);
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
describe('Sage embed tests', () => {
|
package/src/embed/search.spec.ts
CHANGED
|
@@ -8,9 +8,12 @@ import {
|
|
|
8
8
|
getRootEl,
|
|
9
9
|
} from '../test/test-utils';
|
|
10
10
|
|
|
11
|
+
import * as authInstance from '../auth';
|
|
12
|
+
|
|
11
13
|
describe('Trigger', () => {
|
|
12
14
|
beforeEach(() => {
|
|
13
15
|
document.body.innerHTML = getDocumentBody();
|
|
16
|
+
jest.spyOn(authInstance, 'postLoginService').mockResolvedValue(true);
|
|
14
17
|
});
|
|
15
18
|
test('should trigger the event', async (done) => {
|
|
16
19
|
init({
|
|
@@ -83,6 +83,10 @@ describe('Unit test case for ts embed', () => {
|
|
|
83
83
|
resetCachedAuthToken();
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
beforeAll(() => {
|
|
87
|
+
jest.spyOn(authInstance, 'postLoginService').mockResolvedValue(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
86
90
|
describe('AuthExpire embedEvent in cookieless authentication authType', () => {
|
|
87
91
|
beforeAll(() => {
|
|
88
92
|
jest.spyOn(authInstance, 'doCookielessTokenAuth').mockResolvedValueOnce(true);
|
|
@@ -680,6 +684,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
680
684
|
const mockPort: any = {
|
|
681
685
|
postMessage: jest.fn(),
|
|
682
686
|
};
|
|
687
|
+
const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
|
|
683
688
|
await executeAfterWait(() => {
|
|
684
689
|
const iframe = getIFrameEl();
|
|
685
690
|
postMessageToParent(iframe.contentWindow, mockEmbedEventPayload, mockPort);
|
|
@@ -689,6 +694,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
689
694
|
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
690
695
|
authInstance.AuthFailureType.EXPIRY,
|
|
691
696
|
);
|
|
697
|
+
expect(loggerSpy).toHaveBeenCalledTimes(1);
|
|
692
698
|
});
|
|
693
699
|
|
|
694
700
|
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
|
@@ -707,6 +713,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
707
713
|
const searchEmbed = new SearchEmbed(getRootEl(), { ...defaultViewConfig, preRenderId: 'test' });
|
|
708
714
|
jest.spyOn(baseInstance, 'notifyAuthFailure');
|
|
709
715
|
searchEmbed.preRender();
|
|
716
|
+
const loggerSpy = jest.spyOn(logger, 'error').mockResolvedValueOnce(true);
|
|
710
717
|
const mockPort: any = {
|
|
711
718
|
postMessage: jest.fn(),
|
|
712
719
|
};
|
|
@@ -720,6 +727,7 @@ describe('Unit test case for ts embed', () => {
|
|
|
720
727
|
expect(baseInstance.notifyAuthFailure).toBeCalledWith(
|
|
721
728
|
authInstance.AuthFailureType.EXPIRY,
|
|
722
729
|
);
|
|
730
|
+
expect(loggerSpy).toHaveBeenCalledTimes(1);
|
|
723
731
|
});
|
|
724
732
|
|
|
725
733
|
jest.spyOn(authService, 'verifyTokenService').mockClear();
|
package/src/embed/ts-embed.ts
CHANGED
|
@@ -349,6 +349,7 @@ export class TsEmbed {
|
|
|
349
349
|
data: { authToken },
|
|
350
350
|
});
|
|
351
351
|
} catch (e) {
|
|
352
|
+
logger.error(`Received invalid token. Error : ${e?.message}`);
|
|
352
353
|
processAuthFailure(e, this.isPreRendered ? this.preRenderWrapper : this.el);
|
|
353
354
|
}
|
|
354
355
|
} else if (autoLogin) {
|
|
@@ -597,6 +598,7 @@ export class TsEmbed {
|
|
|
597
598
|
* @param url - The URL of the embedded ThoughtSpot app.
|
|
598
599
|
*/
|
|
599
600
|
protected async renderIFrame(url: string): Promise<any> {
|
|
601
|
+
console.log('here 7');
|
|
600
602
|
if (this.isError) {
|
|
601
603
|
return null;
|
|
602
604
|
}
|
|
@@ -606,8 +608,10 @@ export class TsEmbed {
|
|
|
606
608
|
if (url.length > URL_MAX_LENGTH) {
|
|
607
609
|
// warn: The URL is too long
|
|
608
610
|
}
|
|
611
|
+
console.log('here 8');
|
|
609
612
|
|
|
610
613
|
return renderInQueue((nextInQueue) => {
|
|
614
|
+
console.log('here 6');
|
|
611
615
|
const initTimestamp = Date.now();
|
|
612
616
|
|
|
613
617
|
this.executeCallbacks(EmbedEvent.Init, {
|
|
@@ -620,6 +624,7 @@ export class TsEmbed {
|
|
|
620
624
|
uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
|
|
621
625
|
return getAuthPromise()
|
|
622
626
|
?.then((isLoggedIn: boolean) => {
|
|
627
|
+
console.log('here 9', isLoggedIn);
|
|
623
628
|
if (!isLoggedIn) {
|
|
624
629
|
this.handleInsertionIntoDOM(this.embedConfig.loginFailedMessage);
|
|
625
630
|
return;
|
|
@@ -644,7 +649,9 @@ export class TsEmbed {
|
|
|
644
649
|
this.iFrame.addEventListener('error', () => {
|
|
645
650
|
nextInQueue();
|
|
646
651
|
});
|
|
652
|
+
console.log('here 10', this.iFrame);
|
|
647
653
|
this.handleInsertionIntoDOM(this.iFrame);
|
|
654
|
+
console.log('here 11', document.body.innerHTML);
|
|
648
655
|
const prefetchIframe = document.querySelectorAll('.prefetchIframe');
|
|
649
656
|
if (prefetchIframe.length) {
|
|
650
657
|
prefetchIframe.forEach((el) => {
|
package/src/index.ts
CHANGED
|
@@ -21,8 +21,9 @@ import { PinboardEmbed, LiveboardViewConfig, LiveboardEmbed } from './embed/live
|
|
|
21
21
|
import { SearchEmbed, SearchViewConfig } from './embed/search';
|
|
22
22
|
import { SearchBarEmbed, SearchBarViewConfig } from './embed/search-bar';
|
|
23
23
|
import {
|
|
24
|
-
AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter,
|
|
24
|
+
AuthFailureType, AuthStatus, AuthEvent, AuthEventEmitter,
|
|
25
25
|
} from './auth';
|
|
26
|
+
import { getSessionInfo } from './utils/sessionInfoService';
|
|
26
27
|
import {
|
|
27
28
|
AuthType,
|
|
28
29
|
RuntimeFilter,
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
testResetMixpanel,
|
|
7
7
|
} from './mixpanel-service';
|
|
8
8
|
import { AuthType } from './types';
|
|
9
|
+
import { SessionInfo } from './utils/sessionInfoService';
|
|
10
|
+
import { logger } from './utils/logger';
|
|
9
11
|
|
|
10
12
|
const config = {
|
|
11
13
|
thoughtSpotHost: 'https://10.87.89.232',
|
|
@@ -29,7 +31,7 @@ describe('Unit test for mixpanel', () => {
|
|
|
29
31
|
mixpanelToken: 'abc123',
|
|
30
32
|
userGUID: '12345',
|
|
31
33
|
isPublicUser: false,
|
|
32
|
-
};
|
|
34
|
+
} as SessionInfo;
|
|
33
35
|
initMixpanel(sessionInfo);
|
|
34
36
|
expect(mixpanel.init).toHaveBeenCalledWith(sessionInfo.mixpanelToken, undefined, 'tsEmbed');
|
|
35
37
|
expect(mixpanel.identify).toHaveBeenCalledWith(sessionInfo.userGUID);
|
|
@@ -49,7 +51,7 @@ describe('Unit test for mixpanel', () => {
|
|
|
49
51
|
clusterId: 'newClusterId',
|
|
50
52
|
clusterName: 'newClusterName',
|
|
51
53
|
releaseVersion: 'newReleaseVersion',
|
|
52
|
-
};
|
|
54
|
+
} as SessionInfo;
|
|
53
55
|
initMixpanel(sessionInfo);
|
|
54
56
|
|
|
55
57
|
expect(mixpanel.init).toHaveBeenCalledWith(sessionInfo.mixpanelToken, undefined, 'tsEmbed');
|
|
@@ -74,8 +76,15 @@ describe('Unit test for mixpanel', () => {
|
|
|
74
76
|
mixpanelToken: 'abc123',
|
|
75
77
|
userGUID: '12345',
|
|
76
78
|
isPublicUser: false,
|
|
77
|
-
};
|
|
79
|
+
} as SessionInfo;
|
|
78
80
|
initMixpanel(sessionInfo);
|
|
79
81
|
expect(mixpanel.track).toHaveBeenCalledTimes(2);
|
|
80
82
|
});
|
|
83
|
+
|
|
84
|
+
test('init mixpanel with no mixpanel token', () => {
|
|
85
|
+
jest.spyOn(logger, 'error').mockReturnValueOnce(true);
|
|
86
|
+
initMixpanel({ test: 'dummy' } as any);
|
|
87
|
+
expect(logger.error).toHaveBeenCalled();
|
|
88
|
+
expect(mixpanel.register_once).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
81
90
|
});
|
package/src/mixpanel-service.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as mixpanel from 'mixpanel-browser';
|
|
2
2
|
import { logger } from './utils/logger';
|
|
3
|
+
import { SessionInfo } from './utils/sessionInfoService';
|
|
3
4
|
|
|
4
5
|
export const EndPoints = {
|
|
5
6
|
CONFIG: '/callosum/v1/system/config',
|
|
@@ -55,8 +56,9 @@ function emptyQueue() {
|
|
|
55
56
|
*
|
|
56
57
|
* @param sessionInfo
|
|
57
58
|
*/
|
|
58
|
-
export function initMixpanel(sessionInfo:
|
|
59
|
+
export function initMixpanel(sessionInfo: SessionInfo): void {
|
|
59
60
|
if (!sessionInfo || !sessionInfo.mixpanelToken) {
|
|
61
|
+
logger.error('Mixpanel token not found in session info');
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
62
64
|
// On a public cluster the user is anonymous, so don't set the identify to
|
package/src/react/index.spec.tsx
CHANGED
|
@@ -24,6 +24,9 @@ import {
|
|
|
24
24
|
|
|
25
25
|
import { version } from '../../package.json';
|
|
26
26
|
|
|
27
|
+
import * as auth from '../auth';
|
|
28
|
+
import * as sessionService from '../utils/sessionInfoService';
|
|
29
|
+
|
|
27
30
|
const thoughtSpotHost = 'localhost';
|
|
28
31
|
|
|
29
32
|
beforeAll(() => {
|
|
@@ -31,6 +34,10 @@ beforeAll(() => {
|
|
|
31
34
|
thoughtSpotHost,
|
|
32
35
|
authType: AuthType.None,
|
|
33
36
|
});
|
|
37
|
+
jest.spyOn(auth, 'postLoginService').mockReturnValue(true);
|
|
38
|
+
jest.spyOn(sessionService, 'getSessionInfo').mockReturnValue({
|
|
39
|
+
userGUID: 'abcd',
|
|
40
|
+
});
|
|
34
41
|
spyOn(window, 'alert');
|
|
35
42
|
});
|
|
36
43
|
|