Add Expense
Recent Transactions
window.__wcActivityInjected = true;
(function() {
function post(entry) {
try { window.parent.postMessage({ type: 'wc-activity', entry: entry }, '*'); } catch(e) {}
}
function summarise(method, url, status, durationMs, reqBody, resBody) {
var u = url.replace(/^https?://[^/]+/, '') || url;
var action = method === 'GET' ? 'Loaded' : method === 'POST' ? 'Saved' : method === 'PUT' || method === 'PATCH' ? 'Updated' : method === 'DELETE' ? 'Deleted' : 'Sent';
var resource = u.split('?')[0].split('/').filter(Boolean).pop() || 'data';
resource = resource.replace(/-/g,' ').replace(/_/g,' ');
var ok = status >= 200 && status < 300;
var warn = status >= 300 && status < 500;
var label = ok ? 'ok' : warn ? 'warn' : 'err';
var summary = ok ? (action + ' ' + resource) : warn ? ('Could not find ' + resource) : ('Failed to ' + action.toLowerCase() + ' ' + resource);
return { method: method, url: url, status: status, duration: durationMs, summary: summary, label: label, reqBody: (reqBody||'').slice(0,2000), resBody: (resBody||'').slice(0,2000), ts: Date.now() };
}
var _fetch = window.fetch;
window.fetch = function(input, init) {
var method = (init && init.method || 'GET').toUpperCase();
var url = typeof input === 'string' ? input : (input && input.url) || '';
var reqBody = init && init.body ? String(init.body).slice(0,2000) : '';
var t0 = Date.now();
return _fetch.apply(this, arguments).then(function(res) {
var status = res.status;
var duration = Date.now() - t0;
var clone = res.clone();
clone.text().then(function(txt) {
post(summarise(method, url, status, duration, reqBody, txt));
}).catch(function() {
post(summarise(method, url, status, duration, reqBody, ''));
});
return res;
}).catch(function(e) {
post(summarise(method, url, 0, Date.now() - t0, reqBody, e.message));
throw e;
});
};
var _XHR = window.XMLHttpRequest;
window.XMLHttpRequest = function() {
var xhr = new _XHR();
var method = 'GET', url = '', reqBody = '', t0 = 0;
var origOpen = xhr.open.bind(xhr);
xhr.open = function(m, u) { method = (m||'GET').toUpperCase(); url = u||''; origOpen.apply(xhr, arguments); };
var origSend = xhr.send.bind(xhr);
xhr.send = function(body) { reqBody = body ? String(body).slice(0,2000) : ''; t0 = Date.now(); origSend.apply(xhr, arguments); };
xhr.addEventListener('load', function() {
post(summarise(method, url, xhr.status, Date.now()-t0, reqBody, (xhr.responseText||'').slice(0,2000)));
});
xhr.addEventListener('error', function() {
post(summarise(method, url, 0, Date.now()-t0, reqBody, 'Network error'));
});
return xhr;
};
})();
How's this app?
😞
😐
😊
😄