Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interaction tracking #181

Open
marvinhagemeister opened this issue May 1, 2020 · 1 comment
Open

Add interaction tracking #181

marvinhagemeister opened this issue May 1, 2020 · 1 comment

Comments

@marvinhagemeister
Copy link
Member

marvinhagemeister commented May 1, 2020

It's essentially a more powerful performance.measure() alternative that captures additional details that's exclusive to extensions like CPU load.

Links:

@marvinhagemeister
Copy link
Member Author

Turns out this is much more useful, because it can be used to track application performance in Preact and have that sent to a Graphana/Splunk instanace.

Quoting a thread on our slack channel:

the idea is to use this on each click handler

import {unstable_trace as trace} from 'scheduler/tracing'
trace('click', performance.now(), () => setCount(c => c + 1))

function reportProfile(
  id, // the "id" prop of the Profiler tree that has just committed
  phase, // either "mount" (if the tree just mounted) or "update" (if it re-rendered)
  actualDuration, // time spent rendering the committed update
  baseDuration, // estimated time to render the entire subtree without memoization
  startTime, // when React began rendering this update
  commitTime, // when React committed this update
  interactions, // the Set of interactions belonging to this update
) {
  queue.push({
    id,
    phase,
    actualDuration,
    baseDuration,
    startTime,
    commitTime,
    interactions,
  })
  // this is a fire and forget, so we don't return anything.
}

and then each 5 seconds send the request to save the data in Splunk
const queueToSend = [...queue]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant