manifold/web/hooks/use-tracking.ts
2022-10-02 13:39:29 -05:00

15 lines
390 B
TypeScript

import { useEffect } from 'react'
import { track } from 'web/lib/service/analytics'
import { inIframe } from './use-is-iframe'
export const useTracking = (
eventName: string,
eventProperties?: any,
excludeIframe?: boolean
) => {
useEffect(() => {
if (excludeIframe && inIframe()) return
track(eventName, eventProperties)
}, [eventName, eventProperties, excludeIframe])
}