(function() {
const url = 'https://api.apparell.com/api/tracking/product/9170939511126/collect'
const getCookie = function() {
const name = '_apparell' + '=';
const cDecoded = decodeURIComponent(document.cookie);
const cArr = cDecoded.split('; ');
let res;
cArr.forEach(val => {
if (val.indexOf(name) === 0) res = val.substring(name.length);
})
return res
};
const cookie = getCookie() || 'cde2b369-097f-4a24-87bf-76b1b5f14b48';
const expires = 'expires=' + new Date(Date.now() + 31536000000);
document.cookie = '_apparell' + '=' + cookie + '; ' + expires + '; path=/';
const getDefaultParams = function() {
let x = 'connection=' + encodeURI(navigator.userAgent);
x = x + '&lang=' + encodeURI(navigator.language);
x = x + '&referer=' + encodeURI(document.referrer);
x = x + '&url=' + encodeURI(window.location.href);
x = x + '&cookie=' + cookie;
return x
};
const sendData = function(data) {
const r = new window.XMLHttpRequest;
r.open('POST', url, true);
r.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
r.send(getDefaultParams() + data);
};
const initListeners = function() {
sendData('&live=1');
document.onvisibilitychange = function() {
if (document.visibilityState === 'hidden') {
sendData('&live=0');
} else {
sendData('&live=1');
}
};
};
sendData('&live=1');
}).call(this);