@edx/frontend-plugin-learner-dashboard 3.3.2 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _i18n = require("@edx/frontend-platform/i18n");
9
9
  var _paragon = require("@openedx/paragon");
10
10
  var _icons = require("@openedx/paragon/icons");
11
+ var _reactIntersectionObserver = require("react-intersection-observer");
11
12
  var _urls = require("data/services/lms/urls");
12
13
  var _emptyCourse = _interopRequireDefault(require("assets/empty-course.svg"));
13
14
  var _hooks = require("hooks");
@@ -26,15 +27,26 @@ const NoCoursesView = () => {
26
27
  const {
27
28
  courseSearchUrl
28
29
  } = _hooks.reduxHooks.usePlatformSettingsData();
30
+ const viewCorrelationIdRef = (0, _react.useRef)(window.crypto.randomUUID());
31
+ const hasViewEventFired = (0, _react.useRef)(false);
32
+ const {
33
+ ref: exploreCoursesRef,
34
+ inView
35
+ } = (0, _reactIntersectionObserver.useInView)({
36
+ triggerOnce: true
37
+ });
29
38
  const handleExploreCoursesViewed = (0, _react.useCallback)(() => {
30
- (0, _exploreCourses.exploreCoursesViewedCohesion)();
39
+ (0, _exploreCourses.exploreCoursesViewedCohesion)(viewCorrelationIdRef.current);
31
40
  }, []);
32
41
  const handleExploreCoursesClick = () => {
33
- (0, _exploreCourses.exploreCoursesClickedCohesion)();
42
+ (0, _exploreCourses.exploreCoursesClickedCohesion)(viewCorrelationIdRef.current);
34
43
  };
35
44
  (0, _react.useEffect)(() => {
36
- handleExploreCoursesViewed();
37
- }, [handleExploreCoursesViewed]);
45
+ if (!hasViewEventFired.current && inView) {
46
+ handleExploreCoursesViewed();
47
+ hasViewEventFired.current = true;
48
+ }
49
+ }, [handleExploreCoursesViewed, inView]);
38
50
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
39
51
  id: "no-courses-content-view",
40
52
  className: "d-flex align-items-center justify-content-center mb-4.5",
@@ -52,6 +64,7 @@ const NoCoursesView = () => {
52
64
  onClick: handleExploreCoursesClick,
53
65
  href: (0, _urls.baseAppUrl)(courseSearchUrl),
54
66
  iconBefore: _icons.Search,
67
+ ref: exploreCoursesRef,
55
68
  children: formatMessage(_messages.default.exploreCoursesButton)
56
69
  })]
57
70
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_i18n","_paragon","_icons","_urls","_emptyCourse","_interopRequireDefault","_hooks","_exploreCourses","_messages","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NoCoursesView","formatMessage","useIntl","courseSearchUrl","reduxHooks","usePlatformSettingsData","handleExploreCoursesViewed","useCallback","exploreCoursesViewedCohesion","handleExploreCoursesClick","exploreCoursesClickedCohesion","useEffect","jsxs","id","className","children","jsx","Image","src","emptyCourseSVG","alt","messages","bannerAlt","lookingForChallengePrompt","exploreCoursesPrompt","Button","variant","as","onClick","href","baseAppUrl","iconBefore","Search","exploreCoursesButton","_default","exports"],"sources":["../../src/no-courses-view/index.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport React, { useCallback, useEffect } from 'react';\nimport { useIntl } from '@edx/frontend-platform/i18n';\nimport { Button, Image } from '@openedx/paragon';\nimport { Search } from '@openedx/paragon/icons';\nimport { baseAppUrl } from 'data/services/lms/urls';\n\nimport emptyCourseSVG from 'assets/empty-course.svg';\nimport { reduxHooks } from 'hooks';\nimport { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../tracking/trackers/exploreCourses';\n\nimport messages from './messages';\nimport './index.scss';\n\nconst NoCoursesView = () => {\n const { formatMessage } = useIntl();\n const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();\n\n const handleExploreCoursesViewed = useCallback(() => {\n exploreCoursesViewedCohesion();\n }, []);\n\n const handleExploreCoursesClick = () => {\n exploreCoursesClickedCohesion();\n };\n\n useEffect(() => {\n handleExploreCoursesViewed();\n }, [handleExploreCoursesViewed]);\n\n return (\n <div\n id=\"no-courses-content-view\"\n className=\"d-flex align-items-center justify-content-center mb-4.5\"\n >\n <Image src={emptyCourseSVG} alt={formatMessage(messages.bannerAlt)} />\n <h3 className=\"h1\">\n {formatMessage(messages.lookingForChallengePrompt)}\n </h3>\n <p>\n {formatMessage(messages.exploreCoursesPrompt)}\n </p>\n <Button\n variant=\"brand\"\n as=\"a\"\n onClick={handleExploreCoursesClick}\n href={baseAppUrl(courseSearchUrl)}\n iconBefore={Search}\n >\n {formatMessage(messages.exploreCoursesButton)}\n </Button>\n </div>\n );\n};\n\nexport default NoCoursesView;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,eAAA,GAAAR,OAAA;AAEA,IAAAS,SAAA,GAAAH,sBAAA,CAAAN,OAAA;AACAA,OAAA;AAAsB,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAM,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAhB,uBAAA,YAAAA,CAAAY,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,C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AAC,QAAA,gBAEnE,IAAAnC,WAAA,CAAAoC,GAAA,EAAC5C,QAAA,CAAA6C,KAAK;MAACC,GAAG,EAAEC,oBAAe;MAACC,GAAG,EAAEnB,aAAa,CAACoB,iBAAQ,CAACC,SAAS;IAAE,CAAE,CAAC,eACtE,IAAA1C,WAAA,CAAAoC,GAAA;MAAIF,SAAS,EAAC,IAAI;MAAAC,QAAA,EACfd,aAAa,CAACoB,iBAAQ,CAACE,yBAAyB;IAAC,CAChD,CAAC,eACL,IAAA3C,WAAA,CAAAoC,GAAA;MAAAD,QAAA,EACGd,aAAa,CAACoB,iBAAQ,CAACG,oBAAoB;IAAC,CAC5C,CAAC,eACJ,IAAA5C,WAAA,CAAAoC,GAAA,EAAC5C,QAAA,CAAAqD,MAAM;MACLC,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,OAAO,EAAEnB,yBAA0B;MACnCoB,IAAI,EAAE,IAAAC,gBAAU,EAAC3B,eAAe,CAAE;MAClC4B,UAAU,EAAEC,aAAO;MAAAjB,QAAA,EAElBd,aAAa,CAACoB,iBAAQ,CAACY,oBAAoB;IAAC,CACvC,CAAC;EAAA,CACN,CAAC;AAEV,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAApD,OAAA,GAEaiB,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireWildcard","require","_i18n","_paragon","_icons","_reactIntersectionObserver","_urls","_emptyCourse","_interopRequireDefault","_hooks","_exploreCourses","_messages","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NoCoursesView","formatMessage","useIntl","courseSearchUrl","reduxHooks","usePlatformSettingsData","viewCorrelationIdRef","useRef","window","crypto","randomUUID","hasViewEventFired","ref","exploreCoursesRef","inView","useInView","triggerOnce","handleExploreCoursesViewed","useCallback","exploreCoursesViewedCohesion","current","handleExploreCoursesClick","exploreCoursesClickedCohesion","useEffect","jsxs","id","className","children","jsx","Image","src","emptyCourseSVG","alt","messages","bannerAlt","lookingForChallengePrompt","exploreCoursesPrompt","Button","variant","as","onClick","href","baseAppUrl","iconBefore","Search","exploreCoursesButton","_default","exports"],"sources":["../../src/no-courses-view/index.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport React, { useCallback, useEffect, useRef } from 'react';\nimport { useIntl } from '@edx/frontend-platform/i18n';\nimport { Button, Image } from '@openedx/paragon';\nimport { Search } from '@openedx/paragon/icons';\nimport { useInView } from 'react-intersection-observer';\n\nimport { baseAppUrl } from 'data/services/lms/urls';\n\nimport emptyCourseSVG from 'assets/empty-course.svg';\nimport { reduxHooks } from 'hooks';\nimport { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../tracking/trackers/exploreCourses';\n\nimport messages from './messages';\nimport './index.scss';\n\nconst NoCoursesView = () => {\n const { formatMessage } = useIntl();\n const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();\n const viewCorrelationIdRef = useRef(window.crypto.randomUUID());\n const hasViewEventFired = useRef(false);\n\n const { ref: exploreCoursesRef, inView } = useInView({ triggerOnce: true });\n\n const handleExploreCoursesViewed = useCallback(() => {\n exploreCoursesViewedCohesion(viewCorrelationIdRef.current);\n }, []);\n\n const handleExploreCoursesClick = () => {\n exploreCoursesClickedCohesion(viewCorrelationIdRef.current);\n };\n\n useEffect(() => {\n if (!hasViewEventFired.current && inView) {\n handleExploreCoursesViewed();\n hasViewEventFired.current = true;\n }\n }, [handleExploreCoursesViewed, inView]);\n\n return (\n <div\n id=\"no-courses-content-view\"\n className=\"d-flex align-items-center justify-content-center mb-4.5\"\n >\n <Image src={emptyCourseSVG} alt={formatMessage(messages.bannerAlt)} />\n <h3 className=\"h1\">\n {formatMessage(messages.lookingForChallengePrompt)}\n </h3>\n <p>\n {formatMessage(messages.exploreCoursesPrompt)}\n </p>\n <Button\n variant=\"brand\"\n as=\"a\"\n onClick={handleExploreCoursesClick}\n href={baseAppUrl(courseSearchUrl)}\n iconBefore={Search}\n ref={exploreCoursesRef}\n >\n {formatMessage(messages.exploreCoursesButton)}\n </Button>\n </div>\n );\n};\n\nexport default NoCoursesView;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AAEA,IAAAM,YAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,eAAA,GAAAT,OAAA;AAEA,IAAAU,SAAA,GAAAH,sBAAA,CAAAP,OAAA;AACAA,OAAA;AAAsB,IAAAW,WAAA,GAAAX,OAAA;AAAA,SAAAO,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAb,wBAAAa,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAjB,uBAAA,YAAAA,CAAAa,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,C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CAACS,OAAO,GAAG,IAAI;IAClC;EACF,CAAC,EAAE,CAACH,0BAA0B,EAAEH,MAAM,CAAC,CAAC;EAExC,oBACE,IAAAlC,WAAA,CAAA4C,IAAA;IACEC,EAAE,EAAC,yBAAyB;IAC5BC,SAAS,EAAC,yDAAyD;IAAAC,QAAA,gBAEnE,IAAA/C,WAAA,CAAAgD,GAAA,EAACzD,QAAA,CAAA0D,KAAK;MAACC,GAAG,EAAEC,oBAAe;MAACC,GAAG,EAAE/B,aAAa,CAACgC,iBAAQ,CAACC,SAAS;IAAE,CAAE,CAAC,eACtE,IAAAtD,WAAA,CAAAgD,GAAA;MAAIF,SAAS,EAAC,IAAI;MAAAC,QAAA,EACf1B,aAAa,CAACgC,iBAAQ,CAACE,yBAAyB;IAAC,CAChD,CAAC,eACL,IAAAvD,WAAA,CAAAgD,GAAA;MAAAD,QAAA,EACG1B,aAAa,CAACgC,iBAAQ,CAACG,oBAAoB;IAAC,CAC5C,CAAC,eACJ,IAAAxD,WAAA,CAAAgD,GAAA,EAACzD,QAAA,CAAAkE,MAAM;MACLC,OAAO,EAAC,OAAO;MACfC,EAAE,EAAC,GAAG;MACNC,OAAO,EAAEnB,yBAA0B;MACnCoB,IAAI,EAAE,IAAAC,gBAAU,EAACvC,eAAe,CAAE;MAClCwC,UAAU,EAAEC,aAAO;MACnBhC,GAAG,EAAEC,iBAAkB;MAAAc,QAAA,EAEtB1B,aAAa,CAACgC,iBAAQ,CAACY,oBAAoB;IAAC,CACvC,CAAC;EAAA,CACN,CAAC;AAEV,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhE,OAAA,GAEaiB,aAAa","ignoreList":[]}
package/dist/package.json CHANGED
@@ -36,6 +36,7 @@
36
36
  "@optimizely/react-sdk": "^3.2.2",
37
37
  "jest-environment-jsdom": "^30.0.0",
38
38
  "lodash": "^4.17.21",
39
+ "react-intersection-observer": "^10.0.3",
39
40
  "react-redux": "^7.2.4",
40
41
  "react-responsive": "^10.0.0",
41
42
  "reselect": "^5.1.1"
@@ -47,7 +48,7 @@
47
48
  "@openedx/frontend-build": "14.6.2",
48
49
  "@testing-library/jest-dom": "^6.6.3",
49
50
  "@testing-library/react": "^16.2.0",
50
- "jest": "30.2.0",
51
+ "jest": "30.3.0",
51
52
  "react-error-boundary": "^6.1.0",
52
53
  "rosie": "2.1.1",
53
54
  "semantic-release": "^25.0.0",
@@ -5,19 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.exploreCoursesViewedCohesion = exports.exploreCoursesClickedCohesion = void 0;
7
7
  var _logging = require("@edx/frontend-platform/logging");
8
+ var _cookie = require("../cookie");
8
9
  var _constants = require("../constants");
9
- const exploreCoursesViewedCohesion = () => {
10
+ const exploreCoursesViewedCohesion = viewCorrelationId => {
10
11
  if (window.tagular && typeof window.tagular === 'function') {
11
12
  window.tagular?.('beam', {
12
13
  '@type': 'redventures.usertracking.v3.ElementViewed',
13
- metadata: {
14
- webElement: {
15
- elementType: _constants.BUTTON_ELEMENT_TYPE,
16
- htmlId: _constants.EXPLORE_COURSES_HTML_ID,
17
- location: _constants.LOCATION_LEARNER_HOME,
18
- name: _constants.EXPLORE_COURSES_EVENT_NAME,
19
- text: _constants.EXPLORE_COURSES_EVENT_TEXT
20
- }
14
+ viewCorrelationId,
15
+ webElement: {
16
+ elementType: _constants.BUTTON_ELEMENT_TYPE,
17
+ htmlId: _constants.EXPLORE_COURSES_HTML_ID,
18
+ location: _constants.LOCATION_LEARNER_HOME,
19
+ name: _constants.EXPLORE_COURSES_EVENT_NAME,
20
+ text: _constants.EXPLORE_COURSES_EVENT_TEXT,
21
+ position: '1'
21
22
  }
22
23
  });
23
24
  } else {
@@ -25,18 +26,20 @@ const exploreCoursesViewedCohesion = () => {
25
26
  }
26
27
  };
27
28
  exports.exploreCoursesViewedCohesion = exploreCoursesViewedCohesion;
28
- const exploreCoursesClickedCohesion = () => {
29
+ const exploreCoursesClickedCohesion = viewCorrelationId => {
30
+ const correlationId = (0, _cookie.handleCorrelationIDCookie)();
29
31
  if (window.tagular && typeof window.tagular === 'function') {
30
32
  window.tagular?.('beam', {
31
33
  '@type': 'redventures.usertracking.v3.ElementClicked',
32
- metadata: {
33
- webElement: {
34
- elementType: _constants.BUTTON_ELEMENT_TYPE,
35
- htmlId: _constants.EXPLORE_COURSES_HTML_ID,
36
- location: _constants.LOCATION_LEARNER_HOME,
37
- name: _constants.EXPLORE_COURSES_EVENT_NAME,
38
- text: _constants.EXPLORE_COURSES_EVENT_TEXT
39
- }
34
+ correlationId,
35
+ viewCorrelationId,
36
+ webElement: {
37
+ elementType: _constants.BUTTON_ELEMENT_TYPE,
38
+ htmlId: _constants.EXPLORE_COURSES_HTML_ID,
39
+ location: _constants.LOCATION_LEARNER_HOME,
40
+ name: _constants.EXPLORE_COURSES_EVENT_NAME,
41
+ text: _constants.EXPLORE_COURSES_EVENT_TEXT,
42
+ position: '1'
40
43
  }
41
44
  });
42
45
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"exploreCourses.js","names":["_logging","require","_constants","exploreCoursesViewedCohesion","window","tagular","metadata","webElement","elementType","BUTTON_ELEMENT_TYPE","htmlId","EXPLORE_COURSES_HTML_ID","location","LOCATION_LEARNER_HOME","name","EXPLORE_COURSES_EVENT_NAME","text","EXPLORE_COURSES_EVENT_TEXT","logError","exports","exploreCoursesClickedCohesion"],"sources":["../../../src/tracking/trackers/exploreCourses.js"],"sourcesContent":["import { logError } from '@edx/frontend-platform/logging';\n\nimport {\n BUTTON_ELEMENT_TYPE,\n LOCATION_LEARNER_HOME,\n EXPLORE_COURSES_HTML_ID,\n EXPLORE_COURSES_EVENT_NAME,\n EXPLORE_COURSES_EVENT_TEXT,\n} from '../constants';\n\nexport const exploreCoursesViewedCohesion = () => {\n if (window.tagular && typeof window.tagular === 'function') {\n window.tagular?.('beam', {\n '@type': 'redventures.usertracking.v3.ElementViewed',\n metadata: {\n webElement: {\n elementType: BUTTON_ELEMENT_TYPE,\n htmlId: EXPLORE_COURSES_HTML_ID,\n location: LOCATION_LEARNER_HOME,\n name: EXPLORE_COURSES_EVENT_NAME,\n text: EXPLORE_COURSES_EVENT_TEXT,\n },\n },\n });\n } else {\n logError('Cohesion script failed to load before CTA was viewed');\n }\n};\n\nexport const exploreCoursesClickedCohesion = () => {\n if (window.tagular && typeof window.tagular === 'function') {\n window.tagular?.('beam', {\n '@type': 'redventures.usertracking.v3.ElementClicked',\n metadata: {\n webElement: {\n elementType: BUTTON_ELEMENT_TYPE,\n htmlId: EXPLORE_COURSES_HTML_ID,\n location: LOCATION_LEARNER_HOME,\n name: EXPLORE_COURSES_EVENT_NAME,\n text: EXPLORE_COURSES_EVENT_TEXT,\n },\n },\n });\n } else {\n logError('Cohesion script failed to load before CTA was clicked');\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAQO,MAAME,4BAA4B,GAAGA,CAAA,KAAM;EAChD,IAAIC,MAAM,CAACC,OAAO,IAAI,OAAOD,MAAM,CAACC,OAAO,KAAK,UAAU,EAAE;IAC1DD,MAAM,CAACC,OAAO,GAAG,MAAM,EAAE;MACvB,OAAO,EAAE,2CAA2C;MACpDC,QAAQ,EAAE;QACRC,UAAU,EAAE;UACVC,WAAW,EAAEC,8BAAmB;UAChCC,MAAM,EAAEC,kCAAuB;UAC/BC,QAAQ,EAAEC,gCAAqB;UAC/BC,IAAI,EAAEC,qCAA0B;UAChCC,IAAI,EAAEC;QACR;MACF;IACF,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,IAAAC,iBAAQ,EAAC,sDAAsD,CAAC;EAClE;AACF,CAAC;AAACC,OAAA,CAAAhB,4BAAA,GAAAA,4BAAA;AAEK,MAAMiB,6BAA6B,GAAGA,CAAA,KAAM;EACjD,IAAIhB,MAAM,CAACC,OAAO,IAAI,OAAOD,MAAM,CAACC,OAAO,KAAK,UAAU,EAAE;IAC1DD,MAAM,CAACC,OAAO,GAAG,MAAM,EAAE;MACvB,OAAO,EAAE,4CAA4C;MACrDC,QAAQ,EAAE;QACRC,UAAU,EAAE;UACVC,WAAW,EAAEC,8BAAmB;UAChCC,MAAM,EAAEC,kCAAuB;UAC/BC,QAAQ,EAAEC,gCAAqB;UAC/BC,IAAI,EAAEC,qCAA0B;UAChCC,IAAI,EAAEC;QACR;MACF;IACF,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,IAAAC,iBAAQ,EAAC,uDAAuD,CAAC;EACnE;AACF,CAAC;AAACC,OAAA,CAAAC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"file":"exploreCourses.js","names":["_logging","require","_cookie","_constants","exploreCoursesViewedCohesion","viewCorrelationId","window","tagular","webElement","elementType","BUTTON_ELEMENT_TYPE","htmlId","EXPLORE_COURSES_HTML_ID","location","LOCATION_LEARNER_HOME","name","EXPLORE_COURSES_EVENT_NAME","text","EXPLORE_COURSES_EVENT_TEXT","position","logError","exports","exploreCoursesClickedCohesion","correlationId","handleCorrelationIDCookie"],"sources":["../../../src/tracking/trackers/exploreCourses.js"],"sourcesContent":["import { logError } from '@edx/frontend-platform/logging';\nimport { handleCorrelationIDCookie } from '../cookie';\n\nimport {\n BUTTON_ELEMENT_TYPE,\n LOCATION_LEARNER_HOME,\n EXPLORE_COURSES_HTML_ID,\n EXPLORE_COURSES_EVENT_NAME,\n EXPLORE_COURSES_EVENT_TEXT,\n} from '../constants';\n\nexport const exploreCoursesViewedCohesion = (viewCorrelationId) => {\n if (window.tagular && typeof window.tagular === 'function') {\n window.tagular?.('beam', {\n '@type': 'redventures.usertracking.v3.ElementViewed',\n viewCorrelationId,\n webElement: {\n elementType: BUTTON_ELEMENT_TYPE,\n htmlId: EXPLORE_COURSES_HTML_ID,\n location: LOCATION_LEARNER_HOME,\n name: EXPLORE_COURSES_EVENT_NAME,\n text: EXPLORE_COURSES_EVENT_TEXT,\n position: '1',\n },\n });\n } else {\n logError('Cohesion script failed to load before CTA was viewed');\n }\n};\n\nexport const exploreCoursesClickedCohesion = (viewCorrelationId) => {\n const correlationId = handleCorrelationIDCookie();\n\n if (window.tagular && typeof window.tagular === 'function') {\n window.tagular?.('beam', {\n '@type': 'redventures.usertracking.v3.ElementClicked',\n correlationId,\n viewCorrelationId,\n webElement: {\n elementType: BUTTON_ELEMENT_TYPE,\n htmlId: EXPLORE_COURSES_HTML_ID,\n location: LOCATION_LEARNER_HOME,\n name: EXPLORE_COURSES_EVENT_NAME,\n text: EXPLORE_COURSES_EVENT_TEXT,\n position: '1',\n },\n });\n } else {\n logError('Cohesion script failed to load before CTA was clicked');\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAQO,MAAMG,4BAA4B,GAAIC,iBAAiB,IAAK;EACjE,IAAIC,MAAM,CAACC,OAAO,IAAI,OAAOD,MAAM,CAACC,OAAO,KAAK,UAAU,EAAE;IAC1DD,MAAM,CAACC,OAAO,GAAG,MAAM,EAAE;MACvB,OAAO,EAAE,2CAA2C;MACpDF,iBAAiB;MACjBG,UAAU,EAAE;QACVC,WAAW,EAAEC,8BAAmB;QAChCC,MAAM,EAAEC,kCAAuB;QAC/BC,QAAQ,EAAEC,gCAAqB;QAC/BC,IAAI,EAAEC,qCAA0B;QAChCC,IAAI,EAAEC,qCAA0B;QAChCC,QAAQ,EAAE;MACZ;IACF,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,IAAAC,iBAAQ,EAAC,sDAAsD,CAAC;EAClE;AACF,CAAC;AAACC,OAAA,CAAAjB,4BAAA,GAAAA,4BAAA;AAEK,MAAMkB,6BAA6B,GAAIjB,iBAAiB,IAAK;EAClE,MAAMkB,aAAa,GAAG,IAAAC,iCAAyB,EAAC,CAAC;EAEjD,IAAIlB,MAAM,CAACC,OAAO,IAAI,OAAOD,MAAM,CAACC,OAAO,KAAK,UAAU,EAAE;IAC1DD,MAAM,CAACC,OAAO,GAAG,MAAM,EAAE;MACvB,OAAO,EAAE,4CAA4C;MACrDgB,aAAa;MACblB,iBAAiB;MACjBG,UAAU,EAAE;QACVC,WAAW,EAAEC,8BAAmB;QAChCC,MAAM,EAAEC,kCAAuB;QAC/BC,QAAQ,EAAEC,gCAAqB;QAC/BC,IAAI,EAAEC,qCAA0B;QAChCC,IAAI,EAAEC,qCAA0B;QAChCC,QAAQ,EAAE;MACZ;IACF,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,IAAAC,iBAAQ,EAAC,uDAAuD,CAAC;EACnE;AACF,CAAC;AAACC,OAAA,CAAAC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-plugin-learner-dashboard",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "Repository for Learner Dashboard MFE frontend plugins",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -36,6 +36,7 @@
36
36
  "@optimizely/react-sdk": "^3.2.2",
37
37
  "jest-environment-jsdom": "^30.0.0",
38
38
  "lodash": "^4.17.21",
39
+ "react-intersection-observer": "^10.0.3",
39
40
  "react-redux": "^7.2.4",
40
41
  "react-responsive": "^10.0.0",
41
42
  "reselect": "^5.1.1"
@@ -47,7 +48,7 @@
47
48
  "@openedx/frontend-build": "14.6.2",
48
49
  "@testing-library/jest-dom": "^6.6.3",
49
50
  "@testing-library/react": "^16.2.0",
50
- "jest": "30.2.0",
51
+ "jest": "30.3.0",
51
52
  "react-error-boundary": "^6.1.0",
52
53
  "rosie": "2.1.1",
53
54
  "semantic-release": "^25.0.0",
@@ -1,8 +1,10 @@
1
1
  /* eslint-disable import/no-unresolved */
2
- import React, { useCallback, useEffect } from 'react';
2
+ import React, { useCallback, useEffect, useRef } from 'react';
3
3
  import { useIntl } from '@edx/frontend-platform/i18n';
4
4
  import { Button, Image } from '@openedx/paragon';
5
5
  import { Search } from '@openedx/paragon/icons';
6
+ import { useInView } from 'react-intersection-observer';
7
+
6
8
  import { baseAppUrl } from 'data/services/lms/urls';
7
9
 
8
10
  import emptyCourseSVG from 'assets/empty-course.svg';
@@ -15,18 +17,25 @@ import './index.scss';
15
17
  const NoCoursesView = () => {
16
18
  const { formatMessage } = useIntl();
17
19
  const { courseSearchUrl } = reduxHooks.usePlatformSettingsData();
20
+ const viewCorrelationIdRef = useRef(window.crypto.randomUUID());
21
+ const hasViewEventFired = useRef(false);
22
+
23
+ const { ref: exploreCoursesRef, inView } = useInView({ triggerOnce: true });
18
24
 
19
25
  const handleExploreCoursesViewed = useCallback(() => {
20
- exploreCoursesViewedCohesion();
26
+ exploreCoursesViewedCohesion(viewCorrelationIdRef.current);
21
27
  }, []);
22
28
 
23
29
  const handleExploreCoursesClick = () => {
24
- exploreCoursesClickedCohesion();
30
+ exploreCoursesClickedCohesion(viewCorrelationIdRef.current);
25
31
  };
26
32
 
27
33
  useEffect(() => {
28
- handleExploreCoursesViewed();
29
- }, [handleExploreCoursesViewed]);
34
+ if (!hasViewEventFired.current && inView) {
35
+ handleExploreCoursesViewed();
36
+ hasViewEventFired.current = true;
37
+ }
38
+ }, [handleExploreCoursesViewed, inView]);
30
39
 
31
40
  return (
32
41
  <div
@@ -46,6 +55,7 @@ const NoCoursesView = () => {
46
55
  onClick={handleExploreCoursesClick}
47
56
  href={baseAppUrl(courseSearchUrl)}
48
57
  iconBefore={Search}
58
+ ref={exploreCoursesRef}
49
59
  >
50
60
  {formatMessage(messages.exploreCoursesButton)}
51
61
  </Button>
@@ -8,6 +8,13 @@ import { exploreCoursesViewedCohesion, exploreCoursesClickedCohesion } from '../
8
8
 
9
9
  const courseSearchUrl = '/course-search-url';
10
10
 
11
+ jest.mock('react-intersection-observer', () => ({
12
+ useInView: jest.fn(() => ({
13
+ ref: jest.fn(),
14
+ inView: jest.fn(),
15
+ })),
16
+ }));
17
+
11
18
  jest.mock('hooks', () => ({
12
19
  reduxHooks: {
13
20
  usePlatformSettingsData: jest.fn(() => ({
@@ -1,4 +1,5 @@
1
1
  import { logError } from '@edx/frontend-platform/logging';
2
+ import { handleCorrelationIDCookie } from '../cookie';
2
3
 
3
4
  import {
4
5
  BUTTON_ELEMENT_TYPE,
@@ -8,18 +9,18 @@ import {
8
9
  EXPLORE_COURSES_EVENT_TEXT,
9
10
  } from '../constants';
10
11
 
11
- export const exploreCoursesViewedCohesion = () => {
12
+ export const exploreCoursesViewedCohesion = (viewCorrelationId) => {
12
13
  if (window.tagular && typeof window.tagular === 'function') {
13
14
  window.tagular?.('beam', {
14
15
  '@type': 'redventures.usertracking.v3.ElementViewed',
15
- metadata: {
16
- webElement: {
17
- elementType: BUTTON_ELEMENT_TYPE,
18
- htmlId: EXPLORE_COURSES_HTML_ID,
19
- location: LOCATION_LEARNER_HOME,
20
- name: EXPLORE_COURSES_EVENT_NAME,
21
- text: EXPLORE_COURSES_EVENT_TEXT,
22
- },
16
+ viewCorrelationId,
17
+ webElement: {
18
+ elementType: BUTTON_ELEMENT_TYPE,
19
+ htmlId: EXPLORE_COURSES_HTML_ID,
20
+ location: LOCATION_LEARNER_HOME,
21
+ name: EXPLORE_COURSES_EVENT_NAME,
22
+ text: EXPLORE_COURSES_EVENT_TEXT,
23
+ position: '1',
23
24
  },
24
25
  });
25
26
  } else {
@@ -27,18 +28,21 @@ export const exploreCoursesViewedCohesion = () => {
27
28
  }
28
29
  };
29
30
 
30
- export const exploreCoursesClickedCohesion = () => {
31
+ export const exploreCoursesClickedCohesion = (viewCorrelationId) => {
32
+ const correlationId = handleCorrelationIDCookie();
33
+
31
34
  if (window.tagular && typeof window.tagular === 'function') {
32
35
  window.tagular?.('beam', {
33
36
  '@type': 'redventures.usertracking.v3.ElementClicked',
34
- metadata: {
35
- webElement: {
36
- elementType: BUTTON_ELEMENT_TYPE,
37
- htmlId: EXPLORE_COURSES_HTML_ID,
38
- location: LOCATION_LEARNER_HOME,
39
- name: EXPLORE_COURSES_EVENT_NAME,
40
- text: EXPLORE_COURSES_EVENT_TEXT,
41
- },
37
+ correlationId,
38
+ viewCorrelationId,
39
+ webElement: {
40
+ elementType: BUTTON_ELEMENT_TYPE,
41
+ htmlId: EXPLORE_COURSES_HTML_ID,
42
+ location: LOCATION_LEARNER_HOME,
43
+ name: EXPLORE_COURSES_EVENT_NAME,
44
+ text: EXPLORE_COURSES_EVENT_TEXT,
45
+ position: '1',
42
46
  },
43
47
  });
44
48
  } else {