Page MenuHomePhabricator

Include session type in x-analytics header
Open, HighPublic

Description

To enable analysis of traffic data with respect to the authentication method used, MediaWiki should emit the session type as part of the x-analytics header. The relevant information can be obtained from $session->getProvider() and $session->getProviderMetadata().

Event Timeline

Change #1247685 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/extensions/WikimediaEvents@master] Include session type in X-Analytics header

https://gerrit.wikimedia.org/r/1247685

Change #1247685 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] Include session type in X-Analytics header

https://gerrit.wikimedia.org/r/1247685

The task as stated in the description is done but want to 1) refactor the code so it can be reused for T418608: Add label for session type to API metrics, 2) maybe add some information about the consumer to webreqeust.

I confirm I have data in the datalake for auth_type. However, the numbers for api.wikimedia.org are very low for March 12:

select
    x_analytics_map['auth_type'],
    count(1) as c
from wmf.webrequest
where webrequest_source = 'text'
  AND year = 2026 and month = 3 and day = 12
  AND uri_host = 'api.wikimedia.org'
GROUP BY
  x_analytics_map['auth_type']
ORDER BY c DESC
limit 50

+--------------------------+-------+                                            
|x_analytics_map[auth_type]|c      |
+--------------------------+-------+
|null                      |2587964|
|centralauth-cookie        |868    |
|oauth2-owneronly          |3      |
+--------------------------+-------+

Is it expected?

It's expected that most requests are anonymous, but the number shouldn't be quite that low. I would expect about 15% or requests to be authenticated.

I don't think api.wikimedia.org has any authenticated endpoints?

Oh right, api.wikimedia.org! Ironically, that's probably the worst example we have for API calls...

matmarex added subscribers: DAlangi_WMF, matmarex.

Looks like this is done except for this open question on the patch: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikimediaEvents/+/1247685/comment/0f609b8f_af0e5509/

https://wikitech.wikimedia.org/wiki/X-Analytics should be updated when this patch is merged.

Per the table on that page, who should be the point of contact? Maybe Daniel per the task?
Here is the edit: https://wikitech.wikimedia.org/w/index.php?title=X-Analytics&diff=prev&oldid=2388619, I've left "Team" and "Contact" as question marks.

@daniel @JTweed-WMF I think that one is for you :)


The task as stated in the description is done but want to 1) refactor the code so it can be reused for T418608: Add label for session type to API metrics, 2) maybe add some information about the consumer to webreqeust.

As for 1), the work can happen as part of that ticket, if it gets worked on. For 2), I think task T417879 is about doing that, I added a comment there.