feat: add all page views (#5154)
parent
63c3850f0e
commit
714ca8c49f
6 changed files with 42 additions and 29 deletions
@ -0,0 +1,25 @@ |
||||
import { useEffect } from 'react'; |
||||
import { isLoggedIn } from '../../lib/jwt'; |
||||
import { httpPost } from '../../lib/http'; |
||||
import type { ResourceType } from '../../lib/resource-progress'; |
||||
|
||||
type PageVisitProps = { |
||||
resourceId?: string; |
||||
resourceType?: ResourceType; |
||||
}; |
||||
|
||||
export function PageVisit(props: PageVisitProps) { |
||||
const { resourceId, resourceType } = props; |
||||
|
||||
useEffect(() => { |
||||
if (!isLoggedIn()) { |
||||
return; |
||||
} |
||||
|
||||
httpPost(`${import.meta.env.PUBLIC_API_URL}/v1-visit`, { |
||||
...(resourceType && { resourceType, resourceId }), |
||||
}).finally(() => {}); |
||||
}, []); |
||||
|
||||
return null; |
||||
} |
Loading…
Reference in new issue