Skip to content

SCAL-334630 stamp severity on SDK-raised EmbedEvent.Error - #642

Open
sastaachar wants to merge 3 commits into
mainfrom
feat/embed-error-severity
Open

SCAL-334630 stamp severity on SDK-raised EmbedEvent.Error#642
sastaachar wants to merge 3 commits into
mainfrom
feat/embed-error-severity

Conversation

@sastaachar

Copy link
Copy Markdown
Contributor

Summary

Errors raised inside the embedded ThoughtSpot app already carry a severity
(the app stamps one on every EmbedEvent.Error it dispatches, defaulting to
SEV3). Errors the SDK itself raises never did. A host that wants a single
rule for "is this worth showing the user?" therefore had to sniff the error
shape — typeof error.error === 'string' — to tell SDK-raised errors apart
from app-raised ones.

This adds severity to the SDK side so one rule covers both.

Changes

  • EmbedErrorSeverity enum (SEV1 / SEV2 / SEV3), mirroring the levels
    the embedded app already uses, exported from the package root.
  • EmbedErrorDetailsEvent.severity — optional, so existing callers are
    unaffected.
  • handleError defaults to SEV3, so nothing is emitted without a severity.
    A raising site that sets its own severity wins.
  • SEV1 where nothing renders: INIT_SDK_REQUIRED, LOGIN_FAILED,
    LIVEBOARD_VIZ_ID_VALIDATION.
  • SEV2 for the offline warning (the embed recovers), SEV3 for
    API-intercept body parsing.

No behaviour changes for anyone not reading severity; the field is additive
and optional.

Testing

  • Unit tests pass — 437 passed across ts-embed, liveboard,
    api-intercept
  • Three new tests pin the behaviour: SEV1 on missing init, the SEV3
    default, and that an explicit severity is not overridden
  • npm run check-size — 31.8 kB against the 34 kB limit
  • Type-check clean on all changed files

Additional Notes

Motivated by the playground templates in scaligent, which now gate the error
banner on severity === 1. Until this lands, SDK-raised errors carry no
severity and so never trip that gate.

Errors raised inside the embedded app already carry a severity, but
errors the SDK raises itself never did, so a host could not apply one
rule to both sources and had to sniff the error shape instead.

- add EmbedErrorSeverity (SEV1/SEV2/SEV3), mirroring the levels the
  embedded app already uses, and expose it on EmbedErrorDetailsEvent
- default to SEV3 in handleError so no error is emitted without one
- SEV1 where nothing renders: missing init, failed login, missing
  Liveboard ID
- SEV2 for the offline warning, SEV3 for API-intercept body parsing
@sastaachar
sastaachar requested a review from a team as a code owner August 26, 2026 12:35

@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 introduces error severity levels (EmbedErrorSeverity) to the SDK, allowing hosts to determine how severely an error impacts the embedded application. It updates various error dispatch locations to include a severity level (defaulting to SEV3) and adds corresponding unit tests. Feedback on the changes suggests ensuring that console logs capture the defaulted severity rather than the raw error details, and correcting a minor style guide violation in the JSDoc comments where a complete sentence lacks a trailing period.

Comment thread src/embed/ts-embed.ts
Comment thread src/types.ts
* @group Error Handling
*
* @example
* Only surface errors that took the embed down

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.

medium

The description for the @example tag is a complete sentence but does not end with a period. According to the style guide, every description that forms a complete sentence should end with a period.

Suggested change
* Only surface errors that took the embed down
* Only surface errors that took the embed down.
References
  1. Every description that forms a complete sentence should end with a period. (link)

Comment thread src/embed/ts-embed.spec.ts
tse-developer
tse-developer previously approved these changes Aug 26, 2026
The parity spec requires every symbol exported from src/index.ts to be
re-exported from src/react/all-types-export.ts so React consumers can
import it. EmbedErrorSeverity was missing, failing the build.
Comment thread src/types.ts
@sastaachar sastaachar closed this Aug 26, 2026
@sastaachar
sastaachar deleted the feat/embed-error-severity branch August 26, 2026 16:53
@sastaachar sastaachar changed the title feat(errors): stamp severity on SDK-raised EmbedEvent.Error SCAL-334630 stamp severity on SDK-raised EmbedEvent.Error Aug 26, 2026
@sastaachar
sastaachar restored the feat/embed-error-severity branch August 26, 2026 16:54
@sastaachar sastaachar reopened this Aug 26, 2026
@sastaachar sastaachar closed this Aug 26, 2026
@sastaachar sastaachar reopened this Aug 26, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 0c7046c

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.

4 participants