Allow overriding the resultSetType reported via event logging of suggestions
authorErik Bernhardson <ebernhardson@wikimedia.org>
Fri, 18 Dec 2015 21:21:53 +0000 (13:21 -0800)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Fri, 18 Dec 2015 21:33:20 +0000 (13:33 -0800)
Change-Id: I0c1b19019f11b719a6d728d6a46881cc83ca2430

resources/src/mediawiki/mediawiki.searchSuggest.js

index c960d65..ada4924 100644 (file)
@@ -3,6 +3,7 @@
  */
 ( function ( mw, $ ) {
        mw.searchSuggest = {
+               // queries the wiki and calls response with the result
                request: function ( api, query, response, maxRows ) {
                        return api.get( {
                                action: 'opensearch',
@@ -13,7 +14,9 @@
                        } ).done( function ( data ) {
                                response( data[ 1 ] );
                        } );
-               }
+               },
+               // The name of the request api for event logging purposes
+               type: 'prefix'
        };
 
        $( function () {
                        mw.track( 'mediawiki.searchSuggest', {
                                action: 'impression-results',
                                numberOfResults: context.config.suggestions.length,
-                               // FIXME: when other types of search become available change this value accordingly
-                               // See the API call below (opensearch = prefix)
-                               resultSetType: 'prefix'
+                               resultSetType: mw.searchSuggest.type
                        } );
                }