@orbitai/orbitrace 1.1.11 → 1.1.12

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.
Files changed (3) hide show
  1. package/README.md +12 -1
  2. package/dist/index.js +52 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -59,7 +59,6 @@ try {
59
59
  ```javascript
60
60
  await orbitrace.captureMessage("User registered", {
61
61
  userId: "123",
62
- email: "user@example.com",
63
62
  });
64
63
  ```
65
64
 
@@ -78,6 +77,18 @@ In short-lived processes (scripts, CI jobs, serverless functions), call `flush()
78
77
  await orbitrace.flush();
79
78
  ```
80
79
 
80
+ ## Data Collected
81
+
82
+ Each event stores:
83
+
84
+ - The error message (truncated to 200 characters) and stack trace, or the message text.
85
+ - The `metadata` object you pass, plus `env`, `version` and `service` from your configuration.
86
+ - The IP address and user agent of the server that sent the request, with an approximate location derived from that IP.
87
+
88
+ Before sending, metadata values whose key contains `password`, `passwd`, `secret`, `token`, `authorization`, `cookie`, `apikey`, `privatekey`, `credential` or `session` (ignoring case, `-` and `_`) are replaced with `[Filtered]`, at any depth. Error messages and stack traces are sent as they are.
89
+
90
+ Filtering is a safety net, not a guarantee. Do not put personal data (emails, names, addresses) or secrets in metadata or error messages; send stable identifiers such as a user id instead.
91
+
81
92
  ## Environment Variables
82
93
 
83
94
  ```env
package/dist/index.js CHANGED
@@ -5,6 +5,57 @@ const DEDUPE_WINDOW_MS = 10000;
5
5
  // Caps concurrent requests so a loop of distinct errors cannot exhaust the host's sockets or memory.
6
6
  const MAX_IN_FLIGHT = 10;
7
7
  const DEFAULT_RETRY_AFTER_SECONDS = 60;
8
+ // Metadata keys containing any of these (ignoring case, "-" and "_") have their values replaced before sending.
9
+ const SENSITIVE_KEY_PARTS = [
10
+ "password",
11
+ "passwd",
12
+ "secret",
13
+ "token",
14
+ "authorization",
15
+ "cookie",
16
+ "apikey",
17
+ "privatekey",
18
+ "credential",
19
+ "session",
20
+ ];
21
+ const FILTERED_VALUE = "[Filtered]";
22
+
23
+ function isSensitiveKey(key) {
24
+ const normalized = key.toLowerCase().replace(/[-_]/g, "");
25
+ return SENSITIVE_KEY_PARTS.some((part) => normalized.includes(part));
26
+ }
27
+
28
+ // Recurses only into plain objects and arrays so values like Date keep their JSON form.
29
+ // `ancestors` breaks reference cycles, which would otherwise make the request body unserializable.
30
+ function filterSensitive(value, ancestors = new WeakSet()) {
31
+ if (value === null || typeof value !== "object") {
32
+ return value;
33
+ }
34
+
35
+ if (ancestors.has(value)) {
36
+ return "[Circular]";
37
+ }
38
+
39
+ const isArray = Array.isArray(value);
40
+ const prototype = Object.getPrototypeOf(value);
41
+
42
+ if (!isArray && prototype !== Object.prototype && prototype !== null) {
43
+ return value;
44
+ }
45
+
46
+ ancestors.add(value);
47
+ const filtered = isArray
48
+ ? value.map((item) => filterSensitive(item, ancestors))
49
+ : Object.fromEntries(
50
+ Object.entries(value).map(([key, item]) => [
51
+ key,
52
+ isSensitiveKey(key) ? FILTERED_VALUE : filterSensitive(item, ancestors),
53
+ ])
54
+ );
55
+ ancestors.delete(value);
56
+
57
+ return filtered;
58
+ }
8
59
 
9
60
  class Orbitrace {
10
61
  static #config = null;
@@ -82,7 +133,7 @@ class Orbitrace {
82
133
  const payload = {
83
134
  ...fields,
84
135
  metadata: {
85
- ...metadata,
136
+ ...filterSensitive(metadata),
86
137
  env: this.#config.environment,
87
138
  version: this.#config.version,
88
139
  service: this.#config.service,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbitai/orbitrace",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "Error tracking and monitoring for backend Node.js applications",
5
5
  "main": "dist/index.js",
6
6
  "files": [