@edx/frontend-plugin-learner-dashboard 1.5.2 → 1.6.0

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.
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ const CohesionWrapper = () => {
9
+ const [isLoaded, setLoaded] = (0, _react.useState)(false);
10
+ (0, _react.useEffect)(() => {
11
+ if (isLoaded) {
12
+ return null;
13
+ }
14
+ const head = document.getElementsByTagName('head')[0];
15
+ const script = document.createElement('script');
16
+ script.src = 'https://www.edx.org/beam-wrapper.js';
17
+ script.defer = true;
18
+ script.dataset.testId = 'cohesion-test';
19
+ head.appendChild(script);
20
+ setLoaded(true);
21
+ return null;
22
+ }, [isLoaded]);
23
+ return null;
24
+ };
25
+ var _default = exports.default = CohesionWrapper;
26
+ //# sourceMappingURL=CohesionWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CohesionWrapper.js","names":["_react","require","CohesionWrapper","isLoaded","setLoaded","useState","useEffect","head","document","getElementsByTagName","script","createElement","src","defer","dataset","testId","appendChild","_default","exports","default"],"sources":["../../src/cohesion-wrapper/CohesionWrapper.jsx"],"sourcesContent":["import { useState, useEffect } from 'react';\n\nconst CohesionWrapper = () => {\n const [isLoaded, setLoaded] = useState(false);\n\n useEffect(() => {\n if (isLoaded) {\n return null;\n }\n\n const head = document.getElementsByTagName('head')[0];\n const script = document.createElement('script');\n script.src = 'https://www.edx.org/beam-wrapper.js';\n script.defer = true;\n script.dataset.testId = 'cohesion-test';\n head.appendChild(script);\n setLoaded(true);\n return null;\n }, [isLoaded]);\n\n return null;\n};\n\nexport default CohesionWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,eAAe,GAAGA,CAAA,KAAM;EAC5B,MAAM,CAACC,QAAQ,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAE7C,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIH,QAAQ,EAAE;MACZ,OAAO,IAAI;IACb;IAEA,MAAMI,IAAI,GAAGC,QAAQ,CAACC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACrD,MAAMC,MAAM,GAAGF,QAAQ,CAACG,aAAa,CAAC,QAAQ,CAAC;IAC/CD,MAAM,CAACE,GAAG,GAAG,qCAAqC;IAClDF,MAAM,CAACG,KAAK,GAAG,IAAI;IACnBH,MAAM,CAACI,OAAO,CAACC,MAAM,GAAG,eAAe;IACvCR,IAAI,CAACS,WAAW,CAACN,MAAM,CAAC;IACxBN,SAAS,CAAC,IAAI,CAAC;IACf,OAAO,IAAI;EACb,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEajB,eAAe","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _CohesionWrapper = _interopRequireDefault(require("./CohesionWrapper"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = _CohesionWrapper.default;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_CohesionWrapper","_interopRequireDefault","require","e","__esModule","default","_default","exports","CohesionWrapper"],"sources":["../../src/cohesion-wrapper/index.jsx"],"sourcesContent":["import CohesionWrapper from './CohesionWrapper';\n\nexport default CohesionWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAgD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEjCG,wBAAe","ignoreList":[]}
@@ -9,6 +9,9 @@ var _simpleSelectors = require("./simpleSelectors");
9
9
  // Selectors for retrieving course card data in the redux store
10
10
 
11
11
  const courseCard = exports.courseCard = {
12
+ course: (0, _simpleSelectors.mkCardSelector)(_simpleSelectors.cardSimpleSelectors.course, course => ({
13
+ courseName: course.courseName
14
+ })),
12
15
  courseRun: (0, _simpleSelectors.mkCardSelector)(_simpleSelectors.cardSimpleSelectors.courseRun, courseRun => courseRun === null ? {} : {
13
16
  upgradeUrl: courseRun.upgradeUrl,
14
17
  courseId: courseRun.courseId
@@ -35,7 +38,10 @@ const courseCard = exports.courseCard = {
35
38
  isExecEd2UCourse: _constants.EXECUTIVE_EDUCATION_COURSE_MODES.includes(enrollment.mode),
36
39
  canUpgrade: enrollment.canUpgrade
37
40
  };
38
- })
41
+ }),
42
+ courseProvider: (0, _simpleSelectors.mkCardSelector)(_simpleSelectors.cardSimpleSelectors.courseProvider, courseProvider => ({
43
+ name: courseProvider?.name
44
+ }))
39
45
  };
40
46
  var _default = exports.default = courseCard;
41
47
  //# sourceMappingURL=courseCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"courseCard.js","names":["_constants","require","_simpleSelectors","courseCard","exports","courseRun","mkCardSelector","cardSimpleSelectors","upgradeUrl","courseId","entitlement","Object","keys","length","isEntitlement","enrollment","isEnrolled","isVerified","isExecEd2UCourse","EXECUTIVE_EDUCATION_COURSE_MODES","includes","mode","canUpgrade","_default","default"],"sources":["../../../../../src/data/redux/app/selectors/courseCard.js"],"sourcesContent":["// Selectors for retrieving course card data in the redux store\n\nimport { EXECUTIVE_EDUCATION_COURSE_MODES } from '../constants';\nimport { cardSimpleSelectors, mkCardSelector } from './simpleSelectors';\n\nexport const courseCard = {\n courseRun: mkCardSelector(\n cardSimpleSelectors.courseRun,\n (courseRun) => (courseRun === null ? {} : {\n upgradeUrl: courseRun.upgradeUrl,\n courseId: courseRun.courseId,\n }),\n ),\n entitlement: mkCardSelector(\n cardSimpleSelectors.entitlement,\n (entitlement) => {\n if (!entitlement || Object.keys(entitlement).length === 0) {\n return { isEntitlement: false };\n }\n return {\n isEntitlement: true,\n };\n },\n ),\n enrollment: mkCardSelector(\n cardSimpleSelectors.enrollment,\n (enrollment) => {\n if (enrollment == null) {\n return { isEnrolled: false };\n }\n return {\n isEnrolled: enrollment.isEnrolled,\n isVerified: enrollment.isVerified,\n isExecEd2UCourse: EXECUTIVE_EDUCATION_COURSE_MODES.includes(enrollment.mode),\n canUpgrade: enrollment.canUpgrade,\n };\n },\n ),\n};\n\nexport default courseCard;\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKO,MAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACxBE,SAAS,EAAE,IAAAC,+BAAc,EACvBC,oCAAmB,CAACF,SAAS,EAC5BA,SAAS,IAAMA,SAAS,KAAK,IAAI,GAAG,CAAC,CAAC,GAAG;IACxCG,UAAU,EAAEH,SAAS,CAACG,UAAU;IAChCC,QAAQ,EAAEJ,SAAS,CAACI;EACtB,CACF,CAAC;EACDC,WAAW,EAAE,IAAAJ,+BAAc,EACzBC,oCAAmB,CAACG,WAAW,EAC9BA,WAAW,IAAK;IACf,IAAI,CAACA,WAAW,IAAIC,MAAM,CAACC,IAAI,CAACF,WAAW,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE;MACzD,OAAO;QAAEC,aAAa,EAAE;MAAM,CAAC;IACjC;IACA,OAAO;MACLA,aAAa,EAAE;IACjB,CAAC;EACH,CACF,CAAC;EACDC,UAAU,EAAE,IAAAT,+BAAc,EACxBC,oCAAmB,CAACQ,UAAU,EAC7BA,UAAU,IAAK;IACd,IAAIA,UAAU,IAAI,IAAI,EAAE;MACtB,OAAO;QAAEC,UAAU,EAAE;MAAM,CAAC;IAC9B;IACA,OAAO;MACLA,UAAU,EAAED,UAAU,CAACC,UAAU;MACjCC,UAAU,EAAEF,UAAU,CAACE,UAAU;MACjCC,gBAAgB,EAAEC,2CAAgC,CAACC,QAAQ,CAACL,UAAU,CAACM,IAAI,CAAC;MAC5EC,UAAU,EAAEP,UAAU,CAACO;IACzB,CAAC;EACH,CACF;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAnB,OAAA,CAAAoB,OAAA,GAEarB,UAAU","ignoreList":[]}
1
+ {"version":3,"file":"courseCard.js","names":["_constants","require","_simpleSelectors","courseCard","exports","course","mkCardSelector","cardSimpleSelectors","courseName","courseRun","upgradeUrl","courseId","entitlement","Object","keys","length","isEntitlement","enrollment","isEnrolled","isVerified","isExecEd2UCourse","EXECUTIVE_EDUCATION_COURSE_MODES","includes","mode","canUpgrade","courseProvider","name","_default","default"],"sources":["../../../../../src/data/redux/app/selectors/courseCard.js"],"sourcesContent":["// Selectors for retrieving course card data in the redux store\n\nimport { EXECUTIVE_EDUCATION_COURSE_MODES } from '../constants';\nimport { cardSimpleSelectors, mkCardSelector } from './simpleSelectors';\n\nexport const courseCard = {\n course: mkCardSelector(\n cardSimpleSelectors.course,\n (course) => ({\n courseName: course.courseName,\n }),\n ),\n courseRun: mkCardSelector(\n cardSimpleSelectors.courseRun,\n (courseRun) => (courseRun === null ? {} : {\n upgradeUrl: courseRun.upgradeUrl,\n courseId: courseRun.courseId,\n }),\n ),\n entitlement: mkCardSelector(\n cardSimpleSelectors.entitlement,\n (entitlement) => {\n if (!entitlement || Object.keys(entitlement).length === 0) {\n return { isEntitlement: false };\n }\n return {\n isEntitlement: true,\n };\n },\n ),\n enrollment: mkCardSelector(\n cardSimpleSelectors.enrollment,\n (enrollment) => {\n if (enrollment == null) {\n return { isEnrolled: false };\n }\n return {\n isEnrolled: enrollment.isEnrolled,\n isVerified: enrollment.isVerified,\n isExecEd2UCourse: EXECUTIVE_EDUCATION_COURSE_MODES.includes(enrollment.mode),\n canUpgrade: enrollment.canUpgrade,\n };\n },\n ),\n courseProvider: mkCardSelector(\n cardSimpleSelectors.courseProvider,\n (courseProvider) => ({ name: courseProvider?.name }),\n ),\n};\n\nexport default courseCard;\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKO,MAAME,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG;EACxBE,MAAM,EAAE,IAAAC,+BAAc,EACpBC,oCAAmB,CAACF,MAAM,EACzBA,MAAM,KAAM;IACXG,UAAU,EAAEH,MAAM,CAACG;EACrB,CAAC,CACH,CAAC;EACDC,SAAS,EAAE,IAAAH,+BAAc,EACvBC,oCAAmB,CAACE,SAAS,EAC5BA,SAAS,IAAMA,SAAS,KAAK,IAAI,GAAG,CAAC,CAAC,GAAG;IACxCC,UAAU,EAAED,SAAS,CAACC,UAAU;IAChCC,QAAQ,EAAEF,SAAS,CAACE;EACtB,CACF,CAAC;EACDC,WAAW,EAAE,IAAAN,+BAAc,EACzBC,oCAAmB,CAACK,WAAW,EAC9BA,WAAW,IAAK;IACf,IAAI,CAACA,WAAW,IAAIC,MAAM,CAACC,IAAI,CAACF,WAAW,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE;MACzD,OAAO;QAAEC,aAAa,EAAE;MAAM,CAAC;IACjC;IACA,OAAO;MACLA,aAAa,EAAE;IACjB,CAAC;EACH,CACF,CAAC;EACDC,UAAU,EAAE,IAAAX,+BAAc,EACxBC,oCAAmB,CAACU,UAAU,EAC7BA,UAAU,IAAK;IACd,IAAIA,UAAU,IAAI,IAAI,EAAE;MACtB,OAAO;QAAEC,UAAU,EAAE;MAAM,CAAC;IAC9B;IACA,OAAO;MACLA,UAAU,EAAED,UAAU,CAACC,UAAU;MACjCC,UAAU,EAAEF,UAAU,CAACE,UAAU;MACjCC,gBAAgB,EAAEC,2CAAgC,CAACC,QAAQ,CAACL,UAAU,CAACM,IAAI,CAAC;MAC5EC,UAAU,EAAEP,UAAU,CAACO;IACzB,CAAC;EACH,CACF,CAAC;EACDC,cAAc,EAAE,IAAAnB,+BAAc,EAC5BC,oCAAmB,CAACkB,cAAc,EACjCA,cAAc,KAAM;IAAEC,IAAI,EAAED,cAAc,EAAEC;EAAK,CAAC,CACrD;AACF,CAAC;AAAC,IAAAC,QAAA,GAAAvB,OAAA,CAAAwB,OAAA,GAEazB,UAAU","ignoreList":[]}
@@ -13,23 +13,35 @@ const simpleSelectors = exports.simpleSelectors = {
13
13
  enterpriseDashboard: mkSimpleSelector(app => app.enterpriseDashboard || {})
14
14
  };
15
15
  const cardSimpleSelectors = exports.cardSimpleSelectors = {
16
- enrollment: _ref => {
16
+ course: _ref => {
17
17
  let {
18
- enrollment
18
+ course
19
19
  } = _ref;
20
- return enrollment;
20
+ return course;
21
21
  },
22
- entitlement: _ref2 => {
22
+ courseProvider: _ref2 => {
23
23
  let {
24
- entitlement
24
+ courseProvider
25
25
  } = _ref2;
26
- return entitlement;
26
+ return courseProvider;
27
27
  },
28
28
  courseRun: _ref3 => {
29
29
  let {
30
30
  courseRun
31
31
  } = _ref3;
32
32
  return courseRun;
33
+ },
34
+ enrollment: _ref4 => {
35
+ let {
36
+ enrollment
37
+ } = _ref4;
38
+ return enrollment;
39
+ },
40
+ entitlement: _ref5 => {
41
+ let {
42
+ entitlement
43
+ } = _ref5;
44
+ return entitlement;
33
45
  }
34
46
  };
35
47
  const mkCardSelector = (simpleSelector, selector) => (state, cardId) => selector(simpleSelector(simpleSelectors.courseData(state)[cardId]));
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSelectors.js","names":["_reselect","require","appSelector","state","app","exports","mkSimpleSelector","cb","createSelector","simpleSelectors","courseData","enterpriseDashboard","cardSimpleSelectors","enrollment","_ref","entitlement","_ref2","courseRun","_ref3","mkCardSelector","simpleSelector","selector","cardId","hasAvailableDashboards","data","isLearnerPortalEnabled"],"sources":["../../../../../src/data/redux/app/selectors/simpleSelectors.js"],"sourcesContent":["import { createSelector } from 'reselect';\n\nexport const appSelector = (state) => state.app;\nconst mkSimpleSelector = (cb) => createSelector([appSelector], cb);\n\nexport const simpleSelectors = {\n courseData: mkSimpleSelector(app => app.courseData),\n enterpriseDashboard: mkSimpleSelector(app => app.enterpriseDashboard || {}),\n};\n\nexport const cardSimpleSelectors = {\n enrollment: ({ enrollment }) => enrollment,\n entitlement: ({ entitlement }) => entitlement,\n courseRun: ({ courseRun }) => courseRun,\n};\n\nexport const mkCardSelector = (simpleSelector, selector) => (state, cardId) => (\n selector(simpleSelector(simpleSelectors.courseData(state)[cardId]))\n);\n\nexport const hasAvailableDashboards = createSelector(\n [simpleSelectors.enterpriseDashboard],\n (data) => data !== null && data.isLearnerPortalEnabled === true,\n);\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAIC,KAAK,IAAKA,KAAK,CAACC,GAAG;AAACC,OAAA,CAAAH,WAAA,GAAAA,WAAA;AAChD,MAAMI,gBAAgB,GAAIC,EAAE,IAAK,IAAAC,wBAAc,EAAC,CAACN,WAAW,CAAC,EAAEK,EAAE,CAAC;AAE3D,MAAME,eAAe,GAAAJ,OAAA,CAAAI,eAAA,GAAG;EAC7BC,UAAU,EAAEJ,gBAAgB,CAACF,GAAG,IAAIA,GAAG,CAACM,UAAU,CAAC;EACnDC,mBAAmB,EAAEL,gBAAgB,CAACF,GAAG,IAAIA,GAAG,CAACO,mBAAmB,IAAI,CAAC,CAAC;AAC5E,CAAC;AAEM,MAAMC,mBAAmB,GAAAP,OAAA,CAAAO,mBAAA,GAAG;EACjCC,UAAU,EAAEC,IAAA;IAAA,IAAC;MAAED;IAAW,CAAC,GAAAC,IAAA;IAAA,OAAKD,UAAU;EAAA;EAC1CE,WAAW,EAAEC,KAAA;IAAA,IAAC;MAAED;IAAY,CAAC,GAAAC,KAAA;IAAA,OAAKD,WAAW;EAAA;EAC7CE,SAAS,EAAEC,KAAA;IAAA,IAAC;MAAED;IAAU,CAAC,GAAAC,KAAA;IAAA,OAAKD,SAAS;EAAA;AACzC,CAAC;AAEM,MAAME,cAAc,GAAGA,CAACC,cAAc,EAAEC,QAAQ,KAAK,CAAClB,KAAK,EAAEmB,MAAM,KACxED,QAAQ,CAACD,cAAc,CAACX,eAAe,CAACC,UAAU,CAACP,KAAK,CAAC,CAACmB,MAAM,CAAC,CAAC,CACnE;AAACjB,OAAA,CAAAc,cAAA,GAAAA,cAAA;AAEK,MAAMI,sBAAsB,GAAAlB,OAAA,CAAAkB,sBAAA,GAAG,IAAAf,wBAAc,EAClD,CAACC,eAAe,CAACE,mBAAmB,CAAC,EACpCa,IAAI,IAAKA,IAAI,KAAK,IAAI,IAAIA,IAAI,CAACC,sBAAsB,KAAK,IAC7D,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"simpleSelectors.js","names":["_reselect","require","appSelector","state","app","exports","mkSimpleSelector","cb","createSelector","simpleSelectors","courseData","enterpriseDashboard","cardSimpleSelectors","course","_ref","courseProvider","_ref2","courseRun","_ref3","enrollment","_ref4","entitlement","_ref5","mkCardSelector","simpleSelector","selector","cardId","hasAvailableDashboards","data","isLearnerPortalEnabled"],"sources":["../../../../../src/data/redux/app/selectors/simpleSelectors.js"],"sourcesContent":["import { createSelector } from 'reselect';\n\nexport const appSelector = (state) => state.app;\nconst mkSimpleSelector = (cb) => createSelector([appSelector], cb);\n\nexport const simpleSelectors = {\n courseData: mkSimpleSelector(app => app.courseData),\n enterpriseDashboard: mkSimpleSelector(app => app.enterpriseDashboard || {}),\n};\n\nexport const cardSimpleSelectors = {\n course: ({ course }) => course,\n courseProvider: ({ courseProvider }) => courseProvider,\n courseRun: ({ courseRun }) => courseRun,\n enrollment: ({ enrollment }) => enrollment,\n entitlement: ({ entitlement }) => entitlement,\n};\n\nexport const mkCardSelector = (simpleSelector, selector) => (state, cardId) => (\n selector(simpleSelector(simpleSelectors.courseData(state)[cardId]))\n);\n\nexport const hasAvailableDashboards = createSelector(\n [simpleSelectors.enterpriseDash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C,CAAC,CACnE;AAACrB,OAAA,CAAAkB,cAAA,GAAAA,cAAA;AAEK,MAAMI,sBAAsB,GAAAtB,OAAA,CAAAsB,sBAAA,GAAG,IAAAnB,wBAAc,EAClD,CAACC,eAAe,CAACE,mBAAmB,CAAC,EACpCiB,IAAI,IAAKA,IAAI,KAAK,IAAI,IAAIA,IAAI,CAACC,sBAAsB,KAAK,IAC7D,CAAC","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useTrackCourseEvent = exports.useMasqueradeData = exports.useHasAvailableDashboards = exports.useEnterpriseDashboardData = exports.useCourseCardData = exports.useCardEntitlementData = exports.useCardEnrollmentData = exports.useCardCourseRunData = exports.default = void 0;
6
+ exports.useTrackCourseEvent = exports.useMasqueradeData = exports.useHasAvailableDashboards = exports.useEnterpriseDashboardData = exports.useCourseCardData = exports.useCardProviderData = exports.useCardEntitlementData = exports.useCardEnrollmentData = exports.useCardCourseRunData = exports.useCardCourseData = exports.default = void 0;
7
7
  var _reactRedux = require("react-redux");
8
8
  var _courseCard = _interopRequireDefault(require("./app/selectors/courseCard"));
9
9
  var _selectors = require("./requests/selectors");
@@ -16,8 +16,10 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
16
16
  const useCourseCardData = selector => cardId => (0, _reactRedux.useSelector)(state => selector(state, cardId));
17
17
  exports.useCourseCardData = useCourseCardData;
18
18
  const useCardEntitlementData = exports.useCardEntitlementData = useCourseCardData(_courseCard.default.entitlement);
19
+ const useCardCourseData = exports.useCardCourseData = useCourseCardData(_courseCard.default.course);
19
20
  const useCardCourseRunData = exports.useCardCourseRunData = useCourseCardData(_courseCard.default.courseRun);
20
21
  const useCardEnrollmentData = exports.useCardEnrollmentData = useCourseCardData(_courseCard.default.enrollment);
22
+ const useCardProviderData = exports.useCardProviderData = useCourseCardData(_courseCard.default.courseProvider);
21
23
  const useHasAvailableDashboards = () => (0, _reactRedux.useSelector)(_simpleSelectors.hasAvailableDashboards);
22
24
  exports.useHasAvailableDashboards = useHasAvailableDashboards;
23
25
  const useTrackCourseEvent = function (tracker, cardId) {
@@ -27,7 +29,11 @@ const useTrackCourseEvent = function (tracker, cardId) {
27
29
  const {
28
30
  courseId
29
31
  } = useCardCourseRunData(cardId);
30
- return e => tracker(courseId, ...args)(e);
32
+ const org = useCardProviderData(cardId).name;
33
+ const {
34
+ courseName
35
+ } = useCardCourseData(cardId);
36
+ return e => tracker(courseId, org, courseName, ...args)(e);
31
37
  };
32
38
  exports.useTrackCourseEvent = useTrackCourseEvent;
33
39
  const useMasqueradeData = () => (0, _reactRedux.useSelector)(_selectors.masquerade);
@@ -35,6 +41,7 @@ exports.useMasqueradeData = useMasqueradeData;
35
41
  const useEnterpriseDashboardData = () => (0, _reactRedux.useSelector)(_simpleSelectors.simpleSelectors.enterpriseDashboard);
36
42
  exports.useEnterpriseDashboardData = useEnterpriseDashboardData;
37
43
  var _default = exports.default = {
44
+ useCardCourseData,
38
45
  useCardCourseRunData,
39
46
  useCardEnrollmentData,
40
47
  useCardEntitlementData,
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","names":["_reactRedux","require","_courseCard","_interopRequireDefault","_selectors","_simpleSelectors","e","__esModule","default","useCourseCardData","selector","cardId","useSelector","state","exports","useCardEntitlementData","courseCard","entitlement","useCardCourseRunData","courseRun","useCardEnrollmentData","enrollment","useHasAvailableDashboards","hasAvailableDashboards","useTrackCourseEvent","tracker","_len","arguments","length","args","Array","_key","courseId","useMasqueradeData","masquerade","useEnterpriseDashboardData","simpleSelectors","enterpriseDashboard","_default"],"sources":["../../../src/data/redux/hooks.js"],"sourcesContent":["/* eslint-disable import/no-named-as-default */\n/* eslint-disable react-hooks/rules-of-hooks */\nimport { useSelector } from 'react-redux';\nimport courseCard from './app/selectors/courseCard';\nimport { masquerade } from './requests/selectors';\nimport { hasAvailableDashboards, simpleSelectors } from './app/selectors/simpleSelectors';\n\n// eslint-disable-next-line\nexport const useCourseCardData = (selector) => (cardId) => useSelector(\n (state) => selector(state, cardId),\n);\n\nexport const useCardEntitlementData = useCourseCardData(courseCard.entitlement);\n\nexport const useCardCourseRunData = useCourseCardData(courseCard.courseRun);\n\nexport const useCardEnrollmentData = useCourseCardData(courseCard.enrollment);\n\nexport const useHasAvailableDashboards = () => useSelector(hasAvailableDashboards);\n\nexport const useTrackCourseEvent = (tracker, cardId, ...args) => {\n const { courseId } = useCardCourseRunData(cardId);\n return (e) => tracker(courseId, ...args)(e);\n};\n\nexport const useMasqueradeData = () => useSelector(masquerade);\n\nexport const useEnterpriseDashboardData = () => useSelector(simpleSelectors.enterpriseDashboard);\n\nexport default {\n useCardCourseRunData,\n useCardEnrollmentData,\n useCardEntitlementData,\n useHasAvailableDashboards,\n useMasqueradeData,\n useTrackCourseEvent,\n};\n"],"mappings":";;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAA0F,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAL1F;AACA;;AAMA;AACO,MAAMG,iBAAiB,GAAIC,QAAQ,IAAMC,MAAM,IAAK,IAAAC,uBAAW,EACnEC,KAAK,IAAKH,QAAQ,CAACG,KAAK,EAAEF,MAAM,CACnC,CAAC;AAACG,OAAA,CAAAL,iBAAA,GAAAA,iBAAA;AAEK,MAAMM,sBAAsB,GAAAD,OAAA,CAAAC,sBAAA,GAAGN,iBAAiB,CAACO,mBAAU,CAACC,WAAW,CAAC;AAExE,MAAMC,oBAAoB,GAAAJ,OAAA,CAAAI,oBAAA,GAAGT,iBAAiB,CAACO,mBAAU,CAACG,SAAS,CAAC;AAEpE,MAAMC,qBAAqB,GAAAN,OAAA,CAAAM,qBAAA,GAAGX,iBAAiB,CAACO,mBAAU,CAACK,UAAU,CAAC;AAEtE,MAAMC,yBAAyB,GAAGA,CAAA,KAAM,IAAAV,uBAAW,EAACW,uCAAsB,CAAC;AAACT,OAAA,CAAAQ,yBAAA,GAAAA,yBAAA;AAE5E,MAAME,mBAAmB,GAAG,SAAAA,CAACC,OAAO,EAAEd,MAAM,EAAc;EAAA,SAAAe,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAATC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAC1D,MAAM;IAAEC;EAAS,CAAC,GAAGd,oBAAoB,CAACP,MAAM,CAAC;EACjD,OAAQL,CAAC,IAAKmB,OAAO,CAACO,QAAQ,EAAE,GAAGH,IAAI,CAAC,CAACvB,CAAC,CAAC;AAC7C,CAAC;AAACQ,OAAA,CAAAU,mBAAA,GAAAA,mBAAA;AAEK,MAAMS,iBAAiB,GAAGA,CAAA,KAAM,IAAArB,uBAAW,EAACsB,qBAAU,CAAC;AAACpB,OAAA,CAAAmB,iBAAA,GAAAA,iBAAA;AAExD,MAAME,0BAA0B,GAAGA,CAAA,KAAM,IAAAvB,uBAAW,EAACwB,gCAAe,CAACC,mBAAmB,CAAC;AAACvB,OAAA,CAAAqB,0BAAA,GAAAA,0BAAA;AAAA,IAAAG,QAAA,GAAAxB,OAAA,CAAAN,OAAA,GAElF;EACbU,oBAAoB;EACpBE,qBAAqB;EACrBL,sBAAsB;EACtBO,yBAAyB;EACzBW,iBAAiB;EACjBT;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"hooks.js","names":["_reactRedux","require","_courseCard","_interopRequireDefault","_selectors","_simpleSelectors","e","__esModule","default","useCourseCardData","selector","cardId","useSelector","state","exports","useCardEntitlementData","courseCard","entitlement","useCardCourseData","course","useCardCourseRunData","courseRun","useCardEnrollmentData","enrollment","useCardProviderData","courseProvider","useHasAvailableDashboards","hasAvailableDashboards","useTrackCourseEvent","tracker","_len","arguments","length","args","Array","_key","courseId","org","name","courseName","useMasqueradeData","masquerade","useEnterpriseDashboardData","simpleSelectors","enterpriseDashboard","_default"],"sources":["../../../src/data/redux/hooks.js"],"sourcesContent":["/* eslint-disable import/no-named-as-default */\n/* eslint-disable react-hooks/rules-of-hooks */\nimport { useSelector } from 'react-redux';\nimport courseCard from './app/selectors/courseCard';\nimport { masquerade } from './requests/selectors';\nimport { hasAvailableDashboards, simpleSelectors } from './app/selectors/simpleSelectors';\n\n// eslint-disable-next-line\nexport const useCourseCardData = (selector) => (cardId) => useSelector(\n (state) => selector(state, cardId),\n);\n\nexport const useCardEntitlementData = useCourseCardData(courseCard.entitlement);\n\nexport const useCardCourseData = useCourseCardData(courseCard.course);\n\nexport const useCardCourseRunData = useCourseCardData(courseCard.courseRun);\n\nexport const useCardEnrollmentData = useCourseCardData(courseCard.enrollment);\n\nexport const useCardProviderData = useCourseCardData(courseCard.courseProvider);\n\nexport const useHasAvailableDashboards = () => useSelector(hasAvailableDashboards);\n\nexport const useTrackCourseEvent = (tracker, cardId, ...args) => {\n const { courseId } = useCardCourseRunData(cardId);\n const org = useCardProviderData(cardId).name;\n const { courseName } = useCardCourseData(cardId);\n return (e) => tracker(courseId, org, courseName, ...args)(e);\n};\n\nexport const useMasqueradeData = () => useSelector(masquerade);\n\nexport const useEnterpriseDashboardData = () => useSelector(simpleSelectors.enterpriseDashboard);\n\nexport default {\n useCardCourseData,\n useCardCourseRunData,\n useCardEnrollmentData,\n useCardEntitlementData,\n useHasAvailableDashboards,\n useMasqueradeData,\n useTrackCourseEvent,\n};\n"],"mappings":";;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AAA0F,SA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AAM,CAAC;EACjD,MAAM0B,GAAG,GAAGb,mBAAmB,CAACb,MAAM,CAAC,CAAC2B,IAAI;EAC5C,MAAM;IAAEC;EAAW,CAAC,GAAGrB,iBAAiB,CAACP,MAAM,CAAC;EAChD,OAAQL,CAAC,IAAKuB,OAAO,CAACO,QAAQ,EAAEC,GAAG,EAAEE,UAAU,EAAE,GAAGN,IAAI,CAAC,CAAC3B,CAAC,CAAC;AAC9D,CAAC;AAACQ,OAAA,CAAAc,mBAAA,GAAAA,mBAAA;AAEK,MAAMY,iBAAiB,GAAGA,CAAA,KAAM,IAAA5B,uBAAW,EAAC6B,qBAAU,CAAC;AAAC3B,OAAA,CAAA0B,iBAAA,GAAAA,iBAAA;AAExD,MAAME,0BAA0B,GAAGA,CAAA,KAAM,IAAA9B,uBAAW,EAAC+B,gCAAe,CAACC,mBAAmB,CAAC;AAAC9B,OAAA,CAAA4B,0BAAA,GAAAA,0BAAA;AAAA,IAAAG,QAAA,GAAA/B,OAAA,CAAAN,OAAA,GAElF;EACbU,iBAAiB;EACjBE,oBAAoB;EACpBE,qBAAqB;EACrBP,sBAAsB;EACtBW,yBAAyB;EACzBc,iBAAiB;EACjBZ;AACF,CAAC","ignoreList":[]}
package/dist/index.js CHANGED
@@ -3,18 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "EnterpriseDashboardModal", {
6
+ Object.defineProperty(exports, "CohesionWrapper", {
7
7
  enumerable: true,
8
8
  get: function () {
9
9
  return _index.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "HelpChatbot", {
12
+ Object.defineProperty(exports, "EnterpriseDashboardModal", {
13
13
  enumerable: true,
14
14
  get: function () {
15
15
  return _index2.default;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "HelpChatbot", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _index3.default;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "UpgradeButton", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -24,19 +30,20 @@ Object.defineProperty(exports, "UpgradeButton", {
24
30
  Object.defineProperty(exports, "UserCareerMenu", {
25
31
  enumerable: true,
26
32
  get: function () {
27
- return _index3.default;
33
+ return _index4.default;
28
34
  }
29
35
  });
30
36
  Object.defineProperty(exports, "UserDashboardMenu", {
31
37
  enumerable: true,
32
38
  get: function () {
33
- return _index4.default;
39
+ return _index5.default;
34
40
  }
35
41
  });
36
- var _index = _interopRequireDefault(require("./dashboard-modal/index"));
37
- var _index2 = _interopRequireDefault(require("./chatbot/index"));
42
+ var _index = _interopRequireDefault(require("./cohesion-wrapper/index"));
43
+ var _index2 = _interopRequireDefault(require("./dashboard-modal/index"));
44
+ var _index3 = _interopRequireDefault(require("./chatbot/index"));
38
45
  var _upgradeButton = _interopRequireDefault(require("./upgrade-button"));
39
- var _index3 = _interopRequireDefault(require("./career-menu/index"));
40
- var _index4 = _interopRequireDefault(require("./dashboard-menu/index"));
46
+ var _index4 = _interopRequireDefault(require("./career-menu/index"));
47
+ var _index5 = _interopRequireDefault(require("./dashboard-menu/index"));
41
48
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
42
49
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_index","_interopRequireDefault","require","_index2","_upgradeButton","_index3","_index4","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import EnterpriseDashboardModal from './dashboard-modal/index';\nimport HelpChatbot from './chatbot/index';\nimport UpgradeButton from './upgrade-button';\nimport UserCareerMenu from './career-menu/index';\nimport UserDashboardMenu from './dashboard-menu/index';\n\nexport {\n EnterpriseDashboardModal, HelpChatbot, UpgradeButton, UserCareerMenu, UserDashboardMenu,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_index","_interopRequireDefault","require","_index2","_index3","_upgradeButton","_index4","_index5","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import CohesionWrapper from './cohesion-wrapper/index';\nimport EnterpriseDashboardModal from './dashboard-modal/index';\nimport HelpChatbot from './chatbot/index';\nimport UpgradeButton from './upgrade-button';\nimport UserCareerMenu from './career-menu/index';\nimport UserDashboardMenu from './dashboard-menu/index';\n\nexport {\n CohesionWrapper, EnterpriseDashboardModal, HelpChatbot, UpgradeButton, UserCareerMenu, UserDashboardMenu,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AAAuD,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setCorrelationIDCookie = exports.handleCorrelationIDCookie = exports.getCorrelationIDCookie = void 0;
7
+ const getCorrelationIDCookie = () => {
8
+ const name = 'tglr_correlation_id=';
9
+ const decodedCookie = decodeURIComponent(document.cookie);
10
+ const cookieArray = decodedCookie.split(';');
11
+ for (let i = 0; i < cookieArray.length; i++) {
12
+ const cookie = cookieArray[i].trim();
13
+ if (cookie.indexOf(name) === 0) {
14
+ return cookie.substring(name.length, cookie.length);
15
+ }
16
+ }
17
+ return '';
18
+ };
19
+ exports.getCorrelationIDCookie = getCorrelationIDCookie;
20
+ const setCorrelationIDCookie = correlationId => {
21
+ const now = new Date();
22
+ const time = now.getTime();
23
+
24
+ // Cookie expires in 30 minutes, same as when set in marketing page
25
+ const expireTime = time + 1800;
26
+ now.setTime(expireTime);
27
+ document.cookie = `tglr_correlation_id=${correlationId}; expires=${now.toUTCString()}; path=/`;
28
+ };
29
+ exports.setCorrelationIDCookie = setCorrelationIDCookie;
30
+ const handleCorrelationIDCookie = () => {
31
+ // Get correlation ID from URL or cookies if it exists, otherwise set to random UUID
32
+ const queryString = window.location.search;
33
+ const urlParams = new URLSearchParams(queryString);
34
+ const correlationCookie = getCorrelationIDCookie();
35
+ const randomUUID = window.crypto.randomUUID();
36
+ const correlationId = urlParams.get('correlationId') || correlationCookie || randomUUID;
37
+
38
+ // Set CorrelationID cookie if one wasn't set
39
+ if (correlationCookie !== correlationId) {
40
+ setCorrelationIDCookie(correlationId);
41
+ }
42
+ return correlationId;
43
+ };
44
+ exports.handleCorrelationIDCookie = handleCorrelationIDCookie;
45
+ //# sourceMappingURL=cookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.js","names":["getCorrelationIDCookie","name","decodedCookie","decodeURIComponent","document","cookie","cookieArray","split","i","length","trim","indexOf","substring","exports","setCorrelationIDCookie","correlationId","now","Date","time","getTime","expireTime","setTime","toUTCString","handleCorrelationIDCookie","queryString","window","location","search","urlParams","URLSearchParams","correlationCookie","randomUUID","crypto","get"],"sources":["../../src/tracking/cookie.js"],"sourcesContent":["export const getCorrelationIDCookie = () => {\n const name = 'tglr_correlation_id=';\n const decodedCookie = decodeURIComponent(document.cookie);\n const cookieArray = decodedCookie.split(';');\n\n for (let i = 0; i < cookieArray.length; i++) {\n const cookie = cookieArray[i].trim();\n if (cookie.indexOf(name) === 0) {\n return cookie.substring(name.length, cookie.length);\n }\n }\n\n return '';\n};\n\nexport const setCorrelationIDCookie = (correlationId) => {\n const now = new Date();\n const time = now.getTime();\n\n // Cookie expires in 30 minutes, same as when set in marketing page\n const expireTime = time + 1800;\n now.setTime(expireTime);\n document.cookie = `tglr_correlation_id=${correlationId}; expires=${now.toUTCString()}; path=/`;\n};\n\nexport const handleCorrelationIDCookie = () => {\n // Get correlation ID from URL or cookies if it exists, otherwise set to random UUID\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n const correlationCookie = getCorrelationIDCookie();\n const randomUUID = window.crypto.randomUUID();\n\n const correlationId = urlParams.get('correlationId') || correlationCookie || randomUUID;\n\n // Set CorrelationID cookie if one wasn't set\n if (correlationCookie !== correlationId) {\n setCorrelationIDCookie(correlationId);\n }\n\n return correlationId;\n};\n"],"mappings":";;;;;;AAAO,MAAMA,sBAAsB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,IAAI,GAAG,sBAAsB;EACnC,MAAMC,aAAa,GAAGC,kBAAkB,CAACC,QAAQ,CAACC,MAAM,CAAC;EACzD,MAAMC,WAAW,GAAGJ,aAAa,CAACK,KAAK,CAAC,GAAG,CAAC;EAE5C,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,WAAW,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IAC3C,MAAMH,MAAM,GAAGC,WAAW,CAACE,CAAC,CAAC,CAACE,IAAI,CAAC,CAAC;IACpC,IAAIL,MAAM,CAACM,OAAO,CAACV,IAAI,CAAC,KAAK,CAAC,EAAE;MAC9B,OAAOI,MAAM,CAACO,SAAS,CAACX,IAAI,CAACQ,MAAM,EAAEJ,MAAM,CAACI,MAAM,CAAC;IACrD;EACF;EAEA,OAAO,EAAE;AACX,CAAC;AAACI,OAAA,CAAAb,sBAAA,GAAAA,sBAAA;AAEK,MAAMc,sBAAsB,GAAIC,aAAa,IAAK;EACvD,MAAMC,GAAG,GAAG,IAAIC,IAAI,CAAC,CAAC;EACtB,MAAMC,IAAI,GAAGF,GAAG,CAACG,OAAO,CAAC,CAAC;;EAE1B;EACA,MAAMC,UAAU,GAAGF,IAAI,GAAG,IAAI;EAC9BF,GAAG,CAACK,OAAO,CAACD,UAAU,CAAC;EACvBhB,QAAQ,CAACC,MAAM,GAAG,uBAAuBU,aAAa,aAAaC,GAAG,CAACM,WAAW,CAAC,CAAC,UAAU;AAChG,CAAC;AAACT,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAEK,MAAMS,yBAAyB,GAAGA,CAAA,KAAM;EAC7C;EACA,MAAMC,WAAW,GAAGC,MAAM,CAACC,QAAQ,CAACC,MAAM;EAC1C,MAAMC,SAAS,GAAG,IAAIC,eAAe,CAACL,WAAW,CAAC;EAClD,MAAMM,iBAAiB,GAAG9B,sBAAsB,CAAC,CAAC;EAClD,MAAM+B,UAAU,GAAGN,MAAM,CAACO,MAAM,CAACD,UAAU,CAAC,CAAC;EAE7C,MAAMhB,aAAa,GAAGa,SAAS,CAACK,GAAG,CAAC,eAAe,CAAC,IAAIH,iBAAiB,IAAIC,UAAU;;EAEvF;EACA,IAAID,iBAAiB,KAAKf,aAAa,EAAE;IACvCD,sBAAsB,CAACC,aAAa,CAAC;EACvC;EAEA,OAAOA,aAAa;AACtB,CAAC;AAACF,OAAA,CAAAU,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.upgradeClicked = void 0;
7
7
  var _utils = require("../utils");
8
+ var _cookie = require("../cookie");
8
9
  var _constants = require("../constants");
9
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -40,9 +41,30 @@ const upgradeButtonClicked = courseId => (0, _utils.createEventTracker)(_constan
40
41
  const upgradeButtonClickedUpsell = courseId => (0, _utils.createEventTracker)(_constants.eventNames.upgradeButtonClickedUpsell, _objectSpread(_objectSpread({}, upsellOptions), {}, {
41
42
  courseId
42
43
  }));
43
- const upgradeClicked = (courseId, href) => (0, _utils.createLinkTracker)(() => {
44
+ const upgradeButtonClickedCohesion = (org, courseName) => {
45
+ const correlationId = (0, _cookie.handleCorrelationIDCookie)();
46
+ const courseOrganization = org.toLowerCase();
47
+ window.tagular('beam', {
48
+ '@type': 'core.conversions.ConversionTracked.v2',
49
+ correlation: {
50
+ id: correlationId
51
+ },
52
+ metadata: {
53
+ category: 'Enrollment',
54
+ action: 'Upgrade',
55
+ timestamp: new Date().toISOString(),
56
+ productList: [{
57
+ brand: courseOrganization,
58
+ variant: 'courses',
59
+ name: courseName
60
+ }]
61
+ }
62
+ });
63
+ };
64
+ const upgradeClicked = (courseId, org, courseName, href) => (0, _utils.createLinkTracker)(() => {
44
65
  upgradeButtonClicked(courseId)();
45
66
  upgradeButtonClickedUpsell(courseId)();
67
+ upgradeButtonClickedCohesion(org, courseName);
46
68
  logUpgrade({
47
69
  courseId
48
70
  });
@@ -1 +1 @@
1
- {"version":3,"file":"upgradeButton.js","names":["_utils","require","_constants","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","upsellOptions","linkName","linkCategory","logUpgrade","_ref","courseId","logEvent","eventName","eventNames","upgradeButtonClickedEnrollment","data","location","upgradeButtonClicked","createEventTracker","category","categories","upgrade","label","upgradeButtonClickedUpsell","upgradeClicked","href","createLinkTracker","exports"],"sources":["../../../src/tracking/trackers/upgradeButton.js"],"sourcesContent":["import { logEvent, createEventTracker, createLinkTracker } from '../utils';\nimport { eventNames, categories } from '../constants';\n\nconst upsellOptions = {\n linkName: 'course_dashboard_green',\n linkCategory: 'green_update',\n};\n\nconst logUpgrade = ({ courseId }) => logEvent({\n eventName: eventNames.upgradeButtonClickedEnrollment,\n courseId,\n data: { location: 'learner-dashboard' },\n});\n\n// Upgrade Events\n/**\n * There are currently multiple tracked api events for the upgrade event, with different targets.\n * Goal here is to split out the tracked events for easier testing.\n */\nconst upgradeButtonClicked = (courseId) => createEventTracker(\n eventNames.upgradeButtonClicked,\n { category: categories.upgrade, label: courseId },\n);\nconst upgradeButtonClickedUpsell = (courseId) => createEventTracker(\n eventNames.upgradeButtonClickedUpsell,\n { ...upsellOptions, courseId },\n);\nexport const upgradeClicked = (courseId, href) => createLinkTracker(\n () => {\n upgradeButtonClicked(courseId)();\n upgradeButtonClickedUpsell(courseId)();\n logUpgrade({ courseId });\n },\n href,\n);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAAsD,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CA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,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"upgradeButton.js","names":["_utils","require","_cookie","_constants","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","upsellOptions","linkName","linkCategory","logUpgrade","_ref","courseId","logEvent","eventName","eventNames","upgradeButtonClickedEnrollment","data","location","upgradeButtonClicked","createEventTracker","category","categories","upgrade","label","upgradeButtonClickedUpsell","upgradeButtonClickedCohesion","org","courseName","correlationId","handleCorrelationIDCookie","courseOrganization","toLowerCase","window","tagular","correlation","id","metadata","action","timestamp","Date","toISOString","productList","brand","variant","name","upgradeClicked","href","createLinkTracker","exports"],"sources":["../../../src/tracking/trackers/upgradeButton.js"],"sourcesContent":["import { logEvent, createEventTracker, createLinkTracker } from '../utils';\nimport { handleCorrelationIDCookie } from '../cookie';\nimport { eventNames, categories } from '../constants';\n\nconst upsellOptions = {\n linkName: 'course_dashboard_green',\n linkCategory: 'green_update',\n};\n\nconst logUpgrade = ({ courseId }) => logEvent({\n eventName: eventNames.upgradeButtonClickedEnrollment,\n courseId,\n data: { location: 'learner-dashboard' },\n});\n\n// Upgrade Events\n/**\n * There are currently multiple tracked api events for the upgrade event, with different targets.\n * Goal here is to split out the tracked events for easier testing.\n */\nconst upgradeButtonClicked = (courseId) => createEventTracker(\n eventNames.upgradeButtonClicked,\n { category: categories.upgrade, label: courseId },\n);\n\nconst upgradeButtonClickedUpsell = (courseId) => createEventTracker(\n eventNames.upgradeButtonClickedUpsell,\n { ...upsellOptions, courseId },\n);\n\nconst upgradeButtonClickedCohesion = (org, courseName) => {\n const correlationId = handleCorrelationIDCookie();\n const courseOrganization = org.toLowerCase();\n\n window.tagular('beam', {\n '@type': 'core.conversions.ConversionTracked.v2',\n correlation: {\n id: correlationId,\n },\n metadata: {\n category: 'Enrollment',\n action: 'Upgrade',\n timestamp: new Date().toISOString(),\n productList: [{\n brand: courseOrganization,\n variant: 'courses',\n name: courseName,\n }],\n },\n });\n};\n\nexport const upgradeClicked = (courseId, org, courseName, href) => createLinkTracker(\n () => {\n upgradeButtonClicked(courseId)();\n upgradeButtonClickedUpsell(courseId)();\n upgradeButtonClickedCohesion(org, courseName);\n logUpgrade({ courseId });\n },\n href,\n);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAAsD,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI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;AAC1B,CAAC,EACDmC,IACF,CAAC;AAACE,OAAA,CAAAH,cAAA,GAAAA,cAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-plugin-learner-dashboard",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "Repository for Learner Dashboard MFE frontend plugins",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -0,0 +1,24 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ const CohesionWrapper = () => {
4
+ const [isLoaded, setLoaded] = useState(false);
5
+
6
+ useEffect(() => {
7
+ if (isLoaded) {
8
+ return null;
9
+ }
10
+
11
+ const head = document.getElementsByTagName('head')[0];
12
+ const script = document.createElement('script');
13
+ script.src = 'https://www.edx.org/beam-wrapper.js';
14
+ script.defer = true;
15
+ script.dataset.testId = 'cohesion-test';
16
+ head.appendChild(script);
17
+ setLoaded(true);
18
+ return null;
19
+ }, [isLoaded]);
20
+
21
+ return null;
22
+ };
23
+
24
+ export default CohesionWrapper;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import {
3
+ render,
4
+ } from '@testing-library/react';
5
+
6
+ import CohesionWrapper from './CohesionWrapper';
7
+
8
+ describe('Cohesion Wrapper loads', () => {
9
+ it('should load the Cohesion wrapper into the head', () => {
10
+ render(<CohesionWrapper />);
11
+ const script = document.getElementsByTagName('script')[0];
12
+
13
+ expect(script.dataset.testId).toEqual('cohesion-test');
14
+ });
15
+ });
@@ -0,0 +1,3 @@
1
+ import CohesionWrapper from './CohesionWrapper';
2
+
3
+ export default CohesionWrapper;
@@ -4,6 +4,12 @@ import { EXECUTIVE_EDUCATION_COURSE_MODES } from '../constants';
4
4
  import { cardSimpleSelectors, mkCardSelector } from './simpleSelectors';
5
5
 
6
6
  export const courseCard = {
7
+ course: mkCardSelector(
8
+ cardSimpleSelectors.course,
9
+ (course) => ({
10
+ courseName: course.courseName,
11
+ }),
12
+ ),
7
13
  courseRun: mkCardSelector(
8
14
  cardSimpleSelectors.courseRun,
9
15
  (courseRun) => (courseRun === null ? {} : {
@@ -36,6 +42,10 @@ export const courseCard = {
36
42
  };
37
43
  },
38
44
  ),
45
+ courseProvider: mkCardSelector(
46
+ cardSimpleSelectors.courseProvider,
47
+ (courseProvider) => ({ name: courseProvider?.name }),
48
+ ),
39
49
  };
40
50
 
41
51
  export default courseCard;
@@ -103,5 +103,34 @@ describe('courseCard selectors module', () => {
103
103
  expect(selected.isEntitlement).toEqual(true);
104
104
  });
105
105
  });
106
+ describe('courseProvider selector', () => {
107
+ beforeEach(() => {
108
+ loadSelector(courseCard.courseProvider, { name: 'test-provider-name' });
109
+ });
110
+ it('returns a card selector based on courseProvider cardSimpleSelector', () => {
111
+ expect(simpleSelector).toEqual(cardSimpleSelectors.courseProvider);
112
+ });
113
+ describe('name', () => {
114
+ it('passes the provider name if provider is known', () => {
115
+ expect(selected.name).toEqual(testData.name);
116
+ });
117
+ it('passes undefined if provider is not known', () => {
118
+ expect(selector().name).toEqual(undefined);
119
+ });
120
+ });
121
+ });
122
+ describe('course selector', () => {
123
+ beforeEach(() => {
124
+ loadSelector(courseCard.course, {
125
+ courseName: 'test-course-name',
126
+ });
127
+ });
128
+ it('returns a card selector based on course cardSimpleSelector', () => {
129
+ expect(simpleSelector).toEqual(cardSimpleSelectors.course);
130
+ });
131
+ it('passes [courseName]', () => {
132
+ expect(selected.courseName).toEqual(testData.courseName);
133
+ });
134
+ });
106
135
  });
107
136
  });
@@ -9,9 +9,11 @@ export const simpleSelectors = {
9
9
  };
10
10
 
11
11
  export const cardSimpleSelectors = {
12
+ course: ({ course }) => course,
13
+ courseProvider: ({ courseProvider }) => courseProvider,
14
+ courseRun: ({ courseRun }) => courseRun,
12
15
  enrollment: ({ enrollment }) => enrollment,
13
16
  entitlement: ({ entitlement }) => entitlement,
14
- courseRun: ({ courseRun }) => courseRun,
15
17
  };
16
18
 
17
19
  export const mkCardSelector = (simpleSelector, selector) => (state, cardId) => (
@@ -27,6 +27,8 @@ describe('simple selectors', () => {
27
27
  describe('cardSimpleSelectors', () => {
28
28
  keys = keyStore(cardSimpleSelectors);
29
29
  test.each([
30
+ keys.course,
31
+ keys.courseProvider,
30
32
  keys.courseRun,
31
33
  keys.enrollment,
32
34
  keys.entitlement,
@@ -12,15 +12,21 @@ export const useCourseCardData = (selector) => (cardId) => useSelector(
12
12
 
13
13
  export const useCardEntitlementData = useCourseCardData(courseCard.entitlement);
14
14
 
15
+ export const useCardCourseData = useCourseCardData(courseCard.course);
16
+
15
17
  export const useCardCourseRunData = useCourseCardData(courseCard.courseRun);
16
18
 
17
19
  export const useCardEnrollmentData = useCourseCardData(courseCard.enrollment);
18
20
 
21
+ export const useCardProviderData = useCourseCardData(courseCard.courseProvider);
22
+
19
23
  export const useHasAvailableDashboards = () => useSelector(hasAvailableDashboards);
20
24
 
21
25
  export const useTrackCourseEvent = (tracker, cardId, ...args) => {
22
26
  const { courseId } = useCardCourseRunData(cardId);
23
- return (e) => tracker(courseId, ...args)(e);
27
+ const org = useCardProviderData(cardId).name;
28
+ const { courseName } = useCardCourseData(cardId);
29
+ return (e) => tracker(courseId, org, courseName, ...args)(e);
24
30
  };
25
31
 
26
32
  export const useMasqueradeData = () => useSelector(masquerade);
@@ -28,6 +34,7 @@ export const useMasqueradeData = () => useSelector(masquerade);
28
34
  export const useEnterpriseDashboardData = () => useSelector(simpleSelectors.enterpriseDashboard);
29
35
 
30
36
  export default {
37
+ useCardCourseData,
31
38
  useCardCourseRunData,
32
39
  useCardEnrollmentData,
33
40
  useCardEntitlementData,
package/src/index.jsx CHANGED
@@ -1,3 +1,4 @@
1
+ import CohesionWrapper from './cohesion-wrapper/index';
1
2
  import EnterpriseDashboardModal from './dashboard-modal/index';
2
3
  import HelpChatbot from './chatbot/index';
3
4
  import UpgradeButton from './upgrade-button';
@@ -5,5 +6,5 @@ import UserCareerMenu from './career-menu/index';
5
6
  import UserDashboardMenu from './dashboard-menu/index';
6
7
 
7
8
  export {
8
- EnterpriseDashboardModal, HelpChatbot, UpgradeButton, UserCareerMenu, UserDashboardMenu,
9
+ CohesionWrapper, EnterpriseDashboardModal, HelpChatbot, UpgradeButton, UserCareerMenu, UserDashboardMenu,
9
10
  };
@@ -0,0 +1,41 @@
1
+ export const getCorrelationIDCookie = () => {
2
+ const name = 'tglr_correlation_id=';
3
+ const decodedCookie = decodeURIComponent(document.cookie);
4
+ const cookieArray = decodedCookie.split(';');
5
+
6
+ for (let i = 0; i < cookieArray.length; i++) {
7
+ const cookie = cookieArray[i].trim();
8
+ if (cookie.indexOf(name) === 0) {
9
+ return cookie.substring(name.length, cookie.length);
10
+ }
11
+ }
12
+
13
+ return '';
14
+ };
15
+
16
+ export const setCorrelationIDCookie = (correlationId) => {
17
+ const now = new Date();
18
+ const time = now.getTime();
19
+
20
+ // Cookie expires in 30 minutes, same as when set in marketing page
21
+ const expireTime = time + 1800;
22
+ now.setTime(expireTime);
23
+ document.cookie = `tglr_correlation_id=${correlationId}; expires=${now.toUTCString()}; path=/`;
24
+ };
25
+
26
+ export const handleCorrelationIDCookie = () => {
27
+ // Get correlation ID from URL or cookies if it exists, otherwise set to random UUID
28
+ const queryString = window.location.search;
29
+ const urlParams = new URLSearchParams(queryString);
30
+ const correlationCookie = getCorrelationIDCookie();
31
+ const randomUUID = window.crypto.randomUUID();
32
+
33
+ const correlationId = urlParams.get('correlationId') || correlationCookie || randomUUID;
34
+
35
+ // Set CorrelationID cookie if one wasn't set
36
+ if (correlationCookie !== correlationId) {
37
+ setCorrelationIDCookie(correlationId);
38
+ }
39
+
40
+ return correlationId;
41
+ };
@@ -0,0 +1,75 @@
1
+ import * as cookieFunctions from './cookie';
2
+
3
+ describe('cookie functions for Correlation ID', () => {
4
+ beforeEach(() => {
5
+ Object.defineProperty(document, 'cookie', {
6
+ writable: true,
7
+ value: '',
8
+ });
9
+
10
+ Object.defineProperty(global, 'crypto', {
11
+ value: {
12
+ randomUUID: jest.fn(() => 'mocked-random-uuid'),
13
+ },
14
+ });
15
+
16
+ jest.spyOn(global, 'decodeURIComponent').mockImplementation((val) => val);
17
+ });
18
+
19
+ afterEach(() => {
20
+ jest.restoreAllMocks(); // Restore the original document.cookie
21
+ });
22
+
23
+ describe('getCorrelationIDCookie', () => {
24
+ it('returns the Correlation ID cookie if present', () => {
25
+ document.cookie = 'tglr_correlation_id=some_uuid_string;another_cookie=another_string';
26
+ decodeURIComponent.mockReturnValue(document.cookie);
27
+
28
+ expect(cookieFunctions.getCorrelationIDCookie()).toEqual('some_uuid_string');
29
+ });
30
+
31
+ it('returns an empty string when there is no CorrelationID present', () => {
32
+ document.cookie = 'cookie=string';
33
+ decodeURIComponent.mockReturnValue(document.cookie);
34
+
35
+ expect(cookieFunctions.getCorrelationIDCookie()).toEqual('');
36
+ });
37
+ });
38
+
39
+ describe('setCorrelationIDCookie', () => {
40
+ it('sets the Correlation ID cookie', () => {
41
+ const correlationCookie = 'some_uuid_string';
42
+ cookieFunctions.setCorrelationIDCookie(correlationCookie);
43
+
44
+ expect(document.cookie).toContain(`tglr_correlation_id=${correlationCookie}`);
45
+ });
46
+ });
47
+
48
+ describe('handleCorrelationIDCookie', () => {
49
+ it('returns the correlation ID from the URL parameters', () => {
50
+ jest.spyOn(URLSearchParams.prototype, 'get').mockReturnValueOnce('correlation_id_uuid');
51
+
52
+ expect(cookieFunctions.handleCorrelationIDCookie()).toEqual('correlation_id_uuid');
53
+ expect(document.cookie).toContain('tglr_correlation_id=correlation_id_uuid');
54
+ });
55
+
56
+ it('returns the correlation ID from the cookies', () => {
57
+ Object.defineProperty(document, 'cookie', {
58
+ writable: true,
59
+ value: 'tglr_correlation_id=correlation_id_cookie',
60
+ });
61
+
62
+ jest.spyOn(URLSearchParams.prototype, 'get').mockReturnValueOnce('');
63
+ jest.spyOn(cookieFunctions, 'getCorrelationIDCookie').mockImplementation(() => 'correlation_id_cookie');
64
+
65
+ expect(cookieFunctions.handleCorrelationIDCookie()).toEqual('correlation_id_cookie');
66
+ });
67
+
68
+ it('returns the correlation ID provided by a random UUID generator', () => {
69
+ jest.spyOn(URLSearchParams.prototype, 'get').mockReturnValueOnce('');
70
+ jest.spyOn(cookieFunctions, 'getCorrelationIDCookie').mockImplementation(() => '');
71
+
72
+ expect(cookieFunctions.handleCorrelationIDCookie()).toEqual('mocked-random-uuid');
73
+ });
74
+ });
75
+ });
@@ -1,4 +1,5 @@
1
1
  import { logEvent, createEventTracker, createLinkTracker } from '../utils';
2
+ import { handleCorrelationIDCookie } from '../cookie';
2
3
  import { eventNames, categories } from '../constants';
3
4
 
4
5
  const upsellOptions = {
@@ -21,14 +22,39 @@ const upgradeButtonClicked = (courseId) => createEventTracker(
21
22
  eventNames.upgradeButtonClicked,
22
23
  { category: categories.upgrade, label: courseId },
23
24
  );
25
+
24
26
  const upgradeButtonClickedUpsell = (courseId) => createEventTracker(
25
27
  eventNames.upgradeButtonClickedUpsell,
26
28
  { ...upsellOptions, courseId },
27
29
  );
28
- export const upgradeClicked = (courseId, href) => createLinkTracker(
30
+
31
+ const upgradeButtonClickedCohesion = (org, courseName) => {
32
+ const correlationId = handleCorrelationIDCookie();
33
+ const courseOrganization = org.toLowerCase();
34
+
35
+ window.tagular('beam', {
36
+ '@type': 'core.conversions.ConversionTracked.v2',
37
+ correlation: {
38
+ id: correlationId,
39
+ },
40
+ metadata: {
41
+ category: 'Enrollment',
42
+ action: 'Upgrade',
43
+ timestamp: new Date().toISOString(),
44
+ productList: [{
45
+ brand: courseOrganization,
46
+ variant: 'courses',
47
+ name: courseName,
48
+ }],
49
+ },
50
+ });
51
+ };
52
+
53
+ export const upgradeClicked = (courseId, org, courseName, href) => createLinkTracker(
29
54
  () => {
30
55
  upgradeButtonClicked(courseId)();
31
56
  upgradeButtonClickedUpsell(courseId)();
57
+ upgradeButtonClickedCohesion(org, courseName);
32
58
  logUpgrade({ courseId });
33
59
  },
34
60
  href,