Boolean

Booleans are used for simple flags, for example "is a11y enabled"?.

Configuration

Say you're adding a boolean to record whether a11y is enabled on the device. First you need to add an entry for the boolean to the metrics.yaml file:

flags:
  a11y_enabled:
    type: boolean
    description: >
      Records whether a11y is enabled on the device.
    lifetime: application
    ...

API

import org.mozilla.yourApplication.GleanMetrics.Flags

Flags.a11yEnabled.set(System.isAccesibilityEnabled())

There are test APIs available too:

import org.mozilla.yourApplication.GleanMetrics.Flags

// Was anything recorded?
assertTrue(Flags.a11yEnabled.testHasValue())
// Does it have the expected value?
assertTrue(Flags.a11yEnabled.testGetValue())
import org.mozilla.yourApplication.GleanMetrics.Flags;

Flags.INSTANCE.a11yEnabled.set(System.isAccessibilityEnabled());

There are test APIs available too:

import org.mozilla.yourApplication.GleanMetrics.Flags;

// Was anything recorded?
assertTrue(Flags.INSTANCE.a11yEnabled.testHasValue());
// Does it have the expected value?
assertTrue(Flags.INSTANCE.a11yEnabled.testGetValue());
Flags.a11yEnabled.set(self.isAccessibilityEnabled)

There are test APIs available too:

@testable import Glean

// Was anything recorded?
XCTAssertTrue(Flags.a11yEnabled.testHasValue())
// Does the counter have the expected value?
XCTAssertTrue(try Flags.a11yEnabled.testGetValue())
from glean import load_metrics
metrics = load_metrics("metrics.yaml")

metrics.flags.a11y_enabled.set(is_accessibility_enabled())

There are test APIs available too:

# Was anything recorded?
assert metrics.flags.a11y_enabled.test_has_value()
# Does it have the expected value?
assert True is metrics.flags.a11y_enabled.test_get_value()
using static Mozilla.YourApplication.GleanMetrics.FlagsOuter;

Flags.a11yEnabled.Set(System.IsAccessibilityEnabled());

There are test APIs available too:

using static Mozilla.YourApplication.GleanMetrics.FlagsOuter;

// Was anything recorded?
Assert.True(Flags.a11yEnabled.TestHasValue());
// Does it have the expected value?
Assert.True(Flags.a11yEnabled.TestGetValue());

Limits

  • None.

Examples

  • Is a11y enabled?

Recorded errors

  • None.

Reference