@@ -8,6 +8,7 @@ import { useAuthContext } from "contexts/auth/AuthProvider";
8
8
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata" ;
9
9
import { getApplicationName } from "utils/appearance" ;
10
10
import { retrieveRedirect } from "utils/redirect" ;
11
+ import { sendDeploymentEvent } from "utils/telemetry" ;
11
12
import { LoginPageView } from "./LoginPageView" ;
12
13
13
14
export const LoginPage : FC = ( ) => {
@@ -19,6 +20,7 @@ export const LoginPage: FC = () => {
19
20
signIn,
20
21
isSigningIn,
21
22
signInError,
23
+ user,
22
24
} = useAuthContext ( ) ;
23
25
const authMethodsQuery = useQuery ( authMethods ( ) ) ;
24
26
const redirectTo = retrieveRedirect ( location . search ) ;
@@ -29,6 +31,15 @@ export const LoginPage: FC = () => {
29
31
const buildInfoQuery = useQuery ( buildInfo ( metadata [ "build-info" ] ) ) ;
30
32
31
33
if ( isSignedIn ) {
34
+ if ( buildInfoQuery . data ) {
35
+ // This uses `navigator.sendBeacon`, so window.href
36
+ // will not stop the request from being sent!
37
+ sendDeploymentEvent ( buildInfoQuery . data , {
38
+ type : "deployment_login" ,
39
+ user_id : user ?. id ,
40
+ } ) ;
41
+ }
42
+
32
43
// If the redirect is going to a workspace application, and we
33
44
// are missing authentication, then we need to change the href location
34
45
// to trigger a HTTP request. This allows the BE to generate the auth
@@ -74,6 +85,15 @@ export const LoginPage: FC = () => {
74
85
isSigningIn = { isSigningIn }
75
86
onSignIn = { async ( { email, password } ) => {
76
87
await signIn ( email , password ) ;
88
+ if ( buildInfoQuery . data ) {
89
+ // This uses `navigator.sendBeacon`, so navigating away
90
+ // will not prevent it!
91
+ sendDeploymentEvent ( buildInfoQuery . data , {
92
+ type : "deployment_login" ,
93
+ user_id : user ?. id ,
94
+ } ) ;
95
+ }
96
+
77
97
navigate ( "/" ) ;
78
98
} }
79
99
/>
0 commit comments