Revision control
Copy as Markdown
// -*- mode: Swift -*-
// AUTOGENERATED BY glean_parser v22.0.1. DO NOT EDIT. DO NOT COMMIT.
#if canImport(Foundation)
import Foundation
#endif
/* 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
import Glean
// swiftlint:disable superfluous_disable_command
// swiftlint:disable nesting
// swiftlint:disable line_length
// swiftlint:disable identifier_name
// swiftlint:disable force_try
extension GleanMetrics {
class GleanBuild {
private init() {
// Intentionally left private, no external user can instantiate a new global object.
}
public static let info = BuildInfo(buildDate: DateComponents(calendar: Calendar.current, timeZone: TimeZone(abbreviation: "UTC"), year: 2026, month: 11, day: 12, hour: 22, minute: 42, second: 25))
}
enum NimbusEvents {
struct ActivationExtra: EventExtras {
var branch: String?
var experiment: String?
var featureId: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
if let featureId = self.featureId {
record["feature_id"] = String(featureId)
}
return record
}
}
struct DatabaseLoadExtra: EventExtras {
var corrupt: Bool?
var error: String?
var initialVersion: Int32?
var migratedVersion: Int32?
var migrationError: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let corrupt = self.corrupt {
record["corrupt"] = String(corrupt)
}
if let error = self.error {
record["error"] = String(error)
}
if let initialVersion = self.initialVersion {
record["initial_version"] = String(initialVersion)
}
if let migratedVersion = self.migratedVersion {
record["migrated_version"] = String(migratedVersion)
}
if let migrationError = self.migrationError {
record["migration_error"] = String(migrationError)
}
return record
}
}
struct DatabaseMigrationExtra: EventExtras {
var error: String?
var fromVersion: Int32?
var reason: String?
var toVersion: Int32?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let error = self.error {
record["error"] = String(error)
}
if let fromVersion = self.fromVersion {
record["from_version"] = String(fromVersion)
}
if let reason = self.reason {
record["reason"] = String(reason)
}
if let toVersion = self.toVersion {
record["to_version"] = String(toVersion)
}
return record
}
}
struct DisqualificationExtra: EventExtras {
var branch: String?
var experiment: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
return record
}
}
struct EnrollFailedExtra: EventExtras {
var branch: String?
var experiment: String?
var reason: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
if let reason = self.reason {
record["reason"] = String(reason)
}
return record
}
}
struct EnrollmentExtra: EventExtras {
var branch: String?
var experiment: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
return record
}
}
struct EnrollmentStatusExtra: EventExtras {
var branch: String?
var conflictSlug: String?
var errorString: String?
var reason: String?
var slug: String?
var status: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let conflictSlug = self.conflictSlug {
record["conflict_slug"] = String(conflictSlug)
}
if let errorString = self.errorString {
record["error_string"] = String(errorString)
}
if let reason = self.reason {
record["reason"] = String(reason)
}
if let slug = self.slug {
record["slug"] = String(slug)
}
if let status = self.status {
record["status"] = String(status)
}
return record
}
}
struct ExposureExtra: EventExtras {
var branch: String?
var experiment: String?
var featureId: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
if let featureId = self.featureId {
record["feature_id"] = String(featureId)
}
return record
}
}
struct MalformedFeatureExtra: EventExtras {
var branch: String?
var experiment: String?
var featureId: String?
var partId: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
if let featureId = self.featureId {
record["feature_id"] = String(featureId)
}
if let partId = self.partId {
record["part_id"] = String(partId)
}
return record
}
}
struct UnenrollFailedExtra: EventExtras {
var experiment: String?
var reason: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
if let reason = self.reason {
record["reason"] = String(reason)
}
return record
}
}
struct UnenrollmentExtra: EventExtras {
var branch: String?
var experiment: String?
var reason: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let branch = self.branch {
record["branch"] = String(branch)
}
if let experiment = self.experiment {
record["experiment"] = String(experiment)
}
if let reason = self.reason {
record["reason"] = String(reason)
}
return record
}
}
/// Recorded when a feature is configured with an experimental configuration for
/// the first time in this session.
static let activation = EventMetricType<ActivationExtra>( // generated from nimbus_events.activation
CommonMetricData(
category: "nimbus_events",
name: "activation",
sendInPings: ["events"],
lifetime: .ping,
disabled: true,
inSession: true
)
, ["branch", "experiment", "feature_id"]
)
/// An event recorded when the Nimbus database is loaded.
static let databaseLoad = EventMetricType<DatabaseLoadExtra>( // generated from nimbus_events.database_load
CommonMetricData(
category: "nimbus_events",
name: "database_load",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["corrupt", "error", "initial_version", "migrated_version", "migration_error"]
)
/// An event recorded when a database migration occurs.
static let databaseMigration = EventMetricType<DatabaseMigrationExtra>( // generated from nimbus_events.database_migration
CommonMetricData(
category: "nimbus_events",
name: "database_migration",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["error", "from_version", "reason", "to_version"]
)
/// Recorded when a user becomes ineligible to continue receiving the treatment for
/// an enrolled experiment, for reasons such as the user opting out of the
/// experiment or no longer matching targeting for the experiment.
static let disqualification = EventMetricType<DisqualificationExtra>( // generated from nimbus_events.disqualification
CommonMetricData(
category: "nimbus_events",
name: "disqualification",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["branch", "experiment"]
)
/// Recorded when an enrollment fails, including the reason for the failure.
static let enrollFailed = EventMetricType<EnrollFailedExtra>( // generated from nimbus_events.enroll_failed
CommonMetricData(
category: "nimbus_events",
name: "enroll_failed",
sendInPings: ["background-update", "events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["branch", "experiment", "reason"]
)
/// Recorded when a user has met the conditions and is first bucketed into an
/// experiment (i.e. targeting matched and they were randomized into a bucket and
/// branch of the experiment). Expected a maximum of once per experiment per user.
static let enrollment = EventMetricType<EnrollmentExtra>( // generated from nimbus_events.enrollment
CommonMetricData(
category: "nimbus_events",
name: "enrollment",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["branch", "experiment"]
)
/// Recorded for each enrollment status each time the SDK completes application of
/// pending experiments.
static let enrollmentStatus = EventMetricType<EnrollmentStatusExtra>( // generated from nimbus_events.enrollment_status
CommonMetricData(
category: "nimbus_events",
name: "enrollment_status",
sendInPings: ["nimbus-targeting-context"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["branch", "conflict_slug", "error_string", "reason", "slug", "status"]
)
/// Recorded when a user actually observes an experimental treatment, or would have
/// observed an experimental treatment if they had been in a branch that would have
/// shown one.
static let exposure = EventMetricType<ExposureExtra>( // generated from nimbus_events.exposure
CommonMetricData(
category: "nimbus_events",
name: "exposure",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["branch", "experiment", "feature_id"]
)
/// An event sent when Nimbus finishes launching.
static let isReady = EventMetricType<NoExtras>( // generated from nimbus_events.is_ready
CommonMetricData(
category: "nimbus_events",
name: "is_ready",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, []
)
/// Recorded when feature code detects a problem with some part of the feature
/// configuration.
static let malformedFeature = EventMetricType<MalformedFeatureExtra>( // generated from nimbus_events.malformed_feature
CommonMetricData(
category: "nimbus_events",
name: "malformed_feature",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["branch", "experiment", "feature_id", "part_id"]
)
/// Emitted when a user opts out of rollouts (remote improvements).
static let rolloutsOptOut = EventMetricType<NoExtras>( // generated from nimbus_events.rollouts_opt_out
CommonMetricData(
category: "nimbus_events",
name: "rollouts_opt_out",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, []
)
/// Emitted when a user opts out of studies (experiments).
static let studiesOptOut = EventMetricType<NoExtras>( // generated from nimbus_events.studies_opt_out
CommonMetricData(
category: "nimbus_events",
name: "studies_opt_out",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, []
)
/// Recorded when an unenrollment fails, including the reason for the failure.
static let unenrollFailed = EventMetricType<UnenrollFailedExtra>( // generated from nimbus_events.unenroll_failed
CommonMetricData(
category: "nimbus_events",
name: "unenroll_failed",
sendInPings: ["background-update", "events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["experiment", "reason"]
)
/// Recorded when either telemetry is disabled, or the experiment has run for its
/// designed duration (i.e. it is no longer present in the Nimbus Remote Settings
/// collection)
static let unenrollment = EventMetricType<UnenrollmentExtra>( // generated from nimbus_events.unenrollment
CommonMetricData(
category: "nimbus_events",
name: "unenrollment",
sendInPings: ["events"],
lifetime: .ping,
disabled: false,
inSession: true
)
, ["branch", "experiment", "reason"]
)
}
enum NimbusHealth {
struct CacheNotReadyForFeatureExtra: EventExtras {
var featureId: String?
func toExtraRecord() -> [String: String] {
var record = [String: String]()
if let featureId = self.featureId {
record["feature_id"] = String(featureId)
}
return record
}
}
/// Measure how long `applyPendingExperiments` takes.
/// `applyPendingExperiments` uses disk I/O, and happens at
/// startup, as part of the initialization sequence.
static let applyPendingExperimentsTime = TimingDistributionMetricType( // generated from nimbus_health.apply_pending_experiments_time
CommonMetricData(
category: "nimbus_health",
name: "apply_pending_experiments_time",
sendInPings: ["metrics"],
lifetime: .ping,
disabled: false,
inSession: false
)
, .millisecond
)
/// Recorded when an application or library requests a feature configuration before
/// the in memory cache has been populated from the database
static let cacheNotReadyForFeature = EventMetricType<CacheNotReadyForFeatureExtra>( // generated from nimbus_health.cache_not_ready_for_feature
CommonMetricData(
category: "nimbus_health",
name: "cache_not_ready_for_feature",
sendInPings: ["events"],
lifetime: .ping,
disabled: true,
inSession: true
)
, ["feature_id"]
)
/// Measures how long `fetchExperiments` takes.
static let fetchExperimentsTime = TimingDistributionMetricType( // generated from nimbus_health.fetch_experiments_time
CommonMetricData(
category: "nimbus_health",
name: "fetch_experiments_time",
sendInPings: ["metrics"],
lifetime: .ping,
disabled: false,
inSession: false
)
, .millisecond
)
}
final class Pings: Sendable {
public static let shared = Pings()
private init() {
// Intentionally left private, no external user can instantiate a new global object.
}
/// This ping is submitted by Nimbus each time the enrollment workflow has
/// completed.
let nimbusTargetingContext = Ping<NoReasonCodes>(
name: "nimbus-targeting-context",
includeClientId: true,
sendIfEmpty: true,
preciseTimestamps: true,
includeInfoSections: true,
enabled: true,
schedulesPings: [],
reasonCodes: [],
followsCollectionEnabled: true,
uploaderCapabilities: []
)
}
}