Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/88913
Change subject: Story 1264 (2/2): Add click tracking to nearby page and geo(nota)hack overlay ...................................................................... Story 1264 (2/2): Add click tracking to nearby page and geo(nota)hack overlay Change-Id: Ib1b0075b0e6c658d84a615e55be6eaaa89e28a7b --- M javascripts/modules/nearby/Nearby.js M javascripts/modules/nearby/NearbyOverlay.js M javascripts/modules/nearbypages.js M javascripts/specials/overlays/PagePreviewOverlay.js M templates/overlays/pagePreview.html 5 files changed, 23 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/13/88913/1 diff --git a/javascripts/modules/nearby/Nearby.js b/javascripts/modules/nearby/Nearby.js index 021809e..88c7ddd 100644 --- a/javascripts/modules/nearby/Nearby.js +++ b/javascripts/modules/nearby/Nearby.js @@ -1,6 +1,7 @@ ( function( M, $ ) { var NearbyApi = M.require( 'modules/nearby/NearbyApi' ), View = M.require( 'view' ), + MobileWebClickTracking = M.require( 'loggingSchemas/MobileWebClickTracking' ), wgMFMode = mw.config.get( 'wgMFMode' ), LoadingOverlay = M.require( 'LoadingOverlay' ), loader = new LoadingOverlay(), @@ -8,6 +9,7 @@ Nearby = View.extend( { template: M.template.get( 'articleList' ), + source: 'nearby', /** * Renders an error in the existing view * @@ -73,6 +75,9 @@ if ( options.location ) { this.location = options.location; } + if ( options.source ) { + this.source = options.source; + } this.api = new NearbyApi(); this._super( options ); }, @@ -105,7 +110,9 @@ _postRenderLinks: function() { var self = this; this.$( 'a' ).on( 'click', function( ev ) { - var $a = $( ev.currentTarget ); + var $a = $( ev.currentTarget ), + title = $a.find( 'h2' ).text(); + // name funnel for watchlists to catch subsequent uploads $.cookie( 'mwUploadsFunnel', 'nearby', { expires: new Date( new Date().getTime() + 60000) } ); // Note router support required for page previews in beta @@ -115,11 +122,12 @@ ev.preventDefault(); // Trigger preview mode ensure preview code has fully loaded first! + MobileWebClickTracking.log( self.source + '-preview', title ); loader.show(); mw.loader.using( 'mobile.nearby.previews', function() { loader.hide(); // FIXME: [API] should be able to determine longitude/latitude from title - window.location.hash = '#preview/' + $a.data( 'latlng' ) + '/' + $a.find( 'h2' ).text(); + window.location.hash = '#preview/' + self.source + '/' + $a.data( 'latlng' ) + '/' + $a.find( 'h2' ).text(); } ); } } ); diff --git a/javascripts/modules/nearby/NearbyOverlay.js b/javascripts/modules/nearby/NearbyOverlay.js index e22dc09..c44a779 100644 --- a/javascripts/modules/nearby/NearbyOverlay.js +++ b/javascripts/modules/nearby/NearbyOverlay.js @@ -22,6 +22,7 @@ this._super( options ); widget = new Nearby( { + source: options.source, range: 2000, parentOverlay: this, location: { longitude: options.longitude, latitude: options.latitude }, diff --git a/javascripts/modules/nearbypages.js b/javascripts/modules/nearbypages.js index c1716cb..f75bf96 100644 --- a/javascripts/modules/nearbypages.js +++ b/javascripts/modules/nearbypages.js @@ -1,13 +1,15 @@ ( function( M, $ ) { var latLng, lat, lng, NearbyOverlay = M.require( 'modules/nearby/NearbyOverlay' ), + MobileWebClickTracking = M.require( 'loggingSchemas/MobileWebClickTracking' ), overlay; function initNearbyButton( title, latitude, longitude ) { function loadGeoNotAHack() { if ( !overlay ) { - overlay = new NearbyOverlay( { title: title, latitude: latitude, longitude: longitude } ); + MobileWebClickTracking.log( 'geonotahack-clicked' ); + overlay = new NearbyOverlay( { title: title, latitude: latitude, longitude: longitude, source: 'geonotahack' } ); } overlay.show(); } diff --git a/javascripts/specials/overlays/PagePreviewOverlay.js b/javascripts/specials/overlays/PagePreviewOverlay.js index 98cf58e..b0700c4 100644 --- a/javascripts/specials/overlays/PagePreviewOverlay.js +++ b/javascripts/specials/overlays/PagePreviewOverlay.js @@ -2,6 +2,7 @@ ( function( M, $ ) { M.assertMode( [ 'beta', 'alpha' ] ); var Overlay = M.require( 'Overlay' ), + MobileWebClickTracking = M.require( 'loggingSchemas/MobileWebClickTracking' ), api = M.require( 'api' ), ua = window.navigator.userAgent, device = 'unknown', @@ -96,6 +97,7 @@ $preview.empty(); // Display the first content node $preview.append( nodes[0] ); + this.emit( 'post-render' ); } } ); @@ -108,12 +110,16 @@ } M.define( 'PagePreviewOverlay', PagePreviewOverlay ); - M.router.route( /^preview\/(.*)\/(.*)$/, function( latLngString, title ) { + M.router.route( /^preview\/(.*)\/(.*)\/(.*)$/, function( source, latLngString, title ) { // FIXME: API doesn't return pageimage or longitude latitude properties (yet) - new PagePreviewOverlay( { + var p = new PagePreviewOverlay( { title: title, latLngString: latLngString, endpoint: mw.config.get( 'wgMFNearbyEndpoint' ) } ); + p.on( 'post-render', function() { + // Hijack the link in the preview + MobileWebClickTracking.hijackLink( p.$( '.read-in-full' ), source + '-view-full' ); + } ); } ); }( mw.mobileFrontend, jQuery ) ); diff --git a/templates/overlays/pagePreview.html b/templates/overlays/pagePreview.html index 690e010..5ad9e86 100644 --- a/templates/overlays/pagePreview.html +++ b/templates/overlays/pagePreview.html @@ -3,7 +3,7 @@ {{#directionUrl}}<a href="{{directionUrl}}">{{directionLabel}}</a>{{/directionUrl}} </div> <p class="message"> - <a href="{{url}}">{{readMoreLink}}</a> + <a href="{{url}}" class="read-in-full">{{readMoreLink}}</a> </p> <div class="content"> <div class="listThumb {{imgClass}}" {{#imageUrl}}style="background-image: url({{imageUrl}})"{{/imageUrl}}></div> -- To view, visit https://gerrit.wikimedia.org/r/88913 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib1b0075b0e6c658d84a615e55be6eaaa89e28a7b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits