WIP on EXT-5687 (Classifieds are missing the clickthrough data).

Updating click stats on:
* opening classified info
* clicking "Map" or "Teleport" buttons in classified info
* clicking "Details" in the web-based search floater

--HG--
branch : product-engine
master
Vadim Savchuk 2010-03-05 19:03:00 +02:00
parent 739dee86c9
commit eeb6e89e60
5 changed files with 99 additions and 31 deletions

View File

@ -114,6 +114,23 @@ public:
};
static LLDispatchClassifiedClickThrough sClassifiedClickThrough;
// Just to debug errors. Can be thrown away later.
class LLClassifiedClickMessageResponder : public LLHTTPClient::Responder
{
LOG_CLASS(LLClassifiedClickMessageResponder);
public:
// If we get back an error (not found, etc...), handle it here
virtual void errorWithContent(
U32 status,
const std::string& reason,
const LLSD& content)
{
llwarns << "Sending click message failed (" << status << "): [" << reason << "]" << llendl;
llwarns << "Content: [" << content << "]" << llendl;
}
};
/* Re-expose this if we need to have classified ad HTML detail
pages. JC
@ -1234,7 +1251,7 @@ void LLPanelClassifiedInfo::reshape(S32 width, S32 height, BOOL called_from_pare
void LLPanelClassifiedInfo::onOpen(const LLSD& key)
{
LLUUID avatar_id = key["avatar_id"];
LLUUID avatar_id = key["classified_creator_id"];
if(avatar_id.isNull())
{
return;
@ -1251,9 +1268,12 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key)
resetControls();
setClassifiedId(key["classified_id"]);
setClassifiedName(key["name"]);
setDescription(key["desc"]);
setSnapshotId(key["snapshot_id"]);
setClassifiedName(key["classified_name"]);
setDescription(key["classified_desc"]);
setSnapshotId(key["classified_snapshot_id"]);
setFromSearch(key["from_search"]);
llinfos << "Opening classified [" << getClassifiedName() << "] (" << getClassifiedId() << ")" << llendl;
LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this);
LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoRequest(getClassifiedId());
@ -1270,6 +1290,10 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key)
LLHTTPClient::post(url, body, new LLClassifiedStatsResponder(getClassifiedId()));
}
// Update classified click stats.
// *TODO: Should we do this when opening not from search?
sendClickMessage("profile");
setInfoLoaded(false);
}
@ -1285,6 +1309,8 @@ void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType t
setSnapshotId(c_info->snapshot_id);
setParcelId(c_info->parcel_id);
setPosGlobal(c_info->pos_global);
setSimName(c_info->sim_name);
setClassifiedLocation(createLocationText(c_info->parcel_name, c_info->sim_name, c_info->pos_global));
childSetValue("category", LLClassifiedInfo::sCategories[c_info->category]);
@ -1316,7 +1342,19 @@ void LLPanelClassifiedInfo::resetData()
setClassifiedLocation(LLStringUtil::null);
setClassifiedId(LLUUID::null);
setSnapshotId(LLUUID::null);
mPosGlobal.clearVec();
setPosGlobal(LLVector3d::zero);
setParcelId(LLUUID::null);
setSimName(LLStringUtil::null);
setFromSearch(false);
// reset click stats
mTeleportClicksOld = 0;
mMapClicksOld = 0;
mProfileClicksOld = 0;
mTeleportClicksNew = 0;
mMapClicksNew = 0;
mProfileClicksNew = 0;
childSetValue("category", LLStringUtil::null);
childSetValue("content_type", LLStringUtil::null);
childSetText("click_through_text", LLStringUtil::null);
@ -1433,8 +1471,14 @@ void LLPanelClassifiedInfo::setClickThrough(
ct_str.setArg("[TELEPORT]", llformat("%d", self->mTeleportClicksNew + self->mTeleportClicksOld));
ct_str.setArg("[MAP]", llformat("%d", self->mMapClicksNew + self->mMapClicksOld));
ct_str.setArg("[PROFILE]", llformat("%d", self->mProfileClicksNew + self->mProfileClicksOld));
self->childSetText("click_through_text", ct_str.getString());
// *HACK: remove this when there is enough room for click stats in the info panel
self->childSetToolTip("click_through_text", ct_str.getString());
llinfos << "teleport: " << llformat("%d", self->mTeleportClicksNew + self->mTeleportClicksOld)
<< ", map: " << llformat("%d", self->mMapClicksNew + self->mMapClicksOld)
<< ", profile: " << llformat("%d", self->mProfileClicksNew + self->mProfileClicksOld)
<< llendl;
}
}
@ -1504,8 +1548,27 @@ void LLPanelClassifiedInfo::stretchSnapshot()
mSnapshotStreched = true;
}
void LLPanelClassifiedInfo::sendClickMessage(const std::string& type)
{
// You're allowed to click on your own ads to reassure yourself
// that the system is working.
LLSD body;
body["type"] = type;
body["from_search"] = fromSearch();
body["classified_id"] = getClassifiedId();
body["parcel_id"] = getParcelId();
body["dest_pos_global"] = getPosGlobal().getValue();
body["region_name"] = getSimName();
std::string url = gAgent.getRegion()->getCapability("SearchStatTracking");
llinfos << "Sending click msg via capability (url=" << url << ")" << llendl;
llinfos << "body: [" << body << "]" << llendl;
LLHTTPClient::post(url, body, new LLClassifiedClickMessageResponder());
}
void LLPanelClassifiedInfo::onMapClick()
{
sendClickMessage("map");
LLFloaterWorldMap::getInstance()->trackLocation(getPosGlobal());
LLFloaterReg::showInstance("world_map", "center");
}
@ -1514,6 +1577,7 @@ void LLPanelClassifiedInfo::onTeleportClick()
{
if (!getPosGlobal().isExactlyZero())
{
sendClickMessage("teleport");
gAgent.teleportViaLocation(getPosGlobal());
LLFloaterWorldMap::getInstance()->trackLocation(getPosGlobal());
}

View File

@ -204,6 +204,7 @@ private:
class LLPanelClassifiedInfo : public LLPanel, public LLAvatarPropertiesObserver
{
LOG_CLASS(LLPanelClassifiedInfo);
public:
static LLPanelClassifiedInfo* create();
@ -246,6 +247,14 @@ public:
LLUUID getParcelId() { return mParcelId; }
void setSimName(const std::string& sim_name) { mSimName = sim_name; }
std::string getSimName() { return mSimName; }
void setFromSearch(bool val) { mFromSearch = val; }
bool fromSearch() { return mFromSearch; }
bool getInfoLoaded() { return mInfoLoaded; }
void setInfoLoaded(bool loaded) { mInfoLoaded = loaded; }
@ -279,6 +288,7 @@ protected:
const LLVector3d& pos_global);
void stretchSnapshot();
void sendClickMessage(const std::string& type);
void onMapClick();
void onTeleportClick();
@ -290,6 +300,8 @@ private:
LLUUID mClassifiedId;
LLVector3d mPosGlobal;
LLUUID mParcelId;
std::string mSimName;
bool mFromSearch;
bool mInfoLoaded;
bool mSnapshotStreched;
@ -315,6 +327,7 @@ private:
class LLPanelClassifiedEdit : public LLPanelClassifiedInfo
{
LOG_CLASS(LLPanelClassifiedEdit);
public:
static LLPanelClassifiedEdit* create();

View File

@ -140,10 +140,11 @@ public:
params["open_tab_name"] = "panel_picks";
params["show_tab_panel"] = "classified_details";
params["classified_id"] = c_info->classified_id;
params["classified_avatar_id"] = c_info->creator_id;
params["classified_creator_id"] = c_info->creator_id;
params["classified_snapshot_id"] = c_info->snapshot_id;
params["classified_name"] = c_info->name;
params["classified_desc"] = c_info->description;
params["from_search"] = true;
LLSideTray::getInstance()->showPanel("panel_profile_view", params);
}
@ -726,26 +727,20 @@ void LLPanelPicks::openClassifiedInfo()
if (selected_value.isUndefined()) return;
LLClassifiedItem* c_item = getSelectedClassifiedItem();
LLSD params;
params["classified_id"] = c_item->getClassifiedId();
params["classified_creator_id"] = c_item->getAvatarId();
params["classified_snapshot_id"] = c_item->getSnapshotId();
params["classified_name"] = c_item->getClassifiedName();
params["classified_desc"] = c_item->getDescription();
params["from_search"] = false;
openClassifiedInfo(c_item->getClassifiedId(), c_item->getAvatarId(),
c_item->getSnapshotId(), c_item->getClassifiedName(),
c_item->getDescription());
openClassifiedInfo(params);
}
void LLPanelPicks::openClassifiedInfo(const LLUUID &classified_id,
const LLUUID &avatar_id,
const LLUUID &snapshot_id,
const std::string &name, const std::string &desc)
void LLPanelPicks::openClassifiedInfo(const LLSD &params)
{
createClassifiedInfoPanel();
LLSD params;
params["classified_id"] = classified_id;
params["avatar_id"] = avatar_id;
params["snapshot_id"] = snapshot_id;
params["name"] = name;
params["desc"] = desc;
getProfilePanel()->openPanel(mPanelClassifiedInfo, params);
}

View File

@ -119,9 +119,7 @@ private:
void openPickInfo();
void openClassifiedInfo();
void openClassifiedInfo(const LLUUID &classified_id, const LLUUID &avatar_id,
const LLUUID &snapshot_id, const std::string &name,
const std::string &desc);
void openClassifiedInfo(const LLSD& params);
friend class LLPanelProfile;
void showAccordion(const std::string& name, bool show);

View File

@ -171,15 +171,13 @@ void LLPanelProfile::onOpen(const LLSD& key)
}
else if (panel == "classified_details")
{
LLUUID classified_id = key["classified_id"].asUUID();
LLUUID avatar_id = key["classified_avatar_id"].asUUID();
LLUUID snapshot_id = key["classified_snapshot_id"].asUUID();
std::string name = key["classified_name"].asString();
std::string desc = key["classified_desc"].asString();
LLPanelPicks* picks = dynamic_cast<LLPanelPicks *>(getTabContainer()[PANEL_PICKS]);
if (picks)
{
picks->openClassifiedInfo(classified_id, avatar_id, snapshot_id, name, desc);
LLSD params = key;
params.erase("show_tab_panel");
params.erase("open_tab_name");
picks->openClassifiedInfo(params);
}
}
}