Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion visual-embed/host-event-parameterized/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const App = () => {
};
```

> **Triggering host events at load time?** These examples are button-driven, so no readiness handling is needed. For triggers fired automatically at load, use the `subscribedEvent` readiness pattern (requires `useHostEventsV2: true`) — see [update-filters-and-params](../update-filters-and-params/README.md).
> **Triggering host events at load time?** These examples are button-driven, so no readiness handling is needed. For triggers fired automatically at load, use the `subscribedEvent` readiness pattern (no `useHostEventsV2` flag required) — see [update-filters-and-params](../update-filters-and-params/README.md).

## Documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function EmbedWithReactWithOptions() {
// Standard pattern for triggering a host event at load time: listen for the
// "<Event> Subscribed" ready signal via subscribedEvent() — it fires the moment
// the embedded app has registered its handler, so the trigger cannot be dropped.
// Requires useHostEventsV2 on the embed (SDK 1.45.2+ / ThoughtSpot 26.3.0.cl+).
// Note: this does NOT require useHostEventsV2 (Subscribed event: SDK 1.48.0+ / ThoughtSpot 26.4.0.cl+).
useEffect(() => {
const embed = ref.current;
if (!embed) return;
Expand Down Expand Up @@ -51,7 +51,6 @@ function EmbedWithReactWithOptions() {
liveboardId={import.meta.env.VITE_LIVEBOARD_ID}
runtimeFilters={runtimeFilters}
onLoad={onLoad}
useHostEventsV2
fullHeight={true} />
</div>
</>
Expand Down
12 changes: 5 additions & 7 deletions visual-embed/update-filters-and-params/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ questions:

# update-filters-and-params

Working patterns and a decision guide for applying **filters and parameters** to embedded ThoughtSpot content programmatically — at init via `runtimeFilters` / `runtimeParameters`, and after load via the `UpdateRuntimeFilters`, `UpdateFilters`, and `UpdateParameters` host events, including the `subscribedEvent` readiness pattern (requires `useHostEventsV2: true`).
Working patterns and a decision guide for applying **filters and parameters** to embedded ThoughtSpot content programmatically — at init via `runtimeFilters` / `runtimeParameters`, and after load via the `UpdateRuntimeFilters`, `UpdateFilters`, and `UpdateParameters` host events, including the `subscribedEvent` readiness pattern.

## Which mechanism to use

Expand All @@ -30,14 +30,15 @@ Working patterns and a decision guide for applying **filters and parameters** to
| Filters change after load (button, external UI) | **`HostEvent.UpdateRuntimeFilters`** — array of `{ columnName, operator, values }` | SDK 1.9.0 / TS 8.1.0.cl |
| Updating values of a filter that already exists on the Liveboard | **`HostEvent.UpdateFilters`** — `{ filters: [{ column, oper, values }] }` | SDK 1.23.0 / TS 9.4.0.cl |
| Parameter values change after load | **`HostEvent.UpdateParameters`** — array of `{ name, value, isVisibleToUser? }` | SDK 1.29.0 / TS 10.1.0.cl |
| Triggering **any** host event at load time — the standard, recommended pattern | **`embed.subscribedEvent(HostEvent.X)`** listener — fires the exact moment the event is safe to trigger. **Only fires when `useHostEventsV2: true` is set in the embed view config** | SDK 1.45.2+ / TS 26.3.0.cl+ |
| Triggering **any** host event at load time — the standard, recommended pattern | **`embed.subscribedEvent(HostEvent.X)`** listener — fires the exact moment the event is safe to trigger. No `useHostEventsV2` flag required. | SDK 1.48.0+ / TS 26.4.0.cl+ |

Good to know:

- **The `subscribedEvent` readiness pattern works on every embed type** — it is defined on the shared embed base class, so `LiveboardEmbed`, `SearchEmbed`, `SearchBarEmbed`, `AppEmbed`, and `SpotterEmbed` all support it. Prefer it over ad-hoc `Load`/`Data`/`LiveboardRendered` timing for any load-time trigger.
- **`UpdateRuntimeFilters` resets the embedded object to its original state** before applying the new conditions — user changes such as drill-downs are cleared.
- If multiple columns share a name, disambiguate with the `WORKSHEET_NAME::COLUMN_NAME` format in `UpdateFilters` (e.g. `"(Sample) Retail - Apparel::city"`).
- **Common pitfall:** wiring the `Subscribed` readiness listener **without** enabling `useHostEventsV2` — the listener silently never fires. On clusters older than 26.3.0.cl, trigger from `EmbedEvent.Load`/`EmbedEvent.Data` instead, guarded so it runs once.
- **`useHostEventsV2` is NOT required for the `subscribedEvent` readiness pattern.** The `Subscribed` signal fires without it. `useHostEventsV2` is a separate, independent view-config flag that opts into the host-events v2 API — it is not a prerequisite for subscribing to events.
- **Version note:** the `Subscribed` embed event requires SDK 1.48.0+ / TS 26.4.0.cl+. On older clusters, trigger from `EmbedEvent.Load`/`EmbedEvent.Data` instead, guarded so it runs once.

## Key Usage

Expand Down Expand Up @@ -91,8 +92,7 @@ const App = () => {
// method is on the shared embed base class). Fires the moment the embedded app
// has registered its handler, so the trigger cannot be dropped. Same pattern for
// UpdateParameters, UpdateRuntimeFilters, or any other host event.
// REQUIRES useHostEventsV2: true on the embed (see props below) — without the
// flag this "<Event> Subscribed" signal NEVER fires.
// Note: the subscribedEvent pattern does NOT require useHostEventsV2.
useEffect(() => {
const embed = embedRef.current;
if (!embed) return;
Expand Down Expand Up @@ -122,8 +122,6 @@ const App = () => {
{ columnName: "state", operator: RuntimeFilterOp.EQ, values: ["california"] },
]}
runtimeParameters={[{ name: "Discount", value: 0.1 }]}
// Required for the subscribedEvent readiness pattern (SDK 1.45.2+ / TS 26.3.0.cl+).
useHostEventsV2
/>
</>
);
Expand Down
6 changes: 2 additions & 4 deletions visual-embed/update-filters-and-params/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function App() {
// on ANY embed type (LiveboardEmbed, SearchEmbed, AppEmbed, SpotterEmbed — the
// method is on the shared embed base class). Same pattern for UpdateParameters,
// UpdateRuntimeFilters, or any other host event.
// The "<Event> Subscribed" signal ONLY fires when useHostEventsV2 is enabled on
// the embed (see the prop below); without the flag this listener never runs.
// Note: the subscribedEvent pattern does NOT require useHostEventsV2. The
// "<Event> Subscribed" signal fires on its own (SDK 1.48.0+ / TS 26.4.0.cl+).
useEffect(() => {
const embed = liveboardRef.current;
if (!embed) return;
Expand Down Expand Up @@ -132,8 +132,6 @@ function App() {
},
]}
runtimeParameters={[{ name: "Discount", value: 0.1 }]}
// Required for the subscribedEvent readiness pattern (SDK 1.45.2+ / TS 26.3.0.cl+).
useHostEventsV2
/>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions visual-embed/visualization/src/pages/EmbedViaReact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function EmbedViaReact() {
// Standard pattern for triggering a host event at load time: listen for the
// "<Event> Subscribed" ready signal via subscribedEvent() — it fires the moment
// the embedded app has registered its handler, so the trigger cannot be dropped.
// Requires useHostEventsV2 on the embed (SDK 1.45.2+ / ThoughtSpot 26.3.0.cl+).
// Note: this does NOT require useHostEventsV2 (Subscribed event: SDK 1.48.0+ / ThoughtSpot 26.4.0.cl+).
useEffect(() => {
const embed = ref.current;
if (!embed) return;
Expand Down Expand Up @@ -51,7 +51,6 @@ function EmbedViaReact() {
runtimeFilters={runtimeFilters}
liveboardId={import.meta.env.VITE_LIVEBOARD_ID}
vizId={import.meta.env.VITE_LIVEBOARD_VIZ_ID}
useHostEventsV2
onLoad={onLoad} />
</div>
</>
Expand Down
Loading