import { init, AuthType, LogLevel } from '@thoughtspot/visual-embed-sdk';
init({
thoughtSpotHost: '<ThoughtSpot-host>',
authType: AuthType.TrustedAuthTokenCookieless,
getAuthToken: () => fetchAuthTokenFromYourServer(),
isDarkMode: false,
logLevel: LogLevel.ERROR,
});
Global embed configuration
The global embed configuration is the object that you pass to init(). Its options apply to every embedded component on the page, for example authentication, number and date formats, and appearance. Each embedded component also has its own view configuration for settings that apply to that component only. For the full list of global options, see EmbedConfig.
View configuration settingsπ
For options that you can set in both places, such as isDarkMode and additionalFlags, the value in the view configuration takes precedence over the value in init(). For example, you can set isDarkMode: true in init() and isDarkMode: false in the view configuration of one embed to render that embed in the default appearance.
Global configuration propertiesπ
Pass the global configuration to init() when your application loads, before you create any embedded component. thoughtSpotHost and authType are required. All other properties are optional.
The following table lists commonly used properties. For the complete list, types, default values, and the SDK and ThoughtSpot versions that support each property, see EmbedConfig.
| Property | Description |
|---|---|
The hostname or IP address of the ThoughtSpot cluster. Required. | |
The authentication method, such as | |
For trusted authentication, the endpoint that returns the authentication token, or a function that returns a Promise that resolves to the token. Set one of them. | |
The ThoughtSpot user name. Required for trusted authentication. | |
Signs the user in again with the previous login options when the session expires. The default value is | |
Style and text customization for the embedded app. For more information, see Customize UI layout and styles. | |
Custom actions that you define in code. For more information, see Code-based custom actions. | |
Renders the embedded app in dark appearance. See Dark mode. | |
Override the userβs preferred locale for number and date formatting, and set the currency format. | |
The types of messages that the SDK and the embedded app show in the browser console. The default value is | |
Suppresses all alerts in the embedded app when set to | |
Queues the rendering of multiple embedded objects so that each one starts after the previous one finishes. This decreases the load on the browser. The default value is | |
Advanced flags, such as |
Dark modeπ
Set isDarkMode to true to render embedded ThoughtSpot content in dark appearance. The default value is false. Your application controls the appearance of the embed, so this setting overrides the appearance preference of the signed-in user and the color scheme of the operating system.
init({
thoughtSpotHost: '<ThoughtSpot-host>',
authType: AuthType.None,
isDarkMode: true,
});
To switch an open embed between dark and default appearance without reloading it, trigger HostEvent.UpdateTheme with an isDarkMode value. For example, use it to keep the embed in step with a theme switch in your application.
liveboardEmbed.trigger(HostEvent.UpdateTheme, { isDarkMode: false });
The event resolves with the applied value, such as { isDarkMode: false }. If dark appearance is not available in the embed, the embed does not change, and the event rejects with an error message.
|
Note
|
Dark mode requires Visual Embed SDK v1.55.0 or later and ThoughtSpot Cloud 26.12.0.cl or later. For more information, see isDarkMode, HostEvent.UpdateTheme, and UpdateThemeRequest. |
How the SDK passes configuration to the embedded appπ
The SDK has two ways to pass embed configuration to the embedded ThoughtSpot app:
-
Iframe URL (default): The SDK adds the configuration to the iframe URL as query parameters.
-
postMessage: The SDK keeps only the parameters that the app needs at startup on the URL, and sends the rest to the app in apostMessagewhen the app loads.
You choose the method by using the excludeConfigFromURL flag.
Configuration settings for a compact iframe URLπ
By default, the iframe URL includes the embed configuration. This can make the URL very long and make the values visible in the page DOM, browser tools, and proxy logs. The excludeConfigFromURL flag moves most of the configuration out of the URL.
If you use Visual Embed SDK v1.55.0 or later with ThoughtSpot Cloud 26.12.0.cl or later, set excludeConfigFromURL to true in the additionalFlags object to generate a compact iframe URL.
Set the flag in init() to apply it to all embeds, or in the view configuration of one embed. The view configuration value takes precedence, so false in a view configuration turns the flag off for that embed.
init({
thoughtSpotHost: '<ThoughtSpot-host>',
authType: AuthType.None,
additionalFlags: { excludeConfigFromURL: true },
});
// Keep the configuration of this embed on the URL
const liveboardEmbed = new LiveboardEmbed('#tsEmbed', {
liveboardId: '<liveboard-guid>',
additionalFlags: { excludeConfigFromURL: false },
});
|
Note
|
The |
Comparison with the flag on or offπ
| Aspect | Flag off (default) | Flag on |
|---|---|---|
Where most configuration goes | The SDK adds it to the iframe URL as query parameters. | The SDK sends it to the embedded app in a |
Parameters on the iframe URL | The full configuration. | Only the parameters in Parameters that stay on the URL. |
URL length | Grows with the configuration and can reach browser or proxy limits. | Stays short. |
Configuration visible in the iframe URL, browser tools, and proxy logs | Yes. | Only the startup parameters. |
Flags in | Appended to the URL. | Flags that are not startup parameters are sent in the |
First render | The app reads the configuration from the URL. | The app receives the configuration before it renders, so the first load does not flash the default layout. |
Parameters that stay on the URLπ
When the flag is on, the SDK keeps the following parameters on the iframe URL, if they apply to your embed.
Embed and hostπ
| URL parameter | Purpose |
|---|---|
| Marks the app as embedded. |
| The host page URL. The app uses it to validate the origin of the |
| The SDK version. |
| Marks an |
| Marks a |
| Set when a Liveboard embed shows a single visualization ( |
| Marks a |
| Marks a |
| Marks a |
Authentication and Orgπ
| URL parameter | Purpose |
|---|---|
| The authentication type that you set in |
| Whether the app signs the user in automatically. |
| Stops the app from redirecting to its login page. |
| Forces the SAML redirect for embedded SSO. |
| Set for cookieless trusted authentication. |
| Lets the app use pre-fetched authentication information. |
| Blocks access to the full app outside the embed. |
| The Org to load. The authentication information depends on the Org. |
Viewport and loggingπ
| URL parameter | Purpose |
|---|---|
| The height of the host window when the iframe loads. |
| The width of the host window when the iframe loads. |
| The client log level of the app. |
| Lets the app override the native console. |
| An extra tracking key. |
Locale, formats, and appearanceπ
| URL parameter | Purpose |
|---|---|
| The UI language. |
| The locale for number formatting. |
| The locale for date formatting. |
| The currency format. |
| Turns on dark mode. |
| Turns on the theme that dark mode needs. |
Links and navigationπ
| URL parameter | Purpose |
|---|---|
| Lets the host override links in the app. |
| Turns on version 2 of the link overrides. |
| Stops links from opening in a new tab. |
| Uses |
| Legacy flag for the |
Search and contentπ
| URL parameter | Purpose |
|---|---|
| The data sources that search opens with. |
| Whether search opens with the last-selected data sources. |
| The initial search query. To keep it off the URL, set |
| The query mode that Spotter opens in. |
| Shows search results as a table. |
| The tag that filters the metadata lists in an |
| The URL of the custom string IDs file. |
| The URL of the custom icon sprite. |
| Exposes translation IDs in the app. |
Behavior changesπ
-
The iframe URL no longer contains most embed configuration, such as action visibility and Liveboard display options. Scripts, proxies, or monitoring tools that read configuration from the iframe URL stop finding those values. Use the SDK embed configuration as your source for these values.
-
If you do not set the flag, the SDK continues to pass the configuration on the iframe URL.
Pre-rendered embedsπ
For a pre-rendered embed, the SDK sends the configuration when it creates the embed. When you show the pre-rendered embed, the SDK sends the current configuration again, so changes that you made in the meantime take effect.