Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

205
Visualizações
How to track mouse movement without crashing server

I've been tasked with developing metrics for how users interact with our web portal. A coworker suggested that I look into "heat maps" to monitor user mouse position. This idea seemed cool to me. It seems there are already some SaaS solutions, but our budget is thin, so I whipped up some javascript:

class UserLog {
  constructor(){
    // ...
    this.results = {... mouseMovements=[]}
  }
  /* ... more functions ... */

  trackMouseMovement(){
    document.addEventListener('mousemove', (event) => {
      this.results.mouseMovements.push({
        timestamp: Date.now(),
        x: event.pageX,
        y: event.pageY
      });
    });
  }
}

I am currently using a timer to send this array to my server every 10 seconds:

window.setInterval(() => {
  $.ajax({
    url: endpoint, 
    type: "POST",
    data: this.results,
  });
},10*1000);

I'm running into the mouseMovements array can get up to several hundred elements in length and makes my browser cry when the ajax executes.

I can try sending data more frequently, or I can try preprocessing the mouseMovements array:

preprocessData: results =>{
    const newResults= {
      ...results,
      mouseMovements: results.mouseMovements.filter((val, index) => index % 10 == 0)
    }
    return newResults
  }

(1) How do people implement a mouse tracking protocol that allows the user's machine to operate as usual and provides enough resolution on the back end to playback the user's session and understand how to improve their experience on the site?

(2) How often should I be sending the ajax requests to my server? I am looking at some major sites and noticing that their requests seem to be click-driven. Is tracking mouse movements and scrolls not optimal? Or is there a better way of collecting this information?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First, you need to throttle your API request, most of the collaborating products like the Figma design tool, in which you can see other people's mouse position in real-time, most likely sends mouse position once in 600ms.

600ms is janky, but if you think of mouse positions as keyframes, then you can animate between two mouse positions, so the user will always see smooth mouse movement, of course it depends on your animation algorithm.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda