Jump to content

Metrics Platform/Contextual attributes

From Wikitech

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 that are included in the stream configuration 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, types and other constraints (like their maximum length), see the base schema definitions.

JavaScript

The JavaScript client supports these contextual attributes:[1]

  • agent_client_platform
  • agent_client_platform_family
  • page_id
  • page_title
  • page_namespace
  • page_namespace_name
  • page_revision_id
  • page_wikidata_id
  • page_wikidata_qid
  • page_content_language
  • page_is_redirect
  • page_user_groups_allowed_to_move
  • page_user_groups_allowed_to_edit
  • mediawiki_skin
  • mediawiki_version
  • mediawiki_is_production
  • mediawiki_is_debug_mode
  • mediawiki_database
  • mediawiki_site_content_language
  • mediawiki_site_content_language_variant
  • performer_is_logged_in
  • performer_id
  • performer_name
  • performer_session_id
  • performer_active_browsing_session_token
  • performer_pageview_id
  • performer_groups
  • performer_is_bot
  • performer_is_temp
  • performer_language
  • performer_language_variant
  • performer_can_probably_edit_page
  • performer_edit_count
  • performer_edit_count_bucket
  • performer_registration_dt

PHP

The PHP client supports these contextual attributes:[2]

  • agent_client_platform
  • agent_client_platform_family
  • page_id
  • page_title
  • page_namespace
  • page_namespace_name
  • page_revision_id
  • page_wikidata_id
  • page_wikidata_qid
  • page_content_language
  • page_is_redirect
  • page_user_groups_allowed_to_move
  • page_user_groups_allowed_to_edit
  • mediawiki_skin
  • mediawiki_version
  • mediawiki_is_production
  • mediawiki_is_debug_mode
  • mediawiki_database
  • mediawiki_site_content_language
  • mediawiki_site_content_language_variant
  • performer_is_logged_in
  • performer_id
  • performer_name
  • performer_groups
  • performer_is_bot
  • performer_is_temp
  • performer_language
  • performer_language_variant
  • performer_can_probably_edit_page
  • performer_edit_count
  • performer_edit_count_bucket
  • performer_registration_dt

Java

The Java client supports these contextual attributes:[3]

  • agent_app_flavor
  • agent_app_install_id
  • agent_app_theme
  • agent_app_version
  • agent_app_version_name
  • agent_client_platform
  • agent_client_platform_family
  • agent_device_family
  • agent_device_language
  • agent_release_status
  • mediawiki_database
  • page_id
  • page_title
  • page_namespace_id
  • page_namespace_name
  • page_revision_id
  • page_wikidata_qid
  • page_content_language
  • performer_id
  • performer_name
  • performer_is_logged_in
  • performer_is_temp
  • performer_session_id
  • performer_pageview_id
  • performer_groups
  • performer_language_groups
  • performer_language_primary
  • performer_registration_dt

Swift

The Swift client supports these contextual attributes:[4]

  • agent_app_install_id
  • agent_client_platform
  • agent_client_platform_family
  • page_id
  • page_title
  • page_namespace
  • page_namespace_name
  • page_revision_id
  • page_wikidata_id
  • page_content_language
  • page_is_redirect
  • page_user_groups_allowed_to_edit
  • page_user_groups_allowed_to_move
  • mediawiki_skin
  • mediawiki_version
  • mediawiki_is_production
  • mediawiki_is_debug_mode
  • mediawiki_database
  • mediawiki_site_content_language
  • mediawiki_site_content_language_variant
  • performer_is_logged_in
  • performer_id
  • performer_name
  • performer_session_id
  • performer_pageview_id
  • performer_groups
  • performer_is_bot
  • performer_language
  • performer_language_variant
  • performer_can_probably_edit_page
  • performer_edit_count
  • performer_edit_count_bucket
  • performer_registration_dt

Enabling attributes

All 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.

ext-EventStreamConfig.php
// …
'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

  1. gitlab:repos/data-engineering/metrics-platform/-/blob/main/js/src/ContextUtils.js
  2. gitlab:repos/data-engineering/metrics-platform/-/blob/main/php/src/StreamConfig/StreamConfig.php
  3. gitlab:repos/data-engineering/metrics-platform/-/blob/main/java/src/main/java/org/wikimedia/metrics_platform/context/ContextValue.java
  4. gitlab:repos/data-engineering/metrics-platform/-/blob/main/swift/Sources/WikimediaMetricsPlatform/StreamConfig/ContextAttribute.swift