edgee_components_runtime/components/
config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use std::{collections::HashMap, path::PathBuf};

use serde::Deserialize;

#[derive(Deserialize, Debug, Default, Clone)]
pub struct ComponentsConfiguration {
    pub data_collection: Vec<DataCollectionConfiguration>,
    pub cache: Option<PathBuf>,
}

#[derive(Deserialize, Debug, Default, Clone)]
pub struct DataCollectionConfiguration {
    pub name: String,
    pub component: String,
    pub credentials: HashMap<String, String>,
    #[serde(default = "default_component_config")]
    pub config: ComponentConfig,
}

#[derive(Deserialize, Debug, Default, Clone)]
pub struct ComponentConfig {
    #[serde(default = "default_true")]
    pub anonymization: bool,
    #[serde(default = "default_pending")]
    pub default_consent: String,
    #[serde(default = "default_true")]
    pub track_event_enabled: bool,
    #[serde(default = "default_true")]
    pub user_event_enabled: bool,
    #[serde(default = "default_true")]
    pub page_event_enabled: bool,
}

fn default_component_config() -> ComponentConfig {
    ComponentConfig {
        anonymization: true,
        default_consent: "pending".to_string(),
        track_event_enabled: true,
        user_event_enabled: true,
        page_event_enabled: true,
    }
}

fn default_true() -> bool {
    true
}

fn default_pending() -> String {
    "pending".to_string()
}