|
1 | 1 | # 🧪 TestPilot |
2 | 2 |
|
3 | | -**Intelligent Bug Detection & Telemetry Extension for Modern Web Apps** |
4 | | - |
5 | | -TestPilot is a powerful, production-grade Chrome extension designed to catch bugs before your users do. It acts as a black-box flight recorder for your web application, capturing console errors, network failures, slow APIs, performance metrics, and security risks in real-time. |
6 | | - |
7 | | - |
8 | | - |
9 | | -## ✨ Key Features |
10 | | - |
11 | | -- **🚀 Real-time Telemetry**: Captures `console.error`, `console.warn`, unhandled exceptions, and promise rejections. |
12 | | -- **🌐 Network Intelligence**: |
13 | | - - Detects **Slow APIs** (>1000ms by default) |
14 | | - - Identifies **Retry Storms** (rapid repeated failures) |
15 | | - - Captures **CORS Errors** and HTTP 4xx/5xx failures |
16 | | -- **⚡ Performance Monitoring**: |
17 | | - - **Long Task Detection**: Flags UI freezes (>200ms) |
18 | | - - **White Screen Detection**: Alerts on potential rendering crashes |
19 | | -- **🛡️ Security Scanner**: |
20 | | - - Detects sensitive data leaks (JWTs, API keys, PII) in console/storage |
21 | | - - Monitors unsafe storage access |
22 | | -- **📱 Smart Context**: Captures environment details (User Agent, Viewport, Route Changes) for actionable bug reports. |
23 | | -- **🧠 Adaptive Severity**: Automatically escalates issue severity based on frequency (e.g., repeating errors become Critical). |
24 | | - |
25 | | -## 🛠️ Usage |
26 | | - |
27 | | -1. **Install the Extension** (Developer Mode): |
28 | | - - Clone this repo |
29 | | - - Run `npm install` and `npm run build` |
30 | | - - Open `chrome://extensions` |
31 | | - - Enable "Developer mode" |
32 | | - - Click "Load unpacked" and select the `dist` folder |
33 | | - |
34 | | -2. **Start a Session**: |
35 | | - - Click the extension icon |
36 | | - - Hit **Start Session** |
37 | | - - Interact with your web application |
38 | | - - TestPilot records all hidden issues in the background |
39 | | - |
40 | | -3. **Analyze & Export**: |
41 | | - - Open the popup to see a categorized list of issues |
42 | | - - Use **Filters** to focus on Critical/High severity bugs |
43 | | - - Click **Export JSON** or **Export Markdown** to generate a bug report |
| 3 | +**Intelligent Bug Detection & Telemetry Chrome Extension for Modern Web Apps** |
| 4 | + |
| 5 | +TestPilot is a production-grade Chrome extension that acts as a silent flight recorder for your web application. It captures bugs, network failures, security risks, and performance issues in real-time — before your users report them. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## ✨ Features |
| 10 | + |
| 11 | +### 🖥️ Console Monitoring |
| 12 | +- Intercepts `console.error` and `console.warn` calls from deep inside the page (via a **Main World bridge script** that runs before any other JS) |
| 13 | +- Captures the **caller file, line, and column** from the stack trace automatically |
| 14 | +- Passes every console message through the **Security Scanner** before logging |
| 15 | + |
| 16 | +### 🌐 Network Intelligence |
| 17 | +- Wraps both **`window.fetch`** and **`XMLHttpRequest`** to intercept all outgoing requests |
| 18 | +- Captures **HTTP 4xx / 5xx** failures as `network_failure` issues |
| 19 | +- Detects **Slow APIs** — requests exceeding the configurable threshold (default: 1000ms) |
| 20 | +- Detects **API Retry Storms** — automatically escalates to `retry_storm` (Critical) when the same endpoint fails 3+ times within 5 seconds |
| 21 | +- Records **request payload**, **response status**, and **response body** (up to 2000 chars) for every failing or slow request |
| 22 | + |
| 23 | +### ⚡ Runtime Crash Detection |
| 24 | +- Listens for `window.onerror` to catch **unhandled JavaScript exceptions** with full file/line/column/stack metadata |
| 25 | +- Listens for `window.onunhandledrejection` to catch **unhandled Promise rejections** |
| 26 | + |
| 27 | +### 📦 Broken Resource Detection |
| 28 | +- Listens on the capture phase for failed loads of `<img>`, `<script>`, and `<link>` tags |
| 29 | +- Records the tag type, source URL, and outer HTML of the broken element |
| 30 | + |
| 31 | +### 🛡️ Security Scanner |
| 32 | +Automatically scans console output and `localStorage` writes for sensitive data leaks: |
| 33 | +| Pattern | Detected As | |
| 34 | +|---|---| |
| 35 | +| JWT tokens (`eyJ...`) | `JWT Token` | |
| 36 | +| Email addresses | `Email Address` | |
| 37 | +| Phone numbers | `Phone Number` | |
| 38 | +| API keys / secrets | `API Key/Secret` | |
| 39 | +| Sensitive keys written to `localStorage` (`token`, `password`, `api_key`, `jwt`, `auth`) | `storage_leak` | |
| 40 | + |
| 41 | +### 🧠 Severity Engine |
| 42 | +All issues are automatically classified into four severity levels: |
| 43 | + |
| 44 | +| Level | Issue Types | |
| 45 | +|---|---| |
| 46 | +| 🔴 **Critical** | Runtime crashes, white screens, retry storms, CORS failures, security risks, HTTP 5xx | |
| 47 | +| 🟠 **High** | Console errors, resource failures, HTTP 4xx network failures | |
| 48 | +| 🟡 **Medium** | Slow APIs, console warnings | |
| 49 | +| ⚪ **Low** | Console logs | |
| 50 | + |
| 51 | +**Adaptive Escalation:** If the same issue repeats beyond a configurable threshold (default: 10×), its severity automatically upgrades one level (e.g. Medium → High → Critical). |
| 52 | + |
| 53 | +### 🗂️ Issue Deduplication |
| 54 | +Issues are fingerprinted by type + message hash. Repeated occurrences of the same bug increment an `occurrences` counter and update `lastSeen` instead of creating duplicates — keeping reports clean and actionable. |
| 55 | + |
| 56 | +### 📊 Session Management |
| 57 | +- Every recording is isolated as a **Session** with a unique UUID |
| 58 | +- Sessions store full metadata: `userAgent`, `viewport`, `URL`, `platform` |
| 59 | +- Sessions persist across page navigations via `chrome.storage.local` |
| 60 | +- Session history is browsable from the popup |
| 61 | + |
| 62 | +### 📤 Report Export |
| 63 | +Completed sessions can be exported in two formats: |
| 64 | + |
| 65 | +- **JSON** — Raw structured data, ideal for programmatic processing or filing in issue trackers |
| 66 | +- **Markdown** — Human-readable report with: |
| 67 | + - Executive summary with issue counts per severity |
| 68 | + - ⚠️ Critical issue call-out banner |
| 69 | + - **Release Blockers** section (Critical issues only) |
| 70 | + - **High Priority** section |
| 71 | + - **Medium Priority** section |
| 72 | + - Full **Timeline** of all issues sorted by time of occurrence |
| 73 | + |
| 74 | +### 🎨 UI |
| 75 | +- Modern, white-and-blue minimal popup (400px wide) |
| 76 | +- Live issue list with **severity filter buttons** (All / Critical / High / Medium / Low) |
| 77 | +- Issue cards showing type, message, occurrence count, and URL |
| 78 | +- Expandable **request/response body detail** for network issues |
| 79 | +- Session history view with per-session issue count pills |
| 80 | +- Extension badge shows the live total issue count during recording |
| 81 | + |
| 82 | +--- |
44 | 83 |
|
45 | 84 | ## ⚙️ Configuration |
46 | 85 |
|
47 | | -TestPilot includes a **Settings Panel** (click the ⚙ icon) to customize detection thresholds: |
| 86 | +Click the **⚙** icon in the popup to open the Settings panel: |
48 | 87 |
|
49 | 88 | | Setting | Default | Description | |
50 | | -|Observed Metric| Threshold | Impact | |
51 | 89 | |---|---|---| |
52 | | -| **Slow API** | 1000ms | Requests taking longer than this are flagged as "Medium" severity | |
53 | | -| **Long Task** | 200ms | UI freezes longer than this are flagged as "Medium" severity | |
54 | | -| **Escalation** | 10x | Issues repeating this many times automatically upgrade severity | |
| 90 | +| **Slow API Threshold** | `1000` ms | Requests taking longer than this are flagged as Slow API (Medium) | |
| 91 | +| **Escalation Threshold** | `10` × | Issues repeating this many times auto-escalate one severity level | |
| 92 | +| **Monitor Types** | All enabled | Toggle individual monitors on/off (runtime crash, console error, network failure, slow API, retry storm, resource failure, CORS, security risk, white screen) | |
55 | 93 |
|
56 | | -## 🏗️ Architecture |
57 | | - |
58 | | -- **Core**: TypeScript, Vite, Preact |
59 | | -- **State Management**: Chronicled session storage in `chrome.storage.local` |
60 | | -- **Bridge**: Injected script (`bridge.ts`) for deep network/console interception |
61 | | -- **Analysis**: Independent `SeverityEngine` for classifying and prioritizing issues |
| 94 | +--- |
62 | 95 |
|
63 | | -## 📦 Build & Develop |
| 96 | +## 🛠️ Installation (Developer Mode) |
64 | 97 |
|
65 | 98 | ```bash |
66 | | -# Install dependencies |
| 99 | +# 1. Clone the repo |
| 100 | +git clone https://github.com/your-username/TestPilot.git |
| 101 | +cd TestPilot |
| 102 | + |
| 103 | +# 2. Install dependencies |
67 | 104 | npm install |
68 | 105 |
|
69 | | -# Run development build (watch mode) |
| 106 | +# 3. Build for production |
| 107 | +npm run build |
| 108 | +``` |
| 109 | + |
| 110 | +Then in Chrome: |
| 111 | +1. Go to `chrome://extensions` |
| 112 | +2. Enable **Developer mode** (top-right toggle) |
| 113 | +3. Click **Load unpacked** |
| 114 | +4. Select the `dist/` folder |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## 💻 Development |
| 119 | + |
| 120 | +```bash |
| 121 | +# Type-check only (no emit) |
| 122 | +npm run type-check |
| 123 | + |
| 124 | +# Start Vite dev server (for popup UI iteration) |
70 | 125 | npm run dev |
71 | 126 |
|
72 | 127 | # Build for production |
73 | 128 | npm run build |
74 | 129 | ``` |
75 | 130 |
|
| 131 | +--- |
| 132 | + |
| 133 | +## 🏗️ Architecture |
| 134 | + |
| 135 | +``` |
| 136 | +src/ |
| 137 | +├── background/ # Service Worker (persistent background process) |
| 138 | +│ ├── main.ts # Message router — receives TELEMETRY_EVENT messages |
| 139 | +│ ├── eventProcessor.ts # Deduplication, retry-storm detection, badge updates |
| 140 | +│ ├── sessionManager.ts # Start/end sessions, persist to chrome.storage.local |
| 141 | +│ ├── severityEngine.ts # Classifies and escalates issue severity levels |
| 142 | +│ └── storage.ts # Typed wrapper around chrome.storage.local |
| 143 | +│ |
| 144 | +├── content/ # Content Script (runs on every page) |
| 145 | +│ ├── main.ts # Orchestrator — injects bridge, enables all monitors |
| 146 | +│ ├── bridge.ts # Injected into Main World to intercept fetch/XHR/console |
| 147 | +│ ├── consoleMonitor.ts # console.error / console.warn override + security scan |
| 148 | +│ ├── networkMonitor.ts # fetch + XHR override for slow/failed requests |
| 149 | +│ ├── runtimeMonitor.ts # window.onerror + unhandledrejection listeners |
| 150 | +│ └── securityScanner.ts# Regex-based PII / secret detection engine |
| 151 | +│ |
| 152 | +├── core/ # Shared types and utilities |
| 153 | +│ ├── types.ts # IssueType, IssueLevel, Issue, Session, StorageSchema |
| 154 | +│ ├── issueFactory.ts # Constructs Issue objects with fingerprinting |
| 155 | +│ └── fingerprint.ts # Deterministic hash for issue deduplication |
| 156 | +│ |
| 157 | +├── popup/ # Preact UI |
| 158 | +│ ├── index.html |
| 159 | +│ ├── popup.tsx # Full popup app — all views and state logic |
| 160 | +│ └── popup.css # Design system — white/blue theme, scrollbars, animations |
| 161 | +│ |
| 162 | +└── reporting/ |
| 163 | + └── reportGenerator.ts # Generates Markdown and JSON session reports |
| 164 | +``` |
| 165 | + |
| 166 | +**Key design decisions:** |
| 167 | +- The **bridge script** (`bridge.ts`) is injected into the **Main World** (not isolated content script context) so it can intercept the page's own `fetch`, `XMLHttpRequest`, and `console` before any frameworks or libraries wrap them. |
| 168 | +- The **background service worker** is the single source of truth for session state, keeping the popup and content scripts stateless and easily restartable. |
| 169 | +- **Fingerprinting** is done at issue creation time, making deduplication a simple array lookup. |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## 📦 Tech Stack |
| 174 | + |
| 175 | +| Layer | Technology | |
| 176 | +|---|---| |
| 177 | +| UI | [Preact](https://preactjs.com/) + TypeScript | |
| 178 | +| Build | [Vite](https://vitejs.dev/) v7 | |
| 179 | +| Styles | Vanilla CSS | |
| 180 | +| Storage | `chrome.storage.local` | |
| 181 | +| Types | `@types/chrome` | |
| 182 | + |
| 183 | +--- |
| 184 | + |
76 | 185 | ## 🤝 Contributing |
77 | 186 |
|
78 | 187 | 1. Fork the repository |
79 | 188 | 2. Create your feature branch (`git checkout -b feature/amazing-feature`) |
80 | | -3. Commit your changes (`git commit -m 'Add amazing feature'`) |
| 189 | +3. Commit your changes (`git commit -m 'feat: add amazing feature'`) |
81 | 190 | 4. Push to the branch (`git push origin feature/amazing-feature`) |
82 | 191 | 5. Open a Pull Request |
83 | 192 |
|
| 193 | +--- |
| 194 | + |
84 | 195 | ## 📄 License |
85 | 196 |
|
86 | | -MIT License - free to use for personal and commercial projects. |
| 197 | +MIT License — free to use for personal and commercial projects. |
0 commit comments