From ba8620b644ae4c26796cda59ccd8a51fa20c9194 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 9 Jan 2019 13:51:40 -0800 Subject: [PATCH] updating user activity logging --- .../qml/LoginDialog/CompleteProfileBody.qml | 37 +++++++++- .../qml/LoginDialog/LinkAccountBody.qml | 57 +++++++++++++-- .../qml/LoginDialog/LoggingInBody.qml | 73 ++++++++++++++++++- .../resources/qml/LoginDialog/SignUpBody.qml | 39 +++++++--- .../qml/LoginDialog/UsernameCollisionBody.qml | 39 +++++++++- interface/src/Application.cpp | 2 +- 6 files changed, 221 insertions(+), 26 deletions(-) diff --git a/interface/resources/qml/LoginDialog/CompleteProfileBody.qml b/interface/resources/qml/LoginDialog/CompleteProfileBody.qml index 6859b7ab3d..144b91063f 100644 --- a/interface/resources/qml/LoginDialog/CompleteProfileBody.qml +++ b/interface/resources/qml/LoginDialog/CompleteProfileBody.qml @@ -29,6 +29,8 @@ Item { readonly property bool withSteam: withSteam property string errorString: errorString + readonly property bool loginDialogPoppedUp: loginDialog.getLoginDialogPoppedUp() + QtObject { id: d readonly property int minWidth: 480 @@ -123,6 +125,13 @@ Item { fontSize: completeProfileBody.fontSize fontBold: completeProfileBody.fontBold onClicked: { + if (completeProfileBody.loginDialogPoppedUp) { + var data = { + "action": "user clicked cancel on the complete profile screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader }); } } @@ -142,6 +151,12 @@ Item { fontSize: completeProfileBody.fontSize fontBold: completeProfileBody.fontBold onClicked: { + if (completeProfileBody.loginDialogPoppedUp) { + var data = { + "action": "user clicked create profile" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } loginErrorMessage.visible = false; loginDialog.createAccountFromSteam(); } @@ -253,13 +268,29 @@ Item { onHandleCreateCompleted: { console.log("Create Succeeded") - loginDialog.loginThroughSteam(); - bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": true, "linkSteam": false }); + if (completeProfileBody.withSteam) { + if (completeProfileBody.loginDialogPoppedUp) { + var data = { + "action": "user created a profile with Steam successfully from the complete profile screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + loginDialog.loginThroughSteam(); + } + bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam, "linkSteam": false }); } onHandleCreateFailed: { console.log("Create Failed: " + error); + if (completeProfileBody.withSteam) { + if (completeProfileBody.loginDialogPoppedUp) { + var data = { + "action": "user failed to create a profile with Steam from the complete profile screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + } - bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader }); + bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam }); } } diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 987c5b08e4..5048bf0278 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -42,6 +42,8 @@ Item { property string errorString: errorString property bool lostFocus: false + readonly property bool loginDialogPoppedUp: loginDialog.getLoginDialogPoppedUp() + QtObject { id: d readonly property int minWidth: 480 @@ -68,6 +70,20 @@ Item { function login() { loginDialog.login(emailField.text, passwordField.text); + if (linkAccountBody.loginDialogPoppedUp) { + var data; + if (linkAccountBody.linkSteam) { + data = { + "action": "user linking hifi account with Steam" + }; + } else { + data = { + "action": "user logging in" + }; + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": linkAccountBody.withSteam, "withOculus": linkAccountBody.withOculus, "linkSteam": linkAccountBody.linkSteam }); } @@ -294,6 +310,14 @@ Item { topMargin: hifi.dimensions.contentSpacing.y } onClicked: { + if (linkAccountBody.loginDialogPoppedUp) { + var data = { + "action": "user clicked cancel at link account screen" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + loginDialog.dismissLoginDialog(); + } + bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": linkAccountBody.withSteam, "errorString": "" }); } } @@ -310,7 +334,7 @@ Item { topMargin: hifi.dimensions.contentSpacing.y } onClicked: { - linkAccountBody.login() + linkAccountBody.login(); } } TextMetrics { @@ -373,7 +397,12 @@ Item { lightboxPopup.visible = false; } lightboxPopup.visible = true; - // bodyLoader.setSource("CantAccessBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader }); + if (linkAccountBody.loginDialogPoppedUp) { + var data = { + "action": "user clicked can't access account" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } } } HifiControlsUit.Button { @@ -402,6 +431,19 @@ Item { linkAccountBody.withSteam = true; loginDialog.loginThroughSteam(); } + if (linkAccountBody.loginDialogPoppedUp) { + var data; + if (linkAccountBody.withOculus) { + data = { + "action": "user clicked login through Oculus" + }; + } else if (linkAccountBody.withSteam) { + data = { + "action": "user clicked login through Steam" + }; + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": linkAccountBody.withSteam, "withOculus": linkAccountBody.withOculus, "linkSteam": linkAccountBody.linkSteam }); @@ -470,6 +512,12 @@ Item { linkColor: hifi.colors.blueAccent onLinkActivated: { Tablet.playSound(TabletEnums.ButtonClick); + if (linkAccountBody.loginDialogPoppedUp) { + var data = { + "action": "user clicked sign up button" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } bodyLoader.setSource("SignUpBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": "", "linkSteam": linkAccountBody.linkSteam }); } @@ -495,10 +543,9 @@ Item { fontFamily: linkAccountBody.fontFamily fontSize: linkAccountBody.fontSize fontBold: linkAccountBody.fontBold - visible: loginDialog.getLoginDialogPoppedUp() && !linkAccountBody.linkSteam; + visible: linkAccountBody.loginDialogPoppedUp && !linkAccountBody.linkSteam; onClicked: { - if (loginDialog.getLoginDialogPoppedUp()) { - console.log("[ENCOURAGELOGINDIALOG]: user dismissed login screen") + if (linkAccountBody.loginDialogPoppedUp) { var data = { "action": "user dismissed login screen" }; diff --git a/interface/resources/qml/LoginDialog/LoggingInBody.qml b/interface/resources/qml/LoginDialog/LoggingInBody.qml index 355f89667b..65693deccd 100644 --- a/interface/resources/qml/LoginDialog/LoggingInBody.qml +++ b/interface/resources/qml/LoginDialog/LoggingInBody.qml @@ -30,6 +30,8 @@ Item { property bool withOculus: withOculus property bool linkSteam: linkSteam + readonly property bool loginDialogPoppedUp: loginDialog.getLoginDialogPoppedUp() + QtObject { id: d readonly property int minWidth: 480 @@ -62,8 +64,12 @@ Item { running: false; repeat: false; onTriggered: { - if (loginDialog.getLoginDialogPoppedUp()) { + if (loggingInBody.loginDialogPoppedUp) { loginDialog.dismissLoginDialog(); + var data = { + "action": "user logged in successfully"; + }; + UserActivityLogger.logAction("encourageLoginDialog", data); } root.tryDestroy(); } @@ -107,6 +113,12 @@ Item { loggingInText.x = 0; loggingInText.anchors.centerIn = loggingInHeader; loggedInGlyph.visible = true; + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user logged in with Steam successfully" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } } else if (loggingInBody.withOculus) { // reset the flag. loggingInGlyph.visible = false; @@ -115,8 +127,21 @@ Item { loggingInText.anchors.centerIn = loggingInHeader; loggedInGlyph.text = hifi.glyphs.oculus; loggedInGlyph.visible = true; + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user logged in with Oculus successfully" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } } else { loggingInText.text = "You are now logged in!"; + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user logged in successfully" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } + } successTimer.start(); } @@ -234,11 +259,28 @@ Item { target: loginDialog onHandleLinkCompleted: { console.log("Link Succeeded"); - loggingInBody.linkSteam = false; - loggingInBody.loadingSuccess(); + if (loggingInBody.linkSteam) { + loggingInBody.linkSteam = false; + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user linked Steam with their hifi account credentials successfully" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } + + loggingInBody.loadingSuccess(); + } } onHandleLinkFailed: { console.log("Link Failed: " + error); + if (loggingInBody.linkSteam) { + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user linked Steam unsuccessfully" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } + } bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "linkSteam": true, "errorString": error }); } @@ -253,18 +295,43 @@ Item { var errorString = ""; if (loggingInBody.linkSteam && loggingInBody.withSteam) { errorString = "Username or password is incorrect."; + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user failed to link Steam with their hifi account credentials" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam, "linkSteam": loggingInBody.linkSteam, "errorString": errorString }); } else if (loggingInBody.withSteam) { loggingInGlyph.visible = false; errorString = "Your Steam authentication has failed. Please make sure you are logged into Steam and try again."; + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user failed to authenticate with Steam to log in" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam, "errorString": errorString }); } else if (loggingInBody.withOculus) { loggingInGlyph.visible = false; errorString = "Your Oculus authentication has failed. Please make sure you are logged into Oculus and try again." + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user failed to authenticate with Oculus to log in" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": errorString }); } else { errorString = "Username or password is incorrect."; + if (loggingInBody.loginDialogPoppedUp) { + var data = { + "action": "user failed at logging in" + }; + UserActivityLogger.logAction("encourageLoginDialog", data); + } + bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": errorString }); } } diff --git a/interface/resources/qml/LoginDialog/SignUpBody.qml b/interface/resources/qml/LoginDialog/SignUpBody.qml index 5e0e955330..3ba66391e6 100644 --- a/interface/resources/qml/LoginDialog/SignUpBody.qml +++ b/interface/resources/qml/LoginDialog/SignUpBody.qml @@ -40,6 +40,8 @@ Item { property bool linkSteam: linkSteam property bool lostFocus: false + readonly property bool loginDialogPoppedUp: loginDialog.getLoginDialogPoppedUp() + QtObject { id: d readonly property int minWidth: 480 @@ -345,6 +347,12 @@ Item { fontSize: signUpBody.fontSize fontBold: signUpBody.fontBold onClicked: { + if (signUpBody.loginDialogPoppedUp) { + var data = { + "action": "user clicked cancel button at sign up screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "linkSteam": signUpBody.linkSteam }); } } @@ -363,23 +371,18 @@ Item { } onClicked: { + if (signUpBody.loginDialogPoppedUp) { + var data = { + "action": "user clicked sign up button" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } signUpBody.signup(); } } } } - MouseArea { - z: -2 - anchors.fill: parent - acceptedButtons: Qt.LeftButton - onClicked: { - if (!usernameField.focus && !emailField.focus && !passwordField.focus) { - usernameField.focus = true; - } - } - } - Component.onCompleted: { //but rise Tablet's one instead for Tablet interface root.keyboardEnabled = HMD.active; @@ -408,12 +411,26 @@ Item { onHandleSignupCompleted: { console.log("Sign Up Completed"); + if (signUpBody.loginDialogPoppedUp) { + var data = { + "action": "user signed up successfully" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + loginDialog.login(usernameField.text, passwordField.text); bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": false, "linkSteam": false }); } onHandleSignupFailed: { console.log("Sign Up Failed") + if (signUpBody.loginDialogPoppedUp) { + var data = { + "action": "user signed up unsuccessfully" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + if (errorString !== "") { loginErrorMessage.visible = true; var errorStringEdited = errorString.replace(/[\n\r]+/g, "\n"); diff --git a/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml b/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml index d44f5b733c..af46fc0223 100644 --- a/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml +++ b/interface/resources/qml/LoginDialog/UsernameCollisionBody.qml @@ -26,6 +26,10 @@ Item { readonly property int textFieldFontSize: 18 readonly property bool fontBold: true + readonly property bool withSteam: withSteam + + readonly property bool loginDialogPoppedUp: loginDialog.getLoginDialogPoppedUp() + function create() { mainTextContainer.visible = false loginDialog.createAccountFromSteam(textField.text); @@ -197,18 +201,40 @@ Item { target: loginDialog onHandleCreateCompleted: { console.log("Create Succeeded"); - loginDialog.loginThroughSteam(); - bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": true, "linkSteam": false }) + if (usernameCollisionBody.withSteam) { + if (usernameCollisionBody.loginDialogPoppedUp) { + var data = { + "action": "user created a profile with Steam successfully in the username collision screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + + loginDialog.loginThroughSteam(); + } + + bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": usernameCollisionBody.withSteam, "linkSteam": false }) } onHandleCreateFailed: { console.log("Create Failed: " + error) + if (usernameCollisionBody.loginDialogPoppedUp) { + var data = { + "action": "user failed to create account from the username collision screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + mainTextContainer.visible = true mainTextContainer.text = "\"" + textField.text + qsTr("\" is invalid or already taken."); } onHandleLoginCompleted: { console.log("Login Succeeded"); - if (loginDialog.getLoginDialogPoppedUp()) { + if (usernameCollisionBody.loginDialogPoppedUp) { + var data = { + "action": "user logged in successfully from the username collision screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + loginDialog.dismissLoginDialog(); } root.tryDestroy(); @@ -216,6 +242,13 @@ Item { onHandleLoginFailed: { console.log("Login Failed") + if (usernameCollisionBody.loginDialogPoppedUp) { + var data = { + "action": "user failed to log in from the username collision screen" + } + UserActivityLogger.logAction("encourageLoginDialog", data); + } + mainTextContainer.text = "Login Failed"; } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d306c77cce..6f5a0b2e54 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2864,7 +2864,7 @@ void Application::showLoginScreen() { dialogsManager->showLoginDialog(); emit loginDialogFocusEnabled(); QJsonObject loginData = {}; - loginData["action"] = "login dialog shown"; + loginData["action"] = "login dialog popped up"; UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData); _window->setWindowTitle("High Fidelity Interface"); } else {