Ori.livneh has uploaded a new change for review.

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


Change subject: Log User-Agent strings on successful authentication requests
......................................................................

Log User-Agent strings on successful authentication requests

We'd like to have browser usage stats for authenticated users.
Does *not* log user name / IP / etc -- just the bare User-Agent header string.
Schema: https://meta.wikimedia.org/wiki/Schema:LoginUserAgent

Bug: 56575
Change-Id: Ibb93130e209c25c840d723a38b8aaadc4736f0d3
---
M WikimediaEvents.php
1 file changed, 17 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents 
refs/changes/26/93526/1

diff --git a/WikimediaEvents.php b/WikimediaEvents.php
index 48c3f9d..c15bf5d 100644
--- a/WikimediaEvents.php
+++ b/WikimediaEvents.php
@@ -51,6 +51,23 @@
 
 // Hooks
 
+/**
+ * Log User-Agent string of successful logins.
+ * For bug 56575: Browser stats for logged-in vs. anon users for security
+ * support decisions. Logs an empty event if no User-Agent string is available.
+ *
+ * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=56575
+ * @see https://meta.wikimedia.org/wiki/Schema:LoginUserAgent
+ */
+$wgHooks[ 'UserLoginComplete' ][] = function ( &$user, &$html ) {
+       $event = array();
+       if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
+               $event['userAgent'] = $_SERVER[ 'HTTP_USER_AGENT' ];
+       }
+       efLogServerSideEvent( 'LoginUserAgent', 6259872, $event );
+       return true;
+};
+
 $wgHooks[ 'BeforePageDisplay' ][] = function ( &$out, &$skin ) {
        $out->addModules( 'ext.wikimediaEvents.ve' );
        return true;

-- 
To view, visit https://gerrit.wikimedia.org/r/93526
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb93130e209c25c840d723a38b8aaadc4736f0d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to