@errio/core 1.0.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.
Files changed (50) hide show
  1. package/dist/classify.d.ts +11 -0
  2. package/dist/classify.d.ts.map +1 -0
  3. package/dist/classify.js +102 -0
  4. package/dist/classify.js.map +1 -0
  5. package/dist/client.d.ts +42 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +223 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/context.d.ts +29 -0
  10. package/dist/context.d.ts.map +1 -0
  11. package/dist/context.js +60 -0
  12. package/dist/context.js.map +1 -0
  13. package/dist/deploy.d.ts +29 -0
  14. package/dist/deploy.d.ts.map +1 -0
  15. package/dist/deploy.js +50 -0
  16. package/dist/deploy.js.map +1 -0
  17. package/dist/fingerprint.d.ts +30 -0
  18. package/dist/fingerprint.d.ts.map +1 -0
  19. package/dist/fingerprint.js +74 -0
  20. package/dist/fingerprint.js.map +1 -0
  21. package/dist/git.d.ts +12 -0
  22. package/dist/git.d.ts.map +1 -0
  23. package/dist/git.js +60 -0
  24. package/dist/git.js.map +1 -0
  25. package/dist/index.d.ts +12 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +21 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/redact.d.ts +19 -0
  30. package/dist/redact.d.ts.map +1 -0
  31. package/dist/redact.js +86 -0
  32. package/dist/redact.js.map +1 -0
  33. package/dist/sampling.d.ts +13 -0
  34. package/dist/sampling.d.ts.map +1 -0
  35. package/dist/sampling.js +23 -0
  36. package/dist/sampling.js.map +1 -0
  37. package/dist/serializer.d.ts +16 -0
  38. package/dist/serializer.d.ts.map +1 -0
  39. package/dist/serializer.js +92 -0
  40. package/dist/serializer.js.map +1 -0
  41. package/dist/transport.d.ts +39 -0
  42. package/dist/transport.d.ts.map +1 -0
  43. package/dist/transport.js +138 -0
  44. package/dist/transport.js.map +1 -0
  45. package/dist/types.d.ts +148 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/types.js +2 -0
  48. package/dist/types.js.map +1 -0
  49. package/package.json +47 -0
  50. package/src/index.ts +53 -0
@@ -0,0 +1,74 @@
1
+ import { createHash } from 'node:crypto';
2
+ /**
3
+ * Normalize an error message by stripping variable content.
4
+ * This improves dedup accuracy by removing noise like timestamps,
5
+ * line numbers, memory addresses, UUIDs, and temp paths.
6
+ */
7
+ export function normalizeMessage(message) {
8
+ return (message
9
+ // ISO timestamps
10
+ .replace(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})/g, '<TIMESTAMP>')
11
+ // Line:column numbers
12
+ .replace(/:\d+:\d+/g, ':<LINE>:<COL>')
13
+ // Line number patterns
14
+ .replace(/\bline\s+\d+/gi, 'line <N>')
15
+ // Hex addresses
16
+ .replace(/0x[0-9a-fA-F]{6,}/g, '<ADDR>')
17
+ // UUIDs
18
+ .replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, '<UUID>')
19
+ // Temp paths
20
+ .replace(/\/tmp\/[\w./-]+/g, '<TMPPATH>')
21
+ // Excessive whitespace
22
+ .replace(/\s+/g, ' ')
23
+ .trim());
24
+ }
25
+ /**
26
+ * Generate a stable fingerprint for dedup and issue grouping.
27
+ *
28
+ * @param components - Strings to include in the fingerprint (e.g., errorType, normalizedMessage)
29
+ * @returns SHA-256 hex hash
30
+ */
31
+ export function generateFingerprint(...components) {
32
+ const input = components.join(':');
33
+ return createHash('sha256').update(input).digest('hex');
34
+ }
35
+ /**
36
+ * In-memory dedup cache with TTL-based expiry.
37
+ * Prevents the same error from being sent multiple times within a short window.
38
+ */
39
+ export class DedupCache {
40
+ cache = new Map();
41
+ ttlMs;
42
+ constructor(ttlMs = 5 * 60 * 1000) {
43
+ this.ttlMs = ttlMs;
44
+ }
45
+ /** Returns true if the fingerprint was recently seen (within TTL). */
46
+ has(fingerprint) {
47
+ const ts = this.cache.get(fingerprint);
48
+ if (ts === undefined)
49
+ return false;
50
+ if (Date.now() - ts > this.ttlMs) {
51
+ this.cache.delete(fingerprint);
52
+ return false;
53
+ }
54
+ return true;
55
+ }
56
+ /** Record a fingerprint with the current timestamp. */
57
+ add(fingerprint) {
58
+ this.cache.set(fingerprint, Date.now());
59
+ this.cleanup();
60
+ }
61
+ /** Remove expired entries. */
62
+ cleanup() {
63
+ const now = Date.now();
64
+ for (const [key, ts] of this.cache) {
65
+ if (now - ts > this.ttlMs) {
66
+ this.cache.delete(key);
67
+ }
68
+ }
69
+ }
70
+ get size() {
71
+ return this.cache.size;
72
+ }
73
+ }
74
+ //# sourceMappingURL=fingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,CACL,OAAO;QACL,iBAAiB;SAChB,OAAO,CAAC,sEAAsE,EAAE,aAAa,CAAC;QAC/F,sBAAsB;SACrB,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC;QACtC,uBAAuB;SACtB,OAAO,CAAC,gBAAgB,EAAE,UAAU,CAAC;QACtC,gBAAgB;SACf,OAAO,CAAC,oBAAoB,EAAE,QAAQ,CAAC;QACxC,QAAQ;SACP,OAAO,CAAC,gEAAgE,EAAE,QAAQ,CAAC;QACpF,aAAa;SACZ,OAAO,CAAC,kBAAkB,EAAE,WAAW,CAAC;QACzC,uBAAuB;SACtB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CACV,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,UAAoB;IACzD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,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AI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF"}
package/dist/git.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { GitInfo } from './types.js';
2
+ /**
3
+ * Parse a Git remote URL into an "owner/repo" string.
4
+ * Supports SSH and HTTPS URLs with or without .git suffix.
5
+ */
6
+ export declare function parseRepoFullName(remoteUrl: string): string | null;
7
+ /**
8
+ * Detect Git repository information from the current working directory.
9
+ * Returns null fields if git is not available or the directory is not a repo.
10
+ */
11
+ export declare function detectGitInfo(): GitInfo;
12
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUlE;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAuCvC"}
package/dist/git.js ADDED
@@ -0,0 +1,60 @@
1
+ import { execSync } from 'node:child_process';
2
+ /**
3
+ * Parse a Git remote URL into an "owner/repo" string.
4
+ * Supports SSH and HTTPS URLs with or without .git suffix.
5
+ */
6
+ export function parseRepoFullName(remoteUrl) {
7
+ // SSH: git@github.com:owner/repo.git
8
+ const sshMatch = remoteUrl.match(/git@[\w.-]+:([\w.-]+\/[\w.-]+?)(?:\.git)?$/);
9
+ if (sshMatch)
10
+ return sshMatch[1];
11
+ // HTTPS: https://github.com/owner/repo.git
12
+ const httpsMatch = remoteUrl.match(/https?:\/\/[\w.-]+\/([\w.-]+\/[\w.-]+?)(?:\.git)?$/);
13
+ if (httpsMatch)
14
+ return httpsMatch[1];
15
+ return null;
16
+ }
17
+ /**
18
+ * Detect Git repository information from the current working directory.
19
+ * Returns null fields if git is not available or the directory is not a repo.
20
+ */
21
+ export function detectGitInfo() {
22
+ const result = {
23
+ repoFullName: null,
24
+ commitSha: null,
25
+ branch: null,
26
+ };
27
+ try {
28
+ const remoteUrl = execSync('git config --get remote.origin.url', {
29
+ encoding: 'utf8',
30
+ stdio: ['pipe', 'pipe', 'pipe'],
31
+ timeout: 3000,
32
+ }).trim();
33
+ result.repoFullName = parseRepoFullName(remoteUrl);
34
+ }
35
+ catch {
36
+ // Not a git repo or git not available
37
+ }
38
+ try {
39
+ result.commitSha = execSync('git rev-parse HEAD', {
40
+ encoding: 'utf8',
41
+ stdio: ['pipe', 'pipe', 'pipe'],
42
+ timeout: 3000,
43
+ }).trim();
44
+ }
45
+ catch {
46
+ // Ignore
47
+ }
48
+ try {
49
+ result.branch = execSync('git rev-parse --abbrev-ref HEAD', {
50
+ encoding: 'utf8',
51
+ stdio: ['pipe', 'pipe', 'pipe'],
52
+ timeout: 3000,
53
+ }).trim();
54
+ }
55
+ catch {
56
+ // Ignore
57
+ }
58
+ return result;
59
+ }
60
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,qCAAqC;IACrC,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC/E,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEjC,2CAA2C;IAC3C,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACzF,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IAErC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,MAAM,GAAY;QACtB,YAAY,EAAE,IAAI;QAClB,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,IAAI;KACb,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,QAAQ,CAAC,oCAAoC,EAAE;YAC/D,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,OAAO,EAAE,IAAI;SACd,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,CAAC,YAAY,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;IACxC,CAAC;IAED,IAAI,CAAC;QACH,MAAM,CAAC,SAAS,GAAG,QAAQ,CAAC,oBAAoB,EAAE;YAChD,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,OAAO,EAAE,IAAI;SACd,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IAED,IAAI,CAAC;QACH,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,iCAAiC,EAAE;YAC1D,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,OAAO,EAAE,IAAI;SACd,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export { ErrioClient } from './client.js';
2
+ export type { ErrioConfig, ResolvedConfig, ErrioPlugin, ErrioClientInterface, ErrorEvent, ErrorType, Severity, CaptureOptions, CauseEntry, Breadcrumb, RequestContext, ApiResponse, GitInfo, } from './types.js';
3
+ export { getContext, setContext, runWithContext, addBreadcrumb, getBreadcrumbs, clearBreadcrumbs, } from './context.js';
4
+ export { classifyError, defaultSeverity } from './classify.js';
5
+ export { generateFingerprint, normalizeMessage, DedupCache } from './fingerprint.js';
6
+ export { serializeCauseChain, extractFilePaths } from './serializer.js';
7
+ export { redactString, redactObject } from './redact.js';
8
+ export { shouldSample } from './sampling.js';
9
+ export { detectGitInfo, parseRepoFullName } from './git.js';
10
+ export { BatchTransport } from './transport.js';
11
+ export { reportDeploy, type DeployInfo } from './deploy.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,YAAY,EACV,WAAW,EACX,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,QAAQ,EACR,cAAc,EACd,UAAU,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,OAAO,GACR,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAG/D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGrF,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG5D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ // Client
2
+ export { ErrioClient } from './client.js';
3
+ // Context propagation
4
+ export { getContext, setContext, runWithContext, addBreadcrumb, getBreadcrumbs, clearBreadcrumbs, } from './context.js';
5
+ // Classification
6
+ export { classifyError, defaultSeverity } from './classify.js';
7
+ // Fingerprinting and dedup
8
+ export { generateFingerprint, normalizeMessage, DedupCache } from './fingerprint.js';
9
+ // Serialization and file path extraction
10
+ export { serializeCauseChain, extractFilePaths } from './serializer.js';
11
+ // PII and secret redaction
12
+ export { redactString, redactObject } from './redact.js';
13
+ // Sampling
14
+ export { shouldSample } from './sampling.js';
15
+ // Git detection
16
+ export { detectGitInfo, parseRepoFullName } from './git.js';
17
+ // Transport
18
+ export { BatchTransport } from './transport.js';
19
+ // Deploy reporting
20
+ export { reportDeploy } from './deploy.js';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmB1C,sBAAsB;AACtB,OAAO,EACL,UAAU,EACV,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE/D,2BAA2B;AAC3B,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErF,yCAAyC;AACzC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExE,2BAA2B;AAC3B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,WAAW;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,gBAAgB;AAChB,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE5D,YAAY;AACZ,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,mBAAmB;AACnB,OAAO,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PII and secret redaction for error messages, stack traces, and metadata.
3
+ *
4
+ * This runs before events are sent to the API to prevent accidental
5
+ * exposure of sensitive data. It uses pattern matching — not parsing —
6
+ * so it is fast but not exhaustive. Callers should also use allowlists
7
+ * for payload fields in production.
8
+ */
9
+ /**
10
+ * Redact secrets and PII from a string.
11
+ * Returns a new string with sensitive values replaced by [REDACTED].
12
+ */
13
+ export declare function redactString(input: string): string;
14
+ /**
15
+ * Redact secrets and PII from all string values in a plain object (shallow).
16
+ * Non-string values are left unchanged.
17
+ */
18
+ export declare function redactObject(obj: Record<string, unknown>): Record<string, unknown>;
19
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsCH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6BlD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAclF"}
package/dist/redact.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * PII and secret redaction for error messages, stack traces, and metadata.
3
+ *
4
+ * This runs before events are sent to the API to prevent accidental
5
+ * exposure of sensitive data. It uses pattern matching — not parsing —
6
+ * so it is fast but not exhaustive. Callers should also use allowlists
7
+ * for payload fields in production.
8
+ */
9
+ const REDACTION_PLACEHOLDER = '[REDACTED]';
10
+ const SECRET_PATTERNS = [
11
+ // API keys (common formats)
12
+ { pattern: /\b(sk[-_]live[-_][\w]{20,})\b/g, label: 'stripe_key' },
13
+ { pattern: /\b(sk-ant-[\w-]{20,})\b/g, label: 'anthropic_key' },
14
+ { pattern: /\b(sk-[\w]{20,})\b/g, label: 'openai_key' },
15
+ { pattern: /\b(ak_[\w]{32,})\b/g, label: 'errio_key' },
16
+ { pattern: /\b(ghp_[\w]{36,})\b/g, label: 'github_pat' },
17
+ { pattern: /\b(ghs_[\w]{36,})\b/g, label: 'github_server_token' },
18
+ { pattern: /\b(AKIA[\w]{16})\b/g, label: 'aws_access_key' },
19
+ { pattern: /\b(xox[bposa]-[\w-]{10,})\b/g, label: 'slack_token' },
20
+ // Generic bearer/auth tokens in headers
21
+ { pattern: /(Bearer\s+)[\w.=-]{20,}/gi, label: 'bearer_token' },
22
+ { pattern: /(Authorization:\s*)[\w.=-]{20,}/gi, label: 'auth_header' },
23
+ // Passwords in URLs (e.g., mysql://user:password@host)
24
+ { pattern: /:\/\/([\w.-]+):([^@\s]{3,})@/g, label: 'url_password' },
25
+ // Generic password/secret assignments
26
+ { pattern: /(password|passwd|secret|token|api_key|apikey|access_key|private_key)\s*[=:]\s*['"]?([^\s'"]{8,})/gi, label: 'key_value_secret' },
27
+ // JWTs (3 base64 segments separated by dots)
28
+ { pattern: /\beyJ[\w-]+\.eyJ[\w-]+\.[\w-]+\b/g, label: 'jwt' },
29
+ // Email addresses
30
+ { pattern: /\b[\w.+-]+@[\w.-]+\.\w{2,}\b/g, label: 'email' },
31
+ // SSN-like patterns (US)
32
+ { pattern: /\b\d{3}-\d{2}-\d{4}\b/g, label: 'ssn' },
33
+ // Credit card numbers (basic Luhn-candidate patterns)
34
+ { pattern: /\b(?:\d{4}[-\s]?){3}\d{4}\b/g, label: 'credit_card' },
35
+ ];
36
+ /**
37
+ * Redact secrets and PII from a string.
38
+ * Returns a new string with sensitive values replaced by [REDACTED].
39
+ */
40
+ export function redactString(input) {
41
+ if (!input)
42
+ return input;
43
+ let result = input;
44
+ for (const { pattern, label } of SECRET_PATTERNS) {
45
+ // Reset regex state (global flag means lastIndex persists)
46
+ pattern.lastIndex = 0;
47
+ switch (label) {
48
+ case 'url_password':
49
+ // Preserve the URL structure but redact the password
50
+ result = result.replace(pattern, `://$1:${REDACTION_PLACEHOLDER}@`);
51
+ break;
52
+ case 'key_value_secret':
53
+ // Preserve the key name, redact the value
54
+ result = result.replace(pattern, `$1=${REDACTION_PLACEHOLDER}`);
55
+ break;
56
+ case 'bearer_token':
57
+ case 'auth_header':
58
+ // Preserve the prefix, redact the token
59
+ result = result.replace(pattern, `$1${REDACTION_PLACEHOLDER}`);
60
+ break;
61
+ default:
62
+ result = result.replace(pattern, REDACTION_PLACEHOLDER);
63
+ }
64
+ }
65
+ return result;
66
+ }
67
+ /**
68
+ * Redact secrets and PII from all string values in a plain object (shallow).
69
+ * Non-string values are left unchanged.
70
+ */
71
+ export function redactObject(obj) {
72
+ const result = {};
73
+ for (const [key, value] of Object.entries(obj)) {
74
+ if (typeof value === 'string') {
75
+ result[key] = redactString(value);
76
+ }
77
+ else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
78
+ result[key] = redactObject(value);
79
+ }
80
+ else {
81
+ result[key] = value;
82
+ }
83
+ }
84
+ return result;
85
+ }
86
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAE3C,MAAM,eAAe,GAA8C;IACjE,4BAA4B;IAC5B,EAAE,OAAO,EAAE,gCAAgC,EAAE,KAAK,EAAE,YAAY,EAAE;IAClE,EAAE,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAE,eAAe,EAAE;IAC/D,EAAE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,YAAY,EAAE;IACvD,EAAE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,WAAW,EAAE;IACtD,EAAE,OAAO,EAAE,sBAAsB,EAAE,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AAS,qBAAqB,GAAG,CAAC,CAAC;gBACpE,MAAM;YACR,KAAK,kBAAkB;gBACrB,0CAA0C;gBAC1C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,qBAAqB,EAAE,CAAC,CAAC;gBAChE,MAAM;YACR,KAAK,cAAc,CAAC;YACpB,KAAK,aAAa;gBAChB,wCAAwC;gBACxC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,qBAAqB,EAAE,CAAC,CAAC;gBAC/D,MAAM;YACR;gBACE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAA4B;IACvD,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChF,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,KAAgC,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Deterministic sampling based on fingerprint hash.
3
+ *
4
+ * Given the same fingerprint and sample rate, this always returns the same
5
+ * decision. This ensures related events within the same dedup window are
6
+ * consistently included or excluded.
7
+ *
8
+ * @param fingerprint - Stable identifier for the event (e.g., error fingerprint)
9
+ * @param sampleRate - Value between 0.0 (drop all) and 1.0 (keep all)
10
+ * @returns true if the event should be sampled (kept)
11
+ */
12
+ export declare function shouldSample(fingerprint: string, sampleRate: number): boolean;
13
+ //# sourceMappingURL=sampling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampling.d.ts","sourceRoot":"","sources":["../src/sampling.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAS7E"}
@@ -0,0 +1,23 @@
1
+ import { createHash } from 'node:crypto';
2
+ /**
3
+ * Deterministic sampling based on fingerprint hash.
4
+ *
5
+ * Given the same fingerprint and sample rate, this always returns the same
6
+ * decision. This ensures related events within the same dedup window are
7
+ * consistently included or excluded.
8
+ *
9
+ * @param fingerprint - Stable identifier for the event (e.g., error fingerprint)
10
+ * @param sampleRate - Value between 0.0 (drop all) and 1.0 (keep all)
11
+ * @returns true if the event should be sampled (kept)
12
+ */
13
+ export function shouldSample(fingerprint, sampleRate) {
14
+ if (sampleRate >= 1.0)
15
+ return true;
16
+ if (sampleRate <= 0.0)
17
+ return false;
18
+ // Use first 4 bytes of SHA-256 as a deterministic random value
19
+ const hash = createHash('sha256').update(fingerprint).digest();
20
+ const value = hash.readUInt32BE(0) / 0xffffffff;
21
+ return value < sampleRate;
22
+ }
23
+ //# sourceMappingURL=sampling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sampling.js","sourceRoot":"","sources":["../src/sampling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,UAAkB;IAClE,IAAI,UAAU,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,UAAU,IAAI,GAAG;QAAE,OAAO,KAAK,CAAC;IAEpC,+DAA+D;IAC/D,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;IAEhD,OAAO,KAAK,GAAG,UAAU,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { CauseEntry } from './types.js';
2
+ /**
3
+ * Walk the Error.cause chain and serialize each level into a flat array.
4
+ * Handles circular references and enforces a depth limit.
5
+ *
6
+ * @param error - The root error to serialize
7
+ * @returns Array of cause entries (root cause first, deepest last)
8
+ */
9
+ export declare function serializeCauseChain(error: Error): CauseEntry[];
10
+ /**
11
+ * Extract file paths from a stack trace string.
12
+ * Supports JavaScript/TypeScript, Python, Go, Java, Ruby formats.
13
+ * Excludes paths from node_modules, vendor, .yarn, and internal directories.
14
+ */
15
+ export declare function extractFilePaths(stackTrace: string): string[];
16
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,EAAE,CAyC9D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAmC7D"}
@@ -0,0 +1,92 @@
1
+ const MAX_CAUSE_DEPTH = 5;
2
+ const MAX_MESSAGE_LENGTH = 2000;
3
+ const MAX_STACK_LENGTH = 10000;
4
+ /**
5
+ * Walk the Error.cause chain and serialize each level into a flat array.
6
+ * Handles circular references and enforces a depth limit.
7
+ *
8
+ * @param error - The root error to serialize
9
+ * @returns Array of cause entries (root cause first, deepest last)
10
+ */
11
+ export function serializeCauseChain(error) {
12
+ const chain = [];
13
+ const seen = new WeakSet();
14
+ let current = error.cause;
15
+ let depth = 0;
16
+ while (current && depth < MAX_CAUSE_DEPTH) {
17
+ if (typeof current === 'object' && current !== null) {
18
+ // Circular reference guard
19
+ if (seen.has(current))
20
+ break;
21
+ seen.add(current);
22
+ }
23
+ if (current instanceof Error) {
24
+ chain.push({
25
+ name: current.name || 'Error',
26
+ message: truncate(current.message, MAX_MESSAGE_LENGTH),
27
+ stack: current.stack ? truncate(current.stack, MAX_STACK_LENGTH) : undefined,
28
+ });
29
+ current = current.cause;
30
+ }
31
+ else if (typeof current === 'object' && current !== null) {
32
+ // Handle non-Error cause objects (some libraries throw plain objects)
33
+ const obj = current;
34
+ chain.push({
35
+ name: String(obj.name || 'Object'),
36
+ message: truncate(String(obj.message || JSON.stringify(current)), MAX_MESSAGE_LENGTH),
37
+ });
38
+ current = obj.cause;
39
+ }
40
+ else {
41
+ // Primitive cause value
42
+ chain.push({
43
+ name: 'Unknown',
44
+ message: truncate(String(current), MAX_MESSAGE_LENGTH),
45
+ });
46
+ break;
47
+ }
48
+ depth++;
49
+ }
50
+ return chain;
51
+ }
52
+ /**
53
+ * Extract file paths from a stack trace string.
54
+ * Supports JavaScript/TypeScript, Python, Go, Java, Ruby formats.
55
+ * Excludes paths from node_modules, vendor, .yarn, and internal directories.
56
+ */
57
+ export function extractFilePaths(stackTrace) {
58
+ const paths = new Set();
59
+ const patterns = [
60
+ // JS/TS: at Object.func (file.ts:42:10) or at file.ts:42:10
61
+ /(?:at\s+(?:[\w.<>]+\s+)?\(?)((?:\/|\.\/|\.\.\/|[a-zA-Z]:\\)[\w./_\\-]+\.\w+)(?::\d+)?(?::\d+)?\)?/g,
62
+ // Python: File "path/file.py", line 42
63
+ /File\s+"([\w./_\\-]+\.py)",\s+line\s+\d+/g,
64
+ // Go: path/file.go:42
65
+ /([\w./_-]+\.go):\d+/g,
66
+ // Java: at pkg.Class(file.java:42)
67
+ /at\s+[\w.]+\(([\w./_-]+\.java):\d+\)/g,
68
+ // Ruby: from path/file.rb:42
69
+ /from\s+([\w./_-]+\.rb):\d+/g,
70
+ ];
71
+ const excludePatterns = [
72
+ /node_modules/,
73
+ /vendor\//,
74
+ /\.yarn\//,
75
+ /internal\//,
76
+ /<anonymous>/,
77
+ ];
78
+ for (const pattern of patterns) {
79
+ let match;
80
+ while ((match = pattern.exec(stackTrace)) !== null) {
81
+ const filePath = match[1];
82
+ if (filePath && !excludePatterns.some((p) => p.test(filePath))) {
83
+ paths.add(filePath);
84
+ }
85
+ }
86
+ }
87
+ return [...paths];
88
+ }
89
+ function truncate(str, maxLength) {
90
+ return str.length > maxLength ? str.slice(0, maxLength) : str;
91
+ }
92
+ //# sourceMappingURL=serializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer.js","sourceRoot":"","sources":["../src/serializer.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAY;IAC9C,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,OAAO,EAAU,CAAC;IACnC,IAAI,OAAO,GAAY,KAAK,CAAC,KAAK,CAAC;IACnC,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,OAAO,IAAI,KAAK,GAAG,eAAe,EAAE,CAAC;QAC1C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACpD,2BAA2B;YAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAAE,MAAM;YAC7B,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC;QA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oGAAoG;QACpG,uCAAuC;QACvC,2CAA2C;QAC3C,sBAAsB;QACtB,sBAAsB;QACtB,mCAAmC;QACnC,uCAAuC;QACvC,6BAA6B;QAC7B,6BAA6B;KAC9B,CAAC;IAEF,MAAM,eAAe,GAAG;QACtB,cAAc;QACd,UAAU;QACV,UAAU;QACV,YAAY;QACZ,aAAa;KACd,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,KAA6B,CAAC;QAClC,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACnD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1B,IAAI,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;gBAC/D,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW,EAAE,SAAiB;IAC9C,OAAO,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAChE,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { ErrorEvent, ResolvedConfig } from './types.js';
2
+ /**
3
+ * Batched HTTP transport for error events.
4
+ *
5
+ * Events are buffered in memory and flushed either when the batch is full,
6
+ * on a timer interval, or on process shutdown. This reduces HTTP overhead
7
+ * while ensuring events are not lost on process exit.
8
+ */
9
+ export declare class BatchTransport {
10
+ private buffer;
11
+ private flushTimer;
12
+ private shutdownRegistered;
13
+ private flushing;
14
+ private config;
15
+ constructor(config: ResolvedConfig);
16
+ /**
17
+ * Enqueue an event for batched delivery.
18
+ * Triggers an immediate flush if the buffer reaches batchSize.
19
+ */
20
+ enqueue(event: ErrorEvent): void;
21
+ /**
22
+ * Flush all buffered events to the API.
23
+ * Safe to call concurrently — uses a lock to prevent overlapping flushes.
24
+ */
25
+ flush(): Promise<void>;
26
+ /**
27
+ * Stop the flush timer and flush remaining events.
28
+ * Called during graceful shutdown.
29
+ */
30
+ shutdown(): Promise<void>;
31
+ /** Number of events currently buffered. */
32
+ get pendingCount(): number;
33
+ private startFlushTimer;
34
+ private registerShutdownHooks;
35
+ private sendWithRetry;
36
+ private sendEvent;
37
+ private sleep;
38
+ }
39
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,cAAc,EAAE,MAAM,YAAY,CAAC;AAM1E;;;;;;GAMG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,cAAc;IAMlC;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAQhC;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB5B;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ/B,2CAA2C;IAC3C,IAAI,YAAY,IAAI,MAAM,CAEzB;IAMD,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,qBAAqB;YAaf,aAAa;YAmBb,SAAS;IAyBvB,OAAO,CAAC,KAAK;CAMd"}