Options
All
  • Public
  • Public/Protected
  • All
Menu

A datetime metric.

Used to record an absolute date and time, such as the time the user first ran the application.

Hierarchy

Index

Constructors

constructor

Properties

Readonly category

category: string

Readonly disabled

disabled: boolean

Optional dynamicLabel

dynamicLabel?: string

Readonly lifetime

lifetime: Lifetime

Readonly name

name: string

Readonly sendInPings

sendInPings: string[]

timeUnit

timeUnit: default

Readonly type

type: string

Methods

baseIdentifier

  • baseIdentifier(): string
  • The metric's base identifier, including the category and name, but not the label.

    Returns string

    The generated identifier. If category is empty, it's ommitted. Otherwise, it's the combination of the metric's category and name.

identifier

  • identifier(): Promise<string>
  • The metric's unique identifier, including the category, name and label.

    Returns Promise<string>

    The generated identifier. If category is empty, it's ommitted. Otherwise, it's the combination of the metric's category, name and label.

set

  • set(value?: Date): void
  • Set a datetime value, truncating it to the metric's resolution.

    Parameters

    • Optional value: Date

      The Date value to set. If not provided, will record the current time.

    Returns void

shouldRecord

  • shouldRecord(uploadEnabled: boolean): boolean
  • Verify whether or not this metric instance should be recorded.

    Parameters

    • uploadEnabled: boolean

      Whether or not global upload is enabled or disabled.

    Returns boolean

    Whether or not this metric instance should be recorded.

testGetNumRecordedErrors

  • testGetNumRecordedErrors(errorType: string, ping?: string): Promise<number>
  • Returns the number of errors recorded for the given metric.

    Parameters

    • errorType: string

      The type of the error recorded.

    • ping: string = ...

      represents the name of the ping to retrieve the metric for. Defaults to the first value in sendInPings.

    Returns Promise<number>

    the number of errors recorded for the metric.

testGetValue

  • testGetValue(ping?: string): Promise<undefined | Date>
  • Test-only API**

    Gets the currently stored value as a boolean.

    This doesn't clear the stored value.

    Note

    The Date object is always in local time.

    If the currently stored datetime is in a different timezone than local, the resulting Date object will contain the relative local date to the recorded value.

    Parameters

    • ping: string = ...

      the ping from which we want to retrieve this metrics value from. Defaults to the first value in sendInPings.

    Returns Promise<undefined | Date>

    The value found in storage or undefined if nothing was found.

Private testGetValueAsDatetimeMetric

  • testGetValueAsDatetimeMetric(ping: string, fn: string): Promise<undefined | DatetimeMetric>
  • Test-only and private API**

    Gets the currently stored value as a DatetimeMetric.

    This doesn't clear the stored value.

    Parameters

    • ping: string

      The ping from which we want to retrieve this metrics value from.

    • fn: string

      The name of the function that is calling this function. Used for testing purposes.

    Returns Promise<undefined | DatetimeMetric>

    The value found in storage or undefined if nothing was found.

testGetValueAsString

  • testGetValueAsString(ping?: string): Promise<undefined | string>
  • Test-only API**

    Gets the currently stored value as an ISO date string.

    This doesn't clear the stored value.

    Parameters

    • ping: string = ...

      the ping from which we want to retrieve this metrics value from. Defaults to the first value in sendInPings.

    Returns Promise<undefined | string>

    The value found in storage or undefined if nothing was found.

Static _private_setUndispatched

  • _private_setUndispatched(instance: default, value?: Date): Promise<void>
  • An internal implemention of set that does not dispatch the recording task.

    Important

    This is absolutely not meant to be used outside of Glean itself. It may cause multiple issues because it cannot guarantee that the recording of the metric will happen in order with other Glean API calls.

    Parameters

    • instance: default

      The metric instance to record to.

    • Optional value: Date

      The date we want to set to.

    Returns Promise<void>

Generated using TypeDoc