@edx/frontend-plugin-learner-dashboard 2.0.2 → 2.0.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.
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
+ var _logging = require("@edx/frontend-platform/logging");
8
9
  const CohesionWrapper = () => {
9
10
  const [isLoaded, setLoaded] = (0, _react.useState)(false);
10
11
 
@@ -18,6 +19,17 @@ const CohesionWrapper = () => {
18
19
  const script = document.createElement('script');
19
20
  script.src = 'https://www.edx.org/beam-wrapper.js';
20
21
  script.dataset.testId = 'cohesion-test';
22
+ script.onload = () => {
23
+ if (window.tagular && typeof window.tagular === 'function') {
24
+ (0, _logging.logInfo)('Cohesion script loaded successfully!');
25
+ } else {
26
+ // in the case that the script successfully loaded but tagular is still not found
27
+ (0, _logging.logError)('window.tagular not found after Cohesion script load.');
28
+ }
29
+ };
30
+ script.onerror = e => {
31
+ (0, _logging.logError)('Cohesion script failed to load', e);
32
+ };
21
33
  head.appendChild(script);
22
34
  setLoaded(true);
23
35
  }, [isLoaded]);
@@ -1 +1 @@
1
- {"version":3,"file":"CohesionWrapper.js","names":["_react","require","CohesionWrapper","isLoaded","setLoaded","useState","window","chsn_pageType","useEffect","head","document","getElementsByTagName","script","createElement","src","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 // set pageType value\n window.chsn_pageType = 'lms-homepage';\n\n useEffect(() => {\n if (isLoaded) {\n return;\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.dataset.testId = 'cohesion-test';\n head.appendChild(script);\n setLoaded(true);\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;EACAC,MAAM,CAACC,aAAa,GAAG,cAAc;EAErC,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIL,QAAQ,EAAE;MACZ;IACF;IAEA,MAAMM,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,OAAO,CAACC,MAAM,GAAG,eAAe;IACvCP,IAAI,CAACQ,WAAW,CAACL,MAAM,CAAC;IACxBR,SAAS,CAAC,IAAI,CAAC;EACjB,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC;AAAC,IAAAe,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalB,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"CohesionWrapper.js","names":["_react","require","_logging","CohesionWrapper","isLoaded","setLoaded","useState","window","chsn_pageType","useEffect","head","document","getElementsByTagName","script","createElement","src","dataset","testId","onload","tagular","logInfo","logError","onerror","e","appendChild","_default","exports","default"],"sources":["../../src/cohesion-wrapper/CohesionWrapper.jsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { logError, logInfo } from '@edx/frontend-platform/logging';\n\nconst CohesionWrapper = () => {\n const [isLoaded, setLoaded] = useState(false);\n\n // set pageType value\n window.chsn_pageType = 'lms-homepage';\n\n useEffect(() => {\n if (isLoaded) {\n return;\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.dataset.testId = 'cohesion-test';\n\n script.onload = () => {\n if (window.tagular && typeof window.tagular === 'function') {\n logInfo('Cohesion script loaded successfully!');\n } else {\n // in the case that the script successfully loaded but tagular is still not found\n logError('window.tagular not found after Cohesion script load.');\n }\n };\n\n script.onerror = (e) => {\n logError('Cohesion script failed to load', e);\n };\n\n head.appendChild(script);\n setLoaded(true);\n }, [isLoaded]);\n\n return null;\n};\n\nexport default CohesionWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,eAAe,GAAGA,CAAA,KAAM;EAC5B,MAAM,CAACC,QAAQ,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;;EAE7C;EACAC,MAAM,CAACC,aAAa,GAAG,cAAc;EAErC,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIL,QAAQ,EAAE;MACZ;IACF;IAEA,MAAMM,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,OAAO,CAACC,MAAM,GAAG,eAAe;IAEvCJ,MAAM,CAACK,MAAM,GAAG,MAAM;MACpB,IAAIX,MAAM,CAACY,OAAO,IAAI,OAAOZ,MAAM,CAACY,OAAO,KAAK,UAAU,EAAE;QAC1D,IAAAC,gBAAO,EAAC,sCAAsC,CAAC;MACjD,CAAC,MAAM;QACL;QACA,IAAAC,iBAAQ,EAAC,sDAAsD,CAAC;MAClE;IACF,CAAC;IAEDR,MAAM,CAACS,OAAO,GAAIC,CAAC,IAAK;MACtB,IAAAF,iBAAQ,EAAC,gCAAgC,EAAEE,CAAC,CAAC;IAC/C,CAAC;IAEDb,IAAI,CAACc,WAAW,CAACX,MAAM,CAAC;IACxBR,SAAS,CAAC,IAAI,CAAC;EACjB,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaxB,eAAe","ignoreList":[]}
package/dist/package.json CHANGED
@@ -44,7 +44,7 @@
44
44
  "@edx/browserslist-config": "^1.1.1",
45
45
  "@edx/react-unit-test-utils": "^4.0.0",
46
46
  "@edx/reactifex": "^2.1.1",
47
- "@openedx/frontend-build": "14.5.0",
47
+ "@openedx/frontend-build": "14.6.0",
48
48
  "@testing-library/jest-dom": "^6.6.3",
49
49
  "@testing-library/react": "^16.2.0",
50
50
  "jest": "29.7.0",
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.upgradeClicked = void 0;
7
+ var _logging = require("@edx/frontend-platform/logging");
7
8
  var _utils = require("../utils");
8
9
  var _cookie = require("../cookie");
9
10
  var _constants = require("../constants");
@@ -44,22 +45,26 @@ const upgradeButtonClickedUpsell = courseId => (0, _utils.createEventTracker)(_c
44
45
  const upgradeButtonClickedCohesion = (org, courseName) => {
45
46
  const correlationId = (0, _cookie.handleCorrelationIDCookie)();
46
47
  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: 'Upgraded',
55
- timestamp: new Date().toISOString(),
56
- productList: [{
57
- brand: courseOrganization,
58
- variant: 'courses',
59
- name: courseName
60
- }]
61
- }
62
- });
48
+ if (window.tagular && typeof window.tagular === 'function') {
49
+ window.tagular?.('beam', {
50
+ '@type': 'core.conversions.ConversionTracked.v2',
51
+ correlation: {
52
+ id: correlationId
53
+ },
54
+ metadata: {
55
+ category: 'Enrollment',
56
+ action: 'Upgraded',
57
+ timestamp: new Date().toISOString(),
58
+ productList: [{
59
+ brand: courseOrganization,
60
+ variant: 'courses',
61
+ name: courseName
62
+ }]
63
+ }
64
+ });
65
+ } else {
66
+ (0, _logging.logError)('Cohesion script failed to load before upgrade button clicked');
67
+ }
63
68
  };
64
69
  const upgradeClicked = (courseId, org, courseName, href) => (0, _utils.createLinkTracker)(() => {
65
70
  upgradeButtonClicked(courseId)();
@@ -1 +1 @@
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: 'Upgraded',\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,CAA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,oBAAoB,CAACP,QAAQ,CAAC,CAAC,CAAC;EAChCa,0BAA0B,CAACb,QAAQ,CAAC,CAAC,CAAC;EACtCc,4BAA4B,CAACC,GAAG,EAAEC,UAAU,CAAC;EAC7ClB,UAAU,CAAC;IAAEE;EAAS,CAAC,CAAC;AAC1B,CAAC,EACDmC,IACF,CAAC;AAACE,OAAA,CAAAH,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"upgradeButton.js","names":["_logging","require","_utils","_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","logError","upgradeClicked","href","createLinkTracker","exports"],"sources":["../../../src/tracking/trackers/upgradeButton.js"],"sourcesContent":["import { logError } from '@edx/frontend-platform/logging';\nimport { 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 if (window.tagular && typeof window.tagular === 'function') {\n window.tagular?.('beam', {\n '@type': 'core.conversions.ConversionTracked.v2',\n correlation: {\n id: correlationId,\n },\n metadata: {\n category: 'Enrollment',\n action: 'Upgraded',\n timestamp: new Date().toISOString(),\n productList: [{\n brand: courseOrganization,\n variant: 'courses',\n name: courseName,\n }],\n },\n });\n } else {\n logError('Cohesion script failed to load before upgrade button clicked');\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,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAsD,SAAAI,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,C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C;QACnCC,WAAW,EAAE,CAAC;UACZC,KAAK,EAAEZ,kBAAkB;UACzBa,OAAO,EAAE,SAAS;UAClBC,IAAI,EAAEjB;QACR,CAAC;MACH;IACF,CAAC,CAAC;EACJ,CAAC,MAAM;IACL,IAAAkB,iBAAQ,EAAC,8DAA8D,CAAC;EAC1E;AACF,CAAC;AAEM,MAAMC,cAAc,GAAGA,CAACnC,QAAQ,EAAEe,GAAG,EAAEC,UAAU,EAAEoB,IAAI,KAAK,IAAAC,wBAAiB,EAClF,MAAM;EACJ9B,oBAAoB,CAACP,QAAQ,CAAC,CAAC,CAAC;EAChCa,0BAA0B,CAACb,QAAQ,CAAC,CAAC,CAAC;EACtCc,4BAA4B,CAACC,GAAG,EAAEC,UAAU,CAAC;EAC7ClB,UAAU,CAAC;IAAEE;EAAS,CAAC,CAAC;AAC1B,CAAC,EACDoC,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": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Repository for Learner Dashboard MFE frontend plugins",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -44,7 +44,7 @@
44
44
  "@edx/browserslist-config": "^1.1.1",
45
45
  "@edx/react-unit-test-utils": "^4.0.0",
46
46
  "@edx/reactifex": "^2.1.1",
47
- "@openedx/frontend-build": "14.5.0",
47
+ "@openedx/frontend-build": "14.6.0",
48
48
  "@testing-library/jest-dom": "^6.6.3",
49
49
  "@testing-library/react": "^16.2.0",
50
50
  "jest": "29.7.0",
@@ -1,4 +1,5 @@
1
1
  import { useState, useEffect } from 'react';
2
+ import { logError, logInfo } from '@edx/frontend-platform/logging';
2
3
 
3
4
  const CohesionWrapper = () => {
4
5
  const [isLoaded, setLoaded] = useState(false);
@@ -15,6 +16,20 @@ const CohesionWrapper = () => {
15
16
  const script = document.createElement('script');
16
17
  script.src = 'https://www.edx.org/beam-wrapper.js';
17
18
  script.dataset.testId = 'cohesion-test';
19
+
20
+ script.onload = () => {
21
+ if (window.tagular && typeof window.tagular === 'function') {
22
+ logInfo('Cohesion script loaded successfully!');
23
+ } else {
24
+ // in the case that the script successfully loaded but tagular is still not found
25
+ logError('window.tagular not found after Cohesion script load.');
26
+ }
27
+ };
28
+
29
+ script.onerror = (e) => {
30
+ logError('Cohesion script failed to load', e);
31
+ };
32
+
18
33
  head.appendChild(script);
19
34
  setLoaded(true);
20
35
  }, [isLoaded]);
@@ -1,3 +1,4 @@
1
+ import { logError } from '@edx/frontend-platform/logging';
1
2
  import { logEvent, createEventTracker, createLinkTracker } from '../utils';
2
3
  import { handleCorrelationIDCookie } from '../cookie';
3
4
  import { eventNames, categories } from '../constants';
@@ -32,22 +33,26 @@ const upgradeButtonClickedCohesion = (org, courseName) => {
32
33
  const correlationId = handleCorrelationIDCookie();
33
34
  const courseOrganization = org.toLowerCase();
34
35
 
35
- window.tagular('beam', {
36
- '@type': 'core.conversions.ConversionTracked.v2',
37
- correlation: {
38
- id: correlationId,
39
- },
40
- metadata: {
41
- category: 'Enrollment',
42
- action: 'Upgraded',
43
- timestamp: new Date().toISOString(),
44
- productList: [{
45
- brand: courseOrganization,
46
- variant: 'courses',
47
- name: courseName,
48
- }],
49
- },
50
- });
36
+ if (window.tagular && typeof window.tagular === 'function') {
37
+ window.tagular?.('beam', {
38
+ '@type': 'core.conversions.ConversionTracked.v2',
39
+ correlation: {
40
+ id: correlationId,
41
+ },
42
+ metadata: {
43
+ category: 'Enrollment',
44
+ action: 'Upgraded',
45
+ timestamp: new Date().toISOString(),
46
+ productList: [{
47
+ brand: courseOrganization,
48
+ variant: 'courses',
49
+ name: courseName,
50
+ }],
51
+ },
52
+ });
53
+ } else {
54
+ logError('Cohesion script failed to load before upgrade button clicked');
55
+ }
51
56
  };
52
57
 
53
58
  export const upgradeClicked = (courseId, org, courseName, href) => createLinkTracker(