@tracelog/lib 0.7.2 → 0.8.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 +18 -1
- package/dist/browser/tracelog.esm.js +687 -655
- package/dist/browser/tracelog.esm.js.map +1 -1
- package/dist/browser/tracelog.js +2 -2
- package/dist/browser/tracelog.js.map +1 -1
- package/dist/cjs/constants/config.constants.d.ts +1 -1
- package/dist/cjs/constants/config.constants.js +2 -2
- package/dist/cjs/constants/error.constants.d.ts +6 -0
- package/dist/cjs/constants/error.constants.js +10 -1
- package/dist/cjs/managers/sender.manager.d.ts +2 -0
- package/dist/cjs/managers/sender.manager.js +74 -9
- package/dist/cjs/types/error.types.d.ts +11 -0
- package/dist/cjs/types/error.types.js +22 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/esm/constants/config.constants.d.ts +1 -1
- package/dist/esm/constants/config.constants.js +2 -2
- package/dist/esm/constants/error.constants.d.ts +6 -0
- package/dist/esm/constants/error.constants.js +9 -0
- package/dist/esm/managers/sender.manager.d.ts +2 -0
- package/dist/esm/managers/sender.manager.js +76 -11
- package/dist/esm/types/error.types.d.ts +11 -0
- package/dist/esm/types/error.types.js +18 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.js +1 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -162,11 +162,13 @@ Each event contains a base structure with type-specific data:
|
|
|
162
162
|
- `page_url`: Current page URL
|
|
163
163
|
- `timestamp`: Unix timestamp in milliseconds
|
|
164
164
|
- `referrer`: Document referrer (optional)
|
|
165
|
+
- `from_page_url`: Previous page URL (optional)
|
|
165
166
|
- `utm`: UTM parameters (source, medium, campaign, term, content)
|
|
166
167
|
|
|
167
168
|
**Event-specific data:**
|
|
168
169
|
|
|
169
170
|
- **`PAGE_VIEW`**: Navigation tracking
|
|
171
|
+
- `page_view.referrer`: Page referrer
|
|
170
172
|
- `page_view.title`: Page title
|
|
171
173
|
- `page_view.pathname`: URL pathname
|
|
172
174
|
- `page_view.search`: Query string
|
|
@@ -176,7 +178,7 @@ Each event contains a base structure with type-specific data:
|
|
|
176
178
|
- `click_data.x/y`: Viewport coordinates
|
|
177
179
|
- `click_data.relativeX/relativeY`: Element-relative position
|
|
178
180
|
- `click_data.tag/id/class`: Element identifiers
|
|
179
|
-
- `click_data.text/href/title`: Element content
|
|
181
|
+
- `click_data.text/href/title/alt`: Element content
|
|
180
182
|
- `click_data.role/ariaLabel`: Accessibility attributes
|
|
181
183
|
- `click_data.dataAttributes`: Data attributes
|
|
182
184
|
|
|
@@ -247,10 +249,25 @@ tracelog.init();
|
|
|
247
249
|
console.log(tracelog.isInitialized()); // true
|
|
248
250
|
```
|
|
249
251
|
|
|
252
|
+
## Error Handling & Retry Logic
|
|
253
|
+
|
|
254
|
+
TraceLog automatically handles network errors with intelligent retry logic:
|
|
255
|
+
|
|
256
|
+
- **Permanent errors (4xx)**: No retries - events are cleared immediately
|
|
257
|
+
- `400 Bad Request`, `403 Forbidden`, `404 Not Found` → Stop retrying
|
|
258
|
+
- Prevents infinite retry loops for configuration issues (e.g., excluded IPs, invalid projects)
|
|
259
|
+
|
|
260
|
+
- **Temporary errors (5xx)**: Automatic retry with exponential backoff
|
|
261
|
+
- `500`, `502`, `503`, `504` → Retry up to 3 times (5s, 10s, 20s delays)
|
|
262
|
+
- Events persist in localStorage for recovery across page reloads
|
|
263
|
+
|
|
264
|
+
- **Event expiry**: Persisted events expire after 2 hours to prevent stale data recovery
|
|
265
|
+
|
|
250
266
|
## Troubleshooting
|
|
251
267
|
|
|
252
268
|
- **Session issues**: Check localStorage availability and session timeout
|
|
253
269
|
- **Memory usage**: Reduce `sessionTimeout`, lower `samplingRate`, call `destroy()` on cleanup
|
|
270
|
+
- **Events not sending**: Check browser console for `PermanentError` logs indicating 4xx errors
|
|
254
271
|
- **CI failures**: Verify Playwright installation and Node.js ≥20
|
|
255
272
|
|
|
256
273
|
## Development & Contributing
|