Skip to content

Commit c913436

Browse files
author
Katrina Nguyen
committed
feat: adds segment tracking events to groups features
feat: adds segment tracking events to groups features feat: adds more tracking events
1 parent 16c6a9f commit c913436

File tree

14 files changed

+263
-23
lines changed

14 files changed

+263
-23
lines changed

src/components/Admin/AdminSearchForm.jsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ import { Form } from '@openedx/paragon';
77
import { Info } from '@openedx/paragon/icons';
88

99
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
10+
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
1011

1112
import SearchBar from '../SearchBar';
1213
import { formatTimestamp, updateUrl } from '../../utils';
1314
import IconWithTooltip from '../IconWithTooltip';
1415
import { withLocation, withNavigate } from '../../hoc';
16+
import EVENT_NAMES from '../../eventTracking';
1517

1618
class AdminSearchForm extends React.Component {
1719
componentDidUpdate(prevProps) {
@@ -31,8 +33,8 @@ class AdminSearchForm extends React.Component {
3133
} = prevProps;
3234

3335
if (searchQuery !== prevSearchQuery || searchCourseQuery !== prevSearchCourseQuery
34-
|| searchDateQuery !== prevSearchDateQuery || searchBudgetQuery !== prevSearchBudgetQuery
35-
|| searchGroupQuery !== prevSearchGroupQuery) {
36+
|| searchDateQuery !== prevSearchDateQuery || searchBudgetQuery !== prevSearchBudgetQuery
37+
|| searchGroupQuery !== prevSearchGroupQuery) {
3638
this.handleSearch();
3739
}
3840
}
@@ -69,6 +71,11 @@ class AdminSearchForm extends React.Component {
6971
page: 1,
7072
};
7173
updateUrl(navigate, location.pathname, updateParams);
74+
sendEnterpriseTrackEvent(
75+
this.props.enterpriseId,
76+
EVENT_NAMES.LEARNER_PROGRESS_REPORT.FILTER_BY_GROUP_DROPDOWN,
77+
{ group: event.target.value },
78+
);
7279
}
7380

7481
render() {
@@ -81,7 +88,6 @@ class AdminSearchForm extends React.Component {
8188
searchCourseQuery, searchDateQuery, searchQuery, searchBudgetQuery, searchGroupQuery,
8289
},
8390
} = this.props;
84-
8591
const courseTitles = Array.from(new Set(tableData.map(en => en.course_title).sort()));
8692
const courseDates = Array.from(new Set(tableData.map(en => en.course_start_date).sort().reverse()));
8793
const columnWidth = (budgets?.length || groups?.length) ? 'col-md-3' : 'col-md-6';
@@ -252,7 +258,7 @@ class AdminSearchForm extends React.Component {
252258
</Form.Control>
253259
</Form.Group>
254260
</div>
255-
) : null }
261+
) : null}
256262
<div className={classNames('col-12 my-2 my-md-0 px-0 px-md-2 px-lg-3', columnWidth)}>
257263
<Form.Label id="search-email-label" className="mb-2">
258264
<FormattedMessage
@@ -305,6 +311,7 @@ AdminSearchForm.propTypes = {
305311
location: PropTypes.shape({
306312
pathname: PropTypes.string,
307313
}),
314+
enterpriseId: PropTypes.string,
308315
// injected
309316
intl: intlShape.isRequired,
310317
};

src/components/PeopleManagement/CreateGroupModal.jsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import { snakeCaseObject } from '@edx/frontend-platform/utils';
88
import {
99
ActionRow, Button, FullscreenModal, StatefulButton, useToggle,
1010
} from '@openedx/paragon';
11+
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
12+
1113
import LmsApiService from '../../data/services/LmsApiService';
1214
import SystemErrorAlertModal from '../learner-credit-management/cards/assignment-allocation-status-modals/SystemErrorAlertModal';
1315
import CreateGroupModalContent from './CreateGroupModalContent';
1416
import { peopleManagementQueryKeys } from './constants';
17+
import EVENT_NAMES from '../../eventTracking';
1518

1619
const CreateGroupModal = ({
1720
isModalOpen,
@@ -24,6 +27,7 @@ const CreateGroupModal = ({
2427
const [groupName, setGroupName] = useState('');
2528
const [canCreateGroup, setCanCreateGroup] = useState(false);
2629
const [canInviteMembers, setCanInviteMembers] = useState(false);
30+
const [isCreateGroupFileUpload, setIsCreateGroupFileUpload] = useState(false);
2731
const [isSystemErrorModalOpen, openSystemErrorModal, closeSystemErrorModal] = useToggle(false);
2832
const handleCloseCreateGroupModal = () => {
2933
closeModal();
@@ -38,13 +42,32 @@ const CreateGroupModal = ({
3842
groupName,
3943
};
4044
let groupCreationResponse;
41-
4245
try {
4346
groupCreationResponse = await LmsApiService.createEnterpriseGroup(options);
47+
sendEnterpriseTrackEvent(
48+
enterpriseUUID,
49+
EVENT_NAMES.PEOPLE_MANAGEMENT.CREATE_GROUP_MODAL_BUTTON_SUBMIT,
50+
{ status: 'success' },
51+
);
52+
53+
if (isCreateGroupFileUpload) {
54+
sendEnterpriseTrackEvent(
55+
enterpriseUUID,
56+
EVENT_NAMES.PEOPLE_MANAGEMENT.GROUP_CREATE_WITH_UPLOAD_CSV,
57+
);
58+
}
4459
} catch (err) {
4560
logError(err);
4661
setCreateButtonState('error');
4762
openSystemErrorModal();
63+
sendEnterpriseTrackEvent(
64+
enterpriseUUID,
65+
EVENT_NAMES.PEOPLE_MANAGEMENT.CREATE_GROUP_MODAL_BUTTON_SUBMIT,
66+
{
67+
status: 'error',
68+
message: err,
69+
},
70+
);
4871
}
4972

5073
try {
@@ -114,6 +137,7 @@ const CreateGroupModal = ({
114137
onEmailAddressesChange={handleEmailAddressesChange}
115138
isGroupInvite
116139
enterpriseUUID={enterpriseUUID}
140+
setIsCreateGroupFileUpload={setIsCreateGroupFileUpload}
117141
/>
118142
</FullscreenModal>
119143
<SystemErrorAlertModal

src/components/PeopleManagement/CreateGroupModalContent.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { useEnterpriseLearners } from '../learner-credit-management/data';
1818

1919
const CreateGroupModalContent = ({
2020
onEmailAddressesChange,
21+
setIsCreateGroupFileUpload,
2122
onSetGroupName,
2223
isGroupInvite,
2324
enterpriseUUID,
@@ -138,6 +139,7 @@ const CreateGroupModalContent = ({
138139
<FileUpload
139140
memberInviteMetadata={memberInviteMetadata}
140141
setEmailAddressesInputValue={setEmailAddressesInputValue}
142+
setIsCreateGroupFileUpload={setIsCreateGroupFileUpload}
141143
/>
142144
</Col>
143145
<Col>
@@ -161,6 +163,7 @@ CreateGroupModalContent.propTypes = {
161163
onSetGroupName: PropTypes.func,
162164
isGroupInvite: PropTypes.bool,
163165
enterpriseUUID: PropTypes.string.isRequired,
166+
setIsCreateGroupFileUpload: PropTypes.func,
164167
};
165168

166169
export default CreateGroupModalContent;

src/components/PeopleManagement/DownloadCSVButton.jsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import React, { useState, useEffect } from 'react';
22
import PropTypes from 'prop-types';
33
import { useIntl } from '@edx/frontend-platform/i18n';
4+
import { connect } from 'react-redux';
5+
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
46

57
import {
68
Icon, Spinner, StatefulButton, Toast, useToggle,
79
} from '@openedx/paragon';
810
import { Download, Check } from '@openedx/paragon/icons';
911
import { logError } from '@edx/frontend-platform/logging';
1012
import { downloadCsv, getTimeStampedFilename } from '../../utils';
13+
import EVENT_NAMES from '../../eventTracking';
1114

1215
const csvHeaders = ['Name', 'Email', 'Joined Organization', 'Enrollments'];
1316

@@ -16,7 +19,12 @@ const dataEntryToRow = (entry) => {
1619
return [name, email, joinedOrg, enrollments];
1720
};
1821

19-
const DownloadCsvButton = ({ testId, fetchData, totalCt }) => {
22+
const DownloadCsvButton = ({
23+
enterpriseUUID,
24+
testId,
25+
fetchData,
26+
totalCt,
27+
}) => {
2028
const [buttonState, setButtonState] = useState('pageLoading');
2129
const [isToastOpen, openToast, closeToast] = useToggle(false);
2230
const intl = useIntl();
@@ -34,8 +42,23 @@ const DownloadCsvButton = ({ testId, fetchData, totalCt }) => {
3442
downloadCsv(fileName, response.results, csvHeaders, dataEntryToRow);
3543
openToast();
3644
setButtonState('complete');
45+
sendEnterpriseTrackEvent(
46+
enterpriseUUID,
47+
EVENT_NAMES.PEOPLE_MANAGEMENT.DOWNLOAD_ALL_ORG_MEMBERS,
48+
{
49+
status: 'success',
50+
},
51+
);
3752
}).catch((err) => {
3853
logError(err);
54+
sendEnterpriseTrackEvent(
55+
enterpriseUUID,
56+
EVENT_NAMES.PEOPLE_MANAGEMENT.DOWNLOAD_ALL_ORG_MEMBERS,
57+
{
58+
status: 'error',
59+
message: err,
60+
},
61+
);
3962
});
4063
};
4164

@@ -101,6 +124,11 @@ DownloadCsvButton.propTypes = {
101124
fetchData: PropTypes.func.isRequired,
102125
totalCt: PropTypes.number,
103126
testId: PropTypes.string,
127+
enterpriseUUID: PropTypes.string,
104128
};
105129

106-
export default DownloadCsvButton;
130+
const mapStateToProps = state => ({
131+
enterpriseUUID: state.portalConfiguration.enterpriseId,
132+
});
133+
134+
export default connect(mapStateToProps)(DownloadCsvButton);

src/components/PeopleManagement/GroupDetailCard.jsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import PropTypes from 'prop-types';
22
import { useParams } from 'react-router';
3+
import { connect } from 'react-redux';
4+
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
5+
36
import { Card, Hyperlink } from '@openedx/paragon';
47
import { ROUTE_NAMES } from '../EnterpriseApp/data/constants';
8+
import EVENT_NAMES from '../../eventTracking';
59

6-
const GroupDetailCard = ({ group }) => {
10+
const GroupDetailCard = ({ enterpriseUUID, group }) => {
711
const { enterpriseSlug } = useParams();
812
return (
913
<Card className="group-detail-card">
@@ -15,6 +19,12 @@ const GroupDetailCard = ({ group }) => {
1519
<Hyperlink
1620
className="btn btn-outline-primary"
1721
destination={`/${enterpriseSlug}/admin/${ROUTE_NAMES.peopleManagement}/${group.uuid}`}
22+
onClick={() => {
23+
sendEnterpriseTrackEvent(
24+
enterpriseUUID,
25+
EVENT_NAMES.PEOPLE_MANAGEMENT.VIEW_GROUP_PROGRESS_BUTTON,
26+
);
27+
}}
1828
>
1929
View group
2030
</Hyperlink>
@@ -29,6 +39,11 @@ GroupDetailCard.propTypes = {
2939
name: PropTypes.string.isRequired,
3040
uuid: PropTypes.string.isRequired,
3141
}).isRequired,
42+
enterpriseUUID: PropTypes.string,
3243
};
3344

34-
export default GroupDetailCard;
45+
const mapStateToProps = state => ({
46+
enterpriseUUID: state.portalConfiguration.enterpriseId,
47+
});
48+
49+
export default connect(mapStateToProps)(GroupDetailCard);

src/components/PeopleManagement/GroupDetailPage/DownloadCsvIconButton.jsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { defineMessages, useIntl } from '@edx/frontend-platform/i18n';
4+
import { connect } from 'react-redux';
45

6+
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
57
import {
68
Icon, IconButtonWithTooltip, Toast, useToggle,
79
} from '@openedx/paragon';
810
import { Download } from '@openedx/paragon/icons';
911
import { logError } from '@edx/frontend-platform/logging';
1012
import GeneralErrorModal from '../GeneralErrorModal';
1113
import { downloadCsv, getTimeStampedFilename } from '../../../utils';
14+
import EVENT_NAMES from '../../../eventTracking';
1215

1316
const csvHeaders = ['Name', 'Email', 'Recent action', 'Enrollments'];
1417

1518
const DownloadCsvIconButton = ({
19+
enterpriseUUID,
1620
fetchAllData,
1721
dataCount,
1822
testId,
@@ -50,9 +54,22 @@ const DownloadCsvIconButton = ({
5054
))) : response.results;
5155
downloadCsv(fileName, selectedRowIdsToDownload, csvHeaders, dataEntryToRow);
5256
openToast();
57+
sendEnterpriseTrackEvent(
58+
enterpriseUUID,
59+
EVENT_NAMES.PEOPLE_MANAGEMENT.DOWNLOAD_GROUP_MEMBERS,
60+
{ status: 'success' },
61+
);
5362
}).catch((err) => {
5463
logError(err);
5564
openErrorModal();
65+
sendEnterpriseTrackEvent(
66+
enterpriseUUID,
67+
EVENT_NAMES.PEOPLE_MANAGEMENT.DOWNLOAD_GROUP_MEMBERS,
68+
{
69+
status: 'error',
70+
message: err,
71+
},
72+
);
5673
});
5774
};
5875

@@ -86,6 +103,7 @@ DownloadCsvIconButton.defaultProps = {
86103
};
87104

88105
DownloadCsvIconButton.propTypes = {
106+
enterpriseUUID: PropTypes.string,
89107
fetchAllData: PropTypes.func.isRequired,
90108
dataCount: PropTypes.number.isRequired,
91109
testId: PropTypes.string,
@@ -95,4 +113,8 @@ DownloadCsvIconButton.propTypes = {
95113
}),
96114
};
97115

98-
export default DownloadCsvIconButton;
116+
const mapStateToProps = state => ({
117+
enterpriseUUID: state.portalConfiguration.enterpriseId,
118+
});
119+
120+
export default connect(mapStateToProps)(DownloadCsvIconButton);

src/components/PeopleManagement/GroupDetailPage/GroupDetailPage.jsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import React, { useEffect, useState } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { connect } from 'react-redux';
24
import { useParams } from 'react-router-dom';
35
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
46
import {
57
Breadcrumb, Card, Hyperlink, Icon, IconButton, IconButtonWithTooltip, Skeleton, useToggle,
68
} from '@openedx/paragon';
79
import { Delete, Edit } from '@openedx/paragon/icons';
10+
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';
811

912
import { useEnterpriseGroupLearnersTableData, useEnterpriseGroupUuid } from '../data/hooks';
1013
import { ROUTE_NAMES } from '../../EnterpriseApp/data/constants';
@@ -14,8 +17,9 @@ import formatDates from '../utils';
1417
import GroupMembersTable from './GroupMembersTable';
1518
import AddMembersModal from '../AddMembersModal/AddMembersModal';
1619
import { makePlural } from '../../../utils';
20+
import EVENT_NAMES from '../../../eventTracking';
1721

18-
const GroupDetailPage = () => {
22+
const GroupDetailPage = ({ enterpriseUUID }) => {
1923
const intl = useIntl();
2024
const { enterpriseSlug, groupUuid } = useParams();
2125
const { data: enterpriseGroup } = useEnterpriseGroupUuid(groupUuid);
@@ -123,6 +127,12 @@ const GroupDetailPage = () => {
123127
className="btn btn-primary"
124128
target="_blank"
125129
destination={`/${enterpriseSlug}/admin/${ROUTE_NAMES.learners}?group_uuid=${groupUuid}`}
130+
onClick={() => {
131+
sendEnterpriseTrackEvent(
132+
enterpriseUUID,
133+
EVENT_NAMES.PEOPLE_MANAGEMENT.VIEW_GROUP_BUTTON,
134+
);
135+
}}
126136
>
127137
View group progress
128138
</Hyperlink>
@@ -168,4 +178,12 @@ const GroupDetailPage = () => {
168178
);
169179
};
170180

171-
export default GroupDetailPage;
181+
GroupDetailPage.propTypes = {
182+
enterpriseUUID: PropTypes.string,
183+
};
184+
185+
const mapStateToProps = state => ({
186+
enterpriseUUID: state.portalConfiguration.enterpriseId,
187+
});
188+
189+
export default connect(mapStateToProps)(GroupDetailPage);

0 commit comments

Comments
 (0)