Skip to content

Commit

Permalink
feat(AU-2073): Trigger track event when iframe fails on load
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodra committed Jun 3, 2024
1 parent 9437142 commit 622c3e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/courseware/course/sequence/Unit/ContentIFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const testIDs = StrictDict({

const ContentIFrame = ({
iframeUrl,
courseId,
shouldShowContent,
loadingMessage,
id,
Expand All @@ -46,6 +47,7 @@ const ContentIFrame = ({
id,
iframeUrl,
onLoaded,
courseId,
});

const {
Expand Down Expand Up @@ -124,6 +126,7 @@ ContentIFrame.propTypes = {
elementId: PropTypes.string.isRequired,
onLoaded: PropTypes.func,
title: PropTypes.node.isRequired,
courseId: PropTypes.string.isRequired,
};

ContentIFrame.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getConfig } from '@edx/frontend-platform';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import React from 'react';
import { useDispatch } from 'react-redux';

Expand All @@ -22,6 +23,7 @@ export const stateKeys = StrictDict({
const useIFrameBehavior = ({
elementId,
id,
courseId,
iframeUrl,
onLoaded,
}) => {
Expand Down Expand Up @@ -94,6 +96,11 @@ const useIFrameBehavior = ({
const handleIFrameLoad = () => {
if (!hasLoaded) {
setShowError(true);
sendTrackEvent('edx.bi.error.learning.iframe_load_failed', {
iframeUrl,
unitId: id,
courseId,
});
logError('Unit iframe failed to load. Server possibly returned 4xx or 5xx response.', {
iframeUrl,
});
Expand Down
1 change: 1 addition & 0 deletions src/courseware/course/sequence/Unit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const Unit = ({
<UnitSuspense {...{ courseId, id }} />
<ContentIFrame
elementId="unit-iframe"
courseId={courseId}
id={id}
iframeUrl={iframeUrl}
loadingMessage={formatMessage(messages.loadingSequence)}
Expand Down

0 comments on commit 622c3e0

Please sign in to comment.