Skip to content

Instantly share code, notes, and snippets.

@jasonrhodes
Last active July 5, 2019 12:31
Show Gist options
  • Save jasonrhodes/afb081f0e0efed9c108c460b49f7b944 to your computer and use it in GitHub Desktop.
Save jasonrhodes/afb081f0e0efed9c108c460b49f7b944 to your computer and use it in GitHub Desktop.
import { trackUiMetric } from '../wherever'
export function TrackVisit({ app, path, delay = 0 }) {
if (!delay) {
trackUiMetric(app, `visit__${path}`) // something like visit__transactions_list_page
}
useEffect(() => {
if (!delay) {
return;
}
const id = setTimeout(() => trackUiMetric(app, `visit_delay_${delay}ms__${path}`), delay);
return () => clearTimeout(id);
}, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment