1- import type { FC } from "react" ;
1+ import { useEffect , type FC } from "react" ;
22import { Helmet } from "react-helmet-async" ;
33import { useQuery } from "react-query" ;
44import { Navigate , useLocation , useNavigate } from "react-router-dom" ;
@@ -24,10 +24,21 @@ export const LoginPage: FC = () => {
2424const redirectTo = retrieveRedirect ( location . search ) ;
2525const applicationName = getApplicationName ( ) ;
2626const navigate = useNavigate ( ) ;
27-
2827const { metadata} = useEmbeddedMetadata ( ) ;
2928const buildInfoQuery = useQuery ( buildInfo ( metadata [ "build-info" ] ) ) ;
3029
30+ useEffect ( ( ) => {
31+ if ( ! buildInfoQuery . data || isSignedIn ) {
32+ // isSignedIn already tracks with window.href!
33+ return ;
34+ }
35+ // This uses `navigator.sendBeacon`, so navigating away will not prevent it!
36+ sendDeploymentEvent ( buildInfoQuery . data , {
37+ type :"deployment_login" ,
38+ user_id :user ?. id ,
39+ } ) ;
40+ } , [ isSignedIn , buildInfoQuery . data , user ?. id ] ) ;
41+
3142if ( isSignedIn ) {
3243// If the redirect is going to a workspace application, and we
3344// are missing authentication, then we need to change the href location