highlight / highlight

highlight.io: The open source, full-stack monitoring platform. Error monitoring, session replay, logging, distributed tracing, and more.
https://app.highlight.io
Other
7.11k stars 320 forks source link

Disable polling when sorting by something besides timestamp #8594

Closed ccschmitz closed 1 week ago

ccschmitz commented 2 weeks ago

Talked this over w/ @zane and we agreed it probably wasn't that useful and potentially misleading.

linear[bot] commented 2 weeks ago

HIG-4668 Disable polling when sorting by something besides timestamp

greptile-apps[bot] commented 2 weeks ago

To disable polling when sorting by something besides timestamp, modify the useEffect hook in frontend/src/util/search.ts. Add a condition to check the sorting criteria and skip polling if it's not by timestamp.

useEffect(() => {
  if (skip || sortingCriteria !== 'timestamp') {
    return
  }

  // setup a polling interval for sessions after the current date range
  const poll = async () => {
    const variables = variableFn()
    if (variables === undefined) {
      log('search.ts', 'skipping polling for custom time selection')
      pollTimeout.current = setTimeout(
        poll,
        POLL_INTERVAL,
      ) as unknown as number
      return
    }
    const currentTimeout = pollTimeout.current
    const result = await moreDataQuery({ variables })
    if (pollTimeout.current === currentTimeout) {
      const count = getResultCount(result)
      if (count !== undefined) {
        setNumMore(count)
      }
      pollTimeout.current = setTimeout(
        poll,
        POLL_INTERVAL,
      ) as unknown as number
    }
  }
  pollTimeout.current = setTimeout(
    poll,
    POLL_INTERVAL,
  ) as unknown as number
  return () => {
    setNumMore(0)
    clearTimeout(pollTimeout.current)
    pollTimeout.current = undefined
  }
}, [getResultCount, moreDataQuery, variableFn, skip, sortingCriteria])

References

/frontend/src/util/search.ts

Ask Greptile

zane commented 2 weeks ago

@ccschmitz You mentioned the wrong Zane. I don't contribute to this project.