From 6ee3d16f74c2d04fa3871fa1d369b8e3e3c4be35 Mon Sep 17 00:00:00 2001 From: cami Date: Fri, 16 Jul 2021 23:06:38 +0200 Subject: [PATCH 1/2] Logger works --- .../src/components/pages/BehaviorNormal.js | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/frontend/src/components/pages/BehaviorNormal.js b/frontend/src/components/pages/BehaviorNormal.js index 03fd105..422cff1 100644 --- a/frontend/src/components/pages/BehaviorNormal.js +++ b/frontend/src/components/pages/BehaviorNormal.js @@ -7,18 +7,46 @@ import SubmitField from "../SubmitField"; import { Logger } from "@behametrics/logger-web"; export default function BehaviorNormal() { - const [username, setUsername] = useState(""); - const [password, setPassword] = useState(""); + let username = ""; + const setUsername = (tmp_username) => { + username = tmp_username; + }; + + let password = ""; + const setPassword = (tmp_password) => { + password = tmp_password; + }; const [isLoggedIn] = useAuth(); - const handleUsernameChange = (e) => { - setUsername(e.target.value); + let logger = new Logger({ + //inputs: ["cursor", "wheel", "keyboard", "touch"], + inputs: ["keyboard"], + logToConsole: true, + }); + + logger.init(); + + const handleOff = () => { + logger.stop(); + console.log("Logger ausgeschaltet"); }; + + const handleOn = () => { + logger.start(); + console.log("start logging "); + }; + const handlePasswordChange = (e) => { + console.log("handlePasswordChange"); setPassword(e.target.value); }; + const handleUsernameChange = (e) => { + console.log("handleUsernamechange"); + setUsername(e.target.value); + }; + const handleOnCopyEvent = (e) => { e.preventDefault(); console.log("copy not allowed"); @@ -42,7 +70,6 @@ export default function BehaviorNormal() { body: JSON.stringify(opts), }).then((response) => { console.log(response.status); - console.log(isLoggedIn); if (response.status === 401) { response.json().then((resp) => { console.log("nicht so wirklich gut"); @@ -56,27 +83,11 @@ export default function BehaviorNormal() { }); }; - let logger = new Logger({ - //inputs: ["cursor", "wheel", "keyboard", "touch"], - inputs: ["keyboard"], - logToConsole: true, - }); - - const handleOff = () => { - logger.stop(); - logout(); - console.log("Logger ausgeschaltet"); - }; - - useEffect(() => { - logger.init().then(() => logger.start()); - console.log("start logging"); - }, []); - return ( <>

Studie

+

Nachfolgend werden Sie einige Schritte durchlaufen, um ihre Nutzerinteraktion messen zu können. Verwenden Sie hierbei jeweils From c306acc97abbbb1ed3a914831cd4decb8f9be0fc Mon Sep 17 00:00:00 2001 From: cami Date: Sat, 17 Jul 2021 00:52:50 +0200 Subject: [PATCH 2/2] Remove unused things --- frontend/src/components/pages/BehaviorNormal.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/src/components/pages/BehaviorNormal.js b/frontend/src/components/pages/BehaviorNormal.js index 422cff1..ca03d43 100644 --- a/frontend/src/components/pages/BehaviorNormal.js +++ b/frontend/src/components/pages/BehaviorNormal.js @@ -1,7 +1,6 @@ -import React, { useState, useEffect } from "react"; +import React from "react"; import "../../App.css"; import Footer from "../../Footer"; -import { logout, useAuth } from "../../auth/AuthProvider"; import InputField from "../InputField"; import SubmitField from "../SubmitField"; import { Logger } from "@behametrics/logger-web"; @@ -17,8 +16,6 @@ export default function BehaviorNormal() { password = tmp_password; }; - const [isLoggedIn] = useAuth(); - let logger = new Logger({ //inputs: ["cursor", "wheel", "keyboard", "touch"], inputs: ["keyboard"],