plausible_rs/api/event/event_headers.rs
1/// Request headers for the 'POST /api/event' API.
2#[derive(Debug, Clone)]
3pub struct EventHeaders {
4 /// The raw value of User-Agent is used to calculate the `user_id` which identifies a
5 /// [unique visitor](https://plausible.io/data-policy#how-we-count-unique-users-without-cookies)
6 /// in Plausible.
7 ///
8 /// User-Agent is also used to populate the Devices report in your Plausible dashboard.
9 /// The device data is derived from the open source database
10 /// [device-detector](https://github.com/matomo-org/device-detector).
11 /// If your User-Agent is not showing up in your dashboard, it's probably because it is not
12 /// recognized as one in the device-detector database.
13 pub user_agent: String,
14
15 /// Used to get the IP address of the client.
16 ///
17 /// The IP address is used to calculate the `user_id` which identifies a
18 /// [unique visitor](https://plausible.io/data-policy#how-we-count-unique-users-without-cookies)
19 /// in Plausible. The raw value is anonymized and not stored.
20 /// If the header contains a comma-separated list (as it should if the request is sent through
21 /// a chain of proxies), then the first valid IP address from the list is used.
22 ///
23 /// More information can be found on
24 /// [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For).
25 pub x_forwarded_for: String,
26}
27
28impl EventHeaders {
29 #[must_use]
30 pub const fn new(user_agent: String, x_forwarded_for: String) -> Self {
31 Self {
32 user_agent,
33 x_forwarded_for,
34 }
35 }
36}