Skip to content

Forward errorMessage in WebExtensionApiRequest telemetry#1572

Merged
amitjoshi438 merged 2 commits intomainfrom
users/amitjoshi/api-telemetry-error-message
May 4, 2026
Merged

Forward errorMessage in WebExtensionApiRequest telemetry#1572
amitjoshi438 merged 2 commits intomainfrom
users/amitjoshi/api-telemetry-error-message

Conversation

@amitjoshi438
Copy link
Copy Markdown
Contributor

Summary

  • sendAPITelemetry discards errorMessage today: the parameter is accepted and used to build a traceError invocation, but it never lands in properties, so every WebExtensionApiRequestFailure event in Kusto is missing the underlying error detail (status text, response body, OData error code).
  • The save flow already builds a useful message via createHttpResponseError / formatHttpErrorMessage (with the truncated Dataverse response body) and forwards it through sendAPIFailureTelemetry -> sendAPITelemetry. This PR plumbs that string into the telemetry payload.
  • Adds errorMessage?: string to IWebExtensionAPITelemetryData.properties. sendAPITelemetry now sets the field only when present (so success-path events stay clean) and applies a defensive 500-char cap for non-HTTP callers that may pass a raw unbounded error.message.

Test plan

  • npm test (unit, blast-radius check) - 95/95 passing locally
  • npm run test-web-integration - blocked locally by VS Code Insiders editor lock; CI should run cleanly
  • Existing telemetry test sendAPITelemetry_whenErrorMessageIsPassed_shouldCallSendTelemetryException updated to assert errorMessage is now in properties
  • Existing telemetry test sendAPITelemetry_whenErrorMessageNotPassed_shouldCallSendTelemetryException unchanged (validates errorMessage is omitted when not provided)
  • After deploy, query Kusto: WebExtensionApiRequestFailure events should carry non-empty errorMessage containing the truncated response body for HTTP failures
  • After deploy, run the OData error-code bucketing query above to size the dominant save-400 cause

sendAPITelemetry already accepts errorMessage but never adds it to the
telemetry properties object, so all WebExtensionApiRequestFailure events
land in Kusto without the underlying error detail. The save flow already
constructs a useful message via createHttpResponseError /
formatHttpErrorMessage (with the truncated Dataverse response body), but
that information is lost in flight.

Add errorMessage as an optional property on IWebExtensionAPITelemetryData
and have sendAPITelemetry write it to properties only when present (so
success-path events stay clean). Defensive 500-char cap matches the
existing formatHttpErrorMessage limit, in case a non-HTTP caller passes
an unbounded raw error.message.

Unblocks RCA on the dominant save 400 class (~1,892/30d) by exposing the
OData error code in telemetry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@amitjoshi438 amitjoshi438 requested review from a team as code owners April 29, 2026 14:08
Companion to the previous commit. The integration test asserts on the
exact properties shape passed to traceError; now that errorMessage lands
in properties when provided, the expected object needs the field too.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@amitjoshi438 amitjoshi438 requested a review from priyanshu92 May 4, 2026 05:35
@amitjoshi438 amitjoshi438 merged commit 746458d into main May 4, 2026
9 checks passed
@amitjoshi438 amitjoshi438 deleted the users/amitjoshi/api-telemetry-error-message branch May 4, 2026 05:41
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