@ohbug/angular 1.0.5 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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 @@
1
+ var n=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var E=(e,r)=>{for(var a in r)n(e,a,{get:r[a],enumerable:!0})},c=(e,r,a,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!g.call(e,t)&&t!==a&&n(e,t,{get:()=>r[t],enumerable:!(o=p(r,t))||o.enumerable});return e};var m=e=>c(n({},"__esModule",{value:!0}),e);var v={};E(v,{default:()=>s});module.exports=m(v);var l=require("@ohbug/core");function y(e,r){class a{handleError(t){let i={message:t.message,stack:t.stack},u=e.createEvent({category:"error",type:l.EventTypes.ANGULAR,detail:i});e.notify(u)}}return{provide:r,useClass:a}}var s=y;0&&(module.exports={});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{EventTypes as i}from"@ohbug/core";function u(r,t){class a{handleError(e){let o={message:e.message,stack:e.stack},n=r.createEvent({category:"error",type:i.ANGULAR,detail:o});r.notify(n)}}return{provide:t,useClass:a}}var p=u;export{p as default};
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@ohbug/angular",
3
- "version": "1.0.5",
3
+ "version": "2.0.1",
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,40 +12,35 @@
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.umd.js",
16
- "module": "./dist/ohbug-angular.es.js",
17
- "unpkg": "./dist/ohbug-angular.umd.js",
18
- "jsdelivr": "./dist/ohbug-angular.umd.js",
19
- "types": "./dist/index.d.ts",
15
+ "main": "dist/index.js",
16
+ "module": "dist/index.mjs",
17
+ "types": "dist/index.d.ts",
20
18
  "exports": {
21
19
  ".": {
22
- "import": "./dist/ohbug-angular.es.js",
23
- "require": "./dist/ohbug-angular.umd.js"
20
+ "require": "./dist/index.js",
21
+ "import": "./dist/index.mjs",
22
+ "types": "./dist/index.d.ts"
24
23
  }
25
24
  },
26
25
  "files": [
27
26
  "dist"
28
27
  ],
28
+ "sideEffects": false,
29
+ "peerDependencies": {
30
+ "@angular/core": "^13.0.0"
31
+ },
29
32
  "dependencies": {
30
- "@ohbug/core": "^1.1.6"
33
+ "@ohbug/core": "2.0.1",
34
+ "@ohbug/types": "2.0.1"
31
35
  },
32
36
  "devDependencies": {
33
- "@angular/core": "^12.2.4"
34
- },
35
- "peerDependencies": {
36
- "@angular/core": "^10.0.0"
37
- },
38
- "buildOptions": {
39
- "name": "OhbugAngular",
40
- "formats": [
41
- "es",
42
- "umd"
43
- ],
44
- "order": 4
37
+ "@angular/core": "^13.3.8"
45
38
  },
46
39
  "publishConfig": {
47
40
  "access": "public"
48
41
  },
49
- "gitHead": "10a43cc9dc7cceec6a209746b0258de14390aa32"
50
- }
42
+ "scripts": {
43
+ "build": "tsup",
44
+ "dev": "tsup --watch"
45
+ }
46
+ }
@@ -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,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 { extension as default };
@@ -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{i as default};
@@ -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)}}}));