2022-06-15 21:34:34 +00:00
|
|
|
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-06-15 21:34:34 +00:00
|
|
|
|
2022-09-07 03:43:28 +00:00
|
|
|
export const useTracking = (
|
|
|
|
eventName: string,
|
|
|
|
eventProperties?: any,
|
|
|
|
excludeIframe?: boolean
|
|
|
|
) => {
|
2022-06-15 21:34:34 +00:00
|
|
|
useEffect(() => {
|
2022-09-07 03:43:28 +00:00
|
|
|
if (excludeIframe && inIframe()) return
|
2022-06-15 21:34:34 +00:00
|
|
|
track(eventName, eventProperties)
|
2022-10-02 18:39:29 +00:00
|
|
|
}, [eventName, eventProperties, excludeIframe])
|
2022-06-15 21:34:34 +00:00
|
|
|
}
|