This page provides an overview of Metrics Platform Client (MPC) API and behaviors, its implementations and the key differences between them. Our goal is for all MPCs to provide the same API and behave the same way, and to be as clear as possible when they do not.
At the time of writing, all MPCs can be found in the
submit( streamName: string, eventData )
Evaluates the stream and submitted data for submission to the Event Platform intake service according to any sampling rules specified in the stream configuration. If the event passes those sampling rules, then it is supplemented with additional metadata and submitted to the intake service.
- The destination stream name. If the MPC does not have the configuration for the stream available, then the call fails and the event is discarded
- The event data
dispatch( eventName: string, ?customData )
Determines which streams have registered interest in the event with the given name and for each stream:
- An event
Eis constructed with:
null, then for each
- Assert that
keyis snake case
- Create a map
M.data_typeset to the type of
M.valueto the string representation of
- Assert that
Eis supplemented with additional contextual data according to the stream configuration
Eis filtered according to any filtering rules specified in the stream configuration. If
Edoes not pass all those filtering rules, then it is discarded
Eto the stream using
submit( S, E )
Note well that all events are submitted with the value for
- The name of the event, e.g.
- The data relevant to the occurrence and specific to the instrumentation, e.g. the UI element that was clicked
No stream configs
Note that if no stream configs for a given event are found, the event will not be dispatched nor submitted.
Notes and Key Differences
FIXME: Currently, a number of methods that are not part of the MPC API exported via
ext.eventLogging ResourceLoader module and its methods are exposed via mw.eventLog.
The EventLogging extension maintains a list of streams to be included in the module,
$wgEventLoggingStreamNames, which can be used to minimize the size of the module. When
The PHP MPC is also part of the EventLogging extension. Its methods are exposed via
$wgEventLoggingStreamNames is falsy the PHP MPC will not validate whether the destination stream is configured before submitting the event to the destination event service.
The PHP MPC does not support sampling by pageview ID or session ID because they are not known to the server. Sampling support can be added if and when there is a use case for it and an appropriate sampling unit defined.
The Swift EPC library is contained in the
Event Platform group within the
WMF Framework module of the Wikipedia app for iOS. The main client functionality is implemented in
EventPlatformClient , along with the
SamplingController support classes defined in separate files. Additional files in the group contain Core Data model definitions for event storage.
Stream configurations are fetched from the MediaWiki API via Meta-Wiki on app startup. If the stream configuration request fails, it is retried up to 10 times, with an increasing delay period between retries. Stream configurations are not held in persistent storage for subsequent launches.
Before stream configurations are fetched, any events received by the client are stored unconditionally in an InputBuffer with a maximum size of 128 events. If the input buffer reaches its maximum size, the oldest events are removed as needed to make room for new events. After stream configurations are loaded, events in the InputBuffer are evaluated and conditionally moved to persistent storage in Core Data, where they are held for eventual submission to the Event Platform intake service. Subsequently, the InputBuffer is no longer used, and all events received are evaluated and conditionally held in Core Data for submission.
Every 30 seconds, stale entries are pruned from the event storage table, and an attempt is made to submit all remaining entries pending submission. A stale entry is defined as one that has either been successfully submitted or has existed in the storage table for more than 30 days.
The database storage model is a deviation from the Event Platform Client specification and was carried over from the previous analytics client implementation at the iOS app team's request. There is no plan to update other clients to match this behavior.
submit(stream: Stream, eventData: EventInterface, domain: String? = nil)
- An enum defined in
EventPlatformClientthat contains allowed destination stream names as values
EventInterfaceis a protocol requiring that the event data has a
schemaproperty and implements
- The wiki domain. This should be passed when the wiki domain for the current app language does not apply to the event being submitted
FIXME: Update the