feat: pass x-forwarded-for
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Kieran 2024-09-27 16:26:38 +01:00
parent aaad974d8f
commit c47432e58f
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -14,6 +14,8 @@ struct Event {
pub referrer: Option<String>,
#[serde(skip_serializing)]
pub user_agent: Option<String>,
#[serde(skip_serializing)]
pub xff: Option<String>,
}
pub struct PlausibleAnalytics {
@ -39,6 +41,13 @@ impl PlausibleAnalytics {
None => "",
},
)
.set(
"x-forwarded-for",
match &msg.xff {
Some(s) => s,
None => "",
},
)
.send_json(&msg)
{
Ok(v) => info!("Sent {:?}", msg),
@ -68,6 +77,10 @@ impl Analytics for PlausibleAnalytics {
Some(s) => Some(s.to_string()),
None => None,
},
xff: match req.headers().get_one("X-Forwarded-For") {
Some(s) => Some(s.to_string()),
None => None,
}
})?)
}
}