Skip to content

Commit

Permalink
Merge pull request #583 from AkshataKatwal16/reassign-cohorts
Browse files Browse the repository at this point in the history
Issue feat:Add telemetry events for board-enrolment
  • Loading branch information
itsvick authored Jan 8, 2025
2 parents 79508fe + 1956c6b commit b121c62
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/AttendanceComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ const AttendanceComparison: React.FC<AttendanceComparisonProps> = ({
tickFormatter={(value: any) => `${value}%`}
height={0}
reversed={isRTL ? true : false}
domain={[0, 100]}
/>
<YAxis
type="category"
Expand Down
19 changes: 19 additions & 0 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import ConfirmationModal from './ConfirmationModal';
import StyledMenu from './StyledMenu';
import { UpdateDeviceNotification } from '@/services/NotificationService';
import { getUserId } from '../services/ProfileService';
import { Telemetry } from '@/utils/app.constant';
import { telemetryFactory } from '@/utils/telemetry';

interface HeaderProps {
toggleDrawer?: (newOpen: boolean) => () => void;
Expand Down Expand Up @@ -83,6 +85,23 @@ const Header: React.FC<HeaderProps> = ({ toggleDrawer, openDrawer }) => {

const tenantid = localStorage.getItem('tenantId')
const deviceID = localStorage.getItem('deviceID');
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];
const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'logout-user',

type: Telemetry.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
if (deviceID) {
try {

Expand Down
19 changes: 19 additions & 0 deletions src/components/SortingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import ModalComponent from './Modal';
import { avgLearnerAttendanceLimit, lowLearnerAttendanceLimit } from '../../app.config';
import { Telemetry } from '@/utils/app.constant';
import { telemetryFactory } from '../utils/telemetry';

interface sortCardProps {
handleSorting?: (
Expand Down Expand Up @@ -140,6 +142,23 @@ const SortingModal: React.FC<sortCardProps> = ({
sortByStages
],
});
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];
const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'sort-by-applied',

type: Telemetry.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
}
handleCloseModal();
};
Expand Down
20 changes: 19 additions & 1 deletion src/pages/board-enrollment/student-detail/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { logEvent } from '@/utils/googleAnalytics';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import HorizontalLinearStepper from '@/components/HorizontalLinearStepper';
import { FeesStepBoards } from '@/utils/app.constant';
import { FeesStepBoards, Telemetry } from '@/utils/app.constant';
import { useDirection } from '../../../hooks/useDirection';
import BoardEnrollmentProfile from '@/components/BoardEnrollmentProfile';
import { GetStaticPaths } from 'next';
Expand All @@ -40,6 +40,7 @@ import useStore from '@/store/store';
import { updateCohortMemberStatus } from '@/services/MyClassDetailsService';
import ConfirmationModal from '@/components/ConfirmationModal';
import { showToastMessage } from '../../../components/Toastify';
import { telemetryFactory } from '@/utils/telemetry';

interface BoardEnrollment {
boardEnrollmentData: {
Expand Down Expand Up @@ -435,6 +436,23 @@ const BoardEnrollmentDetail = () => {
console.log('API Response:', response);

if (response && response.params.status === 'successful' && response.responseCode === 201) {
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];
const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: `endrolled-student(${userId})-to step ` + nextStep,

type: Telemetry.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
// API successful, update step state to nextStep
setActiveStep(nextStep);
} else {
Expand Down
18 changes: 18 additions & 0 deletions src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,24 @@ const LoginPage = () => {
'error'
);
}

const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];
const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'failed-login',

type: Telemetry.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
}
}
};
Expand Down
20 changes: 19 additions & 1 deletion src/pages/topic-detail-view.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CourseAccordion from '@/components/CourseAccordion';
import Header from '@/components/Header';
import useCourseStore from '@/store/coursePlannerStore';
import { ResourcesType } from '@/utils/app.constant';
import { ResourcesType, Telemetry } from '@/utils/app.constant';
import { logEvent } from '@/utils/googleAnalytics';
import KeyboardBackspaceOutlinedIcon from '@mui/icons-material/KeyboardBackspaceOutlined';
import { Box, Tab, Tabs } from '@mui/material';
Expand All @@ -12,6 +12,7 @@ import router from 'next/router';
import React, { useEffect, useState } from 'react';
import { useDirection } from '../hooks/useDirection';
import { RequisiteType } from '../../app.config';
import { telemetryFactory } from '@/utils/telemetry';

const TopicDetailView = () => {
const [value, setValue] = React.useState(1);
Expand Down Expand Up @@ -42,6 +43,23 @@ const TopicDetailView = () => {
};

const handleChange = (event: React.SyntheticEvent, newValue: number) => {
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];
const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id:
newValue === 1 ? 'change-tab-to-facilitator' : 'change-tab-to-learner',
type: Telemetry.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
setValue(newValue);
};

Expand Down

0 comments on commit b121c62

Please sign in to comment.