reporting-lib 0.1.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 ADDED
@@ -0,0 +1,94 @@
1
+ # reporting-lib
2
+
3
+ A comprehensive monitoring and reporting library for web applications. This library provides error tracking, performance monitoring, and API request data collection capabilities.
4
+
5
+ ## Features
6
+
7
+ - **Error Monitoring**: Automatic error capture and reporting
8
+ - **Performance Monitoring**: Track page load times and route changes
9
+ - **API Monitoring**: Monitor remote API requests and responses
10
+ - **Configurable**: Easy to configure and customize monitoring behavior
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install reporting-lib
16
+ # or
17
+ yarn add reporting-lib
18
+ # or
19
+ pnpm add reporting-lib
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Basic Setup
25
+
26
+ ```javascript
27
+ import monitor from 'reporting-lib';
28
+
29
+ // Initialize the monitoring system
30
+ monitor.init({
31
+ // Your configuration options here
32
+ apiEndpoint: 'https://your-api.com/collect',
33
+ appName: 'MyApp',
34
+ environment: 'production'
35
+ });
36
+ ```
37
+
38
+ ### Configuration Options
39
+
40
+ The `init` method accepts the following configuration options:
41
+
42
+ - `apiEndpoint`: URL where monitoring data will be sent
43
+ - `appName`: Name of your application
44
+ - `environment`: Environment (development, staging, production)
45
+ - `sampleRate`: Sampling rate for data collection (0-1)
46
+ - `enableErrorTracking`: Enable/disable error monitoring (default: true)
47
+ - `enablePerformanceTracking`: Enable/disable performance monitoring (default: true)
48
+ - `enableApiTracking`: Enable/disable API monitoring (default: true)
49
+
50
+ ### Example
51
+
52
+ ```javascript
53
+ import monitor from 'reporting-lib';
54
+
55
+ monitor.init({
56
+ apiEndpoint: 'https://analytics.myapp.com/events',
57
+ appName: 'E-commerce App',
58
+ environment: 'production',
59
+ sampleRate: 1.0,
60
+ enableErrorTracking: true,
61
+ enablePerformanceTracking: true,
62
+ enableApiTracking: true
63
+ });
64
+ ```
65
+
66
+ ## API Reference
67
+
68
+ ### `monitor.init(options)`
69
+
70
+ Initializes the monitoring system with the specified configuration.
71
+
72
+ ### `monitor.setConfig(options)`
73
+
74
+ Updates the configuration after initialization.
75
+
76
+ ## Development
77
+
78
+ ```bash
79
+ # Install dependencies
80
+ pnpm install
81
+
82
+ # Build the project
83
+ pnpm build
84
+
85
+ # Watch mode for development
86
+ pnpm dev
87
+
88
+ # Lint the code
89
+ pnpm lint
90
+ ```
91
+
92
+ ## License
93
+
94
+ MIT
@@ -0,0 +1,5 @@
1
+ declare const monitor: {
2
+ init(options?: {}): void;
3
+ };
4
+ export default monitor;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,OAAO;;CAWZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import { setConfig } from "./config/index.js";
2
+ import error from "./error/index.js";
3
+ import performance from "./performance/index.js";
4
+ import api from "./api/index.js";
5
+ let isInit = false;
6
+ const monitor = {
7
+ init(options = {}) {
8
+ setConfig(options); //配置全局参数
9
+ // 多次初始化只执行一次挂载监听的逻辑
10
+ if (!isInit) {
11
+ error(); //错误监听处理
12
+ performance(); //性能监控
13
+ api(); //api远程请求数据采集
14
+ isInit = true;
15
+ }
16
+ },
17
+ };
18
+ export default monitor;
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,GAAG,MAAM,gBAAgB,CAAC;AAEjC,IAAI,MAAM,GAAG,KAAK,CAAC;AACnB,MAAM,OAAO,GAAG;IACd,IAAI,CAAC,OAAO,GAAG,EAAE;QACf,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;QAC5B,oBAAoB;QACpB,IAAG,CAAC,MAAM,EAAC,CAAC;YACV,KAAK,EAAE,CAAC,CAAC,QAAQ;YACjB,WAAW,EAAE,CAAC,CAAC,MAAM;YACrB,GAAG,EAAE,CAAC,CAAC,aAAa;YACpB,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "reporting-lib",
3
+ "version": "0.1.0",
4
+ "description": "A comprehensive monitoring and reporting library for web applications",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "keywords": [
20
+ "monitoring",
21
+ "reporting",
22
+ "performance",
23
+ "error-tracking",
24
+ "analytics"
25
+ ],
26
+ "author": "",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": ""
31
+ },
32
+ "homepage": "",
33
+ "bugs": {
34
+ "url": ""
35
+ },
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "dev": "tsc --watch",
39
+ "lint": "eslint src --ext .ts",
40
+ "prepublishOnly": "npm run build",
41
+ "clean": "rm -rf dist",
42
+ "prebuild": "npm run clean"
43
+ },
44
+ "devDependencies": {
45
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
46
+ "@typescript-eslint/parser": "^6.0.0",
47
+ "eslint": "^8.0.0",
48
+ "typescript": "^5.4.0"
49
+ },
50
+ "dependencies": {
51
+ "web-vitals": "^5.0.3"
52
+ }
53
+ }