Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYNC: Merge Release/v2.1.1 into master #405

Merged
merged 5 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
NODE_ENV=development
VITE_ENV=dev
VITE_API_HOST=http://localhost:8000/
VITE_ADMIN_PANEL_HOST=http://localhost:3000/
VITE_SECURE_LOCAL_STORAGE_HASH_KEY=ML_SECURE
VITE_SECURE_LOCAL_STORAGE_PREFIX=ML_SECURE
VITE_IV_LENGTH=16
VITE_BUILD_VERSION=dev-build
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ coverage
*.sw?
.env
.env*

!.env.example
2 changes: 1 addition & 1 deletion Jenkinsfile.groovy
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build( job: env.MindloggerWebRefactorNewBuilder )
build( job: env.MindloggerWebRefactorBuilder )
4 changes: 2 additions & 2 deletions src/entities/applet/ui/AppletCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AppletListItem } from '../lib';

import { ROUTES } from '~/shared/constants';
import { CustomCard } from '~/shared/ui';
import { Mixpanel, useCustomNavigation } from '~/shared/utils';
import { MixEvents, MixProperties, Mixpanel, useCustomNavigation } from '~/shared/utils';

type Props = {
applet: AppletListItem;
Expand All @@ -14,7 +14,7 @@ export const AppletCard = ({ applet }: Props) => {
const navigator = useCustomNavigation();

const onAppletCardClick = () => {
Mixpanel.track('Applet click');
Mixpanel.track(MixEvents.AppletClick, { [MixProperties.AppletId]: applet.id });
return navigator.navigate(ROUTES.appletDetails.navigateTo(applet.id));
};

Expand Down
10 changes: 7 additions & 3 deletions src/features/PrivateJoinAccept/ui/PrivateJoinAcceptButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import { useNavigate } from 'react-router-dom';
import { useAcceptPrivateInviteMutation, useInvitationTranslation } from '~/entities/invitation';
import { ROUTES } from '~/shared/constants';
import { BaseButton, useNotification } from '~/shared/ui';
import { Mixpanel } from '~/shared/utils';
import { MixEvents, MixProperties, Mixpanel } from '~/shared/utils';

interface PrivateJoinAcceptButtonProps {
invitationKey: string;
appletId: string;
}

export const PrivateJoinAcceptButton = ({ invitationKey }: PrivateJoinAcceptButtonProps) => {
export const PrivateJoinAcceptButton = ({
invitationKey,
appletId,
}: PrivateJoinAcceptButtonProps) => {
const { t } = useInvitationTranslation();
const navigate = useNavigate();
const { showSuccessNotification } = useNotification();

const { mutate: acceptPrivateInvite, isLoading } = useAcceptPrivateInviteMutation({
onSuccess() {
showSuccessNotification(t('invitationAccepted'));
Mixpanel.track('Invitation Accepted');
Mixpanel.track(MixEvents.InvitationAccepted, { [MixProperties.AppletId]: appletId });
return navigate(ROUTES.appletList.path);
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useAcceptTransferOwnershipQuery } from '../api';

import { PageMessage } from '~/shared/ui';
import Loader from '~/shared/ui/Loader';
import { Mixpanel, useCustomTranslation } from '~/shared/utils';
import { MixEvents, MixProperties, Mixpanel, useCustomTranslation } from '~/shared/utils';

type TransferOwnershipProps = {
appletId: string;
Expand All @@ -21,7 +21,7 @@ export const TransferOwnershipAccept = ({ appletId, keyParam }: TransferOwnershi
{ appletId, key: keyParam },
{
onSuccess() {
Mixpanel.track('Transfer Ownership Accepted');
Mixpanel.track(MixEvents.TransferOwnershipAccepted, { [MixProperties.AppletId]: appletId });
},
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/api/types/invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export type GetInvitationSuccessResponse = BaseSuccessResponse<{
body: string | null;

appletName: string;
appletId: string | number;
appletId: string;
}>;
14 changes: 14 additions & 0 deletions src/shared/utils/analytics/analyticsService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const MixProperties = {
AppletId: 'Applet ID',
SubmitId: 'Submit ID',
};

export const MixEvents = {
AppletClick: 'Applet click',
TransferOwnershipAccepted: 'Transfer Ownership Accepted',
AssessmentCompleted: 'Assessment completed',
AssessmentStarted: 'Assessment Started',
InvitationAccepted: 'Invitation Accepted',
ActivityRestarted: '[Web] Activity Restart Button Pressed',
ActivityResumed: '[Web] Activity Resume Button Pressed',
};
2 changes: 2 additions & 0 deletions src/shared/utils/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './mixpanel';
export * from './analyticsService';
File renamed without changes.
2 changes: 1 addition & 1 deletion src/shared/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export * from './helpers';
// Common
export * from './eventEmitter';
export * from './dictionary.map';
export * from './mixpanel';
export * from './analytics';
export * from './useTimer';
export * from './matchPaths';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usePublicSaveAnswerMutation, useSaveAnswerMutation } from '~/entities/activity';
import { Mixpanel } from '~/shared/utils';
import { MixEvents, MixProperties, Mixpanel } from '~/shared/utils';

type Props = {
isPublic: boolean;
Expand All @@ -9,17 +9,23 @@ type Props = {

export const useSubmitAnswersMutations = (props: Props) => {
const { mutate: submitAnswers, isLoading: submitLoading } = useSaveAnswerMutation({
onSuccess() {
Mixpanel.track('Assessment completed');
onSuccess(_, variables) {
Mixpanel.track(MixEvents.AssessmentCompleted, {
[MixProperties.AppletId]: variables.appletId,
[MixProperties.SubmitId]: variables.submitId,
});

return props.onSubmitSuccess();
},
});

const { mutate: submitPublicAnswers, isLoading: publicSubmitLoading } =
usePublicSaveAnswerMutation({
onSuccess() {
Mixpanel.track('Assessment completed');
onSuccess(_, variables) {
Mixpanel.track(MixEvents.AssessmentCompleted, {
[MixProperties.AppletId]: variables.appletId,
[MixProperties.SubmitId]: variables.submitId,
});

return props.onSubmitSuccess();
},
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/ActivityGroups/model/hooks/useStartEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ActivityStatus, EntityType } from '~/abstract/lib/GroupBuilder';
import { appletModel } from '~/entities/applet';
import { AppletDetailsBaseInfoDTO } from '~/shared/api';
import { ROUTES } from '~/shared/constants';
import { Mixpanel, useCustomNavigation } from '~/shared/utils';
import { MixEvents, MixProperties, Mixpanel, useCustomNavigation } from '~/shared/utils';

type NavigateToEntityProps = {
flowId: string | null;
Expand Down Expand Up @@ -57,7 +57,7 @@ export const useStartEntity = (props: Props) => {
}

function startActivityOrFlow(params: OnActivityCardClickProps) {
Mixpanel.track('Assessment Started');
Mixpanel.track(MixEvents.AssessmentStarted, { [MixProperties.AppletId]: props.applet.id });

const { flowId, eventId, activity, status, shouldRestart } = params;

Expand Down
18 changes: 15 additions & 3 deletions src/widgets/ActivityGroups/ui/ActivityCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ import { ActivityListItem } from '~/abstract/lib/GroupBuilder';
import { useActivityByIdMutation } from '~/entities/activity';
import { appletModel } from '~/entities/applet';
import Loader from '~/shared/ui/Loader';
import { useAppSelector, useCustomMediaQuery } from '~/shared/utils';
import {
MixEvents,
MixProperties,
Mixpanel,
useAppSelector,
useCustomMediaQuery,
} from '~/shared/utils';

type Props = {
activityListItem: ActivityListItem;
Expand Down Expand Up @@ -112,8 +118,14 @@ export const ActivityCard = ({ activityListItem }: Props) => {
);
}

const restartActivity = () => onStartActivity(true);
const resumeActivity = () => onStartActivity(false);
const restartActivity = () => {
onStartActivity(true);
Mixpanel.track(MixEvents.ActivityRestarted, { [MixProperties.AppletId]: context.applet.id });
};
const resumeActivity = () => {
onStartActivity(false);
Mixpanel.track(MixEvents.ActivityResumed, { [MixProperties.AppletId]: context.applet.id });
};

if (isLoading) {
return (
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/FetchInvitation/ui/FetchPrivateInvitation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ export const FetchPrivateInvitation = ({
);
}

const invitation = data?.data?.result;

return (
<Invitation
invite={data?.data?.result}
invite={invitation}
isUserAuthenticated={isAuthenticated}
actionComponent={
<Box display="flex" justifyContent="center" alignItems="center" flexDirection="row">
Expand All @@ -65,7 +67,7 @@ export const FetchPrivateInvitation = ({
margin="16px 0px"
flexDirection={lessThanSM ? 'column' : 'row'}
>
<PrivateJoinAcceptButton invitationKey={keyParams} />
<PrivateJoinAcceptButton invitationKey={keyParams} appletId={invitation.appletId} />
<PrivateJoinDeclineButton />
</Box>
) : (
Expand Down
Loading