@pmate/log-sdk 0.2.0 → 0.2.1
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 +23 -0
- package/dist/browser.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,3 +53,26 @@ Use authenticatedProfile from server authentication, never a client body/header.
|
|
|
53
53
|
|
|
54
54
|
## Counting
|
|
55
55
|
The envelope `id` is the event deduplication key. PV counts pv events; sessions deduplicate `(appId, accessId)`; Profile UV deduplicates `(appId, profileId)` in a defined time window/topic. Missing identifiers are reported separately. Never count HTTP requests or vitals as page views, or infer first-ever visits from a limited retention window.
|
|
56
|
+
|
|
57
|
+
## Error and crash diagnostics
|
|
58
|
+
|
|
59
|
+
Caught exceptions need explicit reporting; a global rejection listener cannot see
|
|
60
|
+
an exception already handled by application code. Use `log.captureError(error,
|
|
61
|
+
{ operation: 'chat.send' })` on browser, React and Node loggers. Error records use
|
|
62
|
+
the `error` topic and include bounded message/stack diagnostics with URL queries
|
|
63
|
+
removed. Applications must redact domain-specific sensitive strings before
|
|
64
|
+
calling this method.
|
|
65
|
+
|
|
66
|
+
Inside `LogProvider`, wrap the application in `LogErrorBoundary` with a `fallback`
|
|
67
|
+
React node. It reports descendant render/lifecycle failures with component stacks.
|
|
68
|
+
Event handlers, asynchronous operations and errors above the boundary require
|
|
69
|
+
separate reporting. Explicitly allowlisted `log.fetch` requests report non-2xx and
|
|
70
|
+
network failures without bodies or request URLs.
|
|
71
|
+
|
|
72
|
+
Node exports `installCrashReporter({ directory, send })`. Install it before
|
|
73
|
+
starting the service. It monitors fatal exceptions without suppressing Node's
|
|
74
|
+
fatal exit, persists up to 20 records, and exposes `replay()` for startup recovery.
|
|
75
|
+
The `send(entry)` callback must resolve only after server acknowledgement, retain
|
|
76
|
+
entry ID/time, and route records to the service's `crash` topic. Failed uploads
|
|
77
|
+
remain on disk. Use a service-specific private persistent directory. It cannot
|
|
78
|
+
capture SIGKILL, OOM kills, native faults, or failures before installation.
|
package/dist/browser.js
CHANGED
|
@@ -97,7 +97,14 @@ export function createLogger(options) {
|
|
|
97
97
|
if (!validId(headers.get(REQUEST_HEADER)))
|
|
98
98
|
headers.set(REQUEST_HEADER, crypto.randomUUID());
|
|
99
99
|
// Refuse redirects so correlation headers cannot leak to another origin.
|
|
100
|
-
return fetch(input, { ...init, headers, redirect: "error" })
|
|
100
|
+
return fetch(input, { ...init, headers, redirect: "error" }).then(response => {
|
|
101
|
+
if (!response.ok)
|
|
102
|
+
transport.append("error", { data: { event: "http.client.failed", origin: url.origin, status: response.status, requestId: headers.get(REQUEST_HEADER), serverRequestId: response.headers.get(REQUEST_HEADER) } });
|
|
103
|
+
return response;
|
|
104
|
+
}, error => {
|
|
105
|
+
transport.append("error", errorInput(error, { operation: "http.fetch" }));
|
|
106
|
+
throw error;
|
|
107
|
+
});
|
|
101
108
|
}
|
|
102
109
|
return fetch(input, init);
|
|
103
110
|
},
|