diff --git a/plugins/vue.js b/plugins/vue.js index 20adcffc08d6..3a339f1c18e4 100644 --- a/plugins/vue.js +++ b/plugins/vue.js @@ -4,6 +4,17 @@ */ 'use strict'; +function formatComponentName (vm) { + if (vm.$root === vm) { + return 'root instance' + } + var name = vm._isVue + ? vm.$options.name || vm.$options._componentTag + : vm.name + return (name ? 'component <' + name + '>' : 'anonymous component') + + (vm._isVue && vm.$options.__file ? ' at ' + vm.$options.__file : '') +} + function vuePlugin(Raven, Vue) { Vue = Vue || window.Vue; @@ -14,7 +25,7 @@ function vuePlugin(Raven, Vue) { Vue.config.errorHandler = function VueErrorHandler(error, vm) { Raven.captureException(error, { extra: { - componentName: Vue.util.formatComponentName(vm), + componentName: formatComponentName(vm), propsData: vm.$options.propsData } }); diff --git a/test/plugins/vue.test.js b/test/plugins/vue.test.js index 354c8636c94a..99957945da51 100644 --- a/test/plugins/vue.test.js +++ b/test/plugins/vue.test.js @@ -12,12 +12,7 @@ describe('Vue plugin', function () { beforeEach(function () { this.sinon.stub(Raven, 'captureException'); this.MockVue = { - config: {}, - util: { - formatComponentName: function() { - return '' - } - } + config: {} }; }); @@ -38,7 +33,7 @@ describe('Vue plugin', function () { propsData: { foo: 'bar' }, - componentName: '' + componentName: 'anonymous component' }); });