Also, the following is our init

Also, the following is our init invocation: init({ thoughtSpotHost: process.env.NEXT_PUBLIC_THOUGHTSPOT_HOST_URL || '', authType: AuthType.TrustedAuthTokenCookieless, username: user?.email, getAuthToken: async () => { try { const { data } = await getDelveToken(); if (data?.get_delve_token.token) { return data.get_delve_token.token; } else { throw new Error('Failed to get ThoughtSpot auth token'); } } catch (error) { console.log({ error }); return ''; } }, });
8 Replies
shikharTS
shikharTS2mo ago
We have seen misses due to http being used instead of https, can you check if the urls contains https and not http?
ferg.rose
ferg.roseOP2mo ago
Thanks for the reply, can confirm we are using https as the scheme in the url string
shikharTS
shikharTS2mo ago
process.env.NEXT_PUBLIC_THOUGHTSPOT_HOST_URL ||
process.env.NEXT_PUBLIC_THOUGHTSPOT_HOST_URL ||
Maybe it is coming out as empty. Did we check process.env.NEXT_PUBLIC_THOUGHTSPOT_HOST_URL's value?
ferg.rose
ferg.roseOP2mo ago
Yes the value of the environment variable is available upon initialisation - I have confirmed this with a log statement before invoking init. For testing purposes I have also thrown in the url as a hardcoded fallback value in case the environment variable is undefined or falsy for whatever reason. I have also tried directly passing the url as a hardcoded string value to no avail. It might be worth mentioning I am invoking init within a React effect hook to avoid a re-render issue. In some of the examples I have seen it is usually invoked outside of the component that renders the embedded component. I am not sure if this could be causing the issue. Again, it is not an issue when I use cookie-based trusted auth. Is there anything else that needs to be considered when using cookieless auth?
utsav.kapoor
utsav.kapoor2mo ago
@ferg.rose - Thanks for giving us the background. Looks like we had a similar issue reported by another dev who faced the same issue with init being inside useEffect. We have the reproduction from him. We will update you once we have the triage done. @jbc is working on it
ferg.rose
ferg.roseOP2mo ago
No worries, thanks a lot for your support!
jbc
jbc2mo ago
@ferg.rose We expect SDK to be initialized way before the component is rendered, so our first suggestion would be to place the init outside the componenet. If you do need to keep inside your component due to some dependency on data, it is better to keep it inside the useEffect, but make the Embed React component not render until init is invoked Also, if in case it isn't possible to have the React visual embed component to be delayed to render, you can have a workaround to init twice, once outside the component and once inside the useEffect. For outside the component, it can be initiated without the auth:
init({
thoughtSpotHost: process.env.NEXT_PUBLIC_THOUGHTSPOT_HOST_URL || '',
authType: AuthType.None,
})
init({
thoughtSpotHost: process.env.NEXT_PUBLIC_THOUGHTSPOT_HOST_URL || '',
authType: AuthType.None,
})
ferg.rose
ferg.roseOP2mo ago
@jbc - In our context, we can't initialise outside of the component (this limitation is related to Next.js and the client-side environment variable not being available during the server-side build phase). The component rendering before initialisation indeed turned out to be the issue here though. Easy to solve just using React state to delay component rendering until after init is invoked. Thank you very much for your prompt assistance with this, you have been very helpful

Did you find this page helpful?