Skip to content

Commit

Permalink
Merge pull request #293 from AkshataKatwal16/relese-changes
Browse files Browse the repository at this point in the history
Issue feat PS-2306: add telemetry events for center, manage user and master data
  • Loading branch information
itsvick authored Nov 6, 2024
2 parents 16e296e + 8d6a05c commit 849a1b8
Show file tree
Hide file tree
Showing 18 changed files with 778 additions and 21 deletions.
62 changes: 61 additions & 1 deletion src/components/ActionIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import cohortIcon from '../../public/images/apartment.svg';


import Image from "next/image";
import { TelemetryEventType } from "@/utils/app.constant";
import { telemetryFactory } from "@/utils/telemetry";

interface ActionCellProps {
onEdit: (rowData: any) => void;
Expand Down Expand Up @@ -45,6 +47,24 @@ const ActionIcon: React.FC<ActionCellProps> = ({
<Box
onClick={() => {
onEdit(rowData);
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];

const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: rowData?.cohortId?'click-edit-delete-action:'+rowData?.cohortId:rowData?.userId? 'edit-on-delete-action:'+rowData?.userId:'edit-on-delete-action',

type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
}}
sx={{
display: "flex",
Expand All @@ -67,7 +87,27 @@ const ActionIcon: React.FC<ActionCellProps> = ({
<Tooltip title={t("COMMON.DELETE")}>
<Box
onClick={() => {

console.log(rowData)

onDelete(rowData);
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];

const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: rowData?.cohortId?'click-on-delete-action:'+rowData?.cohortId:rowData?.userId? 'click-on-delete-action:'+rowData?.userId:'click-on-delete-action',
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
}}
sx={{
display: "flex",
Expand All @@ -91,7 +131,27 @@ const ActionIcon: React.FC<ActionCellProps> = ({
<Box
onClick={() => {
if(reassignCohort)
reassignCohort(rowData);
{
reassignCohort(rowData);
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];

const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'click-on-reassign-action:'+rowData?.userId,
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
}

}}
sx={{
display: "flex",
Expand Down
22 changes: 21 additions & 1 deletion src/components/AddNewCenters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@/components/GeneratedSchemas";
import SimpleModal from "@/components/SimpleModal";
import { getFormRead } from "@/services/CreateUserService";
import { CohortTypes, FormContext, FormContextType, apiCatchingDuration } from "@/utils/app.constant";
import { CohortTypes, FormContext, FormContextType, TelemetryEventType, apiCatchingDuration } from "@/utils/app.constant";
import { useLocationState } from "@/utils/useLocationState";
import { Box, Button, Typography } from "@mui/material";
import { IChangeEvent } from "@rjsf/core";
Expand All @@ -19,6 +19,7 @@ import { createCohort } from "@/services/CohortService/cohortService";
import useSubmittedButtonStore from "@/utils/useSharedState";
import FrameworkCategories from "./FrameworkCategories";
import { useQuery } from "@tanstack/react-query";
import { telemetryFactory } from "@/utils/telemetry";

interface CustomField {
fieldId: string;
Expand Down Expand Up @@ -227,6 +228,25 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
const cohortData = await createCohort(cohortDetails);
if (cohortData) {
showToastMessage(t("CENTERS.CENTER_CREATED_SUCCESSFULLY"), "success");
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];


const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'center-created-successfully',
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);

createCenterStatus? setCreateCenterStatus(false):setCreateCenterStatus(true)
setOpenAddNewCohort(false);
onClose();
Expand Down
43 changes: 43 additions & 0 deletions src/components/CommonUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Role,
RoleId,
Status,
TelemetryEventType,
apiCatchingDuration,
} from "@/utils/app.constant";
import { useLocationState } from "@/utils/useLocationState";
Expand All @@ -39,6 +40,7 @@ import { showToastMessage } from "./Toastify";
import { cohortMemberList } from "@/services/UserList";
import CustomModal from "./CustomModal";
import { setConfig } from "next/config";
import { telemetryFactory } from "@/utils/telemetry";

interface UserModalProps {
open: boolean;
Expand Down Expand Up @@ -372,6 +374,27 @@ const CommonUserModal: React.FC<UserModalProps> = ({
: "TEAM_LEADERS.TEAM_LEADER_UPDATED_SUCCESSFULLY";

showToastMessage(t(messageKey), "success");


const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];


const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: userType+'updated-successfully',
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);

} else {
const response = await createUser(apiBody);
console.log(response);
Expand All @@ -380,6 +403,26 @@ const CommonUserModal: React.FC<UserModalProps> = ({

if (userType === FormContextType.STUDENT) {
showToastMessage(t(messageKey), "success");

const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];


const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: userType+'created-successfully',
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);

}
} else {
showToastMessage(t("COMMON.SOMETHING_WENT_WRONG"), "error");
Expand Down
59 changes: 58 additions & 1 deletion src/components/HeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Select from "@mui/material/Select";
import { useTheme } from "@mui/material/styles";
import { useTranslation } from "next-i18next";
import { useEffect, useState } from "react";
import { QueryKeys, Role, Status } from "@/utils/app.constant";
import { QueryKeys, Role, Status, TelemetryEventType } from "@/utils/app.constant";
import FiberManualRecordIcon from "@mui/icons-material/FiberManualRecord";
import {
getCenterList,
Expand All @@ -28,6 +28,7 @@ import { formatedBlocks, formatedDistricts } from "@/services/formatedCohorts";
import { useRouter } from "next/router";
import useSubmittedButtonStore from "@/utils/useSharedState";
import { userAgent } from "next/server";
import { telemetryFactory } from "@/utils/telemetry";

interface State {
value: string;
Expand Down Expand Up @@ -189,6 +190,26 @@ const HeaderComponent = ({
console.log(error);
}
handleDistrictChange(selected, selectedCodes);

const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];


const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'filter-by-district:'+selected[0],
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);

};

const handleBlockChangeWrapper = async (
Expand Down Expand Up @@ -233,12 +254,48 @@ const HeaderComponent = ({
console.log(dataArray);
setAllCenters(cohortInfo);
handleBlockChange(selected, selectedCodes);
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];


const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'filter-by-block:'+selected[0],
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
};
const handleCenterChangeWrapper = (
selected: string[],
selectedCodes: string[]
) => {
handleCenterChange(selected, selectedCodes);
const windowUrl = window.location.pathname;
const cleanedUrl = windowUrl.replace(/^\//, '');
const env = cleanedUrl.split("/")[0];


const telemetryInteract = {
context: {
env: env,
cdata: [],
},
edata: {
id: 'filter-by-center:'+selected[0],
type: TelemetryEventType.CLICK,
subtype: '',
pageid: cleanedUrl,
},
};
telemetryFactory.interact(telemetryInteract);
};

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReassignCenterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ console.log(filters)
value: cohort.value,
}));

const formattedBlocks = filteredCBlocks.map(location => ({
const formattedBlocks = filteredCBlocks?.map(location => ({
...location,
label: location.label
? location.label.split(' ')
Expand Down
Loading

0 comments on commit 849a1b8

Please sign in to comment.