@edx/frontend-plugin-advertisements 1.23.2 → 1.24.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.
- package/dist/upgrade-modal/ExperimentalUpgradeModal.js +7 -15
- package/dist/upgrade-modal/ExperimentalUpgradeModal.js.map +1 -1
- package/dist/upgrade-modal/UpgradeModalWrapper.js +4 -19
- package/dist/upgrade-modal/UpgradeModalWrapper.js.map +1 -1
- package/dist/upgrade-modal/hooks.js +43 -10
- package/dist/upgrade-modal/hooks.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _modelStore = require("@src/generic/model-store");
|
|
10
10
|
var _UpgradeModal = _interopRequireDefault(require("./UpgradeModal"));
|
|
11
11
|
var _NextButton = _interopRequireDefault(require("./NextButton"));
|
|
12
|
-
var _hooks =
|
|
12
|
+
var _hooks = require("./hooks");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -35,26 +35,18 @@ const ExperimentalUpgradeModal = _ref => {
|
|
|
35
35
|
} = _ref;
|
|
36
36
|
const {
|
|
37
37
|
verifiedMode,
|
|
38
|
-
org
|
|
39
|
-
isStaff
|
|
38
|
+
org
|
|
40
39
|
} = (0, _modelStore.useModel)('courseHomeMeta', courseId);
|
|
41
40
|
const {
|
|
42
|
-
enrollmentMode,
|
|
43
41
|
offer,
|
|
44
42
|
marketingUrl,
|
|
45
43
|
accessExpiration
|
|
46
44
|
} = (0, _modelStore.useModel)('coursewareMeta', courseId);
|
|
47
|
-
const [
|
|
48
|
-
verifiedMode,
|
|
49
|
-
isStaff,
|
|
50
|
-
enrollmentMode
|
|
51
|
-
});
|
|
45
|
+
const [shouldShowModalOnClick, countNextClick] = (0, _hooks.useInCourseUpgradeModal)();
|
|
52
46
|
const handleModal = () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
open();
|
|
57
|
-
}
|
|
47
|
+
countNextClick();
|
|
48
|
+
if (shouldShowModalOnClick) {
|
|
49
|
+
open();
|
|
58
50
|
}
|
|
59
51
|
};
|
|
60
52
|
(0, _react.useEffect)(() => {
|
|
@@ -73,7 +65,7 @@ const ExperimentalUpgradeModal = _ref => {
|
|
|
73
65
|
nextSequenceHandler,
|
|
74
66
|
handleNavigate,
|
|
75
67
|
linkComponent
|
|
76
|
-
}),
|
|
68
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_UpgradeModal.default, {
|
|
77
69
|
isOpen,
|
|
78
70
|
close,
|
|
79
71
|
verifiedMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExperimentalUpgradeModal.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_modelStore","_UpgradeModal","_NextButton","_hooks","_jsxRuntime","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ExperimentalUpgradeModal","_ref","courseId","disabled","buttonText","nextArrow","nextLink","shouldDisplayNotificationTriggerInSequence","sequenceId","unitId","nextSequenceHandler","handleNavigate","isOpen","open","close","linkComponent","verifiedMode","org","
|
|
1
|
+
{"version":3,"file":"ExperimentalUpgradeModal.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_modelStore","_UpgradeModal","_NextButton","_hooks","_jsxRuntime","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ExperimentalUpgradeModal","_ref","courseId","disabled","buttonText","nextArrow","nextLink","shouldDisplayNotificationTriggerInSequence","sequenceId","unitId","nextSequenceHandler","handleNavigate","isOpen","open","close","linkComponent","verifiedMode","org","useModel","offer","marketingUrl","accessExpiration","shouldShowModalOnClick","countNextClick","useInCourseUpgradeModal","handleModal","useEffect","jsxs","Fragment","children","jsx","propTypes","PropTypes","bool","isRequired","string","func","node","_default","exports"],"sources":["../../src/upgrade-modal/ExperimentalUpgradeModal.jsx"],"sourcesContent":["/* eslint import/no-unresolved: 0 */\nimport React, { useEffect } from 'react';\nimport PropTypes from 'prop-types';\n\nimport { useModel } from '@src/generic/model-store';\nimport UpgradeModal from './UpgradeModal';\nimport NextButton from './NextButton';\nimport { useInCourseUpgradeModal } from './hooks';\n\nconst ExperimentalUpgradeModal = ({\n courseId,\n disabled,\n buttonText,\n nextArrow,\n nextLink,\n shouldDisplayNotificationTriggerInSequence,\n sequenceId,\n unitId,\n nextSequenceHandler,\n handleNavigate,\n isOpen,\n open,\n close,\n linkComponent,\n}) => {\n const {\n verifiedMode,\n org,\n } = useModel('courseHomeMeta', courseId);\n\n const {\n offer,\n marketingUrl,\n accessExpiration,\n } = useModel('coursewareMeta', courseId);\n\n const [shouldShowModalOnClick, countNextClick] = useInCourseUpgradeModal();\n\n const handleModal = () => {\n countNextClick();\n if (shouldShowModalOnClick) {\n open();\n }\n };\n\n useEffect(() => {\n handleModal();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [sequenceId]);\n\n return (\n <>\n <NextButton\n {...{\n disabled,\n buttonText,\n nextArrow,\n nextLink,\n shouldDisplayNotificationTriggerInSequence,\n sequenceId,\n unitId,\n nextSequenceHandler,\n handleNavigate,\n linkComponent,\n }}\n />\n <UpgradeModal\n {...{\n isOpen,\n close,\n verifiedMode,\n org,\n courseId,\n offer,\n marketingUrl,\n accessExpiration,\n }}\n />\n </>\n );\n};\n\nExperimentalUpgradeModal.propTypes = {\n disabled: PropTypes.bool.isRequired,\n buttonText: PropTypes.string.isRequired,\n nextArrow: PropTypes.func.isRequired,\n nextLink: PropTypes.string.isRequired,\n shouldDisplayNotificationTriggerInSequence: PropTypes.bool.isRequired,\n sequenceId: PropTypes.string.isRequired,\n unitId: PropTypes.string.isRequired,\n handleNavigate: PropTypes.func.isRequired,\n nextSequenceHandler: PropTypes.func.isRequired,\n isOpen: PropTypes.bool.isRequired,\n open: PropTypes.func.isRequired,\n linkComponent: PropTypes.node.isRequired,\n close: PropTypes.func.isRequired,\n courseId: PropTypes.string.isRequired,\n};\n\nexport default ExperimentalUpgradeModal;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,WAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAAkD,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAE,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAb,wBAAAa,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CAAA,OAAAM,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BAAS,CAACI,IAAI,CAACF,UAAU;EAC/BnB,aAAa,EAAEiB,kBAAS,CAACK,IAAI,CAACH,UAAU;EACxCpB,KAAK,EAAEkB,kBAAS,CAACI,IAAI,CAACF,UAAU;EAChChC,QAAQ,EAAE8B,kBAAS,CAACG,MAAM,CAACD;AAC7B,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAA1D,OAAA,GAEamB,wBAAwB","ignoreList":[]}
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _modelStore = require("@src/generic/model-store");
|
|
9
8
|
var _frontendPlatform = require("@edx/frontend-platform");
|
|
10
9
|
var _DefaultUpgradeModal = _interopRequireDefault(require("./DefaultUpgradeModal"));
|
|
11
10
|
var _ExperimentalUpgradeModal = _interopRequireDefault(require("./ExperimentalUpgradeModal"));
|
|
11
|
+
var _hooks = require("./hooks");
|
|
12
12
|
var _optimizely = _interopRequireDefault(require("../optimizely"));
|
|
13
13
|
var _optimizely2 = require("../data/optimizely");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -19,28 +19,13 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
19
19
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
20
20
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable import/no-unresolved */
|
|
21
21
|
(0, _frontendPlatform.ensureConfig)(['OPTIMIZELY_MODAL_ROLLOUT_WHITELIST'], 'Optimizely In-Course Modal rollout config');
|
|
22
|
-
|
|
23
|
-
// This is not fully functional and is currently just a copy of the UpgradeNotification
|
|
24
|
-
// experiment with the imports updated
|
|
25
|
-
const isExperimentEnabledForOrg = org => {
|
|
26
|
-
const {
|
|
27
|
-
OPTIMIZELY_MODAL_ROLLOUT_WHITELIST
|
|
28
|
-
} = (0, _frontendPlatform.getConfig)();
|
|
29
|
-
if (!OPTIMIZELY_MODAL_ROLLOUT_WHITELIST) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
return OPTIMIZELY_MODAL_ROLLOUT_WHITELIST.includes(org);
|
|
33
|
-
};
|
|
34
22
|
const UpgradeModalWrapper = props => {
|
|
35
23
|
const {
|
|
36
24
|
courseId
|
|
37
25
|
} = props;
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const allowExperiment = isExperimentEnabledForOrg(org);
|
|
42
|
-
|
|
43
|
-
// If the org isn't whitelisted for experiment rollout, don't run the experiment
|
|
26
|
+
const allowExperiment = (0, _hooks.useIsModalExperimentEnabled)(courseId);
|
|
27
|
+
// If the org isn't whitelisted for experiment rollout, or the user would never
|
|
28
|
+
// see the modal anyway, don't run the experiment.
|
|
44
29
|
// We don't want users who aren't being experimented on to be bucketed, which will
|
|
45
30
|
// happen if we call useDecision()
|
|
46
31
|
return allowExperiment ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_optimizely.default, _objectSpread({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpgradeModalWrapper.js","names":["_propTypes","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"file":"UpgradeModalWrapper.js","names":["_propTypes","_interopRequireDefault","require","_frontendPlatform","_DefaultUpgradeModal","_ExperimentalUpgradeModal","_hooks","_optimizely","_optimizely2","_jsxRuntime","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ensureConfig","UpgradeModalWrapper","props","courseId","allowExperiment","useIsModalExperimentEnabled","jsx","defaultComponent","DefaultUpgradeModal","experimentalComponent","ExperimentalUpgradeModal","defaultVariationKey","experimentKey","OPTIMIZELY_VTR_MODAL_EXPERIMENT","KEY","propTypes","PropTypes","string","isRequired","_default","exports"],"sources":["../../src/upgrade-modal/UpgradeModalWrapper.jsx"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nimport PropTypes from 'prop-types';\nimport { ensureConfig } from '@edx/frontend-platform';\n\nimport DefaultUpgradeModal from './DefaultUpgradeModal';\nimport ExperimentalUpgradeModal from './ExperimentalUpgradeModal';\nimport { useIsModalExperimentEnabled } from './hooks';\n\nimport OptimizelyExperiment from '../optimizely';\nimport { OPTIMIZELY_VTR_MODAL_EXPERIMENT } from '../data/optimizely';\n\nensureConfig([\n 'OPTIMIZELY_MODAL_ROLLOUT_WHITELIST',\n], 'Optimizely In-Course Modal rollout config');\n\nconst UpgradeModalWrapper = (props) => {\n const { courseId } = props;\n const allowExperiment = useIsModalExperimentEnabled(courseId);\n // If the org isn't whitelisted for experiment rollout, or the user would never\n // see the modal anyway, don't run the experiment.\n // We don't want users who aren't being experimented on to be bucketed, which will\n // happen if we call useDecision()\n return (\n allowExperiment ? (\n <OptimizelyExperiment\n defaultComponent={DefaultUpgradeModal}\n experimentalComponent={ExperimentalUpgradeModal}\n defaultVariationKey=\"off\"\n experimentKey={OPTIMIZELY_VTR_MODAL_EXPERIMENT.KEY}\n {...props}\n />\n ) : <DefaultUpgradeModal {...props} />\n );\n};\n\nUpgradeModalWrapper.propTypes = {\n courseId: PropTypes.string.isRequired,\n};\n\nexport default UpgradeModalWrapper;\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,oBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,I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ACzBC,aAAa,EAAEC,4CAA+B,CAACC;EAAI,GAC/CZ,KAAK,CACV,CAAC,gBACA,IAAAxC,WAAA,CAAA4C,GAAA,EAACjD,oBAAA,CAAAQ,OAAmB,EAAAc,aAAA,KAAKuB,KAAK,CAAG,CAAC;AAE1C,CAAC;AAEDD,mBAAmB,CAACc,SAAS,GAAG;EAC9BZ,QAAQ,EAAEa,kBAAS,CAACC,MAAM,CAACC;AAC7B,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAvD,OAAA,GAEaoC,mBAAmB","ignoreList":[]}
|
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.useInCourseUpgradeModal = useInCourseUpgradeModal;
|
|
7
|
+
exports.useIsModalExperimentEnabled = useIsModalExperimentEnabled;
|
|
7
8
|
var _react = require("react");
|
|
9
|
+
var _modelStore = require("@src/generic/model-store");
|
|
10
|
+
var _frontendPlatform = require("@edx/frontend-platform");
|
|
11
|
+
/* eslint import/no-unresolved: 0 */
|
|
12
|
+
|
|
8
13
|
const CLICK_COUNT_KEY = 'VTR_IN_COURSE_MODAL_NEXT_CLICK_COUNT';
|
|
9
14
|
const SHOW_MODAL_CLICK_COUNT = 3;
|
|
10
15
|
function isLocalStorageAvailable() {
|
|
@@ -48,23 +53,51 @@ function useClickCount() {
|
|
|
48
53
|
}, [clickCount, localStorageAvailable]);
|
|
49
54
|
return [clickCount, setClickCount];
|
|
50
55
|
}
|
|
51
|
-
function useInCourseUpgradeModal(
|
|
52
|
-
let {
|
|
53
|
-
verifiedMode,
|
|
54
|
-
isStaff,
|
|
55
|
-
enrollmentMode
|
|
56
|
-
} = _ref;
|
|
56
|
+
function useInCourseUpgradeModal() {
|
|
57
57
|
/**
|
|
58
58
|
* Hook that wraps around useClickCount to handle the "modal show" logic
|
|
59
59
|
*/
|
|
60
|
-
const qualifiesForModal = enrollmentMode === 'audit' && verifiedMode && !isStaff;
|
|
61
60
|
const [clickCount, setClickCount] = useClickCount();
|
|
62
61
|
const nextClick = clickCount + 1;
|
|
63
62
|
const countNextClick = () => {
|
|
64
63
|
setClickCount(nextClick);
|
|
65
64
|
};
|
|
66
65
|
const shouldShowModalOnClick = nextClick % SHOW_MODAL_CLICK_COUNT === 0;
|
|
67
|
-
return [
|
|
66
|
+
return [shouldShowModalOnClick, countNextClick];
|
|
67
|
+
}
|
|
68
|
+
function isExperimentEnabledForOrg(org) {
|
|
69
|
+
const {
|
|
70
|
+
OPTIMIZELY_MODAL_ROLLOUT_WHITELIST
|
|
71
|
+
} = (0, _frontendPlatform.getConfig)();
|
|
72
|
+
if (!OPTIMIZELY_MODAL_ROLLOUT_WHITELIST) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return OPTIMIZELY_MODAL_ROLLOUT_WHITELIST.includes(org);
|
|
76
|
+
}
|
|
77
|
+
function useIsModalExperimentEnabled(courseId) {
|
|
78
|
+
/** The following must be true for the experiment to be activated:
|
|
79
|
+
* - The user must be an audit learner
|
|
80
|
+
* - The user must not be staff
|
|
81
|
+
* - The course must have a verified mode
|
|
82
|
+
* - (During rollout) The org must be whitelisted
|
|
83
|
+
*/
|
|
84
|
+
const {
|
|
85
|
+
verifiedMode,
|
|
86
|
+
org,
|
|
87
|
+
isStaff
|
|
88
|
+
} = (0, _modelStore.useModel)('courseHomeMeta', courseId);
|
|
89
|
+
const {
|
|
90
|
+
enrollmentMode
|
|
91
|
+
} = (0, _modelStore.useModel)('coursewareMeta', courseId);
|
|
92
|
+
const enabledForOrg = isExperimentEnabledForOrg(org);
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.info({
|
|
95
|
+
org,
|
|
96
|
+
enabledForOrg,
|
|
97
|
+
enrollmentMode,
|
|
98
|
+
isStaff,
|
|
99
|
+
verifiedMode
|
|
100
|
+
});
|
|
101
|
+
return enrollmentMode === 'audit' && !!verifiedMode && !isStaff && enabledForOrg;
|
|
68
102
|
}
|
|
69
|
-
var _default = exports.default = useInCourseUpgradeModal;
|
|
70
103
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":["_react","require","CLICK_COUNT_KEY","SHOW_MODAL_CLICK_COUNT","isLocalStorageAvailable","testKey","localStorage","setItem","removeItem","e","useClickCount","localStorageAvailable","clickCount","setClickCount","useState","clickString","getItem","clicks","JSON","parse","useEffect","undefined","stringify","useInCourseUpgradeModal","
|
|
1
|
+
{"version":3,"file":"hooks.js","names":["_react","require","_modelStore","_frontendPlatform","CLICK_COUNT_KEY","SHOW_MODAL_CLICK_COUNT","isLocalStorageAvailable","testKey","localStorage","setItem","removeItem","e","useClickCount","localStorageAvailable","clickCount","setClickCount","useState","clickString","getItem","clicks","JSON","parse","useEffect","undefined","stringify","useInCourseUpgradeModal","nextClick","countNextClick","shouldShowModalOnClick","isExperimentEnabledForOrg","org","OPTIMIZELY_MODAL_ROLLOUT_WHITELIST","getConfig","includes","useIsModalExperimentEnabled","courseId","verifiedMode","isStaff","useModel","enrollmentMode","enabledForOrg","console","info"],"sources":["../../src/upgrade-modal/hooks.js"],"sourcesContent":["/* eslint import/no-unresolved: 0 */\nimport { useState, useEffect } from 'react';\nimport { useModel } from '@src/generic/model-store';\nimport { getConfig } from '@edx/frontend-platform';\n\nconst CLICK_COUNT_KEY = 'VTR_IN_COURSE_MODAL_NEXT_CLICK_COUNT';\nconst SHOW_MODAL_CLICK_COUNT = 3;\n\nfunction isLocalStorageAvailable() {\n // A simple helper to check if localStorage is currently available\n const testKey = 'testKey';\n try {\n localStorage.setItem(testKey, testKey);\n localStorage.removeItem(testKey);\n return true;\n } catch (e) {\n return false;\n }\n}\n\nfunction useClickCount() {\n /**\n * Hook that tracks the number of times that a user has clicked something\n * and stores that number in localStorage (if available).\n *\n * Returns: [clickCount, setClickCount]\n * - clickCount (int): The current count of clicks\n * - setClickCount (func): Function to update the number of clicks\n */\n const localStorageAvailable = isLocalStorageAvailable();\n const [clickCount, setClickCount] = useState(() => {\n if (!localStorageAvailable) { return 0; }\n const clickString = localStorage.getItem(CLICK_COUNT_KEY);\n const clicks = JSON.parse(clickString);\n return clicks || 0;\n });\n\n useEffect(() => {\n // When clickCount changes, this will update it in localStorage\n if (clickCount === undefined) { return; }\n if (!localStorageAvailable) { return; }\n localStorage.setItem(CLICK_COUNT_KEY, JSON.stringify(clickCount));\n }, [clickCount, localStorageAvailable]);\n\n return [clickCount, setClickCount];\n}\n\nfunction useInCourseUpgradeModal() {\n /**\n * Hook that wraps around useClickCount to handle the \"modal show\" logic\n */\n const [clickCount, setClickCount] = useClickCount();\n const nextClick = clickCount + 1;\n const countNextClick = () => { setClickCount(nextClick); };\n const shouldShowModalOnClick = nextClick % SHOW_MODAL_CLICK_COUNT === 0;\n return [shouldShowModalOnClick, countNextClick];\n}\n\nfunction isExperimentEnabledForOrg(org) {\n const { OPTIMIZELY_MODAL_ROLLOUT_WHITELIST } = getConfig();\n if (!OPTIMIZELY_MODAL_ROLLOUT_WHITELIST) { return false; }\n return OPTIMIZELY_MODAL_ROLLOUT_WHITELIST.includes(org);\n}\n\nfunction useIsModalExperimentEnabled(courseId) {\n /** The following must be true for the experiment to be activated:\n * - The user must be an audit learner\n * - The user must not be staff\n * - The course must have a verified mode\n * - (During rollout) The org must be whitelisted\n */\n const {\n verifiedMode,\n org,\n isStaff,\n } = useModel('courseHomeMeta', courseId);\n const { enrollmentMode } = useModel('coursewareMeta', courseId);\n const enabledForOrg = isExperimentEnabledForOrg(org);\n // eslint-disable-next-line no-console\n console.info({\n org, enabledForOrg, enrollmentMode, isStaff, verifiedMode,\n });\n return enrollmentMode === 'audit' && !!verifiedMode && !isStaff && enabledForOrg;\n}\n\nexport {\n useInCourseUpgradeModal,\n useIsModalExperimentEnabled,\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GA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