Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(analytics): adding same_sender field to the identity lookup analytics #728

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>,
}
Loading