reportli 1.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 ADDED
@@ -0,0 +1,116 @@
1
+ # Reportli SDK ๐Ÿš€
2
+
3
+ The official, enterprise-grade real-time exception tracking and AI-powered diagnostics SDK for client-side (SPA/Next.js/React/Vue), server-side (Node.js/Express), and full-stack software applications.
4
+
5
+ ---
6
+
7
+ ## Key Features
8
+
9
+ - **๐Ÿ›ก๏ธ 50+ Classified Errors**: Automatically groups and parses crashes including Standard exceptions, React Hydration errors, Invalid Hooks, Stripe Payment failures, database anomalies, CORS issues, Token expirations, and express timeouts.
10
+ - **๐ŸŒ Network Hooking**: Transparently intercept Global `fetch` and standard `XMLHttpRequest` transactions to capture API deviations (e.g. 400 Bad Requests, 401 Unauthorized, 404 Not Founds, and 500 Server Crashes).
11
+ - **๐Ÿ“‚ Resource Validation**: Captures failing third-party style asset downloads, un-resolving JS scripts, font timeouts, and image load errors.
12
+ - **โšก Async/Rejections Safe**: Hooks deep into the browser thread (`unhandledrejection`) and Node processes (`unhandledRejection`, `uncaughtException`) to record issues before threads exit.
13
+ - **๐Ÿ“ข Instant Setup Webhook**: Sells registration success notifications to your telemetry database instantly upon first module configuration.
14
+
15
+ ---
16
+
17
+ ## Installation
18
+
19
+ Install the package via standard node package managers:
20
+
21
+ ```bash
22
+ npm install reportli
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Usage Guide
28
+
29
+ ### 1. Browser/Single-Page Applications & React/Next.js Client (HTML/JS)
30
+
31
+ Simply import and run the initialization at the main entry file (`src/index.tsx`, `app/layout.tsx` or raw `App.js` blocks):
32
+
33
+ ```typescript
34
+ import { Reportli } from 'reportli';
35
+
36
+ Reportli.init({
37
+ apiKey: "YOUR_PROJECT_API_KEY",
38
+ projectName: "My Customer Portal UI",
39
+ projectId: "portal-ui",
40
+ environment: "production",
41
+ userEmail: "client-agent@domain.com"
42
+ });
43
+ ```
44
+
45
+ ### 2. Node.js & Express Backends (Server-Side)
46
+
47
+ Reportli hooks into your routes to catch server-side crashes and express execution exceptions.
48
+
49
+ ```javascript
50
+ const express = require('express');
51
+ const { Reportli } = require('reportli');
52
+
53
+ const app = express();
54
+
55
+ // Initialize the Exception agent
56
+ Reportli.init({
57
+ apiKey: "YOUR_PROJECT_API_KEY",
58
+ projectName: "Billing & Subscriptions API",
59
+ projectId: "billing-api",
60
+ framework: "Express"
61
+ });
62
+
63
+ app.use(express.json());
64
+
65
+ // ... Standard route handlers ...
66
+ app.get("/api/checkout", (req, res) => {
67
+ throw new Error("Stripe payment processing failed: Card declined"); // Auto-caught & classified!
68
+ });
69
+
70
+ // Place Reportli Error Handler at the ultimate end of active middleware
71
+ app.use(Reportli.expressErrorHandler);
72
+
73
+ app.listen(3000);
74
+ ```
75
+
76
+ ### 3. Manual Crash Tracking & Custom Severity
77
+
78
+ Report custom exception payloads with forced severity tiers:
79
+
80
+ ```typescript
81
+ try {
82
+ initiateComplexDbSync();
83
+ } catch (error) {
84
+ // Capture manually
85
+ Reportli.captureException(error, "critical");
86
+ }
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Publishing to npmjs.com
92
+
93
+ Follow these three simple commands to compile, bundle, and release the SDK:
94
+
95
+ 1. **Install Build Dependencies**:
96
+ ```bash
97
+ cd reportli-sdk
98
+ npm install
99
+ ```
100
+
101
+ 2. **Bundle/Build Package**:
102
+ ```bash
103
+ npm run build
104
+ ```
105
+ This generates ESM (`dist/index.mjs`), CommonJS (`dist/index.js`), and fully mapped TS definitions (`dist/index.d.ts`).
106
+
107
+ 3. **Publish to Registry**:
108
+ ```bash
109
+ npm publish --access public
110
+ ```
111
+
112
+ ---
113
+
114
+ ## License
115
+
116
+ This project is licensed under the [MIT License](LICENSE).
package/build.js ADDED
@@ -0,0 +1,52 @@
1
+ const esbuild = require("esbuild");
2
+ const { execSync } = require("child_process");
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+
6
+ async function build() {
7
+ console.log("๐Ÿงน Cleaning dist folder...");
8
+ const distPath = path.join(__dirname, "dist");
9
+ if (fs.existsSync(distPath)) {
10
+ fs.rmSync(distPath, { recursive: true, force: true });
11
+ }
12
+
13
+ console.log("๐Ÿ“ฆ Compiling CommonJS bundle...");
14
+ await esbuild.build({
15
+ entryPoints: ["src/index.ts"],
16
+ outfile: "dist/index.js",
17
+ bundle: true,
18
+ platform: "node",
19
+ format: "cjs",
20
+ target: "es2020",
21
+ sourcemap: true,
22
+ minify: false,
23
+ external: ["esbuild"],
24
+ });
25
+
26
+ console.log("๐Ÿ“ฆ Compiling ES Module bundle...");
27
+ await esbuild.build({
28
+ entryPoints: ["src/index.ts"],
29
+ outfile: "dist/index.mjs",
30
+ bundle: true,
31
+ platform: "neutral",
32
+ format: "esm",
33
+ target: "es2020",
34
+ sourcemap: true,
35
+ minify: false,
36
+ });
37
+
38
+ console.log("๐Ÿท๏ธ Generating TypeScript declaration files...");
39
+ try {
40
+ execSync("npx tsc --emitDeclarationOnly --outDir dist", { cwd: __dirname });
41
+ console.log("โœจ TypeScript declarations generated successfully.");
42
+ } catch (error) {
43
+ console.error("โš ๏ธ Failed to generate TypeScript declaration files. Proceeding anyway...", error);
44
+ }
45
+
46
+ console.log("๐Ÿš€ Reportli SDK build completed successfully!");
47
+ }
48
+
49
+ build().catch((err) => {
50
+ console.error("โŒ Build failed:", err);
51
+ process.exit(1);
52
+ });
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Reportli SDK
3
+ * Enterprise-grade real-time exception tracking and AI diagnostic companion.
4
+ */
5
+ export interface ReportliConfig {
6
+ apiKey: string;
7
+ projectId?: string;
8
+ projectName?: string;
9
+ environment?: string;
10
+ framework?: string;
11
+ disableHmrLogging?: boolean;
12
+ captureUnhandledRejections?: boolean;
13
+ autoCreateGitHubIssues?: boolean;
14
+ userEmail?: string;
15
+ }
16
+ export interface ExceptionPayload {
17
+ apiKey: string;
18
+ projectId?: string;
19
+ projectName?: string;
20
+ errorType: string;
21
+ errorMessage: string;
22
+ errorStack: string;
23
+ framework?: string;
24
+ user_email?: string;
25
+ severity?: "low" | "medium" | "high" | "critical";
26
+ status?: string;
27
+ }
28
+ declare class ReportliTracker {
29
+ private config;
30
+ private isInitialized;
31
+ /**
32
+ * Initializes the Reportli tracker with your secure project credentials.
33
+ */
34
+ init(config: ReportliConfig): void;
35
+ /**
36
+ * Manually captures and files a custom application exception with custom severity.
37
+ */
38
+ captureException(error: Error | any, severityInput?: "low" | "medium" | "high" | "critical"): void;
39
+ /**
40
+ * Express error handler middleware
41
+ */
42
+ expressErrorHandler: (err: any, req: any, res: any, next: any) => void;
43
+ /**
44
+ * Registers global window listeners for DOM-based exceptions.
45
+ */
46
+ private setupBrowserListeners;
47
+ /**
48
+ * Registers node process listeners for server instances.
49
+ */
50
+ private setupNodeListeners;
51
+ /**
52
+ * Safe payload sender with retry limits.
53
+ */
54
+ private sendCrashReport;
55
+ /**
56
+ * Sends registration verification to user edge function on first install.
57
+ */
58
+ private sendRegistrationWebhook;
59
+ /**
60
+ * Capture fetch network status deviations.
61
+ */
62
+ private interceptFetch;
63
+ /**
64
+ * Trace XHR status failures.
65
+ */
66
+ private interceptXhr;
67
+ private logNetworkError;
68
+ private logNetworkFailure;
69
+ /**
70
+ * Helper to safely format raw objects / strings into structured Errors
71
+ */
72
+ private normalizeError;
73
+ /**
74
+ * Comprehensive classification rules checking substring and classifications
75
+ */
76
+ private classifyError;
77
+ }
78
+ export declare const Reportli: ReportliTracker;
79
+ export default Reportli;
80
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CA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