manifold/web/hooks/use-tracking.ts

15 lines
390 B
TypeScript
Raw Permalink Normal View History

import { useEffect } from 'react'
2022-10-02 18:39:29 +00:00
import { track } from 'web/lib/service/analytics'
2022-09-07 03:43:28 +00:00
import { inIframe } from './use-is-iframe'
2022-09-07 03:43:28 +00:00
export const useTracking = (
eventName: string,
eventProperties?: any,
excludeIframe?: boolean
) => {
useEffect(() => {
2022-09-07 03:43:28 +00:00
if (excludeIframe && inIframe()) return
track(eventName, eventProperties)
2022-10-02 18:39:29 +00:00
}, [eventName, eventProperties, excludeIframe])
}