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

thoughtspot / visual-embed-sdk / #1434

14 Jan 2025 09:34PM UTC coverage: 41.895% (-52.0%) from 93.86%
#1434

Pull #65

Prashant.patil
SCAL-233454-exp checking-mixpanel-error
Pull Request #65: test-exported memb

273 of 1106 branches covered (24.68%)

Branch coverage included in aggregate %.

84 of 356 new or added lines in 14 files covered. (23.6%)

1011 existing lines in 23 files now uncovered.

1301 of 2651 relevant lines covered (49.08%)

9.16 hits per line

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

38.89
/src/utils/sessionInfoService.ts
1
import { getEmbedConfig } from '../embed/embedConfig';
17✔
2
import { fetchSessionInfoService } from './authService';
17✔
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 | string = null;
17✔
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 | string> {
17✔
UNCOV
30
    if (!sessionInfo) {
×
UNCOV
31
        const host = getEmbedConfig().thoughtSpotHost;
×
UNCOV
32
        const sessionResponse = await fetchSessionInfoService(host);
×
NEW
33
        const processedSessionInfo = getSessionDetails();
×
UNCOV
34
        sessionInfo = processedSessionInfo;
×
35
    }
UNCOV
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 | string {
17✔
UNCOV
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 => {
69
//     const devMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.devSdkKey;
70
//     const prodMixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.prodSdkKey;
71
//     const mixpanelToken = sessionInfoResp.configInfo.mixpanelConfig.production
72
//         ? prodMixpanelToken
73
//         : devMixpanelToken;
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
const getSessionDetails = () => {
17✔
NEW
86
    const x = '5';
×
NEW
87
    return x;
×
88
};
89

90
/**
91
 * Resets the cached session info object and forces a new fetch on the next call.
92
 * @example ```js
93
 * resetCachedSessionInfo();
94
 * const sessionInfo = await getSessionInfo();
95
 * console.log(sessionInfo);
96
 * ```
97
 * @version SDK: 1.28.3 | ThoughtSpot ts7.april.cl, 7.2.1
98
 * @returns {void}
99
 */
100
export function resetCachedSessionInfo(): void {
17✔
UNCOV
101
    sessionInfo = null;
×
102
}
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