(error: Error, context?: Record<string, unknown>)
| 51 | } |
| 52 | |
| 53 | capture(error: Error, context?: Record<string, unknown>) { |
| 54 | const event: ErrorEvent = { |
| 55 | message: error.message, |
| 56 | stack: error.stack, |
| 57 | context, |
| 58 | timestamp: new Date().toISOString(), |
| 59 | sessionId: this.sessionId, |
| 60 | url: window.location.href, |
| 61 | userAgent: navigator.userAgent, |
| 62 | }; |
| 63 | |
| 64 | this.buffer.push(event); |
| 65 | |
| 66 | // Also log to console for dev visibility |
| 67 | console.error("[ErrorTracker]", error.message, context); |
| 68 | |
| 69 | // Flush if buffer exceeds threshold |
| 70 | if (this.buffer.length >= 10) { |
| 71 | this.flush(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | getSessionId(): string { |
| 76 | return this.sessionId; |
no test coverage detected