@honeybadger-io/vue 3.0.0 → 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.
@@ -1,5 +1,87 @@
1
1
  import Honeybadger from '@honeybadger-io/js';
2
2
 
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
+ }
84
+
3
85
  var HoneybadgerVue = {
4
86
  install: function install (app, options) {
5
87
  if (app.config.debug) {
@@ -14,10 +96,24 @@ var HoneybadgerVue = {
14
96
  if (typeof chainedErrorHandler === 'function') {
15
97
  chainedErrorHandler.call(app, error, vm, info);
16
98
  }
99
+
100
+ if (shouldLogError(app)) {
101
+ logError(app, error, vm, info);
102
+ }
17
103
  };
18
104
  }
19
105
  };
20
106
 
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
+
21
117
  function extractContext (vm) {
22
118
  var options = vm.$options || {};
23
119
  var name = options.name || options._componentTag;
@@ -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 (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 }\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"],"mappings":";;AAEK,IAAC,cAAc,GAAG;AACvB,EAAE,yBAAO,EAAE,GAAG,EAAE,OAAO,EAAE;AACzB,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE;AAC1B,MAAM,OAAO,CAAC,GAAG,oCAAgC,OAAO,CAAC,UAAS;AAClE,KAAK;AACL,IAAIA,IAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,EAAC;AACtD,IAAI,GAAG,CAAC,YAAY,GAAG,YAAW;AAClC,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,GAAG,YAAW;AAC1D,IAAIA,IAAM,mBAAmB,GAAG,GAAG,CAAC,MAAM,CAAC,aAAY;AACvD,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,aAAI,KAAK,EAAE,EAAE,EAAE,IAAI,EAAK;AACnD,MAAM,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAC;AACpF,MAAM,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;AACrD,QAAQ,mBAAmB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAC;AACtD,OAAO;AACP,MAAK;AACL,GAAG;AACH,EAAC;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;;;;"}
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,IAAI,IAAI,EAAE;AACrB,IAAIA,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAC;AAC/C,IAAI,IAAI,GAAG,KA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c,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,6 +5,88 @@ var HoneybadgerVue = (function (exports, Honeybadger) {
5
5
 
6
6
  var Honeybadger__default = /*#__PURE__*/_interopDefaultLegacy(Honeybadger);
7
7
 
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
+ }
89
+
8
90
  var HoneybadgerVue = {
9
91
  install: function install (app, options) {
10
92
  if (app.config.debug) {
@@ -19,10 +101,24 @@ var HoneybadgerVue = (function (exports, Honeybadger) {
19
101
  if (typeof chainedErrorHandler === 'function') {
20
102
  chainedErrorHandler.call(app, error, vm, info);
21
103
  }
104
+
105
+ if (shouldLogError(app)) {
106
+ logError(app, error, vm, info);
107
+ }
22
108
  };
23
109
  }
24
110
  };
25
111
 
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
+
26
122
  function extractContext (vm) {
27
123
  var options = vm.$options || {};
28
124
  var name = options.name || options._componentTag;
@@ -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 (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 }\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","Honeybadger"],"mappings":";;;;;;;AAEK,MAAC,cAAc,GAAG;EACvB,EAAE,yBAAO,EAAE,GAAG,EAAE,OAAO,EAAE;EACzB,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE;EAC1B,MAAM,OAAO,CAAC,GAAG,oCAAgC,OAAO,CAAC,UAAS;EAClE,KAAK;EACL,IAAIA,IAAM,WAAW,GAAGC,+BAAW,CAAC,SAAS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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,K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/_interopDefaultLegacy(Honeybadger);
10
10
 
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
+ }
92
+
11
93
  var HoneybadgerVue = {
12
94
  install: function install (app, options) {
13
95
  if (app.config.debug) {
@@ -22,10 +104,24 @@
22
104
  if (typeof chainedErrorHandler === 'function') {
23
105
  chainedErrorHandler.call(app, error, vm, info);
24
106
  }
107
+
108
+ if (shouldLogError(app)) {
109
+ logError(app, error, vm, info);
110
+ }
25
111
  };
26
112
  }
27
113
  };
28
114
 
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
+
29
125
  function extractContext (vm) {
30
126
  var options = vm.$options || {};
31
127
  var name = options.name || options._componentTag;
@@ -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 (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 }\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","Honeybadger"],"mappings":";;;;;;;;;;AAEK,MAAC,cAAc,GAAG;EACvB,EAAE,yBAAO,EAAE,GAAG,EAAE,OAAO,EAAE;EACzB,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE;EAC1B,MAAM,OAAO,CAAC,GAAG,oCAAgC,OAAO,CAAC,UAAS;EAClE,KAAK;EACL,IAAIA,IAAM,WAAW,GAAGC,+BAAW,CAAC,SAAS,CAAC,OAAO,EAAC;EACtD,IAAI,GAAG,CAAC,YAAY,GAAG,YAAW;EAClC,IAAI,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,GAAG,YAAW;EAC1D,IAAID,IAAM,mBAAmB,GAAG,GAAG,CAAC,MAAM,CAAC,aAAY;EACvD,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,aAAI,KAAK,EAAE,EAAE,EAAE,IAAI,EAAK;EACnD,MAAM,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAC;EACpF,MAAM,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;EACrD,QAAQ,mBAAmB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAC;EACtD,OAAO;EACP,MAAK;EACL,GAAG;EACH,EAAC;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;;;;;;;;;;"}
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,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,OAAO;EAChB,MAAM,EAAE,CAAC,MAAM;EACf,QAAQ,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO;EAC7C,QAAQ,EAAE,IAAI,GAAE;EAChB,EAAEC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,cAAa;EAClD,EAAED,IAAM,IAAI,GAAG,OAAO,CAAC,OAAM;EAC7B,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;EACrB,IAAIA,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAC;EAC/C,IAAI,IAAI,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,EAAC;EAC5B,GAAG;AACH;EACA,EAAE;EACF,IAAI,CAAC,IAAI,WAAO,QAAQ,CAAC,IAAI,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,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;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honeybadger-io/vue",
3
- "version": "3.0.0",
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)",
@@ -74,6 +74,7 @@
74
74
  "copy-webpack-plugin": "^9.0.1",
75
75
  "cross-spawn": "^7.0.2",
76
76
  "css-loader": "^5.2.7",
77
+ "css-minimizer-webpack-plugin": "^3.0.2",
77
78
  "dotenv": "^10.0.0",
78
79
  "eslint": "^7.32.0",
79
80
  "eslint-config-standard": "^16.0.3",
@@ -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,4 +1,5 @@
1
1
  import Honeybadger from '@honeybadger-io/js'
2
+ import { logError } from './error-logging'
2
3
 
3
4
  const HoneybadgerVue = {
4
5
  install (app, options) {
@@ -14,10 +15,24 @@ const HoneybadgerVue = {
14
15
  if (typeof chainedErrorHandler === 'function') {
15
16
  chainedErrorHandler.call(app, error, vm, info)
16
17
  }
18
+
19
+ if (shouldLogError(app)) {
20
+ logError(app, error, vm, info)
21
+ }
17
22
  }
18
23
  }
19
24
  }
20
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
+
21
36
  function extractContext (vm) {
22
37
  const options = vm.$options || {}
23
38
  const name = options.name || options._componentTag
@@ -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,86 +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
- ## [3.0.0] - 2021-09-13
10
- ### Changed
11
- - Vue 3 Support
12
-
13
- ## [1.0.3] - 2021-02-18
14
- ### Fixed
15
- - Another attempt at making TypeScript definitions work. We're now [testing
16
- our type definitions](./honeybadger-vue.test-d.ts) with [tsd](https://github.com/SamVerschueren/tsd#usage).
17
-
18
- ## [1.0.2] - 2021-02-17
19
- ### Fixed
20
- - Fix TypeScript errors in Vue 2
21
-
22
-
23
- ## [1.0.1] - 2021-02-17
24
- ### Fixed
25
- - Add a module export with an `install` function. This fixes builds in newer Vue apps written in TypeScript
26
-
27
- ## [1.0.0] - 2021-01-19
28
- ### Changed
29
- - Migrate honeybadger-js dependency to @honeybadger-io/js 3.0.0
30
- See https://docs.honeybadger.io/lib/javascript/support/upgrading-to-v3.html
31
-
32
- ## [0.0.12] - 2020-09-24
33
- ### Fixed
34
- - Bump honeybadger-js version
35
- - Import `Honeybadger` in TypeScript definitions file (fixes potential missing
36
- name error).
37
-
38
- ## [0.0.11] - 2020-04-24
39
- ### Fixed
40
- - Update honeybadger-js to 2.2.1 (security release, see
41
- [here](https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md#220---2020-03-16))
42
-
43
- ## [0.0.10] - 2020-01-08
44
- ### Fixed
45
- - Fix TypeScript type definitions
46
-
47
- ## [0.0.9] - 2019-12-18
48
- ### Fixed
49
- - Deps & security updates
50
- - TypeScript definitions
51
-
52
- ## [0.0.8] - 2019-05-28
53
- ### Fixed
54
- - Added missing dist/ directory to release
55
-
56
- ## [0.0.7] - 2019-04-16
57
- ### Changed
58
- - Refactored tests to include debug mode output
59
- - Changed the debug output based on Vue debug mode
60
- - Update honeybadger-js to v1.0. See
61
- https://github.com/honeybadger-io/honeybadger-js/blob/master/CHANGELOG.md
62
-
63
- ## [0.0.6] - 2018-12-08
64
- ### Added
65
- - Reduced size of context information sent to Notify
66
- - We now send the props value to honeybadger
67
-
68
- ## [0.0.5] - 2018-12-07
69
- ### Added
70
- - Dependency updates, additional documentation changes
71
-
72
- ## [0.0.4] - 2018-11-07
73
- ### Added
74
- - Minor changes in Readme and travis configuration (no code changes)
75
-
76
- ## [0.0.3] - 2018-11-06
77
- ### Added
78
- - Switch to yarn-based package lock
79
-
80
- ## [0.0.2] - 2018-11-06
81
- ### Added
82
- - Added src folder to published artifact
83
-
84
- ## [0.0.1] - 2018-11-06
85
- ### Added
86
- - Initial release (unpublished due to missing artifacts)