@syntropysoft/syntropyfront 0.4.7 → 0.4.8

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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [0.4.8] - 2026-03-01
2
+
3
+ ### Added
4
+ - **Examples**: Single shared stylesheet `examples/examples.css` for all pure HTML demos.
5
+ - **README (main)**: Examples section with table linking to examples/README.md, basic-usage.html, HTML demos, react-example, vue-example, svelte-example.
6
+
7
+ ### Changed
8
+ - **Keywords (package.json)**: Tuned for accuracy (e.g. production-errors, lightweight, zero-dependencies); removed performance-monitoring / web-performance (not a full APM).
9
+ - **README**: Reorganized for clarity—what it does, why use it, Quick Start, API table, PII/config summary, short Design, Quality, Contributing. Honest impact, no overclaim.
10
+ - **SECURITY.md**: Added **Network access** section (data sent only to your endpoint or callback).
11
+ - **Examples (HTML)**: All pure HTML demos now load the IIFE bundle (`dist/index.min.js`) so they work when opened via file:// after `pnpm run build`. Demos updated to current API (`configure`, `getStats`, no `init`/presets). Worker/Proxy/Presets demos simplified or stubbed where the API is not in the current build.
12
+ - **examples/README.md**: Documents basic-usage, other HTML demos, React/Vue/Svelte with run commands; notes shared CSS and build requirement.
13
+
14
+ ---
15
+
1
16
  ## [0.4.7] - 2026-03-01
2
17
 
3
18
  ### Changed
package/NOTICE CHANGED
@@ -1,4 +1,4 @@
1
1
  SyntropyFront
2
2
  Copyright 2024-2026 Syntropysoft
3
3
 
4
- Version 0.4.7
4
+ Version 0.4.8
package/README.md CHANGED
@@ -5,9 +5,7 @@
5
5
  <h1 align="center">SyntropyFront</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>From Uncertainty to Clarity</strong>
9
- <br />
10
- The Observability Library for High-Performance Teams
8
+ <strong>Capture frontend errors and user actions. One line. ~34 KB. Zero dependencies.</strong>
11
9
  </p>
12
10
 
13
11
  <p align="center">
@@ -21,260 +19,139 @@
21
19
 
22
20
  ---
23
21
 
24
- 🚀 **Automatic observability capture - Just 1 line of code! Zero external dependencies.**
22
+ ## What it does
25
23
 
26
- SyntropyFront automatically captures user interactions, errors, HTTP calls, and console logs, providing a 360° view of the user experience with minimal performance impact.
24
+ When something breaks in production, you get **what broke** and **what the user did before it**. No giant platform, no per-seat pricing. One import and it starts capturing:
27
25
 
28
- ## 🧠 Our Philosophy: Observability with Purpose
26
+ - **Errors** uncaught exceptions and unhandled promise rejections
27
+ - **Clicks** — on buttons, links, and interactive elements (throttled)
28
+ - **HTTP** — `fetch` calls (URL, method; no sensitive headers)
29
+ - **Breadcrumbs** — timeline you can extend with `addBreadcrumb()`
29
30
 
30
- SyntropyFront is not just a log collector; it is a piece of engineering designed under three fundamental pillars:
31
+ Optional: PII masking, sampling, offline retry (IndexedDB), and sending to your endpoint or `onError` callback. **That’s it.** It’s not a full APM; it’s enough to stop debugging blind.
31
32
 
32
- 1. **SOLID Principles**: Each component has a single responsibility. From `QueueManager` to `RetryManager`, the system is extensible and predictable.
33
- 2. **Functional Programming**: We use declarative patterns to transform data, ensuring that error processing and PII obfuscation are pure and without unexpected side effects.
34
- 3. **Privacy by Design (Privacy-by-Default)**: Security is not optional. The system includes a sensitive data masking engine (PII) that acts before any information leaves the client.
33
+ ---
35
34
 
36
- **Network access:** This library uses the network only to send errors and breadcrumbs to the endpoint you configure (`configure({ endpoint })` or `onError`). It does not phone home or send data to third parties by default.
35
+ ## Why use it
37
36
 
38
- ## Key Features
37
+ | Who | What they get |
38
+ |-----|----------------|
39
+ | **Developers** | One import, no config. No excuse to ship with zero visibility. |
40
+ | **PM / Tech Lead** | Visibility from day one. No long “observability” projects. |
41
+ | **Management** | Low cost, no SaaS lock-in. Fewer outages, less firefighting. |
39
42
 
40
- - 🎯 **Smart Click Capture**: Tracks interactions on interactive elements with built-in throttling logic.
41
- - 🚨 **Global Error Management**: Captures uncaught exceptions (`window.onerror`) and promise rejections.
42
- - 🌐 **Network Monitoring**: Intercepts `fetch` calls for full API visibility.
43
- - 🛡️ **PII Masking & ANSI Cleaning**: Automatically protects sensitive data (emails, cards, tokens).
44
- - 🎲 **Probabilistic Sampling**: Controls the volume of data sent to optimize costs and traffic.
45
- - 💾 **Offline Resilience**: Retry queue with *Exponential Backoff* and persistent storage via IndexedDB.
46
- - 📦 **Native Tree Shaking**: Modular architecture that allows you to include only the interceptors you truly need.
43
+ **Network:** Data is sent only to the endpoint or callback you configure. No third parties, no telemetry. See [SECURITY.md](SECURITY.md).
47
44
 
48
- ## 🚀 Quick Start
45
+ ---
49
46
 
50
- ### Installation
47
+ ## Quick Start
51
48
 
52
49
  ```bash
53
50
  pnpm add @syntropysoft/syntropyfront
54
51
  ```
55
52
 
56
- ### Basic Usage (Zero Config)
57
-
58
- Simply import the library in your application's entry point:
53
+ In your app entry (e.g. `main.jsx` or `index.js`):
59
54
 
60
55
  ```javascript
61
56
  import syntropyFront from '@syntropysoft/syntropyfront';
62
- // Done! SyntropyFront auto-initializes and starts capturing events.
57
+ // Done. Errors and breadcrumbs go to the console by default.
63
58
  ```
64
59
 
65
- ## ⚙️ Advanced Configuration
66
-
67
- SyntropyFront is highly configurable to suit your production needs.
60
+ To send to your backend or handle in code:
68
61
 
69
62
  ```javascript
70
- import syntropyFront from '@syntropysoft/syntropyfront';
71
-
72
63
  syntropyFront.configure({
73
- // Your observability backend URL (optional, defaults to console logging)
74
- endpoint: 'https://your-api.com/v1/telemetry',
75
-
76
- // Custom headers for transmission
77
- headers: {
78
- 'Authorization': 'Bearer your-app-token',
79
- 'X-Environment': 'production'
80
- },
81
-
82
- // 🎲 SAMPLING: Only sends 10% of errors to save resources
83
- samplingRate: 0.1,
84
-
85
- // 📦 BATCHING: Batch size and timeout before sending
86
- batchSize: 10,
87
- batchTimeout: 5000,
88
-
89
- // 🛡️ SECURITY: Basic payload encryption (base64/rot13)
90
- encrypt: true,
91
-
92
- // 💾 PERSISTENCE: Enable disk storage if the user is offline
93
- usePersistentBuffer: true,
94
-
95
- // Custom callback to handle the error before it is sent
96
- onError: (payload) => {
97
- console.warn('Error captured:', payload.type);
98
- return payload; // You can modify the payload here if necessary
99
- }
64
+ endpoint: 'https://your-api.com/errors',
65
+ headers: { 'Authorization': 'Bearer YOUR_TOKEN' },
66
+ // optional: samplingRate, batchSize, batchTimeout, usePersistentBuffer, onError
100
67
  });
101
68
  ```
102
69
 
103
- ## 🕹️ Event Capture & Custom Events
104
-
105
- SyntropyFront provides both automatic tracking and manual tools to enrich your observability data.
106
-
107
- ### 🤖 Automatic Capture
108
- By default, the following interceptors are initialized:
109
- - **UI Clicks**: Captures clicks on interactive elements (buttons, links, etc.) with smart selection logic.
110
- - **Network**: Intercepts `fetch` calls, logging requests and responses (without sensitive headers).
111
- - **Errors**: Catch-all for uncaught exceptions and unhandled promise rejections.
112
-
113
- ### 🛠️ Custom Breadcrumbs
114
- Breadcrumbs are a timeline of events that help you understand what happened before an error occurred. You can add your own milestones:
70
+ ---
115
71
 
116
- ```javascript
117
- import syntropyFront from '@syntropysoft/syntropyfront';
72
+ ## Main API
118
73
 
119
- // Simple breadcrumb
120
- syntropyFront.addBreadcrumb('auth', 'User logged in successfully');
74
+ | Method | Description |
75
+ |--------|-------------|
76
+ | `configure(config)` | Set endpoint, headers, sampling, batching, `onError`, etc. |
77
+ | `addBreadcrumb(category, message, data?)` | Add a step to the timeline. |
78
+ | `sendError(error, context?)` | Send an error manually (e.g. from `catch`). |
79
+ | `getBreadcrumbs()` | Current breadcrumbs. |
80
+ | `clearBreadcrumbs()` | Clear the list. |
81
+ | `getStats()` | Queue length, retry status. |
82
+ | `flush()` | Send pending data now. |
83
+ | `destroy()` | Stop capturing and clean up. |
121
84
 
122
- // Breadcrumb with data
123
- syntropyFront.addBreadcrumb('commerce', 'Item added to cart', {
124
- productId: 'abc-123',
125
- price: 49.99,
126
- currency: 'USD'
127
- });
128
- ```
85
+ ---
129
86
 
130
- ### 🚨 Manual Error Reporting
131
- You can manually send errors that you catch in your own `try/catch` blocks:
87
+ ## Optional: PII masking
132
88
 
133
- ```javascript
134
- try {
135
- performRiskyOperation();
136
- } catch (error) {
137
- syntropyFront.sendError(error, {
138
- severity: 'critical',
139
- userId: 'user_99'
140
- });
141
- }
142
- ```
89
+ Sensitive data is masked before leaving the client (emails, tokens, cards, SSN/phone patterns). You can add custom rules via `configure({ maskingRules: [...] })`. See the [full config example](#advanced-configuration) below.
143
90
 
144
91
  ---
145
92
 
146
- ## 🛡️ Sensitive Data Protection (PII Masking)
147
-
148
- SyntropyFront automatically protects your users' privacy. The `DataMaskingManager` detects and obfuscates:
149
- - Email addresses (`j***@example.com`)
150
- - Authentication tokens and passwords
151
- - Credit card numbers (keeps only the last 4 digits)
152
- - SSN and phone numbers
93
+ ## Advanced configuration
153
94
 
154
- ### Custom Rules Configuration
155
95
  ```javascript
156
96
  syntropyFront.configure({
157
- maskingRules: [
158
- {
159
- pattern: /custom_id_\d+/i,
160
- mask: 'HIDDEN_ID'
161
- }
162
- ]
97
+ endpoint: 'https://your-api.com/v1/telemetry',
98
+ headers: { 'Authorization': 'Bearer token', 'X-Environment': 'production' },
99
+ samplingRate: 0.1, // send 10% of events
100
+ batchSize: 10,
101
+ batchTimeout: 5000,
102
+ usePersistentBuffer: true, // retry when offline (IndexedDB)
103
+ onError: (payload) => {
104
+ console.warn('Error captured:', payload.type);
105
+ return payload;
106
+ },
107
+ context: { device: true, window: ['url', 'title'], storage: false }
163
108
  });
164
109
  ```
165
110
 
166
- ## 🏗️ Modular Architecture and Tree Shaking
167
-
168
- In a future version (e.g. 0.5.0), interceptors may be exposed as independent modules. To minimize your bundle size, you would then import only what you need:
169
-
170
- ```javascript
171
- // Instead of global import, use specific interceptors directly
172
- // (Coming soon in the granular export API)
173
- ```
174
-
175
- ### Core Structure
176
- The system is divided into managers with unique responsibilities:
177
- - **QueueManager**: Manages batching and output flow.
178
- - **RetryManager**: Handles smart retries with incremental waits.
179
- - **SerializationManager**: Ensures data is safe for transmission over the network.
180
- - **ContextCollector**: Collects device information and user environment context.
181
-
182
- ## 📊 Quality Metrics
183
-
184
- We take stability seriously. SyntropyFront maintains:
185
- - **Test Coverage**: **87%** (All files).
186
- - **Stryker Mutation Score**: **>71%** (Our tests truly verify logic, they don't just "pass through" it).
187
- - **Zero Dependencies**: We don't add third-party vulnerabilities to your project.
188
-
189
- ## 📖 API Reference
190
-
191
- ### `syntropyFront.configure(config)`
192
- Updates the global configuration of the agent.
193
-
194
- ### `syntropyFront.addBreadcrumb(category, message, data)`
195
- Adds a manual milestone to the timeline.
196
- - `category`: String (e.g., 'auth', 'ui', 'action')
197
- - `message`: Description of the event.
198
- - `data`: (Optional) Object with additional metadata.
111
+ **Context fields** (when enabled): `device`, `window`, `network`, `session`, `ui`, `performance`, `storage`. See docs in the repo for the full list.
199
112
 
200
- ### `syntropyFront.sendError(error, context)`
201
- Manually reports an error.
202
- - `error`: Error object or string.
203
- - `context`: (Optional) Additional data to send with this specific error.
204
-
205
- ### `syntropyFront.flush()`
206
- Forces the immediate sending of all pending events in the queue.
207
-
208
- ### `syntropyFront.getBreadcrumbs()`
209
- Returns the list of current breadcrumbs in memory.
210
-
211
- ### `syntropyFront.clearBreadcrumbs()`
212
- Clears the temporary breadcrumb history.
113
+ ---
213
114
 
214
- ### `syntropyFront.getStats()`
215
- Returns an object with library performance statistics (queue length, retry status, etc.).
115
+ ## Design (short)
216
116
 
217
- ### `syntropyFront.destroy()`
218
- Deactivates all interceptors and stops the agent.
117
+ Built to be predictable and safe: SOLID-style modules, pure functions where it matters, PII masking by default. Data goes only to your endpoint or callback—see [SECURITY.md](SECURITY.md).
219
118
 
220
119
  ---
221
120
 
222
- ## 🔍 Advanced Context Collection
121
+ ## Quality
223
122
 
224
- You can precisely control what environment data is collected when an error occurs.
225
-
226
- ```javascript
227
- syntropyFront.configure({
228
- context: {
229
- // Collect all default fields for these types
230
- device: true,
231
- network: true,
232
-
233
- // Collect ONLY specific fields
234
- window: ['url', 'title', 'viewport'],
235
- performance: ['memory'],
236
-
237
- // Explicitly disable a type
238
- storage: false
239
- }
240
- });
241
- ```
123
+ - **87%** test coverage
124
+ - **Zero** runtime dependencies
125
+ - **Mutation testing** (Stryker) >71%
242
126
 
243
- ### Available Context Fields
244
- - **`device`**: `userAgent`, `language`, `screen`, `timezone`, `cookieEnabled`.
245
- - **`window`**: `url`, `pathname`, `referrer`, `title`, `viewport`.
246
- - **`storage`**: `localStorage`, `sessionStorage` (size and keys only, no values).
247
- - **`network`**: `online`, `connection` (type, downlink).
248
- - **`ui`**: `focused`, `visibility`, `activeElement`.
249
- - **`performance`**: `memory` (heap usage), `timing`.
250
- - **`session`**: `sessionId`, `startTime`, `pageLoadTime`.
127
+ ---
251
128
 
252
- ## 🛠️ Local Development
129
+ ## Examples
253
130
 
254
- If you want to contribute or test the library locally:
131
+ **[examples/README.md](examples/README.md)** Overview and how to run each demo.
255
132
 
256
- 1. **Clone and Install**:
257
- ```bash
258
- git clone https://github.com/Syntropysoft/syntropyfront.git
259
- cd syntropyfront
260
- pnpm install
261
- ```
133
+ | Example | Description |
134
+ |---------|-------------|
135
+ | [basic-usage.html](examples/basic-usage.html) | Vanilla HTML, no build. Run `pnpm run build` then open file:// or use a static server. |
136
+ | [HTML demos](examples/README.md#examples) | More: circular-references, worker, presets, proxy-tracking, lazy-loading, lazy-initialization, custom-objects. |
137
+ | [react-example](examples/react-example/) | React 18. `cd react-example && pnpm install && pnpm start` |
138
+ | [vue-example](examples/vue-example/) | Vue 3 + Vite. `cd vue-example && pnpm install && pnpm run dev` |
139
+ | [svelte-example](examples/svelte-example/) | Svelte 4 + Vite. `cd svelte-example && pnpm install && pnpm run dev` |
262
140
 
263
- 2. **Run Tests**:
264
- ```bash
265
- npm test # Run all tests
266
- npm run test:watch # Watch mode
267
- ```
141
+ ## Contributing / local dev
268
142
 
269
- 3. **Build**:
270
- ```bash
271
- npm run build
272
- ```
143
+ ```bash
144
+ git clone https://github.com/Syntropysoft/syntropyfront.git
145
+ cd syntropyfront
146
+ pnpm install
147
+ pnpm test
148
+ pnpm run build
149
+ ```
273
150
 
274
- ## 📄 License
151
+ ---
275
152
 
276
- This project is licensed under the **Apache License 2.0**. You can freely use, modify, and distribute it in commercial projects.
153
+ ## License
277
154
 
278
- ---
155
+ **Apache-2.0** — use in commercial and open-source projects.
279
156
 
280
- **Developed with ❤️ for a clearer and more stable web.**
157
+ **Developed for a clearer and more stable web.**
package/SECURITY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Security Policy
2
2
 
3
+ ## Network Access
4
+
5
+ This package performs **outgoing HTTP requests only** to the URL that **you** configure via `configure({ endpoint })` or your `onError` callback. No requests are made to third-party servers, to the maintainers, or to any URL not under your control. No telemetry or analytics are sent by the library. You own the destination and the data.
6
+
3
7
  ## Supported Versions
4
8
 
5
9
  Only the latest version of SyntropyFront is supported for security updates.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@syntropysoft/syntropyfront",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "type": "module",
5
- "description": "🚀 Observability library with automatic capture - Just 1 line of code! Automatically captures clicks, errors, HTTP calls, and console logs with flexible error handling.",
5
+ "description": "One line of code to capture frontend errors and user actions. Low cost, no per-seat pricing. Saves time, money, and reputation.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
@@ -24,6 +24,22 @@
24
24
  "SECURITY.md",
25
25
  "CODE_OF_CONDUCT.md"
26
26
  ],
27
+ "scripts": {
28
+ "build": "rollup -c",
29
+ "build:watch": "rollup -c -w",
30
+ "dev": "pnpm run build:watch",
31
+ "test": "jest",
32
+ "test:watch": "jest --watch",
33
+ "test:coverage": "jest --config jest.config.coverage.cjs",
34
+ "test:mutation": "stryker run",
35
+ "test:mutation:watch": "stryker run",
36
+ "test:mutation:quick": "stryker run stryker.quick.conf.json",
37
+ "clean": "rm -rf dist",
38
+ "lint": "eslint src --ext .js",
39
+ "lint:fix": "eslint src --ext .js --fix",
40
+ "postbuild": "cp src/index.d.ts dist/index.d.ts",
41
+ "prepublishOnly": "pnpm run clean && pnpm run build && pnpm test"
42
+ },
27
43
  "keywords": [
28
44
  "frontend",
29
45
  "frontend-monitoring",
@@ -34,33 +50,32 @@
34
50
  "automatic-capture",
35
51
  "click-tracking",
36
52
  "http-monitoring",
37
- "console-logging",
38
53
  "error-handling",
54
+ "crash-reporting",
55
+ "exception-handling",
56
+ "error-reporting",
39
57
  "apm",
58
+ "RUM",
59
+ "real-user-monitoring",
40
60
  "debugging",
41
- "performance-monitoring",
61
+ "production-errors",
62
+ "Sentry-alternative",
63
+ "lightweight",
64
+ "zero-dependencies",
42
65
  "vanilla-js",
43
66
  "framework-agnostic",
44
67
  "client-side",
45
- "logging",
46
- "bug-tracking",
47
- "real-user-monitoring",
48
- "RUM",
49
- "Sentry-alternative",
50
68
  "react",
51
69
  "vue",
52
70
  "svelte",
53
71
  "typescript",
54
72
  "javascript",
55
- "web-analytics",
56
- "user-behavior",
57
- "crash-reporting",
58
- "exception-handling",
73
+ "console-logging",
74
+ "logging",
75
+ "bug-tracking",
59
76
  "telemetry",
60
77
  "application-monitoring",
61
- "error-reporting",
62
- "user-experience",
63
- "web-performance"
78
+ "user-behavior"
64
79
  ],
65
80
  "author": {
66
81
  "name": "Syntropysoft",
@@ -105,24 +120,17 @@
105
120
  "jest-environment-jsdom": "^30.2.0",
106
121
  "rollup": "^4.59.0"
107
122
  },
123
+ "pnpm": {
124
+ "overrides": {
125
+ "serialize-javascript": "^7.0.3"
126
+ },
127
+ "ignoredBuiltDependencies": [
128
+ "unrs-resolver"
129
+ ]
130
+ },
108
131
  "browserslist": [
109
132
  "> 1%",
110
133
  "last 2 versions",
111
134
  "not dead"
112
- ],
113
- "scripts": {
114
- "build": "rollup -c",
115
- "build:watch": "rollup -c -w",
116
- "dev": "pnpm run build:watch",
117
- "test": "jest",
118
- "test:watch": "jest --watch",
119
- "test:coverage": "jest --config jest.config.coverage.cjs",
120
- "test:mutation": "stryker run",
121
- "test:mutation:watch": "stryker run",
122
- "test:mutation:quick": "stryker run stryker.quick.conf.json",
123
- "clean": "rm -rf dist",
124
- "lint": "eslint src --ext .js",
125
- "lint:fix": "eslint src --ext .js --fix",
126
- "postbuild": "cp src/index.d.ts dist/index.d.ts"
127
- }
135
+ ]
128
136
  }