1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-10 01:16:39 +02:00

fix track invite-link user created event (#2689)

Signed-off-by: andreas-unleash <andreas@getunleash.ai>

<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

Adds plausible tracking of invite-link use for all auth types.



## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

<!-- Does it close an issue? Multiple? -->
Closes #

<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
<!--
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
#
-->

### Important files
<!-- PRs can contain a lot of changes, but not all changes are equally
important. Where should a reviewer start looking to get an overview of
the changes? Are any files particularly important? -->


## Discussion points
<!-- Anything about the PR you'd like to discuss before it gets merged?
Got any questions or doubts? -->

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
andreas-unleash 2023-01-11 11:24:11 +02:00 committed by GitHub
parent fc548164a9
commit 7c8647f9f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 9 deletions

View File

@ -15,15 +15,32 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
import { Alert } from '@mui/material';
import { useAuthDetails } from 'hooks/api/getters/useAuth/useAuthDetails';
import { AUTH_PAGE_ID } from 'utils/testIds';
import { useEffect } from 'react';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
interface IAuthenticationProps {
redirect: string;
invited?: boolean;
}
const Authentication = ({ redirect }: IAuthenticationProps) => {
const Authentication = ({
redirect,
invited = false,
}: IAuthenticationProps) => {
const { authDetails } = useAuthDetails();
const params = useQueryParams();
const error = params.get('errorMsg');
const { trackEvent } = usePlausibleTracker();
useEffect(() => {
if (invited) {
trackEvent('invite', {
props: {
eventType: 'user created',
},
});
}
}, [invited, trackEvent]);
if (!authDetails) {
return null;

View File

@ -61,7 +61,7 @@ const Login = () => {
</StyledHeader>
}
/>
<Authentication redirect={redirect} />
<Authentication redirect={redirect} invited={invited} />
</StyledDiv>
</StandaloneLayout>
);

View File

@ -3,7 +3,6 @@ import { useNavigate } from 'react-router-dom';
import { Box, TextField, Typography } from '@mui/material';
import { CREATED, OK } from 'constants/statusCodes';
import useToast from 'hooks/useToast';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import useResetPassword from 'hooks/api/getters/useResetPassword/useResetPassword';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { useUserInvite } from 'hooks/api/getters/useUserInvite/useUserInvite';
@ -40,17 +39,11 @@ export const NewUser = () => {
const { resetPassword, loading: isPasswordSubmitting } =
useAuthResetPasswordApi();
const passwordDisabled = authDetails?.defaultHidden === true;
const { trackEvent } = usePlausibleTracker();
const onSubmitInvitedUser = async (password: string) => {
try {
const res = await addUser(secret, { name, email, password });
if (res.status === CREATED) {
trackEvent('invite', {
props: {
eventType: 'user created',
},
});
navigate('/login?invited=true');
} else {
setToastApiError(