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

thoughtspot / visual-embed-sdk / #1527

03 Feb 2025 05:57AM UTC coverage: 93.972% (+0.09%) from 93.883%
#1527

Pull #100

ajeet-lakhani-ts
SCAL-233969: Add preAuthCache queryparam for iframe, Add flag disablePreauthCache to control cache from Embed params
Pull Request #100: SCAL-233969: Add preauth info call, emit Info call success event Iframe load

971 of 1112 branches covered (87.32%)

Branch coverage included in aggregate %.

48 of 49 new or added lines in 6 files covered. (97.96%)

24 existing lines in 1 file now uncovered.

2443 of 2521 relevant lines covered (96.91%)

59.76 hits per line

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

93.48
/src/utils/authService/tokenizedAuthService.ts
1
import { tokenizedFetch } from '../../tokenizedFetch';
19✔
2
import { logger } from '../logger';
19✔
3
import { EndPoints } from './authService';
19✔
4

5
/**
6
 *
7
 * @param url
8
 * @param options
9
 */
10
function tokenizedFailureLoggedFetch(url: string, options: RequestInit = {}): Promise<Response> {
12✔
11
    return tokenizedFetch(url, options).then(async (r) => {
13✔
12
        if (!r.ok && r.type !== 'opaqueredirect' && r.type !== 'opaque') {
13✔
13
            logger.error(`Failed to fetch ${url}`, await r.text?.());
2!
14
        }
15
        return r;
7✔
16
    });
17
}
18

19
/**
20
 * Fetches the session info from the ThoughtSpot server.
21
 * @param thoughtspotHost
22
 * @returns {Promise<any>}
23
 * @example
24
 * ```js
25
 *  const response = await sessionInfoService();
26
 * ```
27
 */
28
export async function fetchPreauthInfoService(thoughtspotHost: string): Promise<any> {
19✔
29
    const sessionInfoPath = `${thoughtspotHost}${EndPoints.PREAUTH_INFO}`;
10✔
30
    const handleError = (e: any) => {
10✔
31
        const error: any = new Error(`Failed to fetch auth info: ${e.message || e.statusText}`);
6!
32
        error.status = e.status; // Attach the status code to the error object
6✔
33
        throw error;
6✔
34
    };
35

36
    try {
10✔
37
        const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
10✔
38
        return response;
4✔
39
    } catch (e) {
40
        handleError(e);
6✔
NEW
41
        return null;
×
42
    }
43
}
44

45
/**
46
 * Fetches the session info from the ThoughtSpot server.
47
 * @param thoughtspotHost
48
 * @returns {Promise<any>}
49
 * @example
50
 * ```js
51
 *  const response = await sessionInfoService();
52
 * ```
53
 */
54
export async function fetchSessionInfoService(thoughtspotHost: string): Promise<any> {
19✔
55
    const sessionInfoPath = `${thoughtspotHost}${EndPoints.SESSION_INFO}`;
2✔
56
    const response = await tokenizedFailureLoggedFetch(sessionInfoPath);
2✔
57
    if (!response.ok) {
2✔
58
        throw new Error(`Failed to fetch session info: ${response.statusText}`);
1✔
59
    }
60
    const data = await response.json();
1✔
61
    return data;
1✔
62
}
63

64
/**
65
 *
66
 * @param thoughtSpotHost
67
 */
68
export async function fetchLogoutService(thoughtSpotHost: string): Promise<any> {
19✔
69
    return tokenizedFailureLoggedFetch(`${thoughtSpotHost}${EndPoints.LOGOUT}`, {
1✔
70
        credentials: 'include',
71
        method: 'POST',
72
        headers: {
73
            'x-requested-by': 'ThoughtSpot',
74
        },
75
    });
76
}
77

78
/**
79
 * Is active service to check if the user is logged in.
80
 * @param thoughtSpotHost
81
 * @version SDK: 1.28.4 | ThoughtSpot: *
82
 */
83
export async function isActiveService(thoughtSpotHost: string): Promise<boolean> {
19✔
84
    const isActiveUrl = `${thoughtSpotHost}${EndPoints.IS_ACTIVE}`;
3✔
85
    try {
3✔
86
        const res = await tokenizedFetch(isActiveUrl, {
3✔
87
            credentials: 'include',
88
        });
89
        return res.ok;
2✔
90
    } catch (e) {
91
        logger.warn(`Is Logged In Service failed : ${e.message}`);
1✔
92
    }
93

94
    return false;
1✔
95
}
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