import { onEvent, onError } from '../track'; export default function (type: 'setInterval' | 'setTimeout') { const old = window[type]; window[type] = (...args) => { try { onEvent({ type: type, data: (args[1] == undefined) ? '' : args[1] + 'ms', occurredAt: new Date(), source: 'None', page: window.location.href + window.location.hash, HTML: "Not Available" }); return old.apply(window, args); } catch (ex) { onError({ data: ex.name + ": " + ex.message, occurredAt: new Date(), source: type, stack: 'Unavailable', category: 'Unavailable' }); throw ex; } } }