Merge pull request #3169 from murillodigital/master

Adding place/user go to logging
This commit is contained in:
Clément Brisset 2014-07-14 16:41:44 -07:00
commit 529fa50025
3 changed files with 25 additions and 4 deletions

View file

@ -13,6 +13,7 @@
#include "Application.h"
#include "LocationManager.h"
#include <UserActivityLogger.h>
const QString GET_USER_ADDRESS = "/api/v1/users/%1/address";
const QString GET_PLACE_ADDRESS = "/api/v1/places/%1";
@ -60,23 +61,30 @@ void LocationManager::createNamedLocation(NamedLocation* namedLocation) {
}
void LocationManager::goTo(QString destination) {
const QString USER_DESTINATION_TYPE = "user";
const QString PLACE_DESTINATION_TYPE = "place";
const QString OTHER_DESTINATION_TYPE = "coordinate_or_username";
if (destination.startsWith("@")) {
// remove '@' and go to user
goToUser(destination.remove(0, 1));
QString destinationUser = destination.remove(0, 1);
UserActivityLogger::getInstance().wentTo(USER_DESTINATION_TYPE, destinationUser);
goToUser(destinationUser);
return;
}
if (destination.startsWith("#")) {
// remove '#' and go to named place
goToPlace(destination.remove(0, 1));
QString destinationPlace = destination.remove(0, 1);
UserActivityLogger::getInstance().wentTo(PLACE_DESTINATION_TYPE, destinationPlace);
goToPlace(destinationPlace);
return;
}
// go to coordinate destination or to Username
if (!goToDestination(destination)) {
destination = QString(QUrl::toPercentEncoding(destination));
UserActivityLogger::getInstance().wentTo(OTHER_DESTINATION_TYPE, destination);
JSONCallbackParameters callbackParams;
callbackParams.jsonCallbackReceiver = this;
callbackParams.jsonCallbackMethod = "goToAddressFromResponse";

View file

@ -146,3 +146,15 @@ void UserActivityLogger::loadedScript(QString scriptName) {
logAction(ACTION_NAME, actionDetails);
}
void UserActivityLogger::wentTo(QString destinationType, QString destinationName) {
const QString ACTION_NAME = "went_to";
QJsonObject actionDetails;
const QString DESTINATION_TYPE_KEY = "destination_type";
const QString DESTINATION_NAME_KEY = "detination_name";
actionDetails.insert(DESTINATION_TYPE_KEY, destinationType);
actionDetails.insert(DESTINATION_NAME_KEY, destinationName);
logAction(ACTION_NAME, actionDetails);
}

View file

@ -35,6 +35,7 @@ public slots:
void changedDomain(QString domainURL);
void connectedDevice(QString typeOfDevice, QString deviceName);
void loadedScript(QString scriptName);
void wentTo(QString destinationType, QString destinationName);
private slots:
void requestFinished(const QJsonObject& object);