From 46dde5989350a012a3c9b81b012f85d76aba2da5 Mon Sep 17 00:00:00 2001 From: Prashant Patil Date: Thu, 23 Jul 2026 20:47:07 +0530 Subject: [PATCH] SCAL-320501 no need for v2 host event flag for subscribed --- visual-embed/host-event-parameterized/README.md | 2 +- .../src/pages/EmbedWithReactWithOptions.tsx | 3 +-- visual-embed/update-filters-and-params/README.md | 12 +++++------- visual-embed/update-filters-and-params/src/App.tsx | 6 ++---- .../visualization/src/pages/EmbedViaReact.tsx | 3 +-- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/visual-embed/host-event-parameterized/README.md b/visual-embed/host-event-parameterized/README.md index 9eb7b9e..7974790 100644 --- a/visual-embed/host-event-parameterized/README.md +++ b/visual-embed/host-event-parameterized/README.md @@ -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 diff --git a/visual-embed/liveboard/src/pages/EmbedWithReactWithOptions.tsx b/visual-embed/liveboard/src/pages/EmbedWithReactWithOptions.tsx index 596579a..28592d0 100644 --- a/visual-embed/liveboard/src/pages/EmbedWithReactWithOptions.tsx +++ b/visual-embed/liveboard/src/pages/EmbedWithReactWithOptions.tsx @@ -22,7 +22,7 @@ function EmbedWithReactWithOptions() { // Standard pattern for triggering a host event at load time: listen for the // " 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; @@ -51,7 +51,6 @@ function EmbedWithReactWithOptions() { liveboardId={import.meta.env.VITE_LIVEBOARD_ID} runtimeFilters={runtimeFilters} onLoad={onLoad} - useHostEventsV2 fullHeight={true} /> diff --git a/visual-embed/update-filters-and-params/README.md b/visual-embed/update-filters-and-params/README.md index 418ad55..bcfa612 100644 --- a/visual-embed/update-filters-and-params/README.md +++ b/visual-embed/update-filters-and-params/README.md @@ -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 @@ -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 @@ -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 " Subscribed" signal NEVER fires. + // Note: the subscribedEvent pattern does NOT require useHostEventsV2. useEffect(() => { const embed = embedRef.current; if (!embed) return; @@ -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 /> ); diff --git a/visual-embed/update-filters-and-params/src/App.tsx b/visual-embed/update-filters-and-params/src/App.tsx index f4d0736..39ee23d 100644 --- a/visual-embed/update-filters-and-params/src/App.tsx +++ b/visual-embed/update-filters-and-params/src/App.tsx @@ -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 " 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 + // " Subscribed" signal fires on its own (SDK 1.48.0+ / TS 26.4.0.cl+). useEffect(() => { const embed = liveboardRef.current; if (!embed) return; @@ -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 /> diff --git a/visual-embed/visualization/src/pages/EmbedViaReact.tsx b/visual-embed/visualization/src/pages/EmbedViaReact.tsx index 4e1590c..95482ee 100644 --- a/visual-embed/visualization/src/pages/EmbedViaReact.tsx +++ b/visual-embed/visualization/src/pages/EmbedViaReact.tsx @@ -22,7 +22,7 @@ function EmbedViaReact() { // Standard pattern for triggering a host event at load time: listen for the // " 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; @@ -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} />