Skip to content

Consider sending analytics with requestIdleCallback #86

@leonardodino

Description

@leonardodino

Hey there,

I added the <SpeedInsight /> component to a next.js app and noticed most visits weren't appearing on the dashboard.

Dissecting the script that sends this metrics to vercel I noticed it is geared towards sending this data upon navigations/page visibility changes:

  • addEventListener("visibilitychange",c)
  • addEventListener("pagehide",c)
  • addEventListener("popstate",c)
let e=history.pushState.bind(history);
history.pushState = function(...t){
  e(...t);
  try {
    c()
  } catch(n) {
  }
}

the problem we are facing is that the application is a single page checkout, state is mostly client-side and the "happy path" doesn't include any client-side navigation. I believe adding the same listener to requestIdleCallback makes sense here.

(ensures the data is sent during idle periods, so won't disrupt the user, use CPU during busy periods or congest a limited network upload while the page is using them)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions