Skip to content

SCAL-338185: Pass analystId via APP_INIT embedParams.spotterAnalystConfig - #669

Merged
sastaachar merged 1 commit into
thoughtspot:mainfrom
bahetirisabh:SCAL-338185
Sep 21, 2026
Merged

sastaachar merged 1 commit into
thoughtspot:mainfrom
bahetirisabh:SCAL-338185

Conversation

@bahetirisabh

Copy link
Copy Markdown
Contributor

What

spotterAnalystConfig.analystId was being flattened into an analystId query param on the iframe src. The Spotter app reads the analyst config as spotterAnalystConfig.analystId off the APP_INIT payload, so the value never reached it. This moves it to embedParams, alongside the other Spotter object-shaped configs.

Changes

  • Added buildSpotterAnalystAppInitData() in spotter-utils.ts, mirroring buildSpotterShareConversationAppInitData / buildStarterPromptsAppInitData, and chained it into SpotterEmbed.getAppInitData(). It preserves existing embedParams keys and returns the payload untouched when there is no analystId.
  • Declared spotterAnalystConfig on SpotterAppInitData.embedParams.
  • Removed the AnalystId query param write and the now-unused Param.AnalystId enum member (Param is not exported from index.ts, so this is internal surface only).
  • Removed a duplicate SpotterAnalystConfig interface that an earlier merge with main left behind.

Behaviour notes

  • spotterAnalystConfig: {} sends nothing at all rather than an empty object, matching the previous URL-param behaviour and sparing the app from distinguishing "no analyst pinned" from "empty config".
  • The analyst id now arrives one handshake round-trip after load instead of synchronously at bootstrap — the same tradeoff spotterSidebarConfig already makes. It is also no longer exposed in the iframe URL, browser history, or proxy logs.
  • No public API change: SpotterEmbedViewConfig.spotterAnalystConfig is unchanged for hosts.

Testing

  • Replaced the three URL-based analyst tests in conversation.spec.ts with one asserting analystId is absent from the iframe src, plus four APP_INIT tests (present; coexisting with spotterSidebarConfig; absent when unconfigured; absent when {}).
  • Added three unit tests for the new builder in spotter-utils.spec.ts.
  • conversation.spec.ts + spotter-utils.spec.ts: 108 passed. tsc --noEmit and eslint clean.

@bahetirisabh
bahetirisabh requested a review from a team as a code owner September 14, 2026 16:50
@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@thoughtspot/visual-embed-sdk@669

commit: a2d10fe

…nfig

The Spotter app reads the analyst config as spotterAnalystConfig.analystId
off the APP_INIT payload, but the SDK was flattening it into an `analystId`
query param on the iframe src, so the app never picked it up.

- Add buildSpotterAnalystAppInitData(), mirroring the share-conversation and
  starter-prompts builders, and chain it into SpotterEmbed.getAppInitData().
  The config is omitted entirely when analystId is absent, so an empty
  spotterAnalystConfig sends nothing rather than an empty object.
- Drop the AnalystId query param and its now-unused Param enum member.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@bahetirisabh

Copy link
Copy Markdown
Contributor Author

/gemini review

@shivam-kumar-ts

Copy link
Copy Markdown
Contributor

@gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors how spotterAnalystConfig (specifically analystId) is transmitted. Instead of appending it to the iframe URL as a query parameter, it is now sent via the APP_INIT event payload under embedParams. This change includes removing AnalystId from the Param enum, introducing the buildSpotterAnalystAppInitData utility function, and updating the corresponding unit tests to verify the new initialization flow. I have no additional feedback to provide as the implementation is clean and well-tested.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Spotter embed to pass analystId (via spotterAnalystConfig) through the APP_INIT payload (embedParams.spotterAnalystConfig) instead of as a URL query parameter. The changes include updating SpotterEmbed initialization, implementing the buildSpotterAnalystAppInitData utility, removing the deprecated AnalystId query parameter, and updating the unit tests accordingly. There are no review comments, and I have no feedback to provide.

@shivam-kumar-ts shivam-kumar-ts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sastaachar
sastaachar merged commit e7f6b9c into thoughtspot:main Sep 21, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants