@honeybadger-io/vue 1.0.3 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -86,10 +86,14 @@ To perform a release:
86
86
 
87
87
  1. With a clean working tree, use `npm version [new version]` to bump the version, commit the
88
88
  changes, tag the release, and push to GitHub. See `npm help version` for
89
- documentation.
89
+ documentation. Make sure to checkout the correct branch (i.e. if you are planning to release a version with other than `latest` dist tag).
90
+
90
91
 
91
92
  2. To publish the release, use `npm publish`. See `npm help publish` for
92
- documentation.
93
+ documentation. This command will publish the version with the `latest` tag. To publish with a different tag, i.e. `next`, use `npm publish --tag next`.
94
+
95
+
96
+ 3. Verify the published version in Versions tab from [here](https://www.npmjs.com/package/@honeybadger-io/vue).
93
97
 
94
98
  ### License
95
99
 
@@ -1,37 +1,132 @@
1
1
  import Honeybadger from '@honeybadger-io/js';
2
2
 
3
- var HoneybadgerVue = {
4
- install: function install (Vue, options) {
5
- var this$1 = this;
3
+ /**
4
+ * This was taken from https://github.com/vuejs/vue/blob/master/src/core/util/debug.js.
5
+ * The method generateStackTrace is used to log errors the same way as Vue logs them when errorHandler is not set.
6
+ */
7
+
8
+ var classifyRE = /(?:^|[-_])(\w)/g;
9
+ var classify = function (str) { return str
10
+ .replace(classifyRE, function (c) { return c.toUpperCase(); })
11
+ .replace(/[-_]/g, ''); };
12
+
13
+ var formatComponentName = function (vm, includeFile) {
14
+ if (vm.$root === vm) {
15
+ return '<Root>'
16
+ }
17
+ var options = typeof vm === 'function' && vm.cid != null
18
+ ? vm.options
19
+ : vm._isVue
20
+ ? vm.$options || vm.constructor.options
21
+ : vm || {};
22
+ var name = options.name || options._componentTag;
23
+ var file = options.__file;
24
+ if (!name && file) {
25
+ var match = file.match(/([^/\\]+)\.vue$/);
26
+ name = match && match[1];
27
+ }
28
+
29
+ return (
30
+ (name ? ("<" + (classify(name)) + ">") : '<Anonymous>') +
31
+ (file && includeFile !== false ? (" at " + file) : '')
32
+ )
33
+ };
34
+
35
+ var repeat = function (str, n) {
36
+ var res = '';
37
+ while (n) {
38
+ if (n % 2 === 1) { res += str; }
39
+ if (n > 1) { str += str; }
40
+ n >>= 1;
41
+ }
42
+ return res
43
+ };
44
+
45
+ var generateComponentTrace = function (vm) {
46
+ if (vm._isVue && vm.$parent) {
47
+ var tree = [];
48
+ var currentRecursiveSequence = 0;
49
+ while (vm) {
50
+ if (tree.length > 0) {
51
+ var last = tree[tree.length - 1];
52
+ if (last.constructor === vm.constructor) {
53
+ currentRecursiveSequence++;
54
+ vm = vm.$parent;
55
+ continue
56
+ } else if (currentRecursiveSequence > 0) {
57
+ tree[tree.length - 1] = [last, currentRecursiveSequence];
58
+ currentRecursiveSequence = 0;
59
+ }
60
+ }
61
+ tree.push(vm);
62
+ vm = vm.$parent;
63
+ }
64
+ return '\n\nfound in\n\n' + tree
65
+ .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
66
+ ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
67
+ : formatComponentName(vm))); })
68
+ .join('\n')
69
+ } else {
70
+ return ("\n\n(found in " + (formatComponentName(vm)) + ")")
71
+ }
72
+ };
73
+
74
+ function logError (app, error, vm, info) {
75
+ var message = "Error in " + info + ": \"" + (error && error.toString()) + "\"";
76
+
77
+ var trace = vm ? generateComponentTrace(vm) : '';
78
+ if (app.config.warnHandler) {
79
+ app.config.warnHandler.call(null, message, vm, trace);
80
+ } else {
81
+ console.error(("[Vue warn]: " + message + trace));
82
+ }
83
+ }
6
84
 
7
- if (Vue.config.debug) {
85
+ var HoneybadgerVue = {
86
+ install: function install (app, options) {
87
+ if (app.config.debug) {
8
88
  console.log(("Honeybadger configured with " + (options.apiKey)));
9
89
  }
10
90
  var honeybadger = Honeybadger.configure(options);
11
- Vue.$honeybadger = honeybadger;
12
- Vue.prototype.$honeybadger = Vue.$honeybadger;
13
- var chainedErrorHandler = Vue.config.errorHandler;
14
- var extractContext = function (vm) {
15
- var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||
16
- vm.constructor.options : vm || {};
17
- var name = options.name || options._componentTag;
18
- var file = options.__file;
19
- return {
20
- isRoot: vm.$root === vm,
21
- name: name,
22
- props: options.propsData,
23
- parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,
24
- file: file
25
- }
26
- };
27
- Vue.config.errorHandler = function (error, vm, info) {
91
+ app.$honeybadger = honeybadger;
92
+ app.config.globalProperties.$honeybadger = honeybadger;
93
+ var chainedErrorHandler = app.config.errorHandler;
94
+ app.config.errorHandler = function (error, vm, info) {
28
95
  honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } });
29
96
  if (typeof chainedErrorHandler === 'function') {
30
- chainedErrorHandler.call(this$1.Vue, error, vm, info);
97
+ chainedErrorHandler.call(app, error, vm, info);
98
+ }
99
+
100
+ if (shouldLogError(app)) {
101
+ logError(app, error, vm, info);
31
102
  }
32
103
  };
33
104
  }
34
105
  };
35
106
 
36
- export default HoneybadgerVue;
107
+ function shouldLogError (app) {
108
+ if (app.config.warnHandler) {
109
+ return true
110
+ }
111
+
112
+ var hasConsole = typeof console !== 'undefined';
113
+ var isDebug = app.config.debug || process.env.NODE_ENV !== 'production';
114
+ return hasConsole && isDebug
115
+ }
116
+
117
+ function extractContext (vm) {
118
+ var options = vm.$options || {};
119
+ var name = options.name || options._componentTag;
120
+ var file = options.__file;
121
+ var parentName = vm.$parent && vm.$parent.$options ? vm.$parent.$options.name : undefined;
122
+ return {
123
+ isRoot: vm.$root === vm,
124
+ name: name,
125
+ props: vm.$props,
126
+ parentName: parentName,
127
+ file: file
128
+ }
129
+ }
130
+
131
+ export { HoneybadgerVue as default };
37
132
  //# sourceMappingURL=honeybadger-vue.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-vue.esm.js","sources":["../../src/index.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js'\n\nconst HoneybadgerVue = {\n install (Vue, options) {\n if (Vue.config.debug) {\n console.log(`Honeybadger configured with ${options.apiKey}`)\n }\n const honeybadger = Honeybadger.configure(options)\n Vue.$honeybadger = honeybadger\n Vue.prototype.$honeybadger = Vue.$honeybadger\n const chainedErrorHandler = Vue.config.errorHandler\n const extractContext = function (vm) {\n var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||\n vm.constructor.options : vm || {}\n var name = options.name || options._componentTag\n var file = options.__file\n return {\n isRoot: vm.$root === vm,\n name: name,\n props: options.propsData,\n parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,\n file: file\n }\n }\n Vue.config.errorHandler = (error, vm, info) => {\n honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } })\n if (typeof chainedErrorHandler === 'function') {\n chainedErrorHandler.call(this.Vue, error, vm, info)\n }\n }\n }\n}\n\nexport default HoneybadgerVue\n"],"names":["const","this"],"mappings":";;AAEK,IAAC,cAAc,GAAG;EACrB,yBAAO,EAAE,GAAG,EAAE,OAAO,EAAE;;AAAC;IACtB,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE;MACpB,OAAO,CAAC,GAAG,oCAAgC,OAAO,CAAC,MAAM,IAAG;KAC7D;IACDA,IAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,EAAC;IAClD,GAAG,CAAC,YAAY,GAAG,YAAW;IAC9B,GAAG,CAAC,SAAS,CAAC,YAAY,GAAG,GAAG,CAAC,aAAY;IAC7CA,IAAM,mBAAmB,GAAG,GAAG,CAAC,MAAM,CAAC,aAAY;IACnDA,IAAM,cAAc,GAAG,UAAU,EAAE,EAAE;MACnC,IAAI,OAAO,GAAG,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,QAAQ;QAC7F,EAAE,CAAC,WAAW,CAAC,OAAO,GAAG,EAAE,IAAI,GAAE;MACnC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,cAAa;MAChD,IAAI,IAAI,GAAG,OAAO,CAAC,OAAM;MACzB,OAAO;QACL,MAAM,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE;QACvB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,OAAO,CAAC,SAAS;QACxB,cAAc,EAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS;QAC3E,IAAI,EAAE,IAAI;OACX;MACF;IACD,GAAG,CAAC,MAAM,CAAC,YAAY,aAAI,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE;MAC1C,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAC;MAC9E,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;QAC7C,mBAAmB,CAAC,IAAI,CAACC,MAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAC;OACpD;MACF;GACF;;;;;"}
1
+ {"version":3,"file":"honeybadger-vue.esm.js","sources":["../../src/vue-debug.js","../../src/error-logging.js","../../src/index.js"],"sourcesContent":["/**\n * This was taken from https://github.com/vuejs/vue/blob/master/src/core/util/debug.js.\n * The method generateStackTrace is used to log errors the same way as Vue logs them when errorHandler is not set.\n */\n\nconst classifyRE = /(?:^|[-_])(\\w)/g\nconst classify = str => str\n .replace(classifyRE, c => c.toUpperCase())\n .replace(/[-_]/g, '')\n\nconst formatComponentName = (vm, includeFile) => {\n if (vm.$root === vm) {\n return '<Root>'\n }\n const options = typeof vm === 'function' && vm.cid != null\n ? vm.options\n : vm._isVue\n ? vm.$options || vm.constructor.options\n : vm || {}\n let name = options.name || options._componentTag\n const file = options.__file\n if (!name && file) {\n const match = file.match(/([^/\\\\]+)\\.vue$/)\n name = match && match[1]\n }\n\n return (\n (name ? `<${classify(name)}>` : '<Anonymous>') +\n (file && includeFile !== false ? ` at ${file}` : '')\n )\n}\n\nconst repeat = (str, n) => {\n let res = ''\n while (n) {\n if (n % 2 === 1) res += str\n if (n > 1) str += str\n n >>= 1\n }\n return res\n}\n\nexport const generateComponentTrace = vm => {\n if (vm._isVue && vm.$parent) {\n const tree = []\n let currentRecursiveSequence = 0\n while (vm) {\n if (tree.length > 0) {\n const last = tree[tree.length - 1]\n if (last.constructor === vm.constructor) {\n currentRecursiveSequence++\n vm = vm.$parent\n continue\n } else if (currentRecursiveSequence > 0) {\n tree[tree.length - 1] = [last, currentRecursiveSequence]\n currentRecursiveSequence = 0\n }\n }\n tree.push(vm)\n vm = vm.$parent\n }\n return '\\n\\nfound in\\n\\n' + tree\n .map((vm, i) => `${\n i === 0 ? '---> ' : repeat(' ', 5 + i * 2)\n }${\n Array.isArray(vm)\n ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`\n : formatComponentName(vm)\n }`)\n .join('\\n')\n } else {\n return `\\n\\n(found in ${formatComponentName(vm)})`\n }\n}\n","import { generateComponentTrace } from './vue-debug'\n\nexport function logError (app, error, vm, info) {\n const message = `Error in ${info}: \"${error && error.toString()}\"`\n\n const trace = vm ? generateComponentTrace(vm) : ''\n if (app.config.warnHandler) {\n app.config.warnHandler.call(null, message, vm, trace)\n } else {\n console.error(`[Vue warn]: ${message}${trace}`)\n }\n}\n","import Honeybadger from '@honeybadger-io/js'\nimport { logError } from './error-logging'\n\nconst HoneybadgerVue = {\n install (app, options) {\n if (app.config.debug) {\n console.log(`Honeybadger configured with ${options.apiKey}`)\n }\n const honeybadger = Honeybadger.configure(options)\n app.$honeybadger = honeybadger\n app.config.globalProperties.$honeybadger = honeybadger\n const chainedErrorHandler = app.config.errorHandler\n app.config.errorHandler = (error, vm, info) => {\n honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } })\n if (typeof chainedErrorHandler === 'function') {\n chainedErrorHandler.call(app, error, vm, info)\n }\n\n if (shouldLogError(app)) {\n logError(app, error, vm, info)\n }\n }\n }\n}\n\nfunction shouldLogError (app) {\n if (app.config.warnHandler) {\n return true\n }\n\n const hasConsole = typeof console !== 'undefined'\n const isDebug = app.config.debug || process.env.NODE_ENV !== 'production'\n return hasConsole && isDebug\n}\n\nfunction extractContext (vm) {\n const options = vm.$options || {}\n const name = options.name || options._componentTag\n const file = options.__file\n const parentName = vm.$parent && vm.$parent.$options ? vm.$parent.$options.name : undefined\n return {\n isRoot: vm.$root === vm,\n name: name,\n props: vm.$props,\n parentName: parentName,\n file: file\n }\n}\n\nexport default HoneybadgerVue\n"],"names":["const","let"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACAA,IAAM,UAAU,GAAG,kBAAiB;AACpCA,IAAM,QAAQ,aAAG,cAAO,GAAG;AAC3B,GAAG,OAAO,CAAC,UAAU,YAAE,YAAK,CAAC,CAAC,WAAW,KAAE,CAAC;AAC5C,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,KAAC;AACvB;AACAA,IAAM,mBAAmB,aAAI,EAAE,EAAE,WAAW,EAAK;AACjD,EAAE,IAAI,EAAE,CAAC,KAAK,KAAK,EAAE,EAAE;AACvB,IAAI,OAAO,QAAQ;AACnB,GAAG;AACH,EAAEA,IAAM,OAAO,GAAG,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,CAAC,GAAG,IAAI,IAAI;AAC5D,MAAM,EAAE,CAAC,OAAO;AAChB,MAAM,EAAE,CAAC,MAAM;AACf,QAAQ,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO;AAC7C,QAAQ,EAAE,IAAI,GAAE;AAChB,EAAEC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,cAAa;AAClD,EAAED,IAAM,IAAI,GAAG,OAAO,CAAC,OAAM;AAC7B,EAAE,IAAI,CAAC,IAAI,IAA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AAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAY;AAC3E,EAAE,OAAO,UAAU,IAAI,OAAO;AAC9B,CAAC;AACD;AACA,SAAS,cAAc,EAAE,EAAE,EAAE;AAC7B,EAAEA,IAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,IAAI,GAAE;AACnC,EAAEA,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,cAAa;AACpD,EAAEA,IAAM,IAAI,GAAG,OAAO,CAAC,OAAM;AAC7B,EAAEA,IAAM,UAAU,GAAG,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAS;AAC7F,EAAE,OAAO;AACT,IAAI,MAAM,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE;AAC3B,IAAI,IAAI,EAAE,IAAI;AACd,IAAI,KAAK,EAAE,EAAE,CAAC,MAAM;AACpB,IAAI,UAAU,EAAE,UAAU;AAC1B,IAAI,IAAI,EAAE,IAAI;AACd,GAAG;AACH;;;;"}
@@ -5,40 +5,135 @@ var HoneybadgerVue = (function (exports, Honeybadger) {
5
5
 
6
6
  var Honeybadger__default = /*#__PURE__*/_interopDefaultLegacy(Honeybadger);
7
7
 
8
- var HoneybadgerVue = {
9
- install: function install (Vue, options) {
10
- var this$1 = this;
8
+ /**
9
+ * This was taken from https://github.com/vuejs/vue/blob/master/src/core/util/debug.js.
10
+ * The method generateStackTrace is used to log errors the same way as Vue logs them when errorHandler is not set.
11
+ */
12
+
13
+ var classifyRE = /(?:^|[-_])(\w)/g;
14
+ var classify = function (str) { return str
15
+ .replace(classifyRE, function (c) { return c.toUpperCase(); })
16
+ .replace(/[-_]/g, ''); };
17
+
18
+ var formatComponentName = function (vm, includeFile) {
19
+ if (vm.$root === vm) {
20
+ return '<Root>'
21
+ }
22
+ var options = typeof vm === 'function' && vm.cid != null
23
+ ? vm.options
24
+ : vm._isVue
25
+ ? vm.$options || vm.constructor.options
26
+ : vm || {};
27
+ var name = options.name || options._componentTag;
28
+ var file = options.__file;
29
+ if (!name && file) {
30
+ var match = file.match(/([^/\\]+)\.vue$/);
31
+ name = match && match[1];
32
+ }
33
+
34
+ return (
35
+ (name ? ("<" + (classify(name)) + ">") : '<Anonymous>') +
36
+ (file && includeFile !== false ? (" at " + file) : '')
37
+ )
38
+ };
39
+
40
+ var repeat = function (str, n) {
41
+ var res = '';
42
+ while (n) {
43
+ if (n % 2 === 1) { res += str; }
44
+ if (n > 1) { str += str; }
45
+ n >>= 1;
46
+ }
47
+ return res
48
+ };
49
+
50
+ var generateComponentTrace = function (vm) {
51
+ if (vm._isVue && vm.$parent) {
52
+ var tree = [];
53
+ var currentRecursiveSequence = 0;
54
+ while (vm) {
55
+ if (tree.length > 0) {
56
+ var last = tree[tree.length - 1];
57
+ if (last.constructor === vm.constructor) {
58
+ currentRecursiveSequence++;
59
+ vm = vm.$parent;
60
+ continue
61
+ } else if (currentRecursiveSequence > 0) {
62
+ tree[tree.length - 1] = [last, currentRecursiveSequence];
63
+ currentRecursiveSequence = 0;
64
+ }
65
+ }
66
+ tree.push(vm);
67
+ vm = vm.$parent;
68
+ }
69
+ return '\n\nfound in\n\n' + tree
70
+ .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
71
+ ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
72
+ : formatComponentName(vm))); })
73
+ .join('\n')
74
+ } else {
75
+ return ("\n\n(found in " + (formatComponentName(vm)) + ")")
76
+ }
77
+ };
78
+
79
+ function logError (app, error, vm, info) {
80
+ var message = "Error in " + info + ": \"" + (error && error.toString()) + "\"";
81
+
82
+ var trace = vm ? generateComponentTrace(vm) : '';
83
+ if (app.config.warnHandler) {
84
+ app.config.warnHandler.call(null, message, vm, trace);
85
+ } else {
86
+ console.error(("[Vue warn]: " + message + trace));
87
+ }
88
+ }
11
89
 
12
- if (Vue.config.debug) {
90
+ var HoneybadgerVue = {
91
+ install: function install (app, options) {
92
+ if (app.config.debug) {
13
93
  console.log(("Honeybadger configured with " + (options.apiKey)));
14
94
  }
15
95
  var honeybadger = Honeybadger__default['default'].configure(options);
16
- Vue.$honeybadger = honeybadger;
17
- Vue.prototype.$honeybadger = Vue.$honeybadger;
18
- var chainedErrorHandler = Vue.config.errorHandler;
19
- var extractContext = function (vm) {
20
- var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||
21
- vm.constructor.options : vm || {};
22
- var name = options.name || options._componentTag;
23
- var file = options.__file;
24
- return {
25
- isRoot: vm.$root === vm,
26
- name: name,
27
- props: options.propsData,
28
- parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,
29
- file: file
30
- }
31
- };
32
- Vue.config.errorHandler = function (error, vm, info) {
96
+ app.$honeybadger = honeybadger;
97
+ app.config.globalProperties.$honeybadger = honeybadger;
98
+ var chainedErrorHandler = app.config.errorHandler;
99
+ app.config.errorHandler = function (error, vm, info) {
33
100
  honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } });
34
101
  if (typeof chainedErrorHandler === 'function') {
35
- chainedErrorHandler.call(this$1.Vue, error, vm, info);
102
+ chainedErrorHandler.call(app, error, vm, info);
103
+ }
104
+
105
+ if (shouldLogError(app)) {
106
+ logError(app, error, vm, info);
36
107
  }
37
108
  };
38
109
  }
39
110
  };
40
111
 
41
- exports.default = HoneybadgerVue;
112
+ function shouldLogError (app) {
113
+ if (app.config.warnHandler) {
114
+ return true
115
+ }
116
+
117
+ var hasConsole = typeof console !== 'undefined';
118
+ var isDebug = app.config.debug || process.env.NODE_ENV !== 'production';
119
+ return hasConsole && isDebug
120
+ }
121
+
122
+ function extractContext (vm) {
123
+ var options = vm.$options || {};
124
+ var name = options.name || options._componentTag;
125
+ var file = options.__file;
126
+ var parentName = vm.$parent && vm.$parent.$options ? vm.$parent.$options.name : undefined;
127
+ return {
128
+ isRoot: vm.$root === vm,
129
+ name: name,
130
+ props: vm.$props,
131
+ parentName: parentName,
132
+ file: file
133
+ }
134
+ }
135
+
136
+ exports['default'] = HoneybadgerVue;
42
137
 
43
138
  Object.defineProperty(exports, '__esModule', { value: true });
44
139
 
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-vue.js","sources":["../../src/index.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js'\n\nconst HoneybadgerVue = {\n install (Vue, options) {\n if (Vue.config.debug) {\n console.log(`Honeybadger configured with ${options.apiKey}`)\n }\n const honeybadger = Honeybadger.configure(options)\n Vue.$honeybadger = honeybadger\n Vue.prototype.$honeybadger = Vue.$honeybadger\n const chainedErrorHandler = Vue.config.errorHandler\n const extractContext = function (vm) {\n var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||\n vm.constructor.options : vm || {}\n var name = options.name || options._componentTag\n var file = options.__file\n return {\n isRoot: vm.$root === vm,\n name: name,\n props: options.propsData,\n parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,\n file: file\n }\n }\n Vue.config.errorHandler = (error, vm, info) => {\n honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } })\n if (typeof chainedErrorHandler === 'function') {\n chainedErrorHandler.call(this.Vue, error, vm, info)\n }\n }\n }\n}\n\nexport default HoneybadgerVue\n"],"names":["const","Honeybadger","this"],"mappings":";;;;;;;AAEK,MAAC,cAAc,GAAG;IACrB,yBAAO,EAAE,GAAG,EAAE,OAAO,EAAE;;AAAC;MACtB,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE;QACpB,OAAO,CAAC,GAAG,oCAAgC,OAAO,CAAC,MAAM,IAAG;OAC7D;MACDA,IAAM,WAAW,GAAGC,+BAAW,CAAC,SAAS,CAAC,OAAO,EAAC;MAClD,GAAG,CAAC,YAAY,GAAG,YAAW;MAC9B,GAAG,CAAC,SAAS,CAAC,YAAY,GAAG,GAAG,CAAC,aAAY;MAC7CD,IAAM,mBAAmB,GAAG,GAAG,CAAC,MAAM,CAAC,aAAY;MACnDA,IAAM,cAAc,GAAG,UAAU,EAAE,EAAE;QACnC,IAAI,OAAO,GAAG,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,QAAQ;UAC7F,EAAE,CAAC,WAAW,CAAC,OAAO,GAAG,EAAE,IAAI,GAAE;QACnC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,cAAa;QAChD,IAAI,IAAI,GAAG,OAAO,CAAC,OAAM;QACzB,OAAO;UACL,MAAM,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE;UACvB,IAAI,EAAE,IAAI;UACV,KAAK,EAAE,OAAO,CAAC,SAAS;UACxB,cAAc,EAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,GAAG,SAAS;UAC3E,IAAI,EAAE,IAAI;SACX;QACF;MACD,GAAG,CAAC,MAAM,CAAC,YAAY,aAAI,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE;QAC1C,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAC;QAC9E,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;UAC7C,mBAAmB,CAAC,IAAI,CAACE,MAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAC;SACpD;QACF;KACF;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"honeybadger-vue.js","sources":["../../src/vue-debug.js","../../src/error-logging.js","../../src/index.js"],"sourcesContent":["/**\n * This was taken from https://github.com/vuejs/vue/blob/master/src/core/util/debug.js.\n * The method generateStackTrace is used to log errors the same way as Vue logs them when errorHandler is not set.\n */\n\nconst classifyRE = /(?:^|[-_])(\\w)/g\nconst classify = str => str\n .replace(classifyRE, c => c.toUpperCase())\n .replace(/[-_]/g, '')\n\nconst formatComponentName = (vm, includeFile) => {\n if (vm.$root === vm) {\n return '<Root>'\n }\n const options = typeof vm === 'function' && vm.cid != null\n ? vm.options\n : vm._isVue\n ? vm.$options || vm.constructor.options\n : vm || {}\n let name = options.name || options._componentTag\n const file = options.__file\n if (!name && file) {\n const match = file.match(/([^/\\\\]+)\\.vue$/)\n name = match && match[1]\n }\n\n return (\n (name ? `<${classify(name)}>` : '<Anonymous>') +\n (file && includeFile !== false ? ` at ${file}` : '')\n )\n}\n\nconst repeat = (str, n) => {\n let res = ''\n while (n) {\n if (n % 2 === 1) res += str\n if (n > 1) str += str\n n >>= 1\n }\n return res\n}\n\nexport const generateComponentTrace = vm => {\n if (vm._isVue && vm.$parent) {\n const tree = []\n let currentRecursiveSequence = 0\n while (vm) {\n if (tree.length > 0) {\n const last = tree[tree.length - 1]\n if (last.constructor === vm.constructor) {\n currentRecursiveSequence++\n vm = vm.$parent\n continue\n } else if (currentRecursiveSequence > 0) {\n tree[tree.length - 1] = [last, currentRecursiveSequence]\n currentRecursiveSequence = 0\n }\n }\n tree.push(vm)\n vm = vm.$parent\n }\n return '\\n\\nfound in\\n\\n' + tree\n .map((vm, i) => `${\n i === 0 ? '---> ' : repeat(' ', 5 + i * 2)\n }${\n Array.isArray(vm)\n ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`\n : formatComponentName(vm)\n }`)\n .join('\\n')\n } else {\n return `\\n\\n(found in ${formatComponentName(vm)})`\n }\n}\n","import { generateComponentTrace } from './vue-debug'\n\nexport function logError (app, error, vm, info) {\n const message = `Error in ${info}: \"${error && error.toString()}\"`\n\n const trace = vm ? generateComponentTrace(vm) : ''\n if (app.config.warnHandler) {\n app.config.warnHandler.call(null, message, vm, trace)\n } else {\n console.error(`[Vue warn]: ${message}${trace}`)\n }\n}\n","import Honeybadger from '@honeybadger-io/js'\nimport { logError } from './error-logging'\n\nconst HoneybadgerVue = {\n install (app, options) {\n if (app.config.debug) {\n console.log(`Honeybadger configured with ${options.apiKey}`)\n }\n const honeybadger = Honeybadger.configure(options)\n app.$honeybadger = honeybadger\n app.config.globalProperties.$honeybadger = honeybadger\n const chainedErrorHandler = app.config.errorHandler\n app.config.errorHandler = (error, vm, info) => {\n honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } })\n if (typeof chainedErrorHandler === 'function') {\n chainedErrorHandler.call(app, error, vm, info)\n }\n\n if (shouldLogError(app)) {\n logError(app, error, vm, info)\n }\n }\n }\n}\n\nfunction shouldLogError (app) {\n if (app.config.warnHandler) {\n return true\n }\n\n const hasConsole = typeof console !== 'undefined'\n const isDebug = app.config.debug || process.env.NODE_ENV !== 'production'\n return hasConsole && isDebug\n}\n\nfunction extractContext (vm) {\n const options = vm.$options || {}\n const name = options.name || options._componentTag\n const file = options.__file\n const parentName = vm.$parent && vm.$parent.$options ? vm.$parent.$options.name : undefined\n return {\n isRoot: vm.$root === vm,\n name: name,\n props: vm.$props,\n parentName: parentName,\n file: file\n }\n}\n\nexport default HoneybadgerVue\n"],"names":["const","let","Honeybadger"],"mappings":";;;;;;;EAAA;EACA;EACA;EACA;AACA;EACAA,IAAM,UAAU,GAAG,kBAAiB;EACpCA,IAAM,QAAQ,aAAG,cAAO,GAAG;EAC3B,GAAG,OAAO,CAAC,UAAU,YAAE,YAAK,CAAC,CAAC,WAAW,KAAE,CAAC;EAC5C,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,KAAC;AACvB;EACAA,IAAM,mBAAmB,aAAI,EAAE,EAAE,WAAW,EAAK;EACjD,EAAE,IAAI,EAAE,CAAC,KAAK,KAAK,EAAE,EAAE;EACvB,IAAI,OAAO,QAAQ;EACnB,GAAG;EACH,EAAEA,IAAM,OAAO,GAAG,OAAO,EAAE,KAAK,UAAU,IAAI,EAAE,CAAC,GAAG,IAAI,IAAI;EAC5D,MAAM,EAAE,CAAC,OA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;EACP,MAAK;EACL,GAAG;EACH,EAAC;AACD;EACA,SAAS,cAAc,EAAE,GAAG,EAAE;EAC9B,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE;EAC9B,IAAI,OAAO,IAAI;EACf,GAAG;AACH;EACA,EAAEA,IAAM,UAAU,GAAG,OAAO,OAAO,KAAK,YAAW;EACnD,EAAEA,IAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAY;EAC3E,EAAE,OAAO,UAAU,IAAI,OAAO;EAC9B,CAAC;AACD;EACA,SAAS,cAAc,EAAE,EAAE,EAAE;EAC7B,EAAEA,IAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,IAAI,GAAE;EACnC,EAAEA,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,cAAa;EACpD,EAAEA,IAAM,IAAI,GAAG,OAAO,CAAC,OAAM;EAC7B,EAAEA,IAAM,UAAU,GAAG,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAS;EAC7F,EAAE,OAAO;EACT,IAAI,MAAM,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE;EAC3B,IAAI,IAAI,EAAE,IAAI;EACd,IAAI,KAAK,EAAE,EAAE,CAAC,MAAM;EACpB,IAAI,UAAU,EAAE,UAAU;EAC1B,IAAI,IAAI,EAAE,IAAI;EACd,GAAG;EACH;;;;;;;;;;;;"}
@@ -8,40 +8,135 @@
8
8
 
9
9
  var Honeybadger__default = /*#__PURE__*/_interopDefaultLegacy(Honeybadger);
10
10
 
11
- var HoneybadgerVue = {
12
- install: function install (Vue, options) {
13
- var this$1 = this;
11
+ /**
12
+ * This was taken from https://github.com/vuejs/vue/blob/master/src/core/util/debug.js.
13
+ * The method generateStackTrace is used to log errors the same way as Vue logs them when errorHandler is not set.
14
+ */
15
+
16
+ var classifyRE = /(?:^|[-_])(\w)/g;
17
+ var classify = function (str) { return str
18
+ .replace(classifyRE, function (c) { return c.toUpperCase(); })
19
+ .replace(/[-_]/g, ''); };
20
+
21
+ var formatComponentName = function (vm, includeFile) {
22
+ if (vm.$root === vm) {
23
+ return '<Root>'
24
+ }
25
+ var options = typeof vm === 'function' && vm.cid != null
26
+ ? vm.options
27
+ : vm._isVue
28
+ ? vm.$options || vm.constructor.options
29
+ : vm || {};
30
+ var name = options.name || options._componentTag;
31
+ var file = options.__file;
32
+ if (!name && file) {
33
+ var match = file.match(/([^/\\]+)\.vue$/);
34
+ name = match && match[1];
35
+ }
36
+
37
+ return (
38
+ (name ? ("<" + (classify(name)) + ">") : '<Anonymous>') +
39
+ (file && includeFile !== false ? (" at " + file) : '')
40
+ )
41
+ };
42
+
43
+ var repeat = function (str, n) {
44
+ var res = '';
45
+ while (n) {
46
+ if (n % 2 === 1) { res += str; }
47
+ if (n > 1) { str += str; }
48
+ n >>= 1;
49
+ }
50
+ return res
51
+ };
52
+
53
+ var generateComponentTrace = function (vm) {
54
+ if (vm._isVue && vm.$parent) {
55
+ var tree = [];
56
+ var currentRecursiveSequence = 0;
57
+ while (vm) {
58
+ if (tree.length > 0) {
59
+ var last = tree[tree.length - 1];
60
+ if (last.constructor === vm.constructor) {
61
+ currentRecursiveSequence++;
62
+ vm = vm.$parent;
63
+ continue
64
+ } else if (currentRecursiveSequence > 0) {
65
+ tree[tree.length - 1] = [last, currentRecursiveSequence];
66
+ currentRecursiveSequence = 0;
67
+ }
68
+ }
69
+ tree.push(vm);
70
+ vm = vm.$parent;
71
+ }
72
+ return '\n\nfound in\n\n' + tree
73
+ .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
74
+ ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
75
+ : formatComponentName(vm))); })
76
+ .join('\n')
77
+ } else {
78
+ return ("\n\n(found in " + (formatComponentName(vm)) + ")")
79
+ }
80
+ };
81
+
82
+ function logError (app, error, vm, info) {
83
+ var message = "Error in " + info + ": \"" + (error && error.toString()) + "\"";
84
+
85
+ var trace = vm ? generateComponentTrace(vm) : '';
86
+ if (app.config.warnHandler) {
87
+ app.config.warnHandler.call(null, message, vm, trace);
88
+ } else {
89
+ console.error(("[Vue warn]: " + message + trace));
90
+ }
91
+ }
14
92
 
15
- if (Vue.config.debug) {
93
+ var HoneybadgerVue = {
94
+ install: function install (app, options) {
95
+ if (app.config.debug) {
16
96
  console.log(("Honeybadger configured with " + (options.apiKey)));
17
97
  }
18
98
  var honeybadger = Honeybadger__default['default'].configure(options);
19
- Vue.$honeybadger = honeybadger;
20
- Vue.prototype.$honeybadger = Vue.$honeybadger;
21
- var chainedErrorHandler = Vue.config.errorHandler;
22
- var extractContext = function (vm) {
23
- var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||
24
- vm.constructor.options : vm || {};
25
- var name = options.name || options._componentTag;
26
- var file = options.__file;
27
- return {
28
- isRoot: vm.$root === vm,
29
- name: name,
30
- props: options.propsData,
31
- parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,
32
- file: file
33
- }
34
- };
35
- Vue.config.errorHandler = function (error, vm, info) {
99
+ app.$honeybadger = honeybadger;
100
+ app.config.globalProperties.$honeybadger = honeybadger;
101
+ var chainedErrorHandler = app.config.errorHandler;
102
+ app.config.errorHandler = function (error, vm, info) {
36
103
  honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } });
37
104
  if (typeof chainedErrorHandler === 'function') {
38
- chainedErrorHandler.call(this$1.Vue, error, vm, info);
105
+ chainedErrorHandler.call(app, error, vm, info);
106
+ }
107
+
108
+ if (shouldLogError(app)) {
109
+ logError(app, error, vm, info);
39
110
  }
40
111
  };
41
112
  }
42
113
  };
43
114
 
44
- exports.default = HoneybadgerVue;
115
+ function shouldLogError (app) {
116
+ if (app.config.warnHandler) {
117
+ return true
118
+ }
119
+
120
+ var hasConsole = typeof console !== 'undefined';
121
+ var isDebug = app.config.debug || process.env.NODE_ENV !== 'production';
122
+ return hasConsole && isDebug
123
+ }
124
+
125
+ function extractContext (vm) {
126
+ var options = vm.$options || {};
127
+ var name = options.name || options._componentTag;
128
+ var file = options.__file;
129
+ var parentName = vm.$parent && vm.$parent.$options ? vm.$parent.$options.name : undefined;
130
+ return {
131
+ isRoot: vm.$root === vm,
132
+ name: name,
133
+ props: vm.$props,
134
+ parentName: parentName,
135
+ file: file
136
+ }
137
+ }
138
+
139
+ exports['default'] = HoneybadgerVue;
45
140
 
46
141
  Object.defineProperty(exports, '__esModule', { value: true });
47
142
 
@@ -1 +1 @@
1
- {"version":3,"file":"honeybadger-vue.umd.js","sources":["../../src/index.js"],"sourcesContent":["import Honeybadger from '@honeybadger-io/js'\n\nconst HoneybadgerVue = {\n install (Vue, options) {\n if (Vue.config.debug) {\n console.log(`Honeybadger configured with ${options.apiKey}`)\n }\n const honeybadger = Honeybadger.configure(options)\n Vue.$honeybadger = honeybadger\n Vue.prototype.$honeybadger = Vue.$honeybadger\n const chainedErrorHandler = Vue.config.errorHandler\n const extractContext = function (vm) {\n var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||\n vm.constructor.options : vm || {}\n var name = options.name || options._componentTag\n var file = options.__file\n return {\n isRoot: vm.$root === vm,\n name: name,\n props: options.propsData,\n parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,\n file: file\n }\n }\n Vue.config.errorHandler = (error, vm, info) => {\n honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } })\n if (typeof chainedErrorHandler === 'function') {\n chainedErrorHandler.call(this.Vue, error, vm, info)\n }\n }\n }\n}\n\nexport default HoneybadgerVue\n"],"names":["const","Honeybadger","this"],"mappings":";;;;;;;;;;AAEK,MAAC,cAAc,GAAG;IACrB,yBAAO,EAAE,GAAG,EAAE,OAAO,EAAE;;AAAC;MACtB,IAA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AAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAC;SACpD;QACF;KACF;;;;;;;;;;;"}
1
+ {"version":3,"file":"honeybadger-vue.umd.js","sources":["../../src/vue-debug.js","../../src/error-logging.js","../../src/index.js"],"sourcesContent":["/**\n * This was taken from https://github.com/vuejs/vue/blob/master/src/core/util/debug.js.\n * The method generateStackTrace is used to log errors the same way as Vue logs them when errorHandler is not set.\n */\n\nconst classifyRE = /(?:^|[-_])(\\w)/g\nconst classify = str => str\n .replace(classifyRE, c => c.toUpperCase())\n .replace(/[-_]/g, '')\n\nconst formatComponentName = (vm, includeFile) => {\n if (vm.$root === vm) {\n return '<Root>'\n }\n const options = typeof vm === 'function' && vm.cid != null\n ? vm.options\n : vm._isVue\n ? vm.$options || vm.constructor.options\n : vm || {}\n let name = options.name || options._componentTag\n const file = options.__file\n if (!name && file) {\n const match = file.match(/([^/\\\\]+)\\.vue$/)\n name = match && match[1]\n }\n\n return (\n (name ? `<${classify(name)}>` : '<Anonymous>') +\n (file && includeFile !== false ? ` at ${file}` : '')\n )\n}\n\nconst repeat = (str, n) => {\n let res = ''\n while (n) {\n if (n % 2 === 1) res += str\n if (n > 1) str += str\n n >>= 1\n }\n return res\n}\n\nexport const generateComponentTrace = vm => {\n if (vm._isVue && vm.$parent) {\n const tree = []\n let currentRecursiveSequence = 0\n while (vm) {\n if (tree.length > 0) {\n const last = tree[tree.length - 1]\n if (last.constructor === vm.constructor) {\n currentRecursiveSequence++\n vm = vm.$parent\n continue\n } else if (currentRecursiveSequence > 0) {\n tree[tree.length - 1] = [last, currentRecursiveSequence]\n currentRecursiveSequence = 0\n }\n }\n tree.push(vm)\n vm = vm.$parent\n }\n return '\\n\\nfound in\\n\\n' + tree\n .map((vm, i) => `${\n i === 0 ? '---> ' : repeat(' ', 5 + i * 2)\n }${\n Array.isArray(vm)\n ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`\n : formatComponentName(vm)\n }`)\n .join('\\n')\n } else {\n return `\\n\\n(found in ${formatComponentName(vm)})`\n }\n}\n","import { generateComponentTrace } from './vue-debug'\n\nexport function logError (app, error, vm, info) {\n const message = `Error in ${info}: \"${error && error.toString()}\"`\n\n const trace = vm ? generateComponentTrace(vm) : ''\n if (app.config.warnHandler) {\n app.config.warnHandler.call(null, message, vm, trace)\n } else {\n console.error(`[Vue warn]: ${message}${trace}`)\n }\n}\n","import Honeybadger from '@honeybadger-io/js'\nimport { logError } from './error-logging'\n\nconst HoneybadgerVue = {\n install (app, options) {\n if (app.config.debug) {\n console.log(`Honeybadger configured with ${options.apiKey}`)\n }\n const honeybadger = Honeybadger.configure(options)\n app.$honeybadger = honeybadger\n app.config.globalProperties.$honeybadger = honeybadger\n const chainedErrorHandler = app.config.errorHandler\n app.config.errorHandler = (error, vm, info) => {\n honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } })\n if (typeof chainedErrorHandler === 'function') {\n chainedErrorHandler.call(app, error, vm, info)\n }\n\n if (shouldLogError(app)) {\n logError(app, error, vm, info)\n }\n }\n }\n}\n\nfunction shouldLogError (app) {\n if (app.config.warnHandler) {\n return true\n }\n\n const hasConsole = typeof console !== 'undefined'\n const isDebug = app.config.debug || process.env.NODE_ENV !== 'production'\n return hasConsole && isDebug\n}\n\nfunction extractContext (vm) {\n const options = vm.$options || {}\n const name = options.name || options._componentTag\n const file = options.__file\n const parentName = vm.$parent && vm.$parent.$options ? vm.$parent.$options.name : undefined\n return {\n isRoot: vm.$root === vm,\n name: name,\n props: vm.$props,\n parentName: parentName,\n file: file\n }\n}\n\nexport default HoneybadgerVue\n"],"names":["const","let","Honeybadger"],"mappings":";;;;;;;;;;EAAA;EACA;EACA;EACA;AACA;EACAA,IAAM,UAAU,GAAG,kBAAiB;EACpCA,IAAM,QAAQ,aAAG,cAAO,GAAG;EAC3B,GAAG,OAAO,CAAC,UAAU,YAAE,YAAK,CAAC,CAAC,WAAW,KAAE,CAAC;EAC5C,GAAG,OAAO,CAAC,OAAO,E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AAI,EAAE,IAAI;EACd,GAAG;EACH;;;;;;;;;;"}
@@ -1,17 +1,17 @@
1
1
  // Type definitions for honeybadger.js vue integration
2
2
  // Project: https://github.com/honeybadger-io/honeybadger-vue
3
3
 
4
- import Vue from 'vue'
4
+ import { App } from 'vue';
5
5
  import * as Honeybadger from '@honeybadger-io/js'
6
6
 
7
- declare module 'vue/types/vue' {
8
- interface Vue {
7
+ declare module '@vue/runtime-core' {
8
+ interface App {
9
9
  $honeybadger: typeof Honeybadger
10
10
  }
11
11
  }
12
12
 
13
- declare const HoneybadgerVue: {
14
- install(app: typeof Vue, options?: any): void
13
+ declare var HoneybadgerVue: {
14
+ install(app: App, options?: any): void
15
15
  }
16
16
 
17
- export default HoneybadgerVue
17
+ export default HoneybadgerVue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honeybadger-io/vue",
3
- "version": "1.0.3",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "description": "Honeybadger Vue.js client",
6
6
  "author": "Jason Truesdell <jason@yuzuten.com> (https://github.com/JasonTrue)",
@@ -26,9 +26,9 @@
26
26
  ],
27
27
  "homepage": "https://github.com/honeybadger-io/honeybadger-vue#readme",
28
28
  "scripts": {
29
- "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
29
+ "dev": "webpack serve --progress --config build/webpack.dev.conf.js",
30
30
  "start": "npm run dev",
31
- "unit": "jest --config test/unit/jest.conf.js --coverage --forceExit",
31
+ "unit": "jest --config test/unit/jest.conf.js --coverage",
32
32
  "e2e": "node test/e2e/runner.js",
33
33
  "tsd": "npx tsd",
34
34
  "test": "npm run unit",
@@ -45,82 +45,83 @@
45
45
  "prepublishOnly": "npm run build && npm test"
46
46
  },
47
47
  "dependencies": {
48
- "@honeybadger-io/js": "^3.0.3"
48
+ "@honeybadger-io/js": "^3.2.3"
49
49
  },
50
50
  "devDependencies": {
51
- "@babel/core": "^7.12.16",
52
- "@babel/helper-module-imports": "^7.12.13",
53
- "@babel/plugin-syntax-jsx": "^7.12.13",
54
- "@babel/plugin-transform-modules-commonjs": "^7.12.13",
55
- "@babel/plugin-transform-runtime": "^7.12.15",
56
- "@babel/preset-env": "^7.12.16",
57
- "@babel/register": "^7.12.13",
58
- "@babel/runtime": "^7.12.13",
59
- "@vue/runtime-core": "^3.0.5",
60
- "ajv": "^7.1.0",
61
- "autoprefixer": "^10.2.4",
51
+ "@babel/core": "^7.15.0",
52
+ "@babel/helper-module-imports": "^7.14.5",
53
+ "@babel/plugin-syntax-jsx": "^7.14.5",
54
+ "@babel/plugin-transform-modules-commonjs": "^7.15.0",
55
+ "@babel/plugin-transform-runtime": "^7.15.0",
56
+ "@babel/preset-env": "^7.15.0",
57
+ "@babel/register": "^7.15.3",
58
+ "@babel/runtime": "^7.15.3",
59
+ "@vue/compiler-sfc": "^3.1.0",
60
+ "@vue/runtime-core": "^3.2.6",
61
+ "@vue/test-utils": "^2.0.0-rc.12",
62
+ "ajv": "^8.6.1",
63
+ "autoprefixer": "^10.3.3",
62
64
  "babel-core": "^7.0.0-bridge.0",
63
65
  "babel-eslint": "^10.1.0",
64
66
  "babel-helper-vue-jsx-merge-props": "^2.0.3",
65
- "babel-jest": "^26.0.1",
67
+ "babel-jest": "^26.0.0",
66
68
  "babel-loader": "^8.1.0",
67
69
  "babel-plugin-dynamic-import-node": "^2.3.3",
68
70
  "babel-plugin-transform-vue-jsx": "^4.0.1",
69
- "chalk": "^4.0.0",
70
- "chromedriver": "^88.0.0",
71
- "copy-webpack-plugin": "^7.0.0",
71
+ "browser-resolve": "^2.0.0",
72
+ "chalk": "^4.1.2",
73
+ "chromedriver": "^92.0.0",
74
+ "copy-webpack-plugin": "^9.0.1",
72
75
  "cross-spawn": "^7.0.2",
73
- "css-loader": "^5.0.2",
74
- "dotenv": "^8.2.0",
75
- "eslint": "^7.20.0",
76
- "eslint-config-standard": "^16.0.1",
76
+ "css-loader": "^5.2.7",
77
+ "css-minimizer-webpack-plugin": "^3.0.2",
78
+ "dotenv": "^10.0.0",
79
+ "eslint": "^7.32.0",
80
+ "eslint-config-standard": "^16.0.3",
77
81
  "eslint-friendly-formatter": "^4.0.1",
78
82
  "eslint-loader": "^4.0.1",
79
- "eslint-plugin-import": "^2.20.2",
83
+ "eslint-plugin-import": "^2.24.2",
80
84
  "eslint-plugin-node": "^11.1.0",
81
- "eslint-plugin-promise": "^4.3.1",
85
+ "eslint-plugin-promise": "^5.1.0",
82
86
  "eslint-plugin-standard": "^5.0.0",
83
- "eslint-plugin-vue": "^7.0.0",
87
+ "eslint-plugin-vue": "^7.16.0",
84
88
  "file-loader": "^6.0.0",
85
- "friendly-errors-webpack-plugin": "^1.7.0",
86
- "html-webpack-plugin": "^5.1.0",
89
+ "html-webpack-plugin": "^5.3.2",
87
90
  "interactive": "^0.1.9",
88
- "jest": "^26.0.1",
91
+ "jest": "^26.0.0",
89
92
  "jest-serializer-vue": "^2.0.2",
90
- "mini-css-extract-plugin": "^1.3.6",
91
- "nightwatch": "^1.3.4",
93
+ "mini-css-extract-plugin": "^2.0.0",
94
+ "nightwatch": "^1.7.8",
92
95
  "nightwatch-xhr": "^0.4.7",
93
- "node-notifier": "^9.0.0",
94
- "optimize-css-assets-webpack-plugin": "^5.0.3",
95
- "ora": "^5.0.0",
96
+ "node-notifier": "^10.0.0",
97
+ "ora": "^5.4.1",
96
98
  "portfinder": "^1.0.13",
97
- "postcss": "^8.2.6",
98
- "postcss-import": "^14.0.0",
99
- "postcss-loader": "^5.0.0",
100
- "postcss-url": "^10.0.0",
99
+ "postcss": "^8.3.6",
100
+ "postcss-import": "^14.0.2",
101
+ "postcss-loader": "^6.1.1",
102
+ "postcss-url": "^10.1.3",
101
103
  "rimraf": "^3.0.2",
102
- "rollup": "^2.39.0",
104
+ "rollup": "^2.56.3",
103
105
  "rollup-plugin-buble": "^0.19.4",
104
106
  "rollup-plugin-conditional": "^3.1.2",
105
107
  "rollup-plugin-terser": "^7.0.0",
106
- "rollup-plugin-vue": "^5.1.6",
108
+ "rollup-plugin-vue": "^6.0.0-beta.10",
107
109
  "selenium-server": "^3.0.1",
108
- "semver": "^7.3.2",
110
+ "semver": "^7.3.5",
109
111
  "shelljs": "^0.8.3",
110
- "sinon": "^9.2.4",
111
- "terser-webpack-plugin": "^5.1.1",
112
- "tsd": "^0.14.0",
112
+ "sinon": "^11.1.1",
113
+ "terser-webpack-plugin": "^5.1.4",
114
+ "tsd": "^0.17.0",
113
115
  "url-loader": "^4.1.0",
114
- "vue": "^2.5.2",
115
- "vue-jest": "^3.0.5",
116
- "vue-loader": "^15.9.1",
117
- "vue-style-loader": "^4.1.2",
118
- "vue-template-compiler": "^2.5.2",
119
- "webpack": "^5.21.2",
120
- "webpack-bundle-analyzer": "^4.1.0",
121
- "webpack-cli": "^4.5.0",
122
- "webpack-dev-server": "^3.10.3",
123
- "webpack-merge": "^5.0.7",
116
+ "vue": "^3.1.0",
117
+ "vue-jest": "^5.0.0-alpha.10",
118
+ "vue-loader": "^16.3.0",
119
+ "vue-style-loader": "^4.1.3",
120
+ "webpack": "^5.51.1",
121
+ "webpack-bundle-analyzer": "^4.4.2",
122
+ "webpack-cli": "^4.8.0",
123
+ "webpack-dev-server": "^4.0.0",
124
+ "webpack-merge": "^5.8.0",
124
125
  "winston": "^3.1.0"
125
126
  },
126
127
  "engines": {
@@ -0,0 +1,12 @@
1
+ import { generateComponentTrace } from './vue-debug'
2
+
3
+ export function logError (app, error, vm, info) {
4
+ const message = `Error in ${info}: "${error && error.toString()}"`
5
+
6
+ const trace = vm ? generateComponentTrace(vm) : ''
7
+ if (app.config.warnHandler) {
8
+ app.config.warnHandler.call(null, message, vm, trace)
9
+ } else {
10
+ console.error(`[Vue warn]: ${message}${trace}`)
11
+ }
12
+ }
package/src/index.js CHANGED
@@ -1,34 +1,50 @@
1
1
  import Honeybadger from '@honeybadger-io/js'
2
+ import { logError } from './error-logging'
2
3
 
3
4
  const HoneybadgerVue = {
4
- install (Vue, options) {
5
- if (Vue.config.debug) {
5
+ install (app, options) {
6
+ if (app.config.debug) {
6
7
  console.log(`Honeybadger configured with ${options.apiKey}`)
7
8
  }
8
9
  const honeybadger = Honeybadger.configure(options)
9
- Vue.$honeybadger = honeybadger
10
- Vue.prototype.$honeybadger = Vue.$honeybadger
11
- const chainedErrorHandler = Vue.config.errorHandler
12
- const extractContext = function (vm) {
13
- var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||
14
- vm.constructor.options : vm || {}
15
- var name = options.name || options._componentTag
16
- var file = options.__file
17
- return {
18
- isRoot: vm.$root === vm,
19
- name: name,
20
- props: options.propsData,
21
- parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,
22
- file: file
23
- }
24
- }
25
- Vue.config.errorHandler = (error, vm, info) => {
10
+ app.$honeybadger = honeybadger
11
+ app.config.globalProperties.$honeybadger = honeybadger
12
+ const chainedErrorHandler = app.config.errorHandler
13
+ app.config.errorHandler = (error, vm, info) => {
26
14
  honeybadger.notify(error, { context: { vm: extractContext(vm), info: info } })
27
15
  if (typeof chainedErrorHandler === 'function') {
28
- chainedErrorHandler.call(this.Vue, error, vm, info)
16
+ chainedErrorHandler.call(app, error, vm, info)
17
+ }
18
+
19
+ if (shouldLogError(app)) {
20
+ logError(app, error, vm, info)
29
21
  }
30
22
  }
31
23
  }
32
24
  }
33
25
 
26
+ function shouldLogError (app) {
27
+ if (app.config.warnHandler) {
28
+ return true
29
+ }
30
+
31
+ const hasConsole = typeof console !== 'undefined'
32
+ const isDebug = app.config.debug || process.env.NODE_ENV !== 'production'
33
+ return hasConsole && isDebug
34
+ }
35
+
36
+ function extractContext (vm) {
37
+ const options = vm.$options || {}
38
+ const name = options.name || options._componentTag
39
+ const file = options.__file
40
+ const parentName = vm.$parent && vm.$parent.$options ? vm.$parent.$options.name : undefined
41
+ return {
42
+ isRoot: vm.$root === vm,
43
+ name: name,
44
+ props: vm.$props,
45
+ parentName: parentName,
46
+ file: file
47
+ }
48
+ }
49
+
34
50
  export default HoneybadgerVue
@@ -0,0 +1,74 @@
1
+ /**
2
+ * This was taken from https://github.com/vuejs/vue/blob/master/src/core/util/debug.js.
3
+ * The method generateStackTrace is used to log errors the same way as Vue logs them when errorHandler is not set.
4
+ */
5
+
6
+ const classifyRE = /(?:^|[-_])(\w)/g
7
+ const classify = str => str
8
+ .replace(classifyRE, c => c.toUpperCase())
9
+ .replace(/[-_]/g, '')
10
+
11
+ const formatComponentName = (vm, includeFile) => {
12
+ if (vm.$root === vm) {
13
+ return '<Root>'
14
+ }
15
+ const options = typeof vm === 'function' && vm.cid != null
16
+ ? vm.options
17
+ : vm._isVue
18
+ ? vm.$options || vm.constructor.options
19
+ : vm || {}
20
+ let name = options.name || options._componentTag
21
+ const file = options.__file
22
+ if (!name && file) {
23
+ const match = file.match(/([^/\\]+)\.vue$/)
24
+ name = match && match[1]
25
+ }
26
+
27
+ return (
28
+ (name ? `<${classify(name)}>` : '<Anonymous>') +
29
+ (file && includeFile !== false ? ` at ${file}` : '')
30
+ )
31
+ }
32
+
33
+ const repeat = (str, n) => {
34
+ let res = ''
35
+ while (n) {
36
+ if (n % 2 === 1) res += str
37
+ if (n > 1) str += str
38
+ n >>= 1
39
+ }
40
+ return res
41
+ }
42
+
43
+ export const generateComponentTrace = vm => {
44
+ if (vm._isVue && vm.$parent) {
45
+ const tree = []
46
+ let currentRecursiveSequence = 0
47
+ while (vm) {
48
+ if (tree.length > 0) {
49
+ const last = tree[tree.length - 1]
50
+ if (last.constructor === vm.constructor) {
51
+ currentRecursiveSequence++
52
+ vm = vm.$parent
53
+ continue
54
+ } else if (currentRecursiveSequence > 0) {
55
+ tree[tree.length - 1] = [last, currentRecursiveSequence]
56
+ currentRecursiveSequence = 0
57
+ }
58
+ }
59
+ tree.push(vm)
60
+ vm = vm.$parent
61
+ }
62
+ return '\n\nfound in\n\n' + tree
63
+ .map((vm, i) => `${
64
+ i === 0 ? '---> ' : repeat(' ', 5 + i * 2)
65
+ }${
66
+ Array.isArray(vm)
67
+ ? `${formatComponentName(vm[0])}... (${vm[1]} recursive calls)`
68
+ : formatComponentName(vm)
69
+ }`)
70
+ .join('\n')
71
+ } else {
72
+ return `\n\n(found in ${formatComponentName(vm)})`
73
+ }
74
+ }
package/CHANGELOG.md DELETED
@@ -1,82 +0,0 @@
1
- # Changelog
2
- All notable changes to this project will be documented in this file.
3
-
4
- The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
- and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
-
7
- ## [Unreleased]
8
-
9
- ## [1.0.3] - 2021-02-18
10
- ### Fixed
11
- - Another attempt at making TypeScript definitions work. We're now [testing
12
- our type definitions](./honeybadger-vue.test-d.ts) with [tsd](https://github.com/SamVerschueren/tsd#usage).
13
-
14
- ## [1.0.2] - 2021-02-17
15
- ### Fixed
16
- - Fix TypeScript errors in Vue 2
17
-
18
-
19
- ## [1.0.1] - 2021-02-17
20
- ### Fixed
21
- - Add a module export with an `install` function. This fixes builds in newer Vue apps written in TypeScript
22
-
23
- ## [1.0.0] - 2021-01-19
24
- ### Changed
25
- - Migrate honeybadger-js dependency to @honeybadger-io/js 3.0.0
26
- See https://docs.honeybadger.io/lib/javascript/support/upgrading-to-v3.html
27
-
28
- ## [0.0.12] - 2020-09-24
29
- ### Fixed
30
- - Bump honeybadger-js version
31
- - Import `Honeybadger` in TypeScript definitions file (fixes potential missing
32
- name error).
33
-
34
- ## [0.0.11] - 2020-04-24
35
- ### Fixed
36
- - Update honeybadger-js to 2.2.1 (security release, see
37
- [here](https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md#220---2020-03-16))
38
-
39
- ## [0.0.10] - 2020-01-08
40
- ### Fixed
41
- - Fix TypeScript type definitions
42
-
43
- ## [0.0.9] - 2019-12-18
44
- ### Fixed
45
- - Deps & security updates
46
- - TypeScript definitions
47
-
48
- ## [0.0.8] - 2019-05-28
49
- ### Fixed
50
- - Added missing dist/ directory to release
51
-
52
- ## [0.0.7] - 2019-04-16
53
- ### Changed
54
- - Refactored tests to include debug mode output
55
- - Changed the debug output based on Vue debug mode
56
- - Update honeybadger-js to v1.0. See
57
- https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md
58
-
59
- ## [0.0.6] - 2018-12-08
60
- ### Added
61
- - Reduced size of context information sent to Notify
62
- - We now send the props value to honeybadger
63
-
64
- ## [0.0.5] - 2018-12-07
65
- ### Added
66
- - Dependency updates, additional documentation changes
67
-
68
- ## [0.0.4] - 2018-11-07
69
- ### Added
70
- - Minor changes in Readme and travis configuration (no code changes)
71
-
72
- ## [0.0.3] - 2018-11-06
73
- ### Added
74
- - Switch to yarn-based package lock
75
-
76
- ## [0.0.2] - 2018-11-06
77
- ### Added
78
- - Added src folder to published artifact
79
-
80
- ## [0.0.1] - 2018-11-06
81
- ### Added
82
- - Initial release (unpublished due to missing artifacts)