jenkins-bot has submitted this change and it was merged.
Change subject: Record virtual image views
......................................................................
Record virtual image views
Soft-depends on Ie20ed8fc7041e89510a6558d9e2647c67a0a4bbf
Bug: T89088
Change-Id: If1459bd9acde8b6e5040afbd89e2ceafc61dedc9
---
M MultimediaViewer.php
M MultimediaViewerHooks.php
M resources/mmv/logging/mmv.logging.ViewLogger.js
3 files changed, 23 insertions(+), 18 deletions(-)
Approvals:
Gilles: Looks good to me, approved
Gergő Tisza: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/MultimediaViewer.php b/MultimediaViewer.php
index 753d80a..adad382 100644
--- a/MultimediaViewer.php
+++ b/MultimediaViewer.php
@@ -117,12 +117,12 @@
$wgMediaViewerImageQueryParameter = false;
}
-if ( !isset( $wgMediaViewerRecordViewDuration ) ) {
+if ( !isset( $wgMediaViewerRecordVirtualViewBeaconURI ) ) {
/**
- * If set, record the view duration via a HEAD request.
- * @var bool
+ * If set, records a virtual view via the provided beacon URI.
+ * @var string|bool
*/
- $wgMediaViewerRecordViewDuration = false;
+ $wgMediaViewerRecordVirtualViewBeaconURI = false;
}
$wgMessagesDirs['MultimediaViewer'] = __DIR__ . '/i18n';
diff --git a/MultimediaViewerHooks.php b/MultimediaViewerHooks.php
index dcd8960..1c5ac53 100644
--- a/MultimediaViewerHooks.php
+++ b/MultimediaViewerHooks.php
@@ -150,7 +150,7 @@
$wgMediaViewerDurationLoggingSamplingFactor,
$wgMediaViewerDurationLoggingLoggedinSamplingFactor,
$wgMediaViewerAttributionLoggingSamplingFactor,
$wgMediaViewerDimensionLoggingSamplingFactor,
$wgMediaViewerIsInBeta,
$wgMediaViewerUseThumbnailGuessing, $wgMediaViewerImageQueryParameter,
- $wgMediaViewerRecordViewDuration;
+ $wgMediaViewerRecordVirtualViewBeaconURI;
$vars['wgMultimediaViewer'] = array(
'infoLink' => self::$infoLink,
@@ -164,7 +164,7 @@
'attributionSamplingFactor' =>
$wgMediaViewerAttributionLoggingSamplingFactor,
'dimensionSamplingFactor' =>
$wgMediaViewerDimensionLoggingSamplingFactor,
'imageQueryParameter' =>
$wgMediaViewerImageQueryParameter,
- 'recordViewDuration' =>
$wgMediaViewerRecordViewDuration,
+ 'recordVirtualViewBeaconURI' =>
$wgMediaViewerRecordVirtualViewBeaconURI,
'tooltipDelay' => 1000,
);
$vars['wgMediaViewer'] = true;
diff --git a/resources/mmv/logging/mmv.logging.ViewLogger.js
b/resources/mmv/logging/mmv.logging.ViewLogger.js
index 205a52b..1a158d0 100644
--- a/resources/mmv/logging/mmv.logging.ViewLogger.js
+++ b/resources/mmv/logging/mmv.logging.ViewLogger.js
@@ -49,16 +49,16 @@
this.viewDuration = 0;
/**
- * The image URL to hit with a HEAD request
+ * The image URL to record a virtual view for
* @property {string}
*/
this.url = '';
/**
- * Should the view duration be recorded through a HEAD request
- * @property {boolean}
+ * If set, URI to send the beacon request to in order to record
the virtual view
+ * @property {string}
*/
- this.shouldRecordViewDuration = config ?
config.recordViewDuration : false;
+ this.recordVirtualViewBeaconURI = config ?
config.recordVirtualViewBeaconURI : false;
/**
* Browser window
@@ -112,14 +112,19 @@
this.stopViewDuration();
- if ( this.shouldRecordViewDuration && this.viewDuration > 0 ) {
- uri = new mw.Uri( this.url );
- uri.extend( { viewDuration: this.viewDuration } );
+ if ( this.recordVirtualViewBeaconURI ) {
+ uri = new mw.Uri( this.recordVirtualViewBeaconURI );
+ uri.extend( { duration: this.viewDuration,
+ uri: this.url } );
- $.ajax( {
- type: 'HEAD',
- url: uri.toString()
- } );
+ try {
+ navigator.sendBeacon( uri.toString() );
+ } catch ( e ) {
+ $.ajax( {
+ type: 'HEAD',
+ url: uri.toString()
+ } );
+ }
mw.log( 'Image has been viewed for ', this.viewDuration
);
}
@@ -131,7 +136,7 @@
/**
* Sets up the view tracking for the current image
- * @param {string} url URL of the image to send a HEAD request to
+ * @param {string} url URL of the image to record a virtual view for
*/
VL.attach = function ( url ) {
var view = this;
--
To view, visit https://gerrit.wikimedia.org/r/190823
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If1459bd9acde8b6e5040afbd89e2ceafc61dedc9
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gilles <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits