var user_session_data = 'https://heat.theconrad.group/analytics/user_session_data'; var get_screen_shot = 'https://heat.theconrad.group/analytics/get-screenshot'; var rrweb_record_js_link='https://heat.theconrad.group/assets/node_modules/rrweb/dist/record/rrweb-record.min.js'; var heatmap_js_link='https://heat.theconrad.group/assets/heatmap/js/heat_sketch.js'; var block_class = 'rr-block'; var ignore_class = 'rr-ignore'; var maskText_class = 'rr-mask'; var maskInput_option_string = {password:true}; var maskAllInputs = 'false'; var hmsas_22_csrf_token = '51jA5hPB8E2cEqGivQZ1WVkf0YqQZK8KrUPleAe9'; var hmsas_22_fullWidth = 0; var hmsas_22_fullHeight = 0; var hmsas_22_events = []; var hmsas_22_total_clicks = 0; var hmsas_22_has_screenshot; function hmsas_22_ajax_dolphin(link,data,async_type){ xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { hmsas_22_has_screenshot = xhr.responseText; } } xhr.open('POST',link,async_type); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('X-CSRF-TOKEN', hmsas_22_csrf_token); xhr.send(data); } function get_browser_info(){ var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])){ tem=/\brv[ :]+(\d+)/g.exec(ua) || []; return {name:'IE',version:(tem[1]||'')}; } if(M[1]==='Chrome'){ tem=ua.match(/\bOPR\/(\d+)/) if(tem!=null) {return {name:'Opera', version:tem[1]};} } M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);} return { name: M[0], version: M[1] }; } /*** Creating Cookie function ***/ function hmsas_22_createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = '; expires='+date.toGMTString(); } else var expires = ''; document.cookie = name+'='+value+expires+'; path=/'; } /***Read Cookie function**/ function hmsas_22_readCookie(name) { var nameEQ = name + '='; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } /*** Delete Cookie Function ***/ function eraseCookie(name) { hmsas_22_createCookie(name,'',-1); } function hmsas_22_ajax_call(){ var w = document.createElement('link'); var z = document.createElement('script'); var k = document.createElement('script'); z.setAttribute('src',rrweb_record_js_link); k.setAttribute('src',heatmap_js_link); setTimeout(function(){ document.head.appendChild(z); document.head.appendChild(k); },10); /**after browser plugin loaded**/ k.onload=function(){ var hmsas_22_device; var hmsas_22_mobile_desktop; hmsas_22_device=jscd.os; if(jscd.mobile == 'mobile'){ hmsas_22_mobile_desktop='Mobile'; } else if(jscd.mobile == 'tablet'){ hmsas_22_mobile_desktop='Tablet'; } else{ hmsas_22_mobile_desktop='Desktop'; } var browser_info=get_browser_info(); var browser_name=browser_info.name; var browser_version=browser_info.version; var browser_rawdata = JSON.stringify(navigator.userAgent); var website_code = document.querySelector('script#hmsas-22-domain-name').getAttribute('hmsas-22-data-name'); /**Get referer Address**/ var referrer = document.referrer; /** Get Current url **/ var current_url = window.location.href; var screenshot_url = new URL(current_url); var retake_screenshot = screenshot_url.searchParams.get('retake-screenshot'); /*** Get cookie value , if it is already set or not **/ var hmsas_22_cookie_value=hmsas_22_readCookie('hmsas_22_script_cookie'); var extra_value= new Date().getTime(); /**if new visitor set the cookie value a random number***/ if(hmsas_22_cookie_value=='' || hmsas_22_cookie_value==null || hmsas_22_cookie_value === undefined){ var is_new=1; var random_cookie_value=Math.floor(Math.random()*999999); random_cookie_value=random_cookie_value+extra_value.toString(); hmsas_22_createCookie('hmsas_22_script_cookie',random_cookie_value,1); hmsas_22_cookie_value=random_cookie_value; } else{ hmsas_22_createCookie('hmsas_22_script_cookie',hmsas_22_cookie_value,1); var is_new=0; } var hmsas_22_session_value=sessionStorage.getItem('hmsas_22_script_session'); if(hmsas_22_session_value=='' || hmsas_22_session_value==null || hmsas_22_session_value === undefined){ var random_session_value=Math.floor(Math.random()*999999); random_session_value=random_session_value+extra_value.toString(); sessionStorage.setItem('hmsas_22_script_session', random_session_value); hmsas_22_session_value=random_session_value; } var heatmapInstance_mouse_click=[]; var heatmapInstance_mouse_move=[]; var heatmapInstance_mouse_scroll=[]; setTimeout(function(){ hmsas_22_fullHeight = Math.max( document.body.offsetHeight, ); hmsas_22_fullWidth = Math.max( document.body.offsetWidth, ); heatmapInstance_mouse_click = h337.create({ container: document.querySelector('#hmsas-script-loader'), radius: 30 }); heatmapInstance_mouse_scroll = h337.create({ container: document.querySelector('#hmsas-script-loader'), radius: 30 }); heatmapInstance_mouse_move = h337.create({ container: document.querySelector('#hmsas-script-loader'), radius: 30 }); }, 200); /*** User session video ****/ setTimeout(function(){ rrwebRecord({ emit(event){ hmsas_22_events.push(event); }, maskTextClass:maskText_class, blockClass:block_class, ignoreClass:ignore_class, maskAllInputs:maskAllInputs, maskInputOptions:maskInput_option_string }); }, 1000); var hmsas_22_page_title = document.getElementsByTagName('title')[0].innerHTML; document.querySelector('body').onclick = function(ev) { heatmapInstance_mouse_click.addData({ x: ev.pageX, y: ev.pageY, value: 1, }); hmsas_22_total_clicks++; }; document.querySelector('body').onmousemove = function(ev) { heatmapInstance_mouse_move.addData({ x: ev.pageX, y: ev.pageY, value: 1 }); }; document.querySelector('body').onwheel = function(ev) { heatmapInstance_mouse_scroll.addData({ x: ev.pageX, y: ev.pageY, value: 1 }); }; //Screenshot of webpage var image_data; window.onload=function(){ var existency_check = 'yes'; var code_and_url ='website_code='+website_code+'¤t_url='+current_url+'&mobile_desktop='+hmsas_22_mobile_desktop+'&existency_check='+existency_check; hmsas_22_ajax_dolphin(get_screen_shot,code_and_url,false); if(hmsas_22_has_screenshot == 'no' || retake_screenshot == 'yes') { var timeout_time = 10000; if(retake_screenshot == 'yes') { alert('Taking Screenshot may take some times, in this time page will scroll down to bottom and then scroll up to top automatically. Please wait untill the final confirmation message appear. Now please click the ok button to start the process.'); timeout_time = 30000+10000+((document.body.offsetHeight/1000)*2000)+2000; var scrolltotop_timeout_time = 10000+10000+((document.body.offsetHeight/1000)*2000)+2000; } existency_check = 'no'; setTimeout(function() { var loop_counter = document.body.offsetHeight/1000; var loop_timeout_time = 2000; var fullheight_timeout_time = 0; var bottom_pos_final = 0; for(var height_loop=1; height_loop<=loop_counter; height_loop++ ) { (function(){ var _height_loop=height_loop; var bottom_pos = _height_loop*1000; var top_pos = bottom_pos-1000; var individual_loop_timeout_time = loop_timeout_time*_height_loop; setTimeout(function() { window.scrollTo(top_pos, bottom_pos); }, individual_loop_timeout_time); fullheight_timeout_time = loop_timeout_time*_height_loop; bottom_pos_final=bottom_pos; })(); } setTimeout(function() { window.scrollTo(bottom_pos_final,document.body.offsetHeight); }, fullheight_timeout_time); setTimeout(function() { window.scrollTo(0, 0); }, scrolltotop_timeout_time); }, 10000); setTimeout(function() { html2canvas(document.body,{scrollX: -window.scrollX,scrollY: -window.scrollY,windowWidth: document.body.offsetWidth,windowHeight: document.body.offsetHeight}).then(function(canvas){ var image_data = canvas.toDataURL('image/png'); var data ='website_code='+website_code+'¤t_url='+current_url+'&session_value='+hmsas_22_session_value+'&cookie_value='+hmsas_22_cookie_value+'&mobile_desktop='+hmsas_22_mobile_desktop+'&existency_check='+existency_check+'&image_data='+image_data; hmsas_22_ajax_dolphin(get_screen_shot,data,false); if(hmsas_22_has_screenshot == 'done' && retake_screenshot == 'yes') { alert('Screenshot has been taken successfully.'); window.close(); } }); }, timeout_time); } } setInterval(function() { var mouse_click_data = heatmapInstance_mouse_click.getData(); var mouse_move_data = heatmapInstance_mouse_move.getData(); var mouse_scroll_data = heatmapInstance_mouse_scroll.getData(); var ajax_call_condition = 'yes'; heatmapInstance_mouse_click.setData({data:[]}); heatmapInstance_mouse_move.setData({data:[]}); heatmapInstance_mouse_scroll.setData({data:[]}); if(JSON.stringify(hmsas_22_events) == '[]') ajax_call_condition = 'no'; mouse_click_data = JSON.stringify(mouse_click_data); mouse_move_data = JSON.stringify(mouse_move_data); mouse_scroll_data = JSON.stringify(mouse_scroll_data); var height = hmsas_22_fullHeight; var width = hmsas_22_fullWidth; const strintgify_events = JSON.stringify(hmsas_22_events); hmsas_22_events = []; const body = JSON.stringify({'session_data':strintgify_events,'website_code':website_code,'current_url':current_url,'cookie_value':hmsas_22_cookie_value,'session_value':hmsas_22_session_value,'browser_name':browser_name,'browser_version':browser_version,'device':hmsas_22_device,'referrer':referrer,'is_new':is_new,'browser_rawdata':browser_rawdata,'mobile_desktop':hmsas_22_mobile_desktop,'page_title':hmsas_22_page_title,'height':height,'width':width,'mouse_click_data':mouse_click_data,'mouse_move_data':mouse_move_data,'mouse_scroll_data':mouse_scroll_data,'total_clicks':hmsas_22_total_clicks}); hmsas_22_total_clicks = 0; if(ajax_call_condition == 'yes') { fetch(user_session_data, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': hmsas_22_csrf_token }, body, }).then(response=>response.json()) .then((data) => { if(data.session_distroy == 'yes') { sessionStorage.removeItem('hmsas_22_script_session'); location.reload(); } }); } }, 5000); } // end of y.onload } //end of ajax call function init(){ hmsas_22_ajax_call(); } init();