Skip to content

@W-23146707 Add telemetry for errors and URL button clicks in MCP app#530

Merged
jarhun88 merged 11 commits into
mainfrom
dev/feat/mcp-app-error-telemetry
Jul 21, 2026
Merged

@W-23146707 Add telemetry for errors and URL button clicks in MCP app#530
jarhun88 merged 11 commits into
mainfrom
dev/feat/mcp-app-error-telemetry

Conversation

@jarhun88

@jarhun88 jarhun88 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

Adds product telemetry for MCP app UI errors via a new app-only server tool.

  • added New tool record-mcp-app-error (src/tools/web/recordMcpAppError/): the sandboxed MCP app calls it via app.callServerTool to record a tableau_mcp_event.completed product-telemetry event through the existing DirectTelemetryForwarder. Its also called when url link is clicked

  • this is added for any mcp app call that fails (for the embedded viz mcp app scenario only)

  • Registration + scopes: added to toolName.ts / tools.ts, empty mcp/api scopes in scopes.ts, and safelisted in the passthrough-auth guard (the tool makes no Tableau REST API calls).

  • also added a error_message field to the tool call product telemetry to get better undrestanding of onprem errors.

  • added white coloring to the mcp app error background

Motivation and Context

MCP app UI errors were invisible to product telemetry. This routes them through the server (never the browser) so the ingest endpoint/credentials stay inside the trust boundary and events are enriched with request/session/site/user/pod context the client can't produce. The tool is hidden from the model and gated on the mcp-apps feature flag, mirroring get-embed-token.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

How Has This Been Tested?

New/updated unit tests (all passing locally via npx vitest run):

  • recordMcpAppError.test.ts (server tool: properties, app-only visibility, telemetry payload + server enrichment, feature gate)
  • recordMcpAppErrorClient.test.ts (fire-and-forget client: never throws, no-ops without serverTools, omits message when no cause)
  • showError.test.ts, handleToolResult.test.ts, handleConfirmResult.test.ts (wiring across all four scenarios, incl. container-missing)
  • passthroughAuthMiddleware.test.ts (no-API-scope safelist)

Full suite green apart from one pre-existing, unrelated failure (adminInsights/getStaleContentReport date-fixture rot). Lint clean on changed files; MCP app bundles build successfully.

Related Issues

None.

Checklist

  • I have updated the version in the package.json file by using npm run version.
  • I have made any necessary changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have documented any breaking changes in the PR description. (None — new app-only tool, no config/API changes.)

jarhun88 added 3 commits July 15, 2026 20:17
Add an app-only server tool (record-mcp-app-error) that the sandboxed
MCP app calls via app.callServerTool to record a product-telemetry
event through the existing DirectTelemetryForwarder. The app reports
all four showError scenarios (TOOL_ERROR, PARSE_ERROR, AUTH_ERROR,
EMBED_LOAD_ERROR) via a fire-and-forget client that never throws and
no-ops when the host cannot proxy server tools.

The tool is app-only (hidden from the model) and gated on the mcp-apps
feature flag, mirroring get-embed-token. It makes no Tableau REST API
calls; the app supplies scenario (+ optional message) and the server
enriches with request/session/site/user/pod context. Telemetry fires
before the error-UI early-return so errors are recorded even when the
viz container is missing.
The error screen ("Unable to load this Tableau view") rendered on an
off-white background — the browser default showing through the
transparent body/.main/.viz-container ancestors, since no rule set a
background. Paint white on body:has(.mcp-app-error) so it propagates to
the whole viewport edge-to-edge, scoped to the error state only so the
normal viz render is unaffected.
Rename the app-only telemetry tool and its client from the error-specific
record-mcp-app-error / reportMcpAppError to the generic record-event /
recordEvent, so it can carry any MCP-app event, not just errors. The tool
name is updated in lockstep across the client call, the OAuth scope
allowlist, the passthrough-auth allowlist, and toolName.ts.

Add an MCP_APP_CLICKED event: clicking "Open in Tableau" now fires
recordEvent(app, 'MCP_APP_CLICKED', url) fire-and-forget before openLink.

Reshape the emitted event to match: event type tableau_mcp_event.completed
-> tableau_mcp_event, and the payload carries event_type + message in place
of the former scenario / request_id / session_id fields.
@jarhun88
jarhun88 marked this pull request as ready for review July 17, 2026 23:01
@jarhun88 jarhun88 changed the title Record tableau_mcp_event.completed telemetry on MCP app errors @W-23146707 Record tableau_mcp_event.completed telemetry on MCP app errors Jul 17, 2026
@jarhun88 jarhun88 changed the title @W-23146707 Record tableau_mcp_event.completed telemetry on MCP app errors @W-23146707 Add telemetry for errors and URL button clicks in MCP app Jul 17, 2026
Comment thread src/server/oauth/scopes.ts
Comment thread src/tools/web/tool.ts
jarhun88 added 5 commits July 21, 2026 17:27
record-event and get-embed-token are app-only, mcp-apps-gated tools
that don't belong in token-management (OAuth token/consent lifecycle).
Move them into a new mcp-apps group so operators can include/exclude
them independently.
- event_type: cap at 64 chars and require SCREAMING_SNAKE_CASE,
  rejecting malformed values (kept a bounded string, not a hard
  enum, since the event-type set is intentionally app-extensible)
- message: truncate to 1024 chars before forwarding so an
  over-long detail never fails the telemetry call
…r-telemetry

Resolves conflicts from main's src/web/apps/src reorg (flat lib/ split into
embed/, hitl/, shared/): recordEventClient relocated to shared/; combined
imports preserved in showError, handleToolResult, handleConfirmResult; version
reconciled to 3.5.2. Record-event telemetry feature intact.
@jarhun88
jarhun88 merged commit bcc76e4 into main Jul 21, 2026
9 checks passed
@jarhun88
jarhun88 deleted the dev/feat/mcp-app-error-telemetry branch July 21, 2026 22:33
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.

2 participants