Skip to content

Commit

Permalink
feat(analytics): adding field to the identity lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
geekbrother committed Aug 14, 2024
1 parent bb339ca commit cf2a8e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/analytics/identity_lookup_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub struct IdentityLookupInfo {
pub continent: Option<Arc<str>>,

pub client_id: Option<String>,
/// Whether the sender of the request is the same as the address being looked up
pub same_sender: Option<bool>,
}

impl IdentityLookupInfo {
Expand All @@ -44,6 +46,7 @@ impl IdentityLookupInfo {
country: Option<Arc<str>>,
continent: Option<Arc<str>>,
client_id: Option<String>,
same_sender: Option<bool>,
) -> Self {
Self {
timestamp: wc::analytics::time::now(),
Expand All @@ -65,6 +68,7 @@ impl IdentityLookupInfo {
continent,

client_id,
same_sender,
}
}
}
8 changes: 8 additions & 0 deletions src/handlers/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -128,6 +133,7 @@ async fn handler_internal(
country,
continent,
query.client_id.clone(),
same_sender,
));
}

Expand Down Expand Up @@ -176,6 +182,8 @@ pub struct IdentityQueryParams {
pub use_cache: Option<bool>,
/// Client ID for analytics
pub client_id: Option<String>,
/// Request sender address for analytics
pub sender: Option<String>,
}

#[tracing::instrument(skip_all, level = "debug")]
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ pub struct RegisterRequest {
pub struct LookupQueryParams {
/// Optional version parameter to support version-dependent responses
pub api_version: Option<usize>,
/// Request sender address for analytics
pub sender: Option<String>,
}

0 comments on commit cf2a8e9

Please sign in to comment.