@ohbug/vue 2.0.5 → 2.0.8
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 +18 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +78 -1
- package/dist/index.mjs +53 -1
- package/package.json +5 -9
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ pnpm instal @ohbug/browser @ohbug/vue
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
+
Vue3
|
|
17
|
+
|
|
16
18
|
```javascript
|
|
17
19
|
import Vue from 'vue'
|
|
18
20
|
import Ohbug from '@ohbug/browser'
|
|
@@ -24,3 +26,19 @@ Vue.createApp(App)
|
|
|
24
26
|
.use(OhbugVue(client))
|
|
25
27
|
.mount('#app')
|
|
26
28
|
```
|
|
29
|
+
|
|
30
|
+
Vue2
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import Vue from "vue";
|
|
34
|
+
import App from "./App.vue";
|
|
35
|
+
import Ohbug from "@ohbug/browser";
|
|
36
|
+
import OhbugVue from "@ohbug/vue";
|
|
37
|
+
|
|
38
|
+
const client = Ohbug.setup({ apiKey: "YOUR_API_KEY" });
|
|
39
|
+
OhbugVue(client).install(Vue);
|
|
40
|
+
|
|
41
|
+
new Vue({
|
|
42
|
+
render: (h) => h(App)
|
|
43
|
+
}).$mount("#app");
|
|
44
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
interface Vue {
|
|
4
|
+
config: {
|
|
5
|
+
errorHandler?: any;
|
|
6
|
+
warnHandler?: any;
|
|
7
|
+
silent?: boolean;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
3
10
|
|
|
4
11
|
interface VueErrorDetail extends OhbugBaseDetail {
|
|
5
12
|
name: string;
|
|
@@ -10,6 +17,8 @@ interface VueErrorDetail extends OhbugBaseDetail {
|
|
|
10
17
|
props?: Record<string, any>;
|
|
11
18
|
}
|
|
12
19
|
|
|
13
|
-
declare function createVueClient(client: OhbugClient):
|
|
20
|
+
declare function createVueClient(client: OhbugClient): {
|
|
21
|
+
install: (app: Vue) => void;
|
|
22
|
+
};
|
|
14
23
|
|
|
15
24
|
export { VueErrorDetail, createVueClient as default };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,78 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
default: () => createVueClient
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
|
|
27
|
+
// src/install.ts
|
|
28
|
+
var import_core = require("@ohbug/core");
|
|
29
|
+
var getComponent = (instance) => {
|
|
30
|
+
if ((instance == null ? void 0 : instance.$root) === instance) {
|
|
31
|
+
return { component: "Root" };
|
|
32
|
+
}
|
|
33
|
+
const options = instance == null ? void 0 : instance.$options;
|
|
34
|
+
const component = options == null ? void 0 : options.name;
|
|
35
|
+
const file = options == null ? void 0 : options.__file;
|
|
36
|
+
return {
|
|
37
|
+
component,
|
|
38
|
+
file
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
function install(client, Vue) {
|
|
42
|
+
const prev = Vue.config.errorHandler;
|
|
43
|
+
const handler = (error, instance, info) => {
|
|
44
|
+
const { component, file } = getComponent(instance);
|
|
45
|
+
const detail = {
|
|
46
|
+
name: error.name,
|
|
47
|
+
message: error.message,
|
|
48
|
+
stack: error.stack,
|
|
49
|
+
errorInfo: info,
|
|
50
|
+
component,
|
|
51
|
+
file,
|
|
52
|
+
props: instance ? instance.$options.propsData : void 0
|
|
53
|
+
};
|
|
54
|
+
const event = client.createEvent({
|
|
55
|
+
category: "error",
|
|
56
|
+
type: import_core.EventTypes.VUE,
|
|
57
|
+
detail
|
|
58
|
+
});
|
|
59
|
+
client.notify(event);
|
|
60
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
61
|
+
console.error(error);
|
|
62
|
+
}
|
|
63
|
+
if (typeof prev === "function")
|
|
64
|
+
prev(error, instance, info);
|
|
65
|
+
};
|
|
66
|
+
Vue.config.errorHandler = handler;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/index.ts
|
|
70
|
+
function createVueClient(client) {
|
|
71
|
+
return {
|
|
72
|
+
install: (app) => {
|
|
73
|
+
install(client, app);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
// src/install.ts
|
|
2
|
+
import { EventTypes } from "@ohbug/core";
|
|
3
|
+
var getComponent = (instance) => {
|
|
4
|
+
if ((instance == null ? void 0 : instance.$root) === instance) {
|
|
5
|
+
return { component: "Root" };
|
|
6
|
+
}
|
|
7
|
+
const options = instance == null ? void 0 : instance.$options;
|
|
8
|
+
const component = options == null ? void 0 : options.name;
|
|
9
|
+
const file = options == null ? void 0 : options.__file;
|
|
10
|
+
return {
|
|
11
|
+
component,
|
|
12
|
+
file
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
function install(client, Vue) {
|
|
16
|
+
const prev = Vue.config.errorHandler;
|
|
17
|
+
const handler = (error, instance, info) => {
|
|
18
|
+
const { component, file } = getComponent(instance);
|
|
19
|
+
const detail = {
|
|
20
|
+
name: error.name,
|
|
21
|
+
message: error.message,
|
|
22
|
+
stack: error.stack,
|
|
23
|
+
errorInfo: info,
|
|
24
|
+
component,
|
|
25
|
+
file,
|
|
26
|
+
props: instance ? instance.$options.propsData : void 0
|
|
27
|
+
};
|
|
28
|
+
const event = client.createEvent({
|
|
29
|
+
category: "error",
|
|
30
|
+
type: EventTypes.VUE,
|
|
31
|
+
detail
|
|
32
|
+
});
|
|
33
|
+
client.notify(event);
|
|
34
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
35
|
+
console.error(error);
|
|
36
|
+
}
|
|
37
|
+
if (typeof prev === "function")
|
|
38
|
+
prev(error, instance, info);
|
|
39
|
+
};
|
|
40
|
+
Vue.config.errorHandler = handler;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/index.ts
|
|
44
|
+
function createVueClient(client) {
|
|
45
|
+
return {
|
|
46
|
+
install: (app) => {
|
|
47
|
+
install(client, app);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
createVueClient as default
|
|
53
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohbug/vue",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Ohbug SDK for Vue",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "chenyueban <jasonchan0527@gmail.com>",
|
|
@@ -27,14 +27,11 @@
|
|
|
27
27
|
],
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"vue": "
|
|
30
|
+
"vue": "2.x || 3.x"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ohbug/core": "2.
|
|
34
|
-
"@ohbug/types": "2.
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"vue": "^3.2.37"
|
|
33
|
+
"@ohbug/core": "2.1.1",
|
|
34
|
+
"@ohbug/types": "2.1.1"
|
|
38
35
|
},
|
|
39
36
|
"publishConfig": {
|
|
40
37
|
"access": "public"
|
|
@@ -42,6 +39,5 @@
|
|
|
42
39
|
"scripts": {
|
|
43
40
|
"build": "tsup",
|
|
44
41
|
"dev": "tsup --watch"
|
|
45
|
-
}
|
|
46
|
-
"readme": "# `@ohbug/vue`\n\n[](https://www.npmjs.com/package/@ohbug/vue)\n[](https://bundlephobia.com/result?p=@ohbug/vue)\n\nEnglish | [简体中文](./README-zh_CN.md)\n\n## Installation\n\n```\npnpm instal @ohbug/browser @ohbug/vue\n```\n\n## Usage\n\n```javascript\nimport Vue from 'vue'\nimport Ohbug from '@ohbug/browser'\nimport OhbugVue from '@ohbug/vue'\n\nconst client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })\n\nVue.createApp(App)\n .use(OhbugVue(client))\n .mount('#app')\n```\n"
|
|
42
|
+
}
|
|
47
43
|
}
|