From b806f6e76c9de6480cb1853a043206ac95842fea Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Thu, 18 Jun 2015 17:01:52 +0300 Subject: [PATCH] [alohalytics] Special Server-side ID event to add more meta information about received data: - server timestamp - ip address - requested uri - user agent --- 3party/Alohalytics/src/event_base.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/3party/Alohalytics/src/event_base.h b/3party/Alohalytics/src/event_base.h index d87d16039e..f602f043fa 100644 --- a/3party/Alohalytics/src/event_base.h +++ b/3party/Alohalytics/src/event_base.h @@ -90,6 +90,28 @@ struct AlohalyticsIdEvent : public AlohalyticsBaseEvent { }; CEREAL_REGISTER_TYPE_WITH_NAME(AlohalyticsIdEvent, "i") +#ifdef ALOHALYTICS_SERVER +// Special event to store additional server-only information which can be useful for analysis. +struct AlohalyticsIdServerEvent : public AlohalyticsIdEvent { + uint64_t server_timestamp; + std::string ip; + std::string user_agent; + std::string uri; + + virtual std::string ToString() const { + return AlohalyticsIdEvent::ToString() + " SRV:" + TimestampToString(server_timestamp) + " IP:" + ip + " UA:" + + user_agent + " URI:" + uri; + } + + template + void serialize(Archive & ar) { + AlohalyticsIdEvent::serialize(ar); + ar(CEREAL_NVP(server_timestamp), CEREAL_NVP(ip), CEREAL_NVP(user_agent), CEREAL_NVP(uri)); + } +}; +CEREAL_REGISTER_TYPE_WITH_NAME(AlohalyticsIdServerEvent, "is") +#endif + // Simple event with a string name (key) only. struct AlohalyticsKeyEvent : public AlohalyticsBaseEvent { std::string key;