// Generating user fingerprint - https://github.com/Valve/fingerprintjs2#usage if (window.requestIdleCallback) { requestIdleCallback(function () { generate_fp_hash(); }) } else { setTimeout(function () { generate_fp_hash(); }, 500) } function generate_fp_hash(){ Fingerprint2.get(function (components) { var fingerprint_hash = Fingerprint2.x64hash128(components.map(function (pair) { return pair.value }).join(), 31); console.log("bfprt: "+fingerprint_hash); retrive_finger_print_info(fingerprint_hash); //for debugging for (var index in components) { var obj = components[index] var line = obj.key + " = " + String(obj.value).substr(0, 100); // if(funnel.JS_CONSOLE) console.log("user-finger-print", line) } }) } function retrive_finger_print_info(fp_hash) { var xhr = new XMLHttpRequest(); xhr.open('POST', '/ajax-router.php'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Lp-Php-Session-Id', Lp.phpSessionId); xhr.onload = function() { if (xhr.status === 200) { var ajax_response = JSON.parse(xhr.responseText); if(ajax_response.status == 200 || ajax_response.status == 201){ delete ajax_response.status; lpLocalStorage.setItem('fingerprint', JSON.stringify(ajax_response)); } else{ console.error(ajax_response.error); } } }; xhr.send("route=getFingerprint&hash="+fp_hash); } function clearFingerPrint() { lpLocalStorage.removeItem('fingerprint'); }