Debian Codegraph @

third_party/rust/glean/src/core_metrics.rs

raw
1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5 use crate::system;
6
7 /// Metrics included in every ping as `client_info`.
8 #[derive(Debug)]
9 pub struct ClientInfoMetrics {
10 /// The build identifier generated by the CI system (e.g. "1234/A").
11 pub app_build: String,
12 /// The user visible version string (e.g. "1.0.3").
13 pub app_display_version: String,
14 /// The product-provided release channel (e.g. "beta").
15 pub channel: Option<String>,
16 /// The locale of the application during initialization (e.g. "es-ES").
17 pub locale: Option<String>,
18 }
19
20 impl ClientInfoMetrics {
21 /// Creates the client info with dummy values for all.
22 pub fn unknown() -> Self {
23 ClientInfoMetrics {
24 app_build: "Unknown".to_string(),
25 app_display_version: "Unknown".to_string(),
26 channel: None,
27 locale: None,
28 }
29 }
30 }
31
32 impl From<ClientInfoMetrics> for glean_core::ClientInfoMetrics {
33 fn from(metrics: ClientInfoMetrics) -> Self {
34 glean_core::ClientInfoMetrics {
35 app_build: metrics.app_build,
36 app_display_version: metrics.app_display_version,
37 channel: metrics.channel,
38 locale: metrics.locale,
39 os_version: system::get_os_version(),
40 windows_build_number: system::get_windows_build_number(),
41 architecture: system::ARCH.to_string(),
42 ..Default::default()
43 }
44 }
45 }