Skip to content

Commit

Permalink
feat: AA-1121: Add in eventing for Goals (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillon-Dumesnil committed Dec 9, 2021
1 parent f92d2e2 commit 32e299e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/course-home/goal-unsubscribe/GoalUnsubscribe.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import { useParams } from 'react-router-dom';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';

import { Header } from '../../course-header';
Expand Down Expand Up @@ -28,6 +29,10 @@ function GoalUnsubscribe({ intl }) {
setError(true);
},
);
// We unfortunately have no information about the user, course, org, or really anything
// as visiting this page is allowed to be done anonymously and without the context of the course.
// The token can be used to connect a user and course, it will just require some post-processing
sendTrackEvent('edx.ui.lms.goal.unsubscribe', { token });
}, []); // deps=[] to only run once

return (
Expand Down
19 changes: 19 additions & 0 deletions src/course-home/outline-tab/widgets/WeeklyLearningGoalCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React, { useState } from 'react';
import PropTypes from 'prop-types';

import { Form, Card, Icon } from '@edx/paragon';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Email } from '@edx/paragon/icons';
import { useSelector } from 'react-redux';
Expand All @@ -22,8 +24,11 @@ function WeeklyLearningGoalCard({

const {
isMasquerading,
org,
} = useModel('courseHomeMeta', courseId);

const { administrator } = getAuthenticatedUser();

const [daysPerWeekGoal, setDaysPerWeekGoal] = useState(daysPerWeek);
// eslint-disable-next-line react/prop-types
const [isGetReminderSelected, setGetReminderSelected] = useState(subscribedToReminders);
Expand All @@ -35,6 +40,13 @@ function WeeklyLearningGoalCard({
setDaysPerWeekGoal(days);
if (!isMasquerading) { // don't save goal updates while masquerading
saveWeeklyLearningGoal(courseId, days, selectReminders);
sendTrackEvent('edx.ui.lms.goal.days-per-week.changed', {
org_key: org,
courserun_key: courseId,
is_staff: administrator,
num_days: days,
reminder_selected: selectReminders,
});
}
}

Expand All @@ -43,6 +55,13 @@ function WeeklyLearningGoalCard({
setGetReminderSelected(isGetReminderChecked);
if (!isMasquerading) { // don't save goal updates while masquerading
saveWeeklyLearningGoal(courseId, daysPerWeekGoal, isGetReminderChecked);
sendTrackEvent('edx.ui.lms.goal.reminder-selected.changed', {
org_key: org,
courserun_key: courseId,
is_staff: administrator,
num_days: daysPerWeekGoal,
reminder_selected: isGetReminderChecked,
});
}
}

Expand Down

0 comments on commit 32e299e

Please sign in to comment.