jquery.migrate: Instrument with mw.track()
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 18 Aug 2017 01:20:40 +0000 (18:20 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 18 Aug 2017 01:20:40 +0000 (18:20 -0700)
Inspired by cb20b5aa5a68d, which added similar instrumentation
during the jQuery 1.11 migration for MediaWiki in 2014.

This way we can plot overall usage in a Grafana dashboard and
help us track the progres of the on-going migration.

Bug: T124742
Change-Id: Ifab13d52d5681189cfb2faae342373558369b8c0

resources/lib/jquery/jquery.migrate.js

index f094aaa..12212ff 100644 (file)
@@ -6,6 +6,7 @@
  * - Preserve handler of uncaught exceptions in promise chains
  *   https://gerrit.wikimedia.org/r/#/c/360999/
  *   https://github.com/jquery/jquery-migrate/pull/262
+ * - Add mw.track instrumentation for statistics.
  */
 ;( function( factory ) {
        if ( typeof define === "function" && define.amd ) {
@@ -81,6 +82,8 @@ function migrateWarn( msg ) {
        if ( !warnedAbout[ msg ] ) {
                warnedAbout[ msg ] = true;
                jQuery.migrateWarnings.push( msg );
+               // PATCH: Add instrumentation for statistics --Krinkle
+               mw.track( "mw.deprecate", "jquery-migrate" );
                if ( console && console.warn && !jQuery.migrateMute ) {
                        console.warn( "JQMIGRATE: " + msg );
                        if ( jQuery.migrateTrace && console.trace ) {