@newtonschool/react_proctoring_library 0.0.100 → 0.0.102

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.
@@ -9,8 +9,10 @@ var _react = require("react");
9
9
  var _ElectronContext = require("../../contexts/ElectronContext");
10
10
  function useIllegalKeysCombination() {
11
11
  const [keysClickedCount, setKeysClickedCount] = (0, _react.useState)(0);
12
+ const [keysCombinationClicked, setKeysCombinationClicked] = (0, _react.useState)('');
12
13
  const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
13
- const illegalKeysClickHandler = () => {
14
+ const illegalKeysClickHandler = keyCombination => {
15
+ setKeysCombinationClicked(keyCombination);
14
16
  setKeysClickedCount(count => count + 1);
15
17
  };
16
18
  (0, _react.useEffect)(() => {
@@ -25,5 +27,8 @@ function useIllegalKeysCombination() {
25
27
  }
26
28
  }
27
29
  }, [isElectronApp]);
28
- return keysClickedCount;
30
+ return {
31
+ keysClickedCount,
32
+ keysCombinationClicked
33
+ };
29
34
  }
@@ -9,6 +9,9 @@ var _ElectronContext = require("../contexts/ElectronContext");
9
9
  var _useIllegalKeysCombination = require("./electron/useIllegalKeysCombination");
10
10
  function useGenericIllegalKeysCombinationDetected() {
11
11
  const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
12
- const illegalKeysCombinationKeyCount = (0, _useIllegalKeysCombination.useIllegalKeysCombination)();
13
- return isElectronApp ? illegalKeysCombinationKeyCount : 0;
12
+ const illegalKeysCombination = (0, _useIllegalKeysCombination.useIllegalKeysCombination)();
13
+ return isElectronApp ? illegalKeysCombination : {
14
+ keysClickedCount: 0,
15
+ keysCombinationClicked: ''
16
+ };
14
17
  }
@@ -11,6 +11,7 @@ var _utils = require("../utils");
11
11
  var _useGenericSleepDetected = _interopRequireDefault(require("./useGenericSleepDetected"));
12
12
  var _useGenericIllegalKeysCombination = _interopRequireDefault(require("./useGenericIllegalKeysCombination"));
13
13
  var _ElectronContext = require("../contexts/ElectronContext");
14
+ var _defaults = require("../constants/defaults");
14
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
16
  const isWebcamProcessingReliable = (0, _utils.isGPUAvailable)();
16
17
  const useTrackBreachParameters = _ref => {
@@ -31,14 +32,18 @@ const useTrackBreachParameters = _ref => {
31
32
  const recurringFetchIntervalRef = (0, _react.useRef)(null);
32
33
  const isTabSwitched = !(0, _useGenericPageVisibility.default)(proctorParams.tabSwitch);
33
34
  const isPageFocussed = (0, _useGenericPageVisibility.default)(proctorParams.pageFocus);
34
- const illegalKeysCombinationCount = (0, _useGenericIllegalKeysCombination.default)();
35
+ const {
36
+ keysClickedCount: illegalKeysCombinationCount,
37
+ keysCombinationClicked
38
+ } = (0, _useGenericIllegalKeysCombination.default)();
35
39
  const previousIllegalKeysCombinationCount = (0, _react.useRef)(0);
36
40
  const sleepCount = (0, _useGenericSleepDetected.default)();
37
41
  const previousSleepCount = (0, _react.useRef)(0);
38
42
  const sendProctoredParamValues = (0, _react.useCallback)(function () {
39
43
  let isBreach = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
40
44
  let breachParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
41
- getProctorParamValues(proctoringIdentifier, statistics.current, isBreach, breachParam);
45
+ let breachDetails = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
46
+ getProctorParamValues(proctoringIdentifier, statistics.current, isBreach, breachParam, breachDetails);
42
47
  }, [proctoringIdentifier, getProctorParamValues]);
43
48
  (0, _react.useEffect)(() => {
44
49
  let timeoutId = null;
@@ -59,6 +64,7 @@ const useTrackBreachParameters = _ref => {
59
64
  const currentStats = {
60
65
  isTabSwitched,
61
66
  illegalKeysCombinationCount,
67
+ keysCombinationClicked,
62
68
  isIllegalKeysCombinationDetected: illegalKeysCombinationCount > previousIllegalKeysCombinationCount.current,
63
69
  sleepCount,
64
70
  isSleepDetected: sleepCount > previousSleepCount.current,
@@ -69,7 +75,14 @@ const useTrackBreachParameters = _ref => {
69
75
  const breachData = (0, _breachUtils.getDataOnBreach)(statistics, currentStats, proctorParams);
70
76
  (0, _utils.updateStatistics)(statistics, currentStats, proctorParams);
71
77
  if (breachData && allPermissionGrantedOnce.current) {
72
- sendProctoredParamValues(true, breachData.breachedParam);
78
+ const {
79
+ keysCombinationClicked
80
+ } = breachData.data;
81
+ const isIllegalKeysBreached = keysCombinationClicked && breachData.breachedParam === _defaults.STATS_PARAMS.illegalKeysCombinationDetected;
82
+ const breachDetails = isIllegalKeysBreached ? {
83
+ illegal_keys_combination: keysCombinationClicked
84
+ } : {};
85
+ sendProctoredParamValues(true, breachData.breachedParam, breachDetails);
73
86
  if (isElectronApp) {
74
87
  var _window$electron$acti, _window$electron$acti2;
75
88
  if ((_window$electron$acti = window.electron.actions) !== null && _window$electron$acti !== void 0 && _window$electron$acti.captureAndSendSnapshot) {
@@ -60,6 +60,7 @@ const getDataOnBreach = (statistics, currentData, proctorParams) => {
60
60
  isWebcamDataNotReliable,
61
61
  isPageFocussed,
62
62
  illegalKeysCombinationCount,
63
+ keysCombinationClicked,
63
64
  isIllegalKeysCombinationDetected,
64
65
  sleepCount,
65
66
  isSleepDetected
@@ -82,7 +83,8 @@ const getDataOnBreach = (statistics, currentData, proctorParams) => {
82
83
  breachedParam: illegalKeyCombinationDetectedParam,
83
84
  timestamp,
84
85
  data: _objectSpread(_objectSpread({}, data), {}, {
85
- [illegalKeyCombinationDetectedParam]: illegalKeysCombinationCount
86
+ [illegalKeyCombinationDetectedParam]: illegalKeysCombinationCount,
87
+ keysCombinationClicked: keysCombinationClicked
86
88
  })
87
89
  };
88
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonschool/react_proctoring_library",
3
- "version": "0.0.100",
3
+ "version": "0.0.102",
4
4
  "description": "Used to proctor online tests",
5
5
  "author": "ayushkagrawal,shreyachandra,weastel",
6
6
  "main": "dist/index.js",