()
| 4 | import { onDomMutationGuarded } from '../lib/domMutationGuard'; |
| 5 | |
| 6 | export function useError(): void { |
| 7 | const { logEvent } = useLogContext(); |
| 8 | |
| 9 | useEffect(() => { |
| 10 | if (!logEvent) { |
| 11 | return undefined; |
| 12 | } |
| 13 | |
| 14 | window.onerror = (msg, url, line, col, error) => { |
| 15 | logEvent({ |
| 16 | event_name: LogEvent.GlobalError, |
| 17 | extra: JSON.stringify({ |
| 18 | msg, |
| 19 | url, |
| 20 | line, |
| 21 | col, |
| 22 | error, |
| 23 | }), |
| 24 | }); |
| 25 | }; |
| 26 | |
| 27 | return onDomMutationGuarded((method) => { |
| 28 | logEvent({ |
| 29 | event_name: LogEvent.GlobalError, |
| 30 | extra: JSON.stringify({ |
| 31 | msg: `Skipped ${method}: the node is not a child of this node`, |
| 32 | url: window.location.href, |
| 33 | domMutation: true, |
| 34 | }), |
| 35 | }); |
| 36 | }); |
| 37 | }, [logEvent]); |
| 38 | } |
no test coverage detected