AA-218: Course Tool Analytics (#118)
Tracking analytics for onClick events in the Course Tool widget. Extra: Fixed intl error in the Course Dates widget. Co-authored-by: Carla Duarte <cduarte@edx.org>
This commit is contained in:
@@ -14,7 +14,7 @@ function CourseDates({ courseId, intl }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="mb-3">
|
<section className="mb-3">
|
||||||
<h4>{intl.formatMessage(messages.tools)}</h4>
|
<h4>{intl.formatMessage(messages.dates)}</h4>
|
||||||
{datesWidget.courseDateBlocks.map((courseDateBlock) => (
|
{datesWidget.courseDateBlocks.map((courseDateBlock) => (
|
||||||
<DateSummary
|
<DateSummary
|
||||||
key={courseDateBlock.title + courseDateBlock.date}
|
key={courseDateBlock.title + courseDateBlock.date}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
|
||||||
|
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
|
||||||
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import {
|
import {
|
||||||
@@ -16,6 +18,15 @@ function CourseTools({ courseId, intl }) {
|
|||||||
courseTools,
|
courseTools,
|
||||||
} = useModel('outline', courseId);
|
} = useModel('outline', courseId);
|
||||||
|
|
||||||
|
const logClick = (analyticsId) => {
|
||||||
|
const { administrator } = getAuthenticatedUser();
|
||||||
|
sendTrackEvent('edx.course.tool.accessed', {
|
||||||
|
course_id: courseId,
|
||||||
|
is_staff: administrator,
|
||||||
|
tool_name: analyticsId,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const renderIcon = (iconClasses) => {
|
const renderIcon = (iconClasses) => {
|
||||||
switch (iconClasses) {
|
switch (iconClasses) {
|
||||||
case 'edx.bookmarks':
|
case 'edx.bookmarks':
|
||||||
@@ -40,7 +51,7 @@ function CourseTools({ courseId, intl }) {
|
|||||||
<h4>{intl.formatMessage(messages.tools)}</h4>
|
<h4>{intl.formatMessage(messages.tools)}</h4>
|
||||||
{courseTools.map((courseTool) => (
|
{courseTools.map((courseTool) => (
|
||||||
<div key={courseTool.analyticsId}>
|
<div key={courseTool.analyticsId}>
|
||||||
<a data-analytics-id={courseTool.analyticsId} href={courseTool.url}>
|
<a href={courseTool.url} onClick={() => logClick(courseTool.analyticsId)}>
|
||||||
<FontAwesomeIcon icon={renderIcon(courseTool.analyticsId)} className="mr-2" style={{ width: '20px' }} />
|
<FontAwesomeIcon icon={renderIcon(courseTool.analyticsId)} className="mr-2" style={{ width: '20px' }} />
|
||||||
{courseTool.title}
|
{courseTool.title}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user