initial analytics for connections

This commit is contained in:
David Kelly 2017-04-05 11:10:06 -07:00
parent 384f404602
commit 1b6bf90843
3 changed files with 14 additions and 0 deletions

View file

@ -61,6 +61,16 @@ void UserActivityLoggerScriptingInterface::palOpened(float secondsOpened) {
});
}
void UserActivityLoggerScriptingInterface::makeUserConnection(QString otherID, bool success, QString detailsString) {
QJsonObject payload;
payload["otherUser"] = otherID;
payload["success"] = success;
if (detailsString.length() > 0) {
payload["details"] = detailsString;
}
logAction("makeUserConnection", payload);
}
void UserActivityLoggerScriptingInterface::logAction(QString action, QJsonObject details) {
QMetaObject::invokeMethod(&UserActivityLogger::getInstance(), "logAction",
Q_ARG(QString, action),

View file

@ -29,6 +29,7 @@ public:
float tutorialElapsedTime, QString tutorialRunID = "", int tutorialVersion = 0, QString controllerType = "");
Q_INVOKABLE void palAction(QString action, QString target);
Q_INVOKABLE void palOpened(float secondsOpen);
Q_INVOKABLE void makeUserConnection(QString otherUser, bool success, QString details="");
private:
void logAction(QString action, QJsonObject details = {});
};

View file

@ -543,12 +543,14 @@ function connectionRequestCompleted() { // Final result is in. Do effects.
// don't change state (so animation continues while gripped)
// but do send a notification, by calling the slot that emits the signal for it
Window.makeConnection(true, result.connection.new_connection ? "You and " + result.connection.username + " are now connected!" : result.connection.username);
UserActivityLogger.makeUserConnection(connectingId, true, result.connection.new_connection ? "new connection" : "already connected");
return;
} // failed
endHandshake();
debug("failing with result data", result);
// IWBNI we also did some fail sound/visual effect.
Window.makeConnection(false, result.connection);
UserActivityLogger.makeUserConnection(connectingId, false, result.connection);
}
var POLL_INTERVAL_MS = 200, POLL_LIMIT = 5;
function handleConnectionResponseAndMaybeRepeat(error, response) {
@ -573,6 +575,7 @@ function handleConnectionResponseAndMaybeRepeat(error, response) {
} else if (error || (response.status !== 'success')) {
debug('server fail', error, response.status);
result = error ? {status: 'error', connection: error} : response;
UserActivityLogger.makeUserConnection(connectingId, false, error || response);
connectionRequestCompleted();
} else {
debug('server success', result);