Skip to main content

px_native/events/
identity.rs

1//! Inputs to the event collector that come from the synthetic-user
2//! pool (see `px-camoufox/src/infrastructure/synthetic_user.rs`).
3//! Kept as a standalone struct so px-native doesn't depend on the
4//! camoufox crate.
5
6#[derive(Debug, Clone)]
7pub struct SyntheticIdentity {
8    pub user_agent: String,
9    pub locale: String,
10    pub timezone: String,
11    pub viewport: (u32, u32),
12    pub ga_client_id: String,
13    pub session_count: u32,
14    /// Visit-history depth in days. Drives the `first_visit_days_ago`
15    /// timestamp the runtime sometimes attaches.
16    pub first_visit_days_ago: u32,
17}
18
19impl SyntheticIdentity {
20    /// Default identity for use in unit tests. Real production
21    /// identities flow in from the camoufox `SyntheticUserPool`.
22    pub fn test_default() -> Self {
23        Self {
24            user_agent: "Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0"
25                .to_owned(),
26            locale: "es-AR".to_owned(),
27            timezone: "America/Argentina/Buenos_Aires".to_owned(),
28            viewport: (1366, 768),
29            ga_client_id: "GA1.1.000000000.0000000000".to_owned(),
30            session_count: 3,
31            first_visit_days_ago: 14,
32        }
33    }
34}