Gergő Tisza has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/188330

Change subject: Update Sentry to use mw.track
......................................................................

Update Sentry to use mw.track

Soft-depends on Ifc13c207af36dc56be931a3b140063354513a4ec

Bug: T78809
Change-Id: I8d875938cc63d7f0bef3a894f71afe6366204e6b
---
M resources/init.js
M resources/raven/raven.js
2 files changed, 52 insertions(+), 53 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Sentry 
refs/changes/30/188330/1

diff --git a/resources/init.js b/resources/init.js
index 2ea44fc..810dba2 100644
--- a/resources/init.js
+++ b/resources/init.js
@@ -1,22 +1,55 @@
-( function ( mw, Raven ) {
-       var config = mw.config.get( 'wgSentry' ),
-               options = {};
+( function ( mw ) {
+       var raven;
 
-       if ( config.whitelist ) {
-               options.whitelistUrls = config.whitelist.slice( 0 );
-               options.whitelistUrls.push( location.host );
+       /**
+        * @return {jQuery.Deferred} a deferred with the Raven.js object
+        */
+       function initRaven() {
+               return mw.loader.using( 'sentry', function () {
+                       if ( !raven ) {
+                               var config = mw.config.get( 'wgSentry' ),
+                                       options = {};
+
+                               if ( config.whitelist ) {
+                                       options.whitelistUrls = 
config.whitelist.slice( 0 );
+                                       options.whitelistUrls.push( 
location.host );
+                               }
+                               options.collectWindowErrors = config.logOnError;
+                               options.tags = {
+                                       version: mw.config.get( 'wgVersion' ),
+                                       debug: mw.config.get( 'debug' ),
+                                       skin: mw.config.get( 'skin' ),
+                                       action: mw.config.get( 'wgAction' ),
+                                       ns: mw.config.get( 'wgNamespaceNumber' 
),
+                                       pageName: mw.config.get( 'wgPageName' ),
+                                       userGroups: mw.config.get( 
'wgUserGroups' ),
+                                       language: mw.config.get( 
'wgUserLanguage' )
+                               };
+
+                               Raven.config( config.dsn, options).install();
+
+                               raven = Raven;
+                       }
+               } ).then( function () {
+                       return raven;
+               } );
        }
-       options.collectWindowErrors = config.logOnError;
-       options.tags = {
-               version: mw.config.get( 'wgVersion' ),
-               debug: mw.config.get( 'debug' ),
-               skin: mw.config.get( 'skin' ),
-               action: mw.config.get( 'wgAction' ),
-               ns: mw.config.get( 'wgNamespaceNumber' ),
-               pageName: mw.config.get( 'wgPageName' ),
-               userGroups: mw.config.get( 'wgUserGroups' ),
-               language: mw.config.get( 'wgUserLanguage' )
-       };
 
-       Raven.config( config.dsn, options ).install();
-} ) ( mediaWiki, Raven );
+       /**
+        * @param {string} topic mw.track() queue name
+        * @param {object} data
+        * @param {*} data.exception The exception which has been caught
+        * @param {string} data.source Describes what type of function caught 
the exception
+        * @param {string} [data.module] Name of the module which threw the 
exception
+        */
+       function report( topic, data ) {
+               initRaven().done( function ( raven ) {
+                       raven.captureException( data.exception, { tags: {
+                               source: data.source,
+                               module: data.module
+                       } } );
+               } );
+       }
+
+       mw.trackSubscribe( 'errorLogging.exception', report );
+} ) ( mediaWiki );
diff --git a/resources/raven/raven.js b/resources/raven/raven.js
index 2c37e3d..61218fe 100644
--- a/resources/raven/raven.js
+++ b/resources/raven/raven.js
@@ -1836,37 +1836,3 @@
 }
 
 })(this);
-
-/**
- * native plugin
- *
- * Extends support for global error handling for asynchronous browser
- * functions. Adopted from Closure Library's errorhandler.js
- */
-;(function extendToAsynchronousCallbacks(window, Raven) {
-"use strict";
-
-var _helper = function _helper(fnName) {
-    var originalFn = window[fnName];
-    window[fnName] = function ravenAsyncExtension() {
-        // Make a copy of the arguments
-        var args = [].slice.call(arguments);
-        var originalCallback = args[0];
-        if (typeof (originalCallback) === 'function') {
-            args[0] = Raven.wrap(originalCallback);
-        }
-        // IE < 9 doesn't support .call/.apply on setInterval/etTimeout, but it
-        // also only supports 2 argument and doesn't care what this" is, so we
-        // can just call the original function directly.
-        if (originalFn.apply) {
-            return originalFn.apply(this, args);
-        } else {
-            return originalFn(args[0], args[1]);
-        }
-    };
-};
-
-_helper('setTimeout');
-_helper('setInterval');
-
-}(this, Raven));

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d875938cc63d7f0bef3a894f71afe6366204e6b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Sentry
Gerrit-Branch: master
Gerrit-Owner: GergÅ‘ Tisza <[email protected]>

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

Reply via email to