diff --git a/tracker/index.js b/tracker/index.js index b61be850..63ed6fdd 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -168,11 +168,16 @@ const send = payload => { if (trackingDisabled()) return; - + const headers = { + 'Content-Type': 'application/json' + }; + if (typeof cache !== 'undefined') { + headers['x-umami-cache'] = cache; + } return fetch(endpoint, { method: 'POST', body: JSON.stringify({ type: 'event', payload }), - headers: { 'Content-Type': 'application/json', ['x-umami-cache']: cache }, + headers: headers }) .then(res => res.text()) .then(text => (cache = text));