[EBT] Schema-based event&context validation (only in dev mode) #132250
Labels
Feature:Telemetry
Team:Core
Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
When using the EBT APIs, developers need to call
analytics.registerEventType({ eventType, schema })
andanalytics.reportEvent(eventType, { ...eventProperties })
.This can cause a disconnection between the
schema
and theeventProperties
that can lead to reporting unexpected data.Let's add a schema-based validation step to throw when reporting an event that doesn't adhere to the schema specification (only when running in dev mode):
kibana/packages/analytics/client/src/analytics_client/analytics_client.ts
Lines 106 to 108 in 7226982
We may use the
schema_to_io-ts
implementation from the POC: https://github.com/elastic/kibana/pull/95960/files#diff-5eda84ca820acad68804d4415017a209cc784672b6512871063b1f9134abc7e4NOTE: While the
analytics.registerContextProvider
API is less prone to this error, we may want to add the same validation there:kibana/packages/analytics/client/src/analytics_client/context_service.ts
Lines 35 to 37 in 7226982
The text was updated successfully, but these errors were encountered: