Metrics Platform/Contextual attributes
Contextual attributes are fields in the event data that provide information about the performer who triggered the event and the wiki where the event occurred. The values of contextual attributes are populated automatically by Metrics Platform when the event is generated. This page documents the contextual attributes that are supported by each Metrics Platform client.
For attribute descriptions and types, see the base schema definitions.
JavaScript
The JavaScript client supports these contextual attributes:[1]
Included automatically:[2]
agent_client_platformagent_client_platform_family
Optional:
page_idpage_titlepage_namespacepage_namespace_namepage_revision_idpage_wikidata_idpage_wikidata_qidpage_content_languagepage_is_redirectpage_user_groups_allowed_to_movepage_user_groups_allowed_to_editmediawiki_skinmediawiki_versionmediawiki_is_productionmediawiki_is_debug_modemediawiki_databasemediawiki_site_content_languagemediawiki_site_content_language_variantperformer_is_logged_inperformer_idperformer_nameperformer_session_idperformer_active_browsing_session_tokenperformer_pageview_idperformer_groupsperformer_is_botperformer_is_tempperformer_languageperformer_language_variantperformer_can_probably_edit_pageperformer_edit_countperformer_edit_count_bucketperformer_registration_dt
PHP
The PHP client supports these contextual attributes:[3]
Included automatically:[4]
agent_client_platformagent_client_platform_family
Optional:
page_idpage_titlepage_namespacepage_namespace_namepage_revision_idpage_wikidata_idpage_wikidata_qidpage_content_languagepage_is_redirectpage_user_groups_allowed_to_movepage_user_groups_allowed_to_editmediawiki_skinmediawiki_versionmediawiki_is_productionmediawiki_is_debug_modemediawiki_databasemediawiki_site_content_languagemediawiki_site_content_language_variantperformer_is_logged_inperformer_idperformer_nameperformer_groupsperformer_is_botperformer_is_tempperformer_languageperformer_language_variantperformer_can_probably_edit_pageperformer_edit_countperformer_edit_count_bucketperformer_registration_dt
Java
The Java client supports these contextual attributes:[5]
Included automatically:[6]
agent_app_flavoragent_app_install_idagent_app_themeagent_app_versionagent_app_version_nameagent_client_platformagent_client_platform_familyagent_device_familyagent_device_languageagent_release_status
Optional:
mediawiki_databasepage_idpage_titlepage_namespace_idpage_namespace_namepage_revision_idpage_wikidata_qidpage_content_languageperformer_idperformer_nameperformer_is_logged_inperformer_is_tempperformer_session_idperformer_pageview_idperformer_groupsperformer_language_groupsperformer_language_primaryperformer_registration_dt
Swift
The Swift client supports these contextual attributes:[7]
Included automatically:[8]
agent_app_install_idagent_client_platformagent_client_platform_family
Optional:
page_idpage_titlepage_namespacepage_namespace_namepage_revision_idpage_wikidata_idpage_content_languagepage_is_redirectpage_user_groups_allowed_to_editpage_user_groups_allowed_to_movemediawiki_skinmediawiki_versionmediawiki_is_productionmediawiki_is_debug_modemediawiki_databasemediawiki_site_content_languagemediawiki_site_content_language_variantperformer_is_logged_inperformer_idperformer_nameperformer_session_idperformer_pageview_idperformer_groupsperformer_is_botperformer_languageperformer_language_variantperformer_can_probably_edit_pageperformer_edit_countperformer_edit_count_bucketperformer_registration_dt
Enabling optional attributes
While each client includes a few contextual attributes automatically, most attributes must be enabled in the instrument's event stream configuration. To enable a contextual attribute, list the attribute name in the provide_values array. For more information, see the stream configuration guide.
For example, this stream configuration enables two contextual attributes: page_id and page_title.
// …
'mediawiki.interwiki_link_hover' => [
'schema_title' => 'analytics/product_metrics/web/base',
'destination_event_service' => 'eventgate-analytics-external',
'producers' => [
'metrics_platform_client' => [
// Contextual attributes to add to the event before it is submitted to this stream.
'provide_values' => [
"page_id",
"page_title"
],
],
],
],
// …
References
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/js/src/ContextUtils.js
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/js/src/ContextController.js
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/php/src/StreamConfig/StreamConfig.php
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/php/src/ContextController.php
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/java/src/main/java/org/wikimedia/metrics_platform/context/ContextValue.java
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/java/src/main/java/org/wikimedia/metrics_platform/ContextController.java?ref_type=heads#L55
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/swift/Sources/WikimediaMetricsPlatform/StreamConfig/ContextAttribute.swift
- ↑ gitlab:repos/data-engineering/metrics-platform/-/blob/main/swift/Sources/WikimediaMetricsPlatform/Context/ContextController.swift#L16