@ohbug/vue 1.0.12 → 2.0.0

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
@@ -2,14 +2,13 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@ohbug/vue.svg?style=flat-square)](https://www.npmjs.com/package/@ohbug/vue)
4
4
  [![npm bundle size](https://img.shields.io/bundlephobia/min/@ohbug/vue?style=flat-square)](https://bundlephobia.com/result?p=@ohbug/vue)
5
- [![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
5
 
7
6
  English | [简体中文](./README-zh_CN.md)
8
7
 
9
8
  ## Installation
10
9
 
11
10
  ```
12
- yarn add @ohbug/browser @ohbug/vue
11
+ pnpm instal @ohbug/browser @ohbug/vue
13
12
  ```
14
13
 
15
14
  ## Usage
@@ -19,6 +18,9 @@ import Vue from 'vue'
19
18
  import Ohbug from '@ohbug/browser'
20
19
  import OhbugVue from '@ohbug/vue'
21
20
 
22
- const client = Ohbug.init({ apiKey: 'YOUR_API_KEY' })
23
- client.use(OhbugVue, Vue)
21
+ const client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })
22
+
23
+ Vue.createApp(App)
24
+ .use(OhbugVue(client))
25
+ .mount('#app')
24
26
  ```
package/dist/index.js ADDED
@@ -0,0 +1,75 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ default: () => createVueClient
23
+ });
24
+ module.exports = __toCommonJS(src_exports);
25
+
26
+ // src/install.ts
27
+ var import_core = require("@ohbug/core");
28
+ var getComponent = (instance) => {
29
+ if ((instance == null ? void 0 : instance.$root) === instance)
30
+ return { component: "Root" };
31
+ const options = instance == null ? void 0 : instance.$options;
32
+ const component = options == null ? void 0 : options.name;
33
+ const file = options == null ? void 0 : options.__file;
34
+ return {
35
+ component,
36
+ file
37
+ };
38
+ };
39
+ function install(client, Vue) {
40
+ const prev = Vue.config.errorHandler;
41
+ const handler = (error, instance, info) => {
42
+ const { component, file } = getComponent(instance);
43
+ const detail = {
44
+ name: error.name,
45
+ message: error.message,
46
+ stack: error.stack,
47
+ errorInfo: info,
48
+ component,
49
+ file,
50
+ props: instance ? instance.$options.propsData : void 0
51
+ };
52
+ const event = client.createEvent({
53
+ category: "error",
54
+ type: import_core.EventTypes.VUE,
55
+ detail
56
+ });
57
+ client.notify(event);
58
+ if (typeof console !== "undefined" && typeof console.error === "function")
59
+ console.error(error);
60
+ if (typeof prev === "function")
61
+ prev(error, instance, info);
62
+ };
63
+ Vue.config.errorHandler = handler;
64
+ }
65
+
66
+ // src/index.ts
67
+ function createVueClient(client) {
68
+ return {
69
+ install: (app) => {
70
+ install(client, app);
71
+ }
72
+ };
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {});
package/dist/index.mjs ADDED
@@ -0,0 +1,51 @@
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
+ const options = instance == null ? void 0 : instance.$options;
7
+ const component = options == null ? void 0 : options.name;
8
+ const file = options == null ? void 0 : options.__file;
9
+ return {
10
+ component,
11
+ file
12
+ };
13
+ };
14
+ function install(client, Vue) {
15
+ const prev = Vue.config.errorHandler;
16
+ const handler = (error, instance, info) => {
17
+ const { component, file } = getComponent(instance);
18
+ const detail = {
19
+ name: error.name,
20
+ message: error.message,
21
+ stack: error.stack,
22
+ errorInfo: info,
23
+ component,
24
+ file,
25
+ props: instance ? instance.$options.propsData : void 0
26
+ };
27
+ const event = client.createEvent({
28
+ category: "error",
29
+ type: EventTypes.VUE,
30
+ detail
31
+ });
32
+ client.notify(event);
33
+ if (typeof console !== "undefined" && typeof console.error === "function")
34
+ console.error(error);
35
+ if (typeof prev === "function")
36
+ prev(error, instance, info);
37
+ };
38
+ Vue.config.errorHandler = handler;
39
+ }
40
+
41
+ // src/index.ts
42
+ function createVueClient(client) {
43
+ return {
44
+ install: (app) => {
45
+ install(client, app);
46
+ }
47
+ };
48
+ }
49
+ export {
50
+ createVueClient as default
51
+ };
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@ohbug/vue",
3
- "version": "1.0.12",
3
+ "version": "2.0.0",
4
4
  "description": "Ohbug SDK for Vue",
5
+ "license": "Apache-2.0",
5
6
  "author": "chenyueban <jasonchan0527@gmail.com>",
6
7
  "homepage": "https://github.com/ohbug-org/ohbug",
7
8
  "bugs": {
@@ -11,34 +12,37 @@
11
12
  "type": "git",
12
13
  "url": "https://github.com/ohbug-org/ohbug"
13
14
  },
14
- "license": "Apache-2.0",
15
- "main": "dist/ohbug-vue.cjs.js",
16
- "module": "dist/ohbug-vue.esm.js",
17
- "unpkg": "dist/ohbug-vue.umd.js",
18
- "jsdelivr": "dist/ohbug-vue.umd.js",
15
+ "main": "dist/index.js",
16
+ "module": "dist/index.mjs",
19
17
  "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "require": "./dist/index.js",
21
+ "import": "./dist/index.mjs",
22
+ "types": "./dist/index.d.ts"
23
+ }
24
+ },
20
25
  "files": [
21
- "dist"
26
+ "dist",
27
+ "src"
22
28
  ],
29
+ "sideEffects": false,
30
+ "peerDependencies": {
31
+ "vue": "^3.0.0"
32
+ },
23
33
  "dependencies": {
24
- "@ohbug/core": "^1.1.5"
34
+ "@ohbug/core": "2.0.0",
35
+ "@ohbug/types": "2.0.0"
25
36
  },
26
37
  "devDependencies": {
27
- "vue": "^2.6.11"
28
- },
29
- "peerDependencies": {
30
- "vue": "^2.6.0"
31
- },
32
- "buildOptions": {
33
- "name": "OhbugVue",
34
- "formats": [
35
- "esm",
36
- "umd",
37
- "cjs"
38
- ],
39
- "order": 4
38
+ "vue": "^3.2.33"
40
39
  },
41
40
  "publishConfig": {
42
41
  "access": "public"
43
- }
44
- }
42
+ },
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "dev": "tsup --watch"
46
+ },
47
+ "readme": "# `@ohbug/vue`\n\n[![npm](https://img.shields.io/npm/v/@ohbug/vue.svg?style=flat-square)](https://www.npmjs.com/package/@ohbug/vue)\n[![npm bundle size](https://img.shields.io/bundlephobia/min/@ohbug/vue?style=flat-square)](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"
48
+ }
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ import type { OhbugClient } from '@ohbug/types'
2
+ import type { Plugin } from 'vue'
3
+ import { install } from './install'
4
+
5
+ export type { VueErrorDetail } from './install'
6
+
7
+ export default function createVueClient(client: OhbugClient): Plugin {
8
+ return {
9
+ install: (app) => {
10
+ install(client, app)
11
+ },
12
+ }
13
+ }
package/src/install.ts ADDED
@@ -0,0 +1,58 @@
1
+ import { EventTypes } from '@ohbug/core'
2
+ import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types'
3
+ import type { App, ComponentPublicInstance } from 'vue'
4
+
5
+ export interface VueErrorDetail extends OhbugBaseDetail {
6
+ name: string
7
+ stack?: string
8
+ errorInfo: string
9
+ component?: string
10
+ file?: string
11
+ props?: Record<string, any>
12
+ }
13
+
14
+ const getComponent = (instance: ComponentPublicInstance | null) => {
15
+ if (instance?.$root === instance)
16
+ return { component: 'Root' }
17
+
18
+ const options = instance?.$options
19
+ const component = options?.name
20
+ const file = options?.__file
21
+
22
+ return {
23
+ component,
24
+ file,
25
+ }
26
+ }
27
+
28
+ export function install(client: OhbugClient, Vue: App) {
29
+ const prev = Vue.config.errorHandler
30
+
31
+ const handler = (error: Error, instance: ComponentPublicInstance | null, info: string) => {
32
+ const { component, file } = getComponent(instance)
33
+
34
+ const detail: VueErrorDetail = {
35
+ name: error.name,
36
+ message: error.message,
37
+ stack: error.stack,
38
+ errorInfo: info,
39
+ component,
40
+ file,
41
+ props: instance ? instance.$options.propsData : undefined,
42
+ }
43
+ const event = client.createEvent<VueErrorDetail>({
44
+ category: 'error',
45
+ type: EventTypes.VUE,
46
+ detail,
47
+ })
48
+
49
+ client.notify(event)
50
+
51
+ if (typeof console !== 'undefined' && typeof console.error === 'function')
52
+ console.error(error)
53
+ if (typeof prev === 'function') prev(error, instance, info)
54
+ }
55
+
56
+ // @ts-expect-error type is not assignable
57
+ Vue.config.errorHandler = handler
58
+ }
@@ -1,2 +0,0 @@
1
- export declare const extension: import("@ohbug/types").OhbugExtension<any>;
2
- //# sourceMappingURL=extension.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,4CAQpB,CAAA"}
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export type { VueErrorDetail } from './install';
2
- export { extension as default } from './extension';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA"}
package/dist/install.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
2
- import type { VueConstructor } from 'vue';
3
- export interface VueErrorDetail extends OhbugBaseDetail {
4
- name: string;
5
- stack?: string;
6
- errorInfo: string;
7
- component: string;
8
- file: string;
9
- props?: Record<string, any>;
10
- }
11
- export declare function install(client: OhbugClient, Vue: VueConstructor): void;
12
- //# sourceMappingURL=install.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAEzC,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B;AAkBD,wBAAgB,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,cAAc,QA6B/D"}
@@ -1,239 +0,0 @@
1
- 'use strict';
2
-
3
- /*! *****************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
-
18
- var __assign = function() {
19
- __assign = Object.assign || function __assign(t) {
20
- for (var s, i = 1, n = arguments.length; i < n; i++) {
21
- s = arguments[i];
22
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
-
29
- function isString(value) {
30
- return typeof value === 'string';
31
- }
32
- function isObject(value) {
33
- return Object.prototype.toString.call(value) === '[object Object]';
34
- }
35
-
36
- function createExtension(extension) {
37
- return extension;
38
- }
39
-
40
- var Action = /** @class */ (function () {
41
- function Action(message, data, type, timestamp) {
42
- this.type = type;
43
- this.timestamp = timestamp || new Date().toISOString();
44
- this.message = message;
45
- this.data = data;
46
- }
47
- return Action;
48
- }());
49
- function getErrorMessage(message, data) {
50
- return new Error("Invalid data\n- " + message + ", got " + JSON.stringify(data));
51
- }
52
-
53
- function addMetaData(map, section, data) {
54
- if (!section)
55
- return;
56
- map[section] = data;
57
- }
58
- function getMetaData(map, section) {
59
- if (map[section]) {
60
- return map[section];
61
- }
62
- return undefined;
63
- }
64
- function deleteMetaData(map, section) {
65
- if (map[section]) {
66
- return delete map[section];
67
- }
68
- return undefined;
69
- }
70
-
71
- /** @class */ ((function () {
72
- function Event(values, client) {
73
- var apiKey = values.apiKey, appVersion = values.appVersion, appType = values.appType, releaseStage = values.releaseStage, timestamp = values.timestamp, category = values.category, type = values.type, sdk = values.sdk, detail = values.detail, device = values.device, user = values.user, actions = values.actions, metaData = values.metaData;
74
- this.apiKey = apiKey;
75
- this.appVersion = appVersion;
76
- this.appType = appType;
77
- this.releaseStage = releaseStage;
78
- this.timestamp = timestamp;
79
- this.category = category;
80
- this.type = type;
81
- this.sdk = sdk;
82
- this.detail = detail;
83
- this.device = device;
84
- this.user = user;
85
- this.actions = actions;
86
- this.metaData = metaData;
87
- this._client = client;
88
- }
89
- Object.defineProperty(Event.prototype, "_isOhbugEvent", {
90
- get: function () {
91
- return true;
92
- },
93
- enumerable: false,
94
- configurable: true
95
- });
96
- /**
97
- * Add an action.
98
- * Once the threshold is reached, the oldest breadcrumbs will be deleted.
99
- * 新增一个动作。
100
- * 一旦达到阈值,最老的 Action 将被删除。
101
- *
102
- * @param message
103
- * @param data
104
- * @param type
105
- * @param timestamp
106
- */
107
- Event.prototype.addAction = function (message, data, type, timestamp) {
108
- var _a, _b;
109
- var actions = this.actions;
110
- var targetMessage = isString(message) ? message : '';
111
- var targetData = data || {};
112
- var targetType = isString(type) ? type : '';
113
- var action = new Action(targetMessage, targetData, targetType, timestamp);
114
- if (actions.length >= ((_b = (_a = this._client) === null || _a === void 0 ? void 0 : _a._config.maxActions) !== null && _b !== void 0 ? _b : 30)) {
115
- actions.shift();
116
- }
117
- actions.push(action);
118
- };
119
- /**
120
- * Get current user information
121
- * 获取当前的用户信息
122
- */
123
- Event.prototype.getUser = function () {
124
- return this.user;
125
- };
126
- /**
127
- * Set current user information
128
- * 设置当前的用户信息
129
- */
130
- Event.prototype.setUser = function (user) {
131
- var _a;
132
- if (isObject(user) && Object.keys(user).length <= 6) {
133
- this.user = __assign(__assign({}, this.user), user);
134
- return this.getUser();
135
- }
136
- (_a = this._client) === null || _a === void 0 ? void 0 : _a._logger.warn(getErrorMessage('setUser should be an object and have up to 6 attributes', user));
137
- return undefined;
138
- };
139
- /**
140
- * Add metaData
141
- * 新增 metaData
142
- *
143
- * @param section
144
- * @param data
145
- */
146
- Event.prototype.addMetaData = function (section, data) {
147
- return addMetaData(this.metaData, section, data);
148
- };
149
- /**
150
- * Get metaData
151
- * 获取 metaData
152
- *
153
- * @param section
154
- */
155
- Event.prototype.getMetaData = function (section) {
156
- return getMetaData(this.metaData, section);
157
- };
158
- /**
159
- * Delete metaData
160
- * 删除 metaData
161
- *
162
- * @param section
163
- */
164
- Event.prototype.deleteMetaData = function (section) {
165
- return deleteMetaData(this.metaData, section);
166
- };
167
- Event.prototype.toJSON = function () {
168
- var _a = this, apiKey = _a.apiKey, appVersion = _a.appVersion, appType = _a.appType, timestamp = _a.timestamp, category = _a.category, type = _a.type, sdk = _a.sdk, device = _a.device, detail = _a.detail, user = _a.user, actions = _a.actions, metaData = _a.metaData, releaseStage = _a.releaseStage;
169
- return {
170
- apiKey: apiKey,
171
- appVersion: appVersion,
172
- appType: appType,
173
- timestamp: timestamp,
174
- category: category,
175
- type: type,
176
- sdk: sdk,
177
- device: device,
178
- detail: detail,
179
- user: user,
180
- actions: actions,
181
- metaData: metaData,
182
- releaseStage: releaseStage,
183
- };
184
- };
185
- return Event;
186
- })());
187
-
188
- var getComponent = function (vm) {
189
- if (vm.$root === vm)
190
- return {
191
- component: 'Root',
192
- };
193
- var options = vm.$options;
194
- var component = options.name;
195
- var file = options.__file;
196
- return {
197
- component: component,
198
- file: file,
199
- };
200
- };
201
- function install(client, Vue) {
202
- var prev = Vue.config.errorHandler;
203
- var handler = function (error, vm, info) {
204
- var _a = getComponent(vm), component = _a.component, file = _a.file;
205
- var detail = {
206
- name: error.name,
207
- message: error.message,
208
- stack: error.stack,
209
- errorInfo: info,
210
- component: component,
211
- file: file,
212
- props: vm ? vm.$options.propsData : undefined,
213
- };
214
- var event = client.createEvent({
215
- category: 'error',
216
- type: 'vue',
217
- detail: detail,
218
- });
219
- client.notify(event);
220
- if (typeof console !== 'undefined' && typeof console.error === 'function')
221
- console.error(error);
222
- if (typeof prev === 'function')
223
- prev(error, vm, info);
224
- };
225
- // eslint-disable-next-line no-param-reassign
226
- Vue.config.errorHandler = handler;
227
- }
228
-
229
- var extension = createExtension({
230
- name: 'OhbugVue',
231
- init: function (client, Vue) {
232
- if (!Vue) {
233
- throw new Error('Ohbug @ohbug/vue reference to `Vue` was undefined');
234
- }
235
- return install(client, Vue);
236
- },
237
- });
238
-
239
- module.exports = extension;
@@ -1,237 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- var __assign = function() {
17
- __assign = Object.assign || function __assign(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
-
27
- function isString(value) {
28
- return typeof value === 'string';
29
- }
30
- function isObject(value) {
31
- return Object.prototype.toString.call(value) === '[object Object]';
32
- }
33
-
34
- function createExtension(extension) {
35
- return extension;
36
- }
37
-
38
- var Action = /** @class */ (function () {
39
- function Action(message, data, type, timestamp) {
40
- this.type = type;
41
- this.timestamp = timestamp || new Date().toISOString();
42
- this.message = message;
43
- this.data = data;
44
- }
45
- return Action;
46
- }());
47
- function getErrorMessage(message, data) {
48
- return new Error("Invalid data\n- " + message + ", got " + JSON.stringify(data));
49
- }
50
-
51
- function addMetaData(map, section, data) {
52
- if (!section)
53
- return;
54
- map[section] = data;
55
- }
56
- function getMetaData(map, section) {
57
- if (map[section]) {
58
- return map[section];
59
- }
60
- return undefined;
61
- }
62
- function deleteMetaData(map, section) {
63
- if (map[section]) {
64
- return delete map[section];
65
- }
66
- return undefined;
67
- }
68
-
69
- /** @class */ ((function () {
70
- function Event(values, client) {
71
- var apiKey = values.apiKey, appVersion = values.appVersion, appType = values.appType, releaseStage = values.releaseStage, timestamp = values.timestamp, category = values.category, type = values.type, sdk = values.sdk, detail = values.detail, device = values.device, user = values.user, actions = values.actions, metaData = values.metaData;
72
- this.apiKey = apiKey;
73
- this.appVersion = appVersion;
74
- this.appType = appType;
75
- this.releaseStage = releaseStage;
76
- this.timestamp = timestamp;
77
- this.category = category;
78
- this.type = type;
79
- this.sdk = sdk;
80
- this.detail = detail;
81
- this.device = device;
82
- this.user = user;
83
- this.actions = actions;
84
- this.metaData = metaData;
85
- this._client = client;
86
- }
87
- Object.defineProperty(Event.prototype, "_isOhbugEvent", {
88
- get: function () {
89
- return true;
90
- },
91
- enumerable: false,
92
- configurable: true
93
- });
94
- /**
95
- * Add an action.
96
- * Once the threshold is reached, the oldest breadcrumbs will be deleted.
97
- * 新增一个动作。
98
- * 一旦达到阈值,最老的 Action 将被删除。
99
- *
100
- * @param message
101
- * @param data
102
- * @param type
103
- * @param timestamp
104
- */
105
- Event.prototype.addAction = function (message, data, type, timestamp) {
106
- var _a, _b;
107
- var actions = this.actions;
108
- var targetMessage = isString(message) ? message : '';
109
- var targetData = data || {};
110
- var targetType = isString(type) ? type : '';
111
- var action = new Action(targetMessage, targetData, targetType, timestamp);
112
- if (actions.length >= ((_b = (_a = this._client) === null || _a === void 0 ? void 0 : _a._config.maxActions) !== null && _b !== void 0 ? _b : 30)) {
113
- actions.shift();
114
- }
115
- actions.push(action);
116
- };
117
- /**
118
- * Get current user information
119
- * 获取当前的用户信息
120
- */
121
- Event.prototype.getUser = function () {
122
- return this.user;
123
- };
124
- /**
125
- * Set current user information
126
- * 设置当前的用户信息
127
- */
128
- Event.prototype.setUser = function (user) {
129
- var _a;
130
- if (isObject(user) && Object.keys(user).length <= 6) {
131
- this.user = __assign(__assign({}, this.user), user);
132
- return this.getUser();
133
- }
134
- (_a = this._client) === null || _a === void 0 ? void 0 : _a._logger.warn(getErrorMessage('setUser should be an object and have up to 6 attributes', user));
135
- return undefined;
136
- };
137
- /**
138
- * Add metaData
139
- * 新增 metaData
140
- *
141
- * @param section
142
- * @param data
143
- */
144
- Event.prototype.addMetaData = function (section, data) {
145
- return addMetaData(this.metaData, section, data);
146
- };
147
- /**
148
- * Get metaData
149
- * 获取 metaData
150
- *
151
- * @param section
152
- */
153
- Event.prototype.getMetaData = function (section) {
154
- return getMetaData(this.metaData, section);
155
- };
156
- /**
157
- * Delete metaData
158
- * 删除 metaData
159
- *
160
- * @param section
161
- */
162
- Event.prototype.deleteMetaData = function (section) {
163
- return deleteMetaData(this.metaData, section);
164
- };
165
- Event.prototype.toJSON = function () {
166
- var _a = this, apiKey = _a.apiKey, appVersion = _a.appVersion, appType = _a.appType, timestamp = _a.timestamp, category = _a.category, type = _a.type, sdk = _a.sdk, device = _a.device, detail = _a.detail, user = _a.user, actions = _a.actions, metaData = _a.metaData, releaseStage = _a.releaseStage;
167
- return {
168
- apiKey: apiKey,
169
- appVersion: appVersion,
170
- appType: appType,
171
- timestamp: timestamp,
172
- category: category,
173
- type: type,
174
- sdk: sdk,
175
- device: device,
176
- detail: detail,
177
- user: user,
178
- actions: actions,
179
- metaData: metaData,
180
- releaseStage: releaseStage,
181
- };
182
- };
183
- return Event;
184
- })());
185
-
186
- var getComponent = function (vm) {
187
- if (vm.$root === vm)
188
- return {
189
- component: 'Root',
190
- };
191
- var options = vm.$options;
192
- var component = options.name;
193
- var file = options.__file;
194
- return {
195
- component: component,
196
- file: file,
197
- };
198
- };
199
- function install(client, Vue) {
200
- var prev = Vue.config.errorHandler;
201
- var handler = function (error, vm, info) {
202
- var _a = getComponent(vm), component = _a.component, file = _a.file;
203
- var detail = {
204
- name: error.name,
205
- message: error.message,
206
- stack: error.stack,
207
- errorInfo: info,
208
- component: component,
209
- file: file,
210
- props: vm ? vm.$options.propsData : undefined,
211
- };
212
- var event = client.createEvent({
213
- category: 'error',
214
- type: 'vue',
215
- detail: detail,
216
- });
217
- client.notify(event);
218
- if (typeof console !== 'undefined' && typeof console.error === 'function')
219
- console.error(error);
220
- if (typeof prev === 'function')
221
- prev(error, vm, info);
222
- };
223
- // eslint-disable-next-line no-param-reassign
224
- Vue.config.errorHandler = handler;
225
- }
226
-
227
- var extension = createExtension({
228
- name: 'OhbugVue',
229
- init: function (client, Vue) {
230
- if (!Vue) {
231
- throw new Error('Ohbug @ohbug/vue reference to `Vue` was undefined');
232
- }
233
- return install(client, Vue);
234
- },
235
- });
236
-
237
- export default extension;
@@ -1,15 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- var t=function(){return(t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function e(t){return"string"==typeof t}var n=function(t,e,n,r){this.type=n,this.timestamp=r||(new Date).toISOString(),this.message=t,this.data=e};!function(){function r(t,e){var n=t.apiKey,r=t.appVersion,o=t.appType,i=t.releaseStage,a=t.timestamp,s=t.category,p=t.type,c=t.sdk,u=t.detail,f=t.device,h=t.user,l=t.actions,y=t.metaData;this.apiKey=n,this.appVersion=r,this.appType=o,this.releaseStage=i,this.timestamp=a,this.category=s,this.type=p,this.sdk=c,this.detail=u,this.device=f,this.user=h,this.actions=l,this.metaData=y,this._client=e}Object.defineProperty(r.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),r.prototype.addAction=function(t,r,o,i){var a,s,p=this.actions,c=e(t)?t:"",u=r||{},f=e(o)?o:"",h=new n(c,u,f,i);p.length>=(null!==(s=null===(a=this._client)||void 0===a?void 0:a._config.maxActions)&&void 0!==s?s:30)&&p.shift(),p.push(h)},r.prototype.getUser=function(){return this.user},r.prototype.setUser=function(e){var n,r,o;if(r=e,"[object Object]"===Object.prototype.toString.call(r)&&Object.keys(e).length<=6)return this.user=t(t({},this.user),e),this.getUser();null===(n=this._client)||void 0===n||n._logger.warn((o=e,new Error("Invalid data\n- "+"setUser should be an object and have up to 6 attributes"+", got "+JSON.stringify(o))))},r.prototype.addMetaData=function(t,e){return function(t,e,n){e&&(t[e]=n)}(this.metaData,t,e)},r.prototype.getMetaData=function(t){return function(t,e){if(t[e])return t[e]}(this.metaData,t)},r.prototype.deleteMetaData=function(t){return function(t,e){if(t[e])return delete t[e]}(this.metaData,t)},r.prototype.toJSON=function(){var t=this;return{apiKey:t.apiKey,appVersion:t.appVersion,appType:t.appType,timestamp:t.timestamp,category:t.category,type:t.type,sdk:t.sdk,device:t.device,detail:t.detail,user:t.user,actions:t.actions,metaData:t.metaData,releaseStage:t.releaseStage}}}();var r={name:"OhbugVue",init:function(t,e){if(!e)throw new Error("Ohbug @ohbug/vue reference to `Vue` was undefined");return function(t,e){var n=e.config.errorHandler;e.config.errorHandler=function(e,r,o){var i=function(t){if(t.$root===t)return{component:"Root"};var e=t.$options;return{component:e.name,file:e.__file}}(r),a=i.component,s=i.file,p={name:e.name,message:e.message,stack:e.stack,errorInfo:o,component:a,file:s,props:r?r.$options.propsData:void 0},c=t.createEvent({category:"error",type:"vue",detail:p});t.notify(c),"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e),"function"==typeof n&&n(e,r,o)}}(t,e)}};export default r;
@@ -1,245 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
- typeof define === 'function' && define.amd ? define(factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.OhbugVue = factory());
5
- }(this, (function () { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
-
22
- var __assign = function() {
23
- __assign = Object.assign || function __assign(t) {
24
- for (var s, i = 1, n = arguments.length; i < n; i++) {
25
- s = arguments[i];
26
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
27
- }
28
- return t;
29
- };
30
- return __assign.apply(this, arguments);
31
- };
32
-
33
- function isString(value) {
34
- return typeof value === 'string';
35
- }
36
- function isObject(value) {
37
- return Object.prototype.toString.call(value) === '[object Object]';
38
- }
39
-
40
- function createExtension(extension) {
41
- return extension;
42
- }
43
-
44
- var Action = /** @class */ (function () {
45
- function Action(message, data, type, timestamp) {
46
- this.type = type;
47
- this.timestamp = timestamp || new Date().toISOString();
48
- this.message = message;
49
- this.data = data;
50
- }
51
- return Action;
52
- }());
53
- function getErrorMessage(message, data) {
54
- return new Error("Invalid data\n- " + message + ", got " + JSON.stringify(data));
55
- }
56
-
57
- function addMetaData(map, section, data) {
58
- if (!section)
59
- return;
60
- map[section] = data;
61
- }
62
- function getMetaData(map, section) {
63
- if (map[section]) {
64
- return map[section];
65
- }
66
- return undefined;
67
- }
68
- function deleteMetaData(map, section) {
69
- if (map[section]) {
70
- return delete map[section];
71
- }
72
- return undefined;
73
- }
74
-
75
- /** @class */ ((function () {
76
- function Event(values, client) {
77
- var apiKey = values.apiKey, appVersion = values.appVersion, appType = values.appType, releaseStage = values.releaseStage, timestamp = values.timestamp, category = values.category, type = values.type, sdk = values.sdk, detail = values.detail, device = values.device, user = values.user, actions = values.actions, metaData = values.metaData;
78
- this.apiKey = apiKey;
79
- this.appVersion = appVersion;
80
- this.appType = appType;
81
- this.releaseStage = releaseStage;
82
- this.timestamp = timestamp;
83
- this.category = category;
84
- this.type = type;
85
- this.sdk = sdk;
86
- this.detail = detail;
87
- this.device = device;
88
- this.user = user;
89
- this.actions = actions;
90
- this.metaData = metaData;
91
- this._client = client;
92
- }
93
- Object.defineProperty(Event.prototype, "_isOhbugEvent", {
94
- get: function () {
95
- return true;
96
- },
97
- enumerable: false,
98
- configurable: true
99
- });
100
- /**
101
- * Add an action.
102
- * Once the threshold is reached, the oldest breadcrumbs will be deleted.
103
- * 新增一个动作。
104
- * 一旦达到阈值,最老的 Action 将被删除。
105
- *
106
- * @param message
107
- * @param data
108
- * @param type
109
- * @param timestamp
110
- */
111
- Event.prototype.addAction = function (message, data, type, timestamp) {
112
- var _a, _b;
113
- var actions = this.actions;
114
- var targetMessage = isString(message) ? message : '';
115
- var targetData = data || {};
116
- var targetType = isString(type) ? type : '';
117
- var action = new Action(targetMessage, targetData, targetType, timestamp);
118
- if (actions.length >= ((_b = (_a = this._client) === null || _a === void 0 ? void 0 : _a._config.maxActions) !== null && _b !== void 0 ? _b : 30)) {
119
- actions.shift();
120
- }
121
- actions.push(action);
122
- };
123
- /**
124
- * Get current user information
125
- * 获取当前的用户信息
126
- */
127
- Event.prototype.getUser = function () {
128
- return this.user;
129
- };
130
- /**
131
- * Set current user information
132
- * 设置当前的用户信息
133
- */
134
- Event.prototype.setUser = function (user) {
135
- var _a;
136
- if (isObject(user) && Object.keys(user).length <= 6) {
137
- this.user = __assign(__assign({}, this.user), user);
138
- return this.getUser();
139
- }
140
- (_a = this._client) === null || _a === void 0 ? void 0 : _a._logger.warn(getErrorMessage('setUser should be an object and have up to 6 attributes', user));
141
- return undefined;
142
- };
143
- /**
144
- * Add metaData
145
- * 新增 metaData
146
- *
147
- * @param section
148
- * @param data
149
- */
150
- Event.prototype.addMetaData = function (section, data) {
151
- return addMetaData(this.metaData, section, data);
152
- };
153
- /**
154
- * Get metaData
155
- * 获取 metaData
156
- *
157
- * @param section
158
- */
159
- Event.prototype.getMetaData = function (section) {
160
- return getMetaData(this.metaData, section);
161
- };
162
- /**
163
- * Delete metaData
164
- * 删除 metaData
165
- *
166
- * @param section
167
- */
168
- Event.prototype.deleteMetaData = function (section) {
169
- return deleteMetaData(this.metaData, section);
170
- };
171
- Event.prototype.toJSON = function () {
172
- var _a = this, apiKey = _a.apiKey, appVersion = _a.appVersion, appType = _a.appType, timestamp = _a.timestamp, category = _a.category, type = _a.type, sdk = _a.sdk, device = _a.device, detail = _a.detail, user = _a.user, actions = _a.actions, metaData = _a.metaData, releaseStage = _a.releaseStage;
173
- return {
174
- apiKey: apiKey,
175
- appVersion: appVersion,
176
- appType: appType,
177
- timestamp: timestamp,
178
- category: category,
179
- type: type,
180
- sdk: sdk,
181
- device: device,
182
- detail: detail,
183
- user: user,
184
- actions: actions,
185
- metaData: metaData,
186
- releaseStage: releaseStage,
187
- };
188
- };
189
- return Event;
190
- })());
191
-
192
- var getComponent = function (vm) {
193
- if (vm.$root === vm)
194
- return {
195
- component: 'Root',
196
- };
197
- var options = vm.$options;
198
- var component = options.name;
199
- var file = options.__file;
200
- return {
201
- component: component,
202
- file: file,
203
- };
204
- };
205
- function install(client, Vue) {
206
- var prev = Vue.config.errorHandler;
207
- var handler = function (error, vm, info) {
208
- var _a = getComponent(vm), component = _a.component, file = _a.file;
209
- var detail = {
210
- name: error.name,
211
- message: error.message,
212
- stack: error.stack,
213
- errorInfo: info,
214
- component: component,
215
- file: file,
216
- props: vm ? vm.$options.propsData : undefined,
217
- };
218
- var event = client.createEvent({
219
- category: 'error',
220
- type: 'vue',
221
- detail: detail,
222
- });
223
- client.notify(event);
224
- if (typeof console !== 'undefined' && typeof console.error === 'function')
225
- console.error(error);
226
- if (typeof prev === 'function')
227
- prev(error, vm, info);
228
- };
229
- // eslint-disable-next-line no-param-reassign
230
- Vue.config.errorHandler = handler;
231
- }
232
-
233
- var extension = createExtension({
234
- name: 'OhbugVue',
235
- init: function (client, Vue) {
236
- if (!Vue) {
237
- throw new Error('Ohbug @ohbug/vue reference to `Vue` was undefined');
238
- }
239
- return install(client, Vue);
240
- },
241
- });
242
-
243
- return extension;
244
-
245
- })));
@@ -1,15 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).OhbugVue=e()}(this,(function(){"use strict";
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var t=function(){return(t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function e(t){return"string"==typeof t}var n=function(t,e,n,o){this.type=n,this.timestamp=o||(new Date).toISOString(),this.message=t,this.data=e};!function(){function o(t,e){var n=t.apiKey,o=t.appVersion,i=t.appType,r=t.releaseStage,a=t.timestamp,s=t.category,p=t.type,u=t.sdk,c=t.detail,f=t.device,l=t.user,h=t.actions,d=t.metaData;this.apiKey=n,this.appVersion=o,this.appType=i,this.releaseStage=r,this.timestamp=a,this.category=s,this.type=p,this.sdk=u,this.detail=c,this.device=f,this.user=l,this.actions=h,this.metaData=d,this._client=e}Object.defineProperty(o.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),o.prototype.addAction=function(t,o,i,r){var a,s,p=this.actions,u=e(t)?t:"",c=o||{},f=e(i)?i:"",l=new n(u,c,f,r);p.length>=(null!==(s=null===(a=this._client)||void 0===a?void 0:a._config.maxActions)&&void 0!==s?s:30)&&p.shift(),p.push(l)},o.prototype.getUser=function(){return this.user},o.prototype.setUser=function(e){var n,o,i;if(o=e,"[object Object]"===Object.prototype.toString.call(o)&&Object.keys(e).length<=6)return this.user=t(t({},this.user),e),this.getUser();null===(n=this._client)||void 0===n||n._logger.warn((i=e,new Error("Invalid data\n- "+"setUser should be an object and have up to 6 attributes"+", got "+JSON.stringify(i))))},o.prototype.addMetaData=function(t,e){return function(t,e,n){e&&(t[e]=n)}(this.metaData,t,e)},o.prototype.getMetaData=function(t){return function(t,e){if(t[e])return t[e]}(this.metaData,t)},o.prototype.deleteMetaData=function(t){return function(t,e){if(t[e])return delete t[e]}(this.metaData,t)},o.prototype.toJSON=function(){var t=this;return{apiKey:t.apiKey,appVersion:t.appVersion,appType:t.appType,timestamp:t.timestamp,category:t.category,type:t.type,sdk:t.sdk,device:t.device,detail:t.detail,user:t.user,actions:t.actions,metaData:t.metaData,releaseStage:t.releaseStage}}}();return{name:"OhbugVue",init:function(t,e){if(!e)throw new Error("Ohbug @ohbug/vue reference to `Vue` was undefined");return function(t,e){var n=e.config.errorHandler;e.config.errorHandler=function(e,o,i){var r=function(t){if(t.$root===t)return{component:"Root"};var e=t.$options;return{component:e.name,file:e.__file}}(o),a=r.component,s=r.file,p={name:e.name,message:e.message,stack:e.stack,errorInfo:i,component:a,file:s,props:o?o.$options.propsData:void 0},u=t.createEvent({category:"error",type:"vue",detail:p});t.notify(u),"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e),"function"==typeof n&&n(e,o,i)}}(t,e)}}}));