From 2f4cb7c534852c7cec142d102520b01a4a7b5c0d Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Mon, 12 Mar 2012 18:24:06 -0400
Subject: [PATCH] SH-2970 WIP - send per-appearance-change metrics packet
 (disabled)

---
 indra/newview/llagent.cpp        |  1 +
 indra/newview/llvoavatarself.cpp | 48 ++++++++++++++++++++++++++++++++
 indra/newview/llvoavatarself.h   |  1 +
 3 files changed, 50 insertions(+)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index af3a4099446..9f764c6e41e 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -3779,6 +3779,7 @@ void LLAgent::sendAgentSetAppearance()
 		return;
 	}
 
+	gAgentAvatarp->sendAppearanceChangeMetrics();
 	llinfos << gAgentAvatarp->avString() << "TAT: Sent AgentSetAppearance: " << gAgentAvatarp->getBakedStatusForPrintout() << llendl;
 	//dumpAvatarTEs( "sendAgentSetAppearance()" );
 
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 27d499b9c44..4e75582a935 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2089,6 +2089,7 @@ const std::string LLVOAvatarSelf::debugDumpAllLocalTextureDataInfo() const
 // Dump avatar metrics data.
 LLSD LLVOAvatarSelf::metricsData()
 {
+	// runway - add region info
 	LLSD result;
 	result["id"] = getID();
 	result["rez_status"] = getRezzedStatus();
@@ -2109,6 +2110,53 @@ LLSD LLVOAvatarSelf::metricsData()
 	return result;
 }
 
+class ViewerAppearanceChangeMetricsResponder: public LLCurl::Responder
+{
+public:
+	ViewerAppearanceChangeMetricsResponder()
+	{
+	}
+
+	virtual void completed(U32 status,
+						   const std::string& reason,
+						   const LLSD& content)
+	{
+		if (isGoodStatus(status))
+		{
+			llinfos << "OK" << llendl;
+			result(content);
+		}
+		else
+		{
+			llwarns << "Failed " << status << " reason " << reason << llendl;
+			error(status,reason);
+		}
+	}
+};
+
+void LLVOAvatarSelf::sendAppearanceChangeMetrics()
+{
+	gAgentAvatarp->stopAllPhases();
+
+	LLSD msg = metricsData();
+	msg["message"] = "ViewerAppearanceChangeMetrics";
+
+	llinfos << "message: " << msg << llendl;
+	std::string	caps_url;
+	if (getRegion())
+	{
+		// runway - change here to activate.
+		caps_url = "";//getRegion()->getCapability("ViewerMetrics");
+	}
+	if (!caps_url.empty())
+	{
+		LLCurlRequest::headers_t headers;
+		LLHTTPClient::post(caps_url,
+							msg,
+							new ViewerAppearanceChangeMetricsResponder);
+	}
+}
+
 const LLUUID& LLVOAvatarSelf::grabBakedTexture(EBakedTextureIndex baked_index) const
 {
 	if (canGrabBakedTexture(baked_index))
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index c9098f174c2..fc1b602764b 100755
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -370,6 +370,7 @@ class LLVOAvatarSelf :
 	const std::string		debugDumpLocalTextureDataInfo(const LLTexLayerSet* layerset) const; // Lists out state of this particular baked texture layer
 	const std::string		debugDumpAllLocalTextureDataInfo() const; // Lists out which baked textures are at highest LOD
 	LLSD					metricsData();
+	void					sendAppearanceChangeMetrics(); // send data associated with completing a change.
 private:
 	LLFrameTimer    		mDebugSelfLoadTimer;
 	F32						mDebugTimeWearablesLoaded;
-- 
GitLab