@ohbug/angular 1.0.4 → 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/angular.svg?style=flat-square)](https://www.npmjs.com/package/@ohbug/angular)
4
4
  [![npm bundle size](https://img.shields.io/bundlephobia/min/@ohbug/angular?style=flat-square)](https://bundlephobia.com/result?p=@ohbug/angular)
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/angular
11
+ pnpm instal @ohbug/browser @ohbug/angular
13
12
  ```
14
13
 
15
14
  ## Usage
@@ -18,13 +17,13 @@ yarn add @ohbug/browser @ohbug/angular
18
17
  // app.module.ts
19
18
  import Ohbug from '@ohbug/browser'
20
19
  import { ErrorHandler } from '@angular/core'
20
+ import OhbugAngular from '@ohbug/angular'
21
21
 
22
- const client = Ohbug.init({ apiKey: 'YOUR_API_KEY' })
23
- const OhbugProvider = client.use(OhbugAngular, ErrorHandler)
22
+ const client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })
24
23
 
25
24
  @NgModule({
26
25
  // others
27
- providers: [OhbugProvider],
26
+ providers: [OhbugAngular(client, ErrorHandler)],
28
27
  })
29
28
  export class AppModule {}
30
29
  ```
package/dist/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
- export type { AngularErrorDetail } from './createProvider';
2
- export { extension as default } from './extension';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { ErrorHandler } from '@angular/core';
2
+ import { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
3
+
4
+ interface AngularErrorDetail extends OhbugBaseDetail {
5
+ stack?: string;
6
+ }
7
+ declare function createProvider(client: OhbugClient, errorHandler: ErrorHandler): {
8
+ provide: ErrorHandler;
9
+ useClass: any;
10
+ };
11
+
12
+ export { AngularErrorDetail, createProvider as default };
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
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: () => createProvider_default
23
+ });
24
+ module.exports = __toCommonJS(src_exports);
25
+
26
+ // src/createProvider.ts
27
+ var import_core = require("@ohbug/core");
28
+ function createProvider(client, errorHandler) {
29
+ class OhbugErrorHandler {
30
+ handleError(err) {
31
+ const detail = {
32
+ message: err.message,
33
+ stack: err.stack
34
+ };
35
+ const event = client.createEvent({
36
+ category: "error",
37
+ type: import_core.EventTypes.ANGULAR,
38
+ detail
39
+ });
40
+ client.notify(event);
41
+ }
42
+ }
43
+ return {
44
+ provide: errorHandler,
45
+ useClass: OhbugErrorHandler
46
+ };
47
+ }
48
+ var createProvider_default = createProvider;
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {});
package/dist/index.mjs ADDED
@@ -0,0 +1,26 @@
1
+ // src/createProvider.ts
2
+ import { EventTypes } from "@ohbug/core";
3
+ function createProvider(client, errorHandler) {
4
+ class OhbugErrorHandler {
5
+ handleError(err) {
6
+ const detail = {
7
+ message: err.message,
8
+ stack: err.stack
9
+ };
10
+ const event = client.createEvent({
11
+ category: "error",
12
+ type: EventTypes.ANGULAR,
13
+ detail
14
+ });
15
+ client.notify(event);
16
+ }
17
+ }
18
+ return {
19
+ provide: errorHandler,
20
+ useClass: OhbugErrorHandler
21
+ };
22
+ }
23
+ var createProvider_default = createProvider;
24
+ export {
25
+ createProvider_default as default
26
+ };
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@ohbug/angular",
3
- "version": "1.0.4",
3
+ "version": "2.0.0",
4
4
  "description": "Ohbug SDK for Angular",
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,35 +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-angular.cjs.js",
16
- "module": "dist/ohbug-angular.esm.js",
17
- "unpkg": "dist/ohbug-angular.umd.js",
18
- "jsdelivr": "dist/ohbug-angular.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
+ "@angular/core": "^13.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
- "@angular/core": "^12.1.3"
28
- },
29
- "peerDependencies": {
30
- "@angular/core": "^10.0.0"
31
- },
32
- "buildOptions": {
33
- "name": "OhbugAngular",
34
- "formats": [
35
- "esm",
36
- "umd",
37
- "cjs"
38
- ],
39
- "order": 4
38
+ "@angular/core": "^13.3.8"
40
39
  },
41
40
  "publishConfig": {
42
41
  "access": "public"
43
42
  },
44
- "gitHead": "e7722dc78a6dbcd98b0fea0a83ebae4629f2b308"
45
- }
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "dev": "tsup --watch"
46
+ },
47
+ "readme": "# `@ohbug/angular`\n\n[![npm](https://img.shields.io/npm/v/@ohbug/angular.svg?style=flat-square)](https://www.npmjs.com/package/@ohbug/angular)\n[![npm bundle size](https://img.shields.io/bundlephobia/min/@ohbug/angular?style=flat-square)](https://bundlephobia.com/result?p=@ohbug/angular)\n\nEnglish | [简体中文](./README-zh_CN.md)\n\n## Installation\n\n```\npnpm instal @ohbug/browser @ohbug/angular\n```\n\n## Usage\n\n```jsx\n// app.module.ts\nimport Ohbug from '@ohbug/browser'\nimport { ErrorHandler } from '@angular/core'\nimport OhbugAngular from '@ohbug/angular'\n\nconst client = Ohbug.setup({ apiKey: 'YOUR_API_KEY' })\n\n@NgModule({\n // others\n providers: [OhbugAngular(client, ErrorHandler)],\n})\nexport class AppModule {}\n```\n"
48
+ }
@@ -0,0 +1,37 @@
1
+ import type { ErrorHandler } from '@angular/core'
2
+ import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types'
3
+ import { EventTypes } from '@ohbug/core'
4
+
5
+ export interface AngularErrorDetail extends OhbugBaseDetail {
6
+ stack?: string
7
+ }
8
+
9
+ function createProvider(
10
+ client: OhbugClient,
11
+ errorHandler: ErrorHandler,
12
+ ): {
13
+ provide: ErrorHandler
14
+ useClass: any
15
+ } {
16
+ class OhbugErrorHandler implements ErrorHandler {
17
+ handleError(err: Error): void {
18
+ const detail: AngularErrorDetail = {
19
+ message: err.message,
20
+ stack: err.stack,
21
+ }
22
+ const event = client.createEvent<AngularErrorDetail>({
23
+ category: 'error',
24
+ type: EventTypes.ANGULAR,
25
+ detail,
26
+ })
27
+ client.notify(event)
28
+ }
29
+ }
30
+
31
+ return {
32
+ provide: errorHandler,
33
+ useClass: OhbugErrorHandler,
34
+ }
35
+ }
36
+
37
+ export default createProvider
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export type { AngularErrorDetail } from './createProvider'
2
+ export { default } from './createProvider'
@@ -1,11 +0,0 @@
1
- import { ErrorHandler } from '@angular/core';
2
- import type { OhbugBaseDetail, OhbugClient } from '@ohbug/types';
3
- export interface AngularErrorDetail extends OhbugBaseDetail {
4
- stack?: string;
5
- }
6
- declare function createProvider(client: OhbugClient, errorHandler: ErrorHandler): {
7
- provide: ErrorHandler;
8
- useClass: any;
9
- };
10
- export default createProvider;
11
- //# sourceMappingURL=createProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createProvider.d.ts","sourceRoot":"","sources":["../src/createProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAEhE,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,iBAAS,cAAc,CACrB,MAAM,EAAE,WAAW,EACnB,YAAY,EAAE,YAAY,GACzB;IACD,OAAO,EAAE,YAAY,CAAA;IACrB,QAAQ,EAAE,GAAG,CAAA;CACd,CAoBA;AAED,eAAe,cAAc,CAAA"}
@@ -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":"AAGA,eAAO,MAAM,SAAS,4CAGpB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA"}
@@ -1,217 +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
- function createProvider(client, errorHandler) {
189
- var OhbugErrorHandler = /** @class */ (function () {
190
- function OhbugErrorHandler() {
191
- }
192
- OhbugErrorHandler.prototype.handleError = function (err) {
193
- var detail = {
194
- message: err.message,
195
- stack: err.stack,
196
- };
197
- var event = client.createEvent({
198
- category: 'error',
199
- type: 'angular',
200
- detail: detail,
201
- });
202
- client.notify(event);
203
- };
204
- return OhbugErrorHandler;
205
- }());
206
- return {
207
- provide: errorHandler,
208
- useClass: OhbugErrorHandler,
209
- };
210
- }
211
-
212
- var extension = createExtension({
213
- name: 'OhbugAngular',
214
- init: function (client, ErrorHandler) { return createProvider(client, ErrorHandler); },
215
- });
216
-
217
- module.exports = extension;
@@ -1,215 +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
- function createProvider(client, errorHandler) {
187
- var OhbugErrorHandler = /** @class */ (function () {
188
- function OhbugErrorHandler() {
189
- }
190
- OhbugErrorHandler.prototype.handleError = function (err) {
191
- var detail = {
192
- message: err.message,
193
- stack: err.stack,
194
- };
195
- var event = client.createEvent({
196
- category: 'error',
197
- type: 'angular',
198
- detail: detail,
199
- });
200
- client.notify(event);
201
- };
202
- return OhbugErrorHandler;
203
- }());
204
- return {
205
- provide: errorHandler,
206
- useClass: OhbugErrorHandler,
207
- };
208
- }
209
-
210
- var extension = createExtension({
211
- name: 'OhbugAngular',
212
- init: function (client, ErrorHandler) { return createProvider(client, ErrorHandler); },
213
- });
214
-
215
- 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,a=1,i=arguments.length;a<i;a++)for(var n in e=arguments[a])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function e(t){return"string"==typeof t}var a=function(t,e,a,i){this.type=a,this.timestamp=i||(new Date).toISOString(),this.message=t,this.data=e};!function(){function i(t,e){var a=t.apiKey,i=t.appVersion,n=t.appType,r=t.releaseStage,s=t.timestamp,o=t.category,p=t.type,u=t.sdk,c=t.detail,h=t.device,l=t.user,y=t.actions,f=t.metaData;this.apiKey=a,this.appVersion=i,this.appType=n,this.releaseStage=r,this.timestamp=s,this.category=o,this.type=p,this.sdk=u,this.detail=c,this.device=h,this.user=l,this.actions=y,this.metaData=f,this._client=e}Object.defineProperty(i.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),i.prototype.addAction=function(t,i,n,r){var s,o,p=this.actions,u=e(t)?t:"",c=i||{},h=e(n)?n:"",l=new a(u,c,h,r);p.length>=(null!==(o=null===(s=this._client)||void 0===s?void 0:s._config.maxActions)&&void 0!==o?o:30)&&p.shift(),p.push(l)},i.prototype.getUser=function(){return this.user},i.prototype.setUser=function(e){var a,i,n;if(i=e,"[object Object]"===Object.prototype.toString.call(i)&&Object.keys(e).length<=6)return this.user=t(t({},this.user),e),this.getUser();null===(a=this._client)||void 0===a||a._logger.warn((n=e,new Error("Invalid data\n- "+"setUser should be an object and have up to 6 attributes"+", got "+JSON.stringify(n))))},i.prototype.addMetaData=function(t,e){return function(t,e,a){e&&(t[e]=a)}(this.metaData,t,e)},i.prototype.getMetaData=function(t){return function(t,e){if(t[e])return t[e]}(this.metaData,t)},i.prototype.deleteMetaData=function(t){return function(t,e){if(t[e])return delete t[e]}(this.metaData,t)},i.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 i={name:"OhbugAngular",init:function(t,e){return function(t,e){return{provide:e,useClass:function(){function e(){}return e.prototype.handleError=function(e){var a={message:e.message,stack:e.stack},i=t.createEvent({category:"error",type:"angular",detail:a});t.notify(i)},e}()}}(t,e)}};export default i;
@@ -1,223 +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.OhbugAngular = 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
- function createProvider(client, errorHandler) {
193
- var OhbugErrorHandler = /** @class */ (function () {
194
- function OhbugErrorHandler() {
195
- }
196
- OhbugErrorHandler.prototype.handleError = function (err) {
197
- var detail = {
198
- message: err.message,
199
- stack: err.stack,
200
- };
201
- var event = client.createEvent({
202
- category: 'error',
203
- type: 'angular',
204
- detail: detail,
205
- });
206
- client.notify(event);
207
- };
208
- return OhbugErrorHandler;
209
- }());
210
- return {
211
- provide: errorHandler,
212
- useClass: OhbugErrorHandler,
213
- };
214
- }
215
-
216
- var extension = createExtension({
217
- name: 'OhbugAngular',
218
- init: function (client, ErrorHandler) { return createProvider(client, ErrorHandler); },
219
- });
220
-
221
- return extension;
222
-
223
- })));
@@ -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).OhbugAngular=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,i=1,n=arguments.length;i<n;i++)for(var a in e=arguments[i])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t}).apply(this,arguments)};function e(t){return"string"==typeof t}var i=function(t,e,i,n){this.type=i,this.timestamp=n||(new Date).toISOString(),this.message=t,this.data=e};return function(){function n(t,e){var i=t.apiKey,n=t.appVersion,a=t.appType,r=t.releaseStage,o=t.timestamp,s=t.category,p=t.type,u=t.sdk,c=t.detail,f=t.device,h=t.user,l=t.actions,d=t.metaData;this.apiKey=i,this.appVersion=n,this.appType=a,this.releaseStage=r,this.timestamp=o,this.category=s,this.type=p,this.sdk=u,this.detail=c,this.device=f,this.user=h,this.actions=l,this.metaData=d,this._client=e}Object.defineProperty(n.prototype,"_isOhbugEvent",{get:function(){return!0},enumerable:!1,configurable:!0}),n.prototype.addAction=function(t,n,a,r){var o,s,p=this.actions,u=e(t)?t:"",c=n||{},f=e(a)?a:"",h=new i(u,c,f,r);p.length>=(null!==(s=null===(o=this._client)||void 0===o?void 0:o._config.maxActions)&&void 0!==s?s:30)&&p.shift(),p.push(h)},n.prototype.getUser=function(){return this.user},n.prototype.setUser=function(e){var i,n,a;if(n=e,"[object Object]"===Object.prototype.toString.call(n)&&Object.keys(e).length<=6)return this.user=t(t({},this.user),e),this.getUser();null===(i=this._client)||void 0===i||i._logger.warn((a=e,new Error("Invalid data\n- "+"setUser should be an object and have up to 6 attributes"+", got "+JSON.stringify(a))))},n.prototype.addMetaData=function(t,e){return function(t,e,i){e&&(t[e]=i)}(this.metaData,t,e)},n.prototype.getMetaData=function(t){return function(t,e){if(t[e])return t[e]}(this.metaData,t)},n.prototype.deleteMetaData=function(t){return function(t,e){if(t[e])return delete t[e]}(this.metaData,t)},n.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}}}(),{name:"OhbugAngular",init:function(t,e){return function(t,e){return{provide:e,useClass:function(){function e(){}return e.prototype.handleError=function(e){var i={message:e.message,stack:e.stack},n=t.createEvent({category:"error",type:"angular",detail:i});t.notify(n)},e}()}}(t,e)}}}));