mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
27 lines
749 B
TypeScript
27 lines
749 B
TypeScript
import {useEffect, useRef} from 'react';
|
|
|
|
import {trackAnalytics} from 'sentry/utils/analytics';
|
|
import useOrganization from 'sentry/utils/useOrganization';
|
|
import {useUser} from 'sentry/utils/useUser';
|
|
|
|
function useReplayPageview(type: 'replay.details-time-spent' | 'replay.list-time-spent') {
|
|
const user = useUser();
|
|
const organization = useOrganization();
|
|
const startTimeRef = useRef(Date.now());
|
|
|
|
useEffect(() => {
|
|
const startTime = startTimeRef.current;
|
|
|
|
return () => {
|
|
const endTime = Date.now();
|
|
trackAnalytics(type, {
|
|
organization,
|
|
seconds: (endTime - startTime) / 1000,
|
|
user_email: user.email,
|
|
});
|
|
};
|
|
}, [organization, type, user.email]);
|
|
}
|
|
|
|
export default useReplayPageview;
|