Vue: Split off error logger into its own plugin

Change-Id: Idbbaf2a5fb174aabefa9206d889c62c71846ac5f
This commit is contained in:
Roan Kattouw 2021-08-18 00:09:45 -07:00 committed by James D. Forrester
parent 5af89e32c7
commit 15e8d65b89
3 changed files with 27 additions and 16 deletions

View file

@ -574,6 +574,7 @@ return [
'vue' => [
'packageFiles' => [
'resources/src/vue/index.js',
'resources/src/vue/errorLogger.js',
'resources/src/vue/i18n.js',
[
'name' => 'resources/lib/vue/vue.js',

View file

@ -0,0 +1,25 @@
/*!
* Plugin that captures errors from Vue code and logs them to mw.errorLogger
*/
module.exports = {
install: function ( Vue ) {
/**
* @class Vue
*/
/**
* Track component errors that bubble up to the Vue.js runtime on the `error.vue` analytics
* event topic for one or more subscribers to send to an error logging service. Also log those
* errors to the console, which is the default behaviour of the Vue.js runtime.
*
* See also <https://phabricator.wikimedia.org/T249826>.
*
* @ignore
* @param {Error} error
*/
Vue.config.errorHandler = function ( error ) {
mw.errorLogger.logError( error, 'error.vue' );
mw.log.error( error );
};
}
};

View file

@ -1,23 +1,8 @@
( function () {
var Vue = require( '../../lib/vue/vue.js' );
Vue.use( require( './errorLogger.js' ) );
Vue.use( require( './i18n.js' ) );
/**
* Track component errors that bubble up to the Vue.js runtime on the `error.vue` analytics
* event topic for one or more subscribers to send to an error logging service. Also log those
* errors to the console, which is the default behaviour of the Vue.js runtime.
*
* See also <https://phabricator.wikimedia.org/T249826>.
*
* @ignore
* @param {Error} error
*/
Vue.config.errorHandler = function ( error ) {
mw.errorLogger.logError( error, 'error.vue' );
mw.log.error( error );
};
module.exports = Vue;
}() );