@tracelog/lib 2.9.0-rc.107.4 → 2.9.0-rc.108.13

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
@@ -127,7 +127,9 @@ tracelog.destroy();
127
127
  | Method | Description |
128
128
  |--------|-------------|
129
129
  | `init(config?)` | Initialize tracking (see [Configuration](#configuration)) |
130
- | `event(name, metadata?)` | Track custom events |
130
+ | `event(name, metadata?, options?)` | Track custom events. `options.critical: true` triggers a double-write delivery (dedicated single-event `sendBeacon` + main-queue drain) so the event survives an imminent navigation. Backend must deduplicate by `event.id`. See [API_REFERENCE.md](./API_REFERENCE.md#eventname-metadata-options) for the full contract. |
131
+ | `flushImmediately()` | Force an async `fetch` flush of all pending events. Returns `Promise<boolean>`. |
132
+ | `flushImmediatelySync()` | Force a `sendBeacon` flush. Use for custom unload handlers; the library already wires this to `pagehide`/`beforeunload`/`visibilitychange`. |
131
133
  | `updateGlobalMetadata(metadata)` | Replace all global metadata |
132
134
  | `mergeGlobalMetadata(metadata)` | Merge with existing global metadata |
133
135
  | `on(event, callback)` | Subscribe to events (`'event'` or `'queue'`) |
@@ -189,6 +191,10 @@ await tracelog.init({
189
191
  samplingRate: 1.0, // 100% (default)
190
192
  sensitiveQueryParams: ['token'], // Add to defaults
191
193
 
194
+ // Flush behavior (defaults below; both flags default to true)
195
+ flushOnSpaNavigation: true, // Flush after pushState/replaceState/popstate/hashchange
196
+ flushOnPageHidden: true, // Flush when document.hidden becomes true (mobile Safari coverage)
197
+
192
198
  // Integrations (pick one, multiple, or none)
193
199
  integrations: {
194
200
  tracelog: { projectId: 'your-id' }, // TraceLog SaaS