nimbus/stateful/matcher.rs
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//! This module defines all the information needed to match a user with an experiment.
6//! Soon it will also include a `match` function of some sort that does the matching.
7//!
8//! It contains the `AppContext`
9//! provided by the consuming client.
10//!
11use serde_derive::{Deserialize, Serialize};
12use serde_json::{Map, Value};
13
14/// The `AppContext` object represents the parameters and characteristics of the
15/// consuming application that we are interested in for targeting purposes. The
16/// `app_name` and `channel` fields are not optional as they are expected
17/// to be provided by all consuming applications as they are used in the top-level
18/// targeting that help to ensure that an experiment is only processed
19/// by the correct application.
20///
21/// Definitions of the fields are as follows:
22/// - `app_name`: This is the name of the application (e.g. "Fenix" or "Firefox iOS")
23/// - `app_id`: This is the application identifier, especially for mobile (e.g. "org.mozilla.fenix")
24/// - `channel`: This is the delivery channel of the application (e.g "nightly")
25/// - `app_version`: The user visible version string (e.g. "1.0.3")
26/// - `app_build`: The build identifier generated by the CI system (e.g. "1234/A")
27/// - `architecture`: The architecture of the device, (e.g. "arm", "x86")
28/// - `device_manufacturer`: The manufacturer of the device the application is running on
29/// - `device_model`: The model of the device the application is running on
30/// - `locale`: The locale of the application during initialization (e.g. "es-ES")
31/// - `os`: The name of the operating system (e.g. "Android", "iOS", "Darwin", "Windows")
32/// - `os_version`: The user-visible version of the operating system (e.g. "1.2.3")
33/// - `android_sdk_version`: Android specific for targeting specific sdk versions
34/// - `debug_tag`: Used for debug purposes as a way to match only developer builds, etc.
35/// - `installation_date`: The date the application installed the app
36/// - `home_directory`: The application's home directory
37/// - `custom_targeting_attributes`: Contains attributes specific to the application, derived by the application
38#[derive(Deserialize, Serialize, Debug, Clone, Default)]
39pub struct AppContext {
40 pub app_name: String,
41 pub app_id: String,
42 pub channel: String,
43 pub app_version: Option<String>,
44 pub app_build: Option<String>,
45 pub architecture: Option<String>,
46 pub device_manufacturer: Option<String>,
47 pub device_model: Option<String>,
48 pub locale: Option<String>,
49 pub os: Option<String>,
50 pub os_version: Option<String>,
51 pub android_sdk_version: Option<String>,
52 pub debug_tag: Option<String>,
53 pub installation_date: Option<i64>,
54 pub home_directory: Option<String>,
55 #[serde(flatten)]
56 pub custom_targeting_attributes: Option<Map<String, Value>>,
57}