({ user }: { user: User })
| 95 | : () => ({ track: () => null }); |
| 96 | |
| 97 | export const useSegmentPageTracking = ({ user }: { user: User }) => { |
| 98 | const location = useLocation(); |
| 99 | |
| 100 | React.useEffect(() => { |
| 101 | if (!segment) { |
| 102 | return; |
| 103 | } |
| 104 | segment.page( |
| 105 | undefined, // category |
| 106 | undefined, // name |
| 107 | { |
| 108 | // Include the hash because the Frontegg admin portal uses the hash |
| 109 | // for routing. |
| 110 | hash: location.hash, |
| 111 | }, |
| 112 | { |
| 113 | groupId: user.tenantId, |
| 114 | }, |
| 115 | ); |
| 116 | }, [location, user]); |
| 117 | |
| 118 | React.useEffect(() => { |
| 119 | if (!segment) { |
| 120 | return; |
| 121 | } |
| 122 | segment.identify(user.id); |
| 123 | }, [user]); |
| 124 | }; |
no test coverage detected