@loggerjs/browser 0.5.2 → 0.5.4

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
@@ -58,7 +58,7 @@ Logs batch over HTTP, queue while offline, replay with backoff when the network
58
58
  | Transport | Delivers to |
59
59
  | --- | --- |
60
60
  | `browserHttpTransport` | your collector — batching, offline queue, online replay with backoff, `sendBeacon` on page hide |
61
- | `indexedDbTransport` | a local, queryable IndexedDB store (TTL, pruning, optional Storage Buckets and durability hints) |
61
+ | `indexedDbTransport` | a local, queryable IndexedDB store (session indexes, TTL, pruning, optional Storage Buckets, durability hints, and optional localStorage spill) |
62
62
  | `browserWebSocketTransport` | a WebSocket (codec-encoded batches, queues while closed) |
63
63
  | `browserServiceWorkerTransport` | a service worker for centralized delivery; `ready()` waits for `serviceWorker.ready` with `target: "ready"` |
64
64
  | `browserBroadcastChannelTransport` | other tabs via `BroadcastChannel` |
@@ -68,9 +68,47 @@ Logs batch over HTTP, queue while offline, replay with backoff when the network
68
68
 
69
69
  - `memoryBrowserHttpOfflineQueue()` — short-lived in-memory retry buffer.
70
70
  - `indexedDbBrowserHttpOfflineQueue()` — survives page reloads.
71
- - `exportLogsToZip()` + `downloadBlob()` — export a persisted store as a zip containing `logs.ndjson` and `manifest.json`.
71
+ - `exportLogsToZip()` + `downloadBlob()` — export a persisted store as a zip containing `logs.ndjson` or `logs.json`, `manifest.json`, optional per-session files, and optional `recent.ndjson` or `recent.json`.
72
72
  - Call the `indexedDbTransport()` instance's `stats()` to read flush, prune, query, drop, and buffer-depth counters.
73
73
 
74
+ For a support-log store that survives reloads and exports per page session, the
75
+ short setup is:
76
+
77
+ ```ts
78
+ import { createLogger } from "@loggerjs/core";
79
+ import { indexedDbTransport } from "@loggerjs/browser/transport-indexeddb";
80
+ import { downloadBlob, exportLogsToZip } from "@loggerjs/browser/export-zip";
81
+ import { privacyGuardProcessor, redactProcessor } from "@loggerjs/processors";
82
+
83
+ const supportStore = indexedDbTransport({
84
+ dbName: "my-app-support-logs",
85
+ localStorageSpill: { namespace: "my-app-support-logs" },
86
+ });
87
+
88
+ export const logger = createLogger({
89
+ category: ["web"],
90
+ processors: [redactProcessor(), privacyGuardProcessor()],
91
+ transports: [supportStore],
92
+ });
93
+
94
+ export async function downloadSupportLogs() {
95
+ await logger.flush();
96
+ const zip = await exportLogsToZip(supportStore, {
97
+ groupBySession: true,
98
+ includeRecent: true,
99
+ query: { order: "asc" },
100
+ });
101
+ downloadBlob(zip, "support-logs.zip");
102
+ }
103
+ ```
104
+
105
+ `indexedDbTransport()` assigns a page-session id by default for browser support
106
+ stores. Use `query({ sessionId })`, `sessions()`, and
107
+ `exportLogsToZip(..., { groupBySession: true, includeRecent: true })` to build
108
+ support bundles around reload-sized sessions. Enable `localStorageSpill` only
109
+ as a bounded last-chance buffer for the still-unconfirmed memory tail during
110
+ ordinary reloads or tab closes; IndexedDB remains the queryable source of truth.
111
+
74
112
  Browser delivery has runtime loss windows: tab close can cut off async work,
75
113
  `sendBeacon` is size- and user-agent-limited, service worker delivery depends on
76
114
  activation and lifetime, and IndexedDB persistence depends on quota and browser