make sure analytics is setup before calling show on Intercom

This commit is contained in:
Satindar Dhillon 2022-10-14 13:44:04 -07:00
parent 22a5850c1e
commit fcef8e14e7

View file

@ -1,11 +1,21 @@
import { useEffect } from 'react'
import { useEffect, useCallback } from 'react'
import { SettingsLayout } from '../components/templates/SettingsLayout'
import { setupAnalytics } from '../lib/analytics'
export default function Support(): JSX.Element {
useEffect(() => {
const initAnalytics = useCallback(() => {
setupAnalytics()
window.Intercom('show')
}, [])
useEffect(() => {
initAnalytics()
window.addEventListener('load', initAnalytics)
return () => {
window.removeEventListener('load', initAnalytics)
}
}, [initAnalytics])
return (
<SettingsLayout title="Support">
<></>