• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thoughtspot / visual-embed-sdk / #1480

21 Jan 2025 10:27AM UTC coverage: 38.568% (-2.7%) from 41.223%
#1480

push

Prashant.patil
SCAL-233454-exp auto-attach wv msg handler lint errors

227 of 1153 branches covered (19.69%)

Branch coverage included in aggregate %.

0 of 15 new or added lines in 1 file covered. (0.0%)

445 existing lines in 8 files now uncovered.

1244 of 2661 relevant lines covered (46.75%)

8.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

31.82
/src/utils/sessionInfoService.ts
1
import { getEmbedConfig } from '../embed/embedConfig';
16✔
2
import { fetchSessionInfoService } from './authService';
16✔
3

4
export type SessionInfo = {
5
    releaseVersion: string;
6
    userGUID: string;
7
    currentOrgId: number;
8
    privileges: string[];
9
    mixpanelToken: string;
10
    isPublicUser: boolean;
11
    clusterId: string;
12
    clusterName: string;
13
    [key: string]: any;
14
};
15

16
let sessionInfo: null | SessionInfo = null;
16✔
17

18
/**
19
 * Returns the session info object and caches it for future use.
20
 * Once fetched the session info object is cached and returned from the cache on
21
 * subsequent calls.
22
 * @example ```js
23
 * const sessionInfo = await getSessionInfo();
24
 * console.log(sessionInfo);
25
 * ```
26
 * @version SDK: 1.28.3 | ThoughtSpot: *
27
 * @returns {Promise<SessionInfo>} The session info object.
28
 */
29
export async function getSessionInfo(): Promise<SessionInfo> {
16✔
30
    if (!sessionInfo) {
×
31
        const host = getEmbedConfig().thoughtSpotHost;
×
32
        const sessionResponse = await fetchSessionInfoService(host);
×
33
        const processedSessionInfo = getSessionDetails(sessionResponse);
×
34
        sessionInfo = processedSessionInfo;
×
35
    }
36
    return sessionInfo;
×
37
}
38

39
/**
40
 * Returns the cached session info object. If the client is not authenticated the
41
 * function will return null.
42
 * @example ```js
43
 * const sessionInfo = getCachedSessionInfo();
44
 * if (sessionInfo) {
45
 *   console.log(sessionInfo);
46
 * } else {
47
 *   console.log('Not authenticated');
48
 * }
49
 * ```
50
 * @returns {SessionInfo | null} The session info object.
51
 * @version SDK: 1.28.3 | ThoughtSpot: *
52
 */
53
export function getCachedSessionInfo(): SessionInfo | null {
16✔
54
    return sessionInfo;
×
55
}
56

57
/**
58
 * Processes the session info response and returns the session info object.
59
 *  @param sessionInfoResp {any} Response from the session info API.
60
 *  @returns {SessionInfo} The session info object.
61
 *  @example ```js
62
 *  const sessionInfoResp = await fetch(sessionInfoPath);
63
 *  const sessionInfo = getSessionDetails(sessionInfoResp);
64
 *  console.log(sessionInfo);
65
 *  ```
66
 * @version SDK: 1.28.3 | ThoughtSpot: *
67
 */
68
export const getSessionDetails = (sessionInfoResp: any): SessionInfo => {
16✔
UNCOV
69
    const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
×
UNCOV
70
    const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
×
UNCOV
71
    const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
×
72
        ? prodMixpanelToken
73
        : devMixpanelToken;
UNCOV
74
    return {
×
75
        userGUID: sessionInfoResp.userGUID,
76
        mixpanelToken,
77
        isPublicUser: sessionInfoResp.configInfo.isPublicUser,
78
        releaseVersion: sessionInfoResp.releaseVersion,
79
        clusterId: sessionInfoResp.configInfo.selfClusterId,
80
        clusterName: sessionInfoResp.configInfo.selfClusterName,
81
        ...sessionInfoResp,
82
    };
83
};
84

85
/**
86
 * Resets the cached session info object and forces a new fetch on the next call.
87
 * @example ```js
88
 * resetCachedSessionInfo();
89
 * const sessionInfo = await getSessionInfo();
90
 * console.log(sessionInfo);
91
 * ```
92
 * @version SDK: 1.28.3 | ThoughtSpot ts7.april.cl, 7.2.1
93
 * @returns {void}
94
 */
95
export function resetCachedSessionInfo(): void {
16✔
UNCOV
96
    sessionInfo = null;
×
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc