@tracelog/lib 0.7.3 → 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 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