AA-476: Send org_key with tracking events (#286)
Also convert the course tool click event from accidentally being a segment event into a log event, like it is on the LMS.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
|
||||
import { sendTrackingLogEvent } from '@edx/frontend-platform/analytics';
|
||||
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
|
||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
@@ -14,6 +14,7 @@ import messages from '../messages';
|
||||
import { useModel } from '../../../generic/model-store';
|
||||
|
||||
function CourseTools({ courseId, intl }) {
|
||||
const { org } = useModel('courses', courseId);
|
||||
const {
|
||||
courseTools,
|
||||
} = useModel('outline', courseId);
|
||||
@@ -24,8 +25,10 @@ function CourseTools({ courseId, intl }) {
|
||||
|
||||
const logClick = (analyticsId) => {
|
||||
const { administrator } = getAuthenticatedUser();
|
||||
sendTrackEvent('edx.course.tool.accessed', {
|
||||
course_id: courseId,
|
||||
sendTrackingLogEvent('edx.course.tool.accessed', {
|
||||
org_key: org,
|
||||
courserun_key: courseId,
|
||||
course_id: courseId, // should only be courserun_key, but left as-is for historical reasons
|
||||
is_staff: administrator,
|
||||
tool_name: analyticsId,
|
||||
});
|
||||
|
||||
@@ -9,10 +9,13 @@ import ClapsTablet from './assets/claps_456x328.gif';
|
||||
import messages from './messages';
|
||||
import SocialIcons from '../../social-share/SocialIcons';
|
||||
import { recordFirstSectionCelebration } from './utils';
|
||||
import { useModel } from '../../../generic/model-store';
|
||||
|
||||
function CelebrationModal({
|
||||
courseId, intl, open, ...rest
|
||||
}) {
|
||||
const { org } = useModel('courses', courseId);
|
||||
|
||||
const layout = layoutGenerator({
|
||||
mobile: 0,
|
||||
tablet: 400,
|
||||
@@ -23,7 +26,7 @@ function CelebrationModal({
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
recordFirstSectionCelebration(courseId);
|
||||
recordFirstSectionCelebration(org, courseId);
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
|
||||
@@ -16,14 +16,16 @@ function handleNextSectionCelebration(sequenceId, nextSequenceId, nextUnitId) {
|
||||
});
|
||||
}
|
||||
|
||||
function recordFirstSectionCelebration(courseId) {
|
||||
function recordFirstSectionCelebration(org, courseId) {
|
||||
// Tell the LMS
|
||||
postFirstSectionCelebrationComplete(courseId);
|
||||
|
||||
// Tell our analytics
|
||||
const { administrator } = getAuthenticatedUser();
|
||||
sendTrackEvent('edx.ui.lms.celebration.first_section.opened', {
|
||||
course_id: courseId,
|
||||
org_key: org,
|
||||
courserun_key: courseId,
|
||||
course_id: courseId, // should only be courserun_key, but left as-is for historical reasons
|
||||
is_staff: administrator,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ function CourseCelebration({ intl }) {
|
||||
certificateData,
|
||||
end,
|
||||
linkedinAddToProfileUrl,
|
||||
org,
|
||||
relatedPrograms,
|
||||
verifiedMode,
|
||||
verifyIdentityUrl,
|
||||
@@ -218,7 +219,7 @@ function CourseCelebration({ intl }) {
|
||||
break;
|
||||
}
|
||||
|
||||
useEffect(() => logVisit(courseId, administrator, visitEvent), [courseId, administrator, visitEvent]);
|
||||
useEffect(() => logVisit(org, courseId, administrator, visitEvent), [org, courseId, administrator, visitEvent]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -15,14 +15,14 @@ import { logClick, logVisit } from './utils';
|
||||
|
||||
function CourseNonPassing({ intl }) {
|
||||
const { courseId } = useSelector(state => state.courseware);
|
||||
const { tabs } = useModel('courses', courseId);
|
||||
const { org, tabs } = useModel('courses', courseId);
|
||||
const { administrator } = getAuthenticatedUser();
|
||||
|
||||
// Get progress tab link for 'view grades' button
|
||||
const progressTab = tabs.find(tab => tab.slug === 'progress');
|
||||
const progressLink = progressTab && progressTab.url;
|
||||
|
||||
useEffect(() => logVisit(courseId, administrator, 'nonpassing'), [courseId, administrator]);
|
||||
useEffect(() => logVisit(org, courseId, administrator, 'nonpassing'), [org, courseId, administrator]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -72,27 +72,29 @@ function getCourseExitText(courseId, intl) {
|
||||
|
||||
// Meant to be used as part of a button's onClick handler.
|
||||
// For convenience, you can pass a falsy event and it will be ignored.
|
||||
const logClick = (courseId, administrator, event) => {
|
||||
const logClick = (org, courseId, administrator, event) => {
|
||||
if (!event) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendTrackEvent(`edx.ui.lms.course_exit.${event}.clicked`, {
|
||||
course_id: courseId,
|
||||
org_key: org,
|
||||
courserun_key: courseId,
|
||||
is_staff: administrator,
|
||||
});
|
||||
};
|
||||
|
||||
// Use like the following to call this only once on initial page load:
|
||||
// useEffect(() => logVisit(courseId, administrator, variant), [courseId, administrator, variant]);
|
||||
// useEffect(() => logVisit(org, courseId, administrator, variant), [org, courseId, administrator, variant]);
|
||||
// For convenience, you can pass a falsy variant and it will be ignored.
|
||||
const logVisit = (courseId, administrator, variant) => {
|
||||
const logVisit = (org, courseId, administrator, variant) => {
|
||||
if (!variant) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendTrackEvent('edx.ui.lms.course_exit.visited', {
|
||||
course_id: courseId,
|
||||
org_key: org,
|
||||
courserun_key: courseId,
|
||||
is_staff: administrator,
|
||||
variant,
|
||||
});
|
||||
|
||||
@@ -31,6 +31,7 @@ function SocialIcons({
|
||||
}) {
|
||||
const {
|
||||
marketingUrl,
|
||||
org,
|
||||
title,
|
||||
} = useModel('courses', courseId);
|
||||
|
||||
@@ -48,7 +49,9 @@ function SocialIcons({
|
||||
|
||||
const { administrator } = getAuthenticatedUser();
|
||||
sendTrackEvent(analyticsId, {
|
||||
course_id: courseId,
|
||||
org_key: org,
|
||||
courserun_key: courseId,
|
||||
course_id: courseId, // should only be courserun_key, but left as-is for historical reasons
|
||||
is_staff: administrator,
|
||||
service,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user