Dzahn has submitted this change and it was merged.

Change subject: Add basic EventLogging to Wikimedia Blog
......................................................................


Add basic EventLogging to Wikimedia Blog

This change set adds an image tag to the Wikimedia blog side-bar that logs the
request and referer(sic) URLs using the bits endpoint for EventLogging. As
requested by Diederik and Tilman.

I tested the code-block within the get_eventlogging_url() by itself, but I
don't have a full-fledged WMF Wordpress setup to experiment with to verify the
whole package.

Change-Id: I9bd1d3f53e1cb7ee54a0c7abbd2d2ccf40f946e3
---
M WMBlog.php
1 file changed, 24 insertions(+), 0 deletions(-)

Approvals:
  Dzahn: Verified; Looks good to me, approved



diff --git a/WMBlog.php b/WMBlog.php
index cd02100..771abf7 100644
--- a/WMBlog.php
+++ b/WMBlog.php
@@ -78,6 +78,29 @@
                return $instance;
        }
 
+       function get_eventlogging_url() {
+               // construct url for logging current request using EventLogging 
API
+               // url should be set as the 'src' attribute of an image
+               // see <http://mediawiki.org/wiki/Extension:EventLogging>.
+               if ( empty( $_SERVER['REQUEST_URI'] ) ) {
+                       return false;
+               }
+
+               $event = array(
+                       'event' => array( 'requestUrl' => 
$_SERVER['REQUEST_URI'] ),
+                       'revision' => 5308166,
+                       'schema' => 'WikimediaBlogVisit',
+                       'webHost' => $_SERVER['HTTP_HOST'],
+                       'wiki' => 'blog'
+               );
+
+               if ( !empty( $_SERVER['HTTP_REFERER'] ) ) {
+                       $event['event']['referrerUrl'] = 
$_SERVER['HTTP_REFERER'];
+               }
+
+               return urlencode( json_encode( $event ) );
+       }
+
        function widget( $args, $instance ) {
                // output the content of the widget
                extract( $args );
@@ -93,6 +116,7 @@
                        <li><a href="http://wordpress.org/"; title="<?php echo 
esc_attr(__('Powered by WordPress, state-of-the-art semantic personal 
publishing platform.')); ?>">WordPress.org</a></li>
                        <?php wp_meta(); ?>
                        </ul>
+                       <img style="display: none;" 
src="//bits.wikimedia.org/event.gif?<?php echo $this->get_eventlogging_url(); 
?>;">
                <?php echo $after_widget;
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9bd1d3f53e1cb7ee54a0c7abbd2d2ccf40f946e3
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/communications/WMBlog
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Diederik <[email protected]>
Gerrit-Reviewer: Dzahn <[email protected]>
Gerrit-Reviewer: Eloquence <[email protected]>
Gerrit-Reviewer: Guillom <[email protected]>

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

Reply via email to