From cf2a8e9914b198b3df8fa6b9810d9d7193e7aa75 Mon Sep 17 00:00:00 2001 From: Max Kalashnikoff Date: Tue, 13 Aug 2024 17:35:44 +0200 Subject: [PATCH] feat(analytics): adding field to the identity lookup --- src/analytics/identity_lookup_info.rs | 4 ++++ src/handlers/identity.rs | 8 ++++++++ src/handlers/profile/mod.rs | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/analytics/identity_lookup_info.rs b/src/analytics/identity_lookup_info.rs index 9f0b37394..01b01a95a 100644 --- a/src/analytics/identity_lookup_info.rs +++ b/src/analytics/identity_lookup_info.rs @@ -28,6 +28,8 @@ pub struct IdentityLookupInfo { pub continent: Option>, pub client_id: Option, + /// Whether the sender of the request is the same as the address being looked up + pub same_sender: Option, } impl IdentityLookupInfo { @@ -44,6 +46,7 @@ impl IdentityLookupInfo { country: Option>, continent: Option>, client_id: Option, + same_sender: Option, ) -> Self { Self { timestamp: wc::analytics::time::now(), @@ -65,6 +68,7 @@ impl IdentityLookupInfo { continent, client_id, + same_sender, } } } diff --git a/src/handlers/identity.rs b/src/handlers/identity.rs index 722a8c5c0..1bdaf4fb5 100644 --- a/src/handlers/identity.rs +++ b/src/handlers/identity.rs @@ -116,6 +116,11 @@ async fn handler_internal( .map(|geo| (geo.country, geo.continent, geo.region)) .unwrap_or((None, None, None)); + let same_sender = query + .sender + .as_ref() + .map(|sender| sender == &address.to_string()); + state.analytics.identity_lookup(IdentityLookupInfo::new( &query.0, address, @@ -128,6 +133,7 @@ async fn handler_internal( country, continent, query.client_id.clone(), + same_sender, )); } @@ -176,6 +182,8 @@ pub struct IdentityQueryParams { pub use_cache: Option, /// Client ID for analytics pub client_id: Option, + /// Request sender address for analytics + pub sender: Option, } #[tracing::instrument(skip_all, level = "debug")] diff --git a/src/handlers/profile/mod.rs b/src/handlers/profile/mod.rs index 006e2347b..a4abb86ae 100644 --- a/src/handlers/profile/mod.rs +++ b/src/handlers/profile/mod.rs @@ -87,4 +87,6 @@ pub struct RegisterRequest { pub struct LookupQueryParams { /// Optional version parameter to support version-dependent responses pub api_version: Option, + /// Request sender address for analytics + pub sender: Option, }