The goals of eliminating schema creation during the creation of an analytics instrument and having a data contract between a data producer through to a Data Scientist are irreconcilable.
The first attempt at eliminating schema creation was to create the analytics/mediawiki/metrics_platform schema (AKA the monoschema). The monoschema contains many optional "Core Fields" – properties that are used relatively frequently in analytics instruments – and a custom_data property, which can contain arbitrary amounts of data that don't fit into those Core Fields. Using the monoschema in your instrument means that you don't have to create a new schema but also that there's no data contract between your instrument (the data producer) and the Data Scientist.
We can, however, minimise schema creation by providing a set of schemas and/or schema fragments that represent "Core Interactions" – interactions that are frequently instrumented, e.g.
- The user entering/exiting a funnel
- The user seeing a UI element
- The user tapping/clicking a UI element
- …
Further, for each Core Interaction schema that we provide, we can create a corresponding API and protocol for submitting an event that can be validated with that schema, e.g.
type Token = string; interface ScopedEventSubmitter { readonly funnelEntryToken: Token; submitClick( elementID: string, elementFriendlyName?: string ): void; } interface MetricsPlatform { /** * Creates an event submitter that submits events to the stream. All * submitted events will have the `funnel_entry_token` property set. * * Before the event submitter is returned, a `funnel_enter` event * representing the user entering the funnel is submitted. */ enterFunnel( streamName: string, funnelEntryToken?: Token ): ScopedEventSubmitter; getEnteredFunnels(): string[]; } namespace mw { export metricsPlatform: MetricsPlatform; } // --- const PAGEVIEW_TOKEN: Token = mw.user.getPageviewToken(); const submitter = mw.metricsPlatform.enterFunnel( 'mediawiki.ui.clicks', PAGEVIEW_TOKEN ); // Later... submitter.submitClick( 'pt-notifications-alert', 'notifications' );