summaryrefslogtreecommitdiffstats
path: root/third_party/rust/glean-core/src/metrics/remote_settings_config.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/glean-core/src/metrics/remote_settings_config.rs
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/glean-core/src/metrics/remote_settings_config.rs')
-rw-r--r--third_party/rust/glean-core/src/metrics/remote_settings_config.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/third_party/rust/glean-core/src/metrics/remote_settings_config.rs b/third_party/rust/glean-core/src/metrics/remote_settings_config.rs
new file mode 100644
index 0000000000..e7a560e81c
--- /dev/null
+++ b/third_party/rust/glean-core/src/metrics/remote_settings_config.rs
@@ -0,0 +1,52 @@
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+use std::collections::HashMap;
+
+use serde::{Deserialize, Serialize};
+
+/// Represents a list of metrics and an associated boolean property
+/// indicating if the metric is enabledfrom the remote-settings
+/// configuration store. The expected format of this data is stringified JSON
+/// in the following format:
+/// ```json
+/// {
+/// "category.metric_name": true
+/// }
+/// ```
+#[derive(Serialize, Deserialize, Debug, Clone, Default)]
+pub struct RemoteSettingsConfig {
+ /// This is a `HashMap` consisting of base_identifiers as keys
+ /// and bool values representing an override for the `disabled`
+ /// property of the metric, only inverted to reduce confusion.
+ /// If a particular metric has a value of `true` here, it means
+ /// the default of the metric will be overriden and set to the
+ /// enabled state.
+ #[serde(default)]
+ pub metrics_enabled: HashMap<String, bool>,
+
+ /// This is a `HashMap` consisting of ping names as keys and
+ /// boolean values representing on override for the default
+ /// enabled state of the ping of the same name.
+ #[serde(default)]
+ pub pings_enabled: HashMap<String, bool>,
+}
+
+impl RemoteSettingsConfig {
+ /// Creates a new RemoteSettingsConfig
+ pub fn new() -> Self {
+ Default::default()
+ }
+}
+
+impl TryFrom<String> for RemoteSettingsConfig {
+ type Error = crate::ErrorKind;
+
+ fn try_from(json: String) -> Result<Self, Self::Error> {
+ match serde_json::from_str(json.as_str()) {
+ Ok(config) => Ok(config),
+ Err(e) => Err(crate::ErrorKind::Json(e)),
+ }
+ }
+}