Skip to main content

matomo/models/
actions.rs

1use serde::Deserialize;
2use serde_with::{serde_as, DisplayFromStr, PickFirst};
3
4/// A node in `Actions.getPageUrls` / `Actions.getPageTitles`. These are
5/// recursive trees: a node may carry an inline `subtable` (when Matomo is
6/// queried with `flat=0` and expanded) or just an `idsubdatatable` pointer to
7/// fetch the children separately.
8#[serde_as]
9#[derive(Debug, Clone, Deserialize)]
10pub struct ActionPage {
11    pub label: String,
12    #[serde(default)]
13    pub nb_visits: i64,
14    #[serde(default)]
15    pub nb_hits: i64,
16    #[serde(default)]
17    pub sum_time_spent: i64,
18    #[serde(default)]
19    pub entry_nb_visits: i64,
20    #[serde(default)]
21    pub entry_nb_actions: i64,
22    #[serde(default)]
23    pub exit_nb_visits: i64,
24    #[serde_as(as = "Option<PickFirst<(_, DisplayFromStr)>>")]
25    #[serde(default)]
26    pub avg_time_on_page: Option<f64>,
27    #[serde(default)]
28    pub bounce_rate: Option<String>,
29    #[serde(default)]
30    pub exit_rate: Option<String>,
31    /// Present only on leaf URL nodes.
32    #[serde(default)]
33    pub url: Option<String>,
34    #[serde(default)]
35    pub segment: Option<String>,
36    /// Pointer to fetch this node's children in a follow-up call.
37    #[serde(default)]
38    pub idsubdatatable: Option<i64>,
39    /// Inline children when the tree was expanded server-side.
40    #[serde(default)]
41    pub subtable: Option<Vec<ActionPage>>,
42}
43
44/// `Actions.getDownloads` row.
45#[derive(Debug, Clone, Deserialize)]
46pub struct Download {
47    pub label: String,
48    #[serde(default)]
49    pub nb_visits: i64,
50    #[serde(default)]
51    pub nb_hits: i64,
52    #[serde(default)]
53    pub sum_time_spent: i64,
54    #[serde(default)]
55    pub url: Option<String>,
56    #[serde(default)]
57    pub idsubdatatable: Option<i64>,
58    #[serde(default)]
59    pub subtable: Option<Vec<Download>>,
60}
61
62/// `Actions.getOutlinks` row.
63#[derive(Debug, Clone, Deserialize)]
64pub struct Outlink {
65    pub label: String,
66    #[serde(default)]
67    pub nb_visits: i64,
68    #[serde(default)]
69    pub nb_hits: i64,
70    #[serde(default)]
71    pub sum_time_spent: i64,
72    #[serde(default)]
73    pub url: Option<String>,
74    #[serde(default)]
75    pub idsubdatatable: Option<i64>,
76    #[serde(default)]
77    pub subtable: Option<Vec<Outlink>>,
78}