manifold/web/hooks/use-tracking.ts

15 lines
352 B
TypeScript
Raw Normal View History

import { track } from '@amplitude/analytics-browser'
import { useEffect } from 'react'
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)
}, [])
}