# 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
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html

---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
  - "Firefox :: Messaging System"

# Keys added to messaging_system should also be added to microsurvey below,
# unless they carry sensitive/identifying information. The microsurvey ping
# basically mirrors the messaging_system ping, except that it includes
# event_input_value and excludes client_id and browser_session_id, to protect
# the user's privacy. When in doubt, ask in the #omc Slack channel.
messaging_system:
  event_context_parse_error: &event_context_parse_error
    type: counter
    lifetime: ping
    description: |
      How often we failed to parse event_context as JSON.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_reason: &event_reason
    type: string
    lifetime: ping
    description: |
      The event_context's `reason`. Likely something like
      "welcome-window-closed" or "app-shut-down",.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_page: &event_page
    type: string
    lifetime: ping
    description: |
      The event_context's `page`. Almost always "about:welcome".
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_source: &event_source
    type: string
    lifetime: ping
    description: |
      The event_context's `source`. Likely something like "primary_button".
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_context: &event_context
    type: text
    lifetime: ping
    description: |
      The stringified JSON of `event_context`.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - web_activity
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_screen_family: &event_screen_family
    type: text
    lifetime: ping
    description: |
      A string identifier of the message family derived from the message id
      (e.g. MR_WELCOME_DEFAULT).
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1867627
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - web_activity
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
      - nsauermann@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_screen_id: &event_screen_id
    type: text
    lifetime: ping
    description: |
      A string identifier of the message screen id
      (e.g. AW_MOBILE_DOWNLOAD).
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1867627
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - web_activity
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
      - nsauermann@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_screen_initials: &event_screen_initials
    type: text
    lifetime: ping
    description: |
      A string identifier of the message screen initials
      (e.g. 'EMAG' for EASY_SETUP, MOBILE_DOWNLOADS, AMO, GRATITUDE).
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1867627
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - web_activity
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
      - nsauermann@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event_screen_index: &event_screen_index
    type: quantity
    unit: integer
    lifetime: ping
    description: |
      A number identifier of the screen index in a sequence of screens
      (e.g. 0 for first message).
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - web_activity
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
      - nsauermann@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  message_id: &message_id
    type: text
    lifetime: ping
    description: |
      A string identifier of the message in Activity Stream Router.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - web_activity
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  event: &event
    type: string
    description: >
      The type of event. Any user defined string
      (e.g. “IMPRESSION”, “CLICK_BUTTON”, "INDEXEDDB_OPEN_FAILED", “SESSION_END”)
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  ping_type: &ping_type
    type: string
    description: >
      Type of event the ping is capturing.
      e.g. "cfr", "onboarding"
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  source: &source
    type: string
    description: >
      The source of the interaction described by the other metrics.
      e.g. "frecent_links", "newtab", "CFR"
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  locale: &locale
    type: string
    lifetime: ping
    description: >
      The locale as supplied to the messaging system by
      `Services.locale.appLocaleAsBCP47`.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  client_id:
    type: uuid
    lifetime: ping
    description: |
      The client_id according to Telemetry.
      Might not always have a value due to policy around specific types of
      ping being sent. Value may be the canary client id
      `c0ffeec0-ffee-c0ff-eec0-ffeec0ffeec0`
      in pings near when the data upload pref is disabled (if Telemetry gets
      to go first), or between when a client_id has been removed and when it
      has been regenerated.
      Present only in some circumstances (see
      [bug 1484035]https://bugzilla.mozilla.org/show_bug.cgi?id=1484035)).
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1755549
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1484035
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1755549
    data_sensitivity:
      - technical
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  browser_session_id:
    type: uuid
    lifetime: ping
    # Disable yamllint for long lines.
    # yamllint disable
    description: >
      The Legacy Telemetry browser "session id".
      Identifies a specific period from application start to shutdown.
      See [the "main" ping docs](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/data/main-ping.html)
      for details.
    # yamllint enable
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  impression_id: &impression_id
    type: uuid
    lifetime: ping
    description: >
      The unique impression identifier for a specific client.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  bucket_id: &bucket_id
    type: string
    lifetime: ping
    description: >
      A name shared between multiple messages that may individually be too
      targeted. e.g. a message that gets shown on specific websites or a message
      asking about personal information.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  addon_version: &addon_version
    type: string
    lifetime: ping
    description: >
      Used to hold the system addon's version,
      now is almost certainly an echo of the app's build id.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  unknown_key_count: &unknown_key_count
    type: counter
    description: |
      The sum of all unknown keys counted.
      Useful for testing.
      Can be removed after bug 1600008 is resolved.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - chutten@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  unknown_keys: &unknown_keys
    type: labeled_counter
    description: |
      Ping keys supplied to the messaging system for which
      we did not have a corresponding metric mapped to how often they attempted
      to be recorded.
      You may have forgotten to define an appropriate metric in
      `browser/components/newtab/metrics.yaml`.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  glean_ping_for_ping_failures: &glean_ping_for_ping_failures
    type: counter
    description: |
      How often something went awry within
      `AboutWelcome.submitGleanPingForPing`, preventing ping submission.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
      - chutten@mozilla.com
    expires: never
    send_in_pings:
      - metrics

  invalid_nested_data: &invalid_nested_data
    type: labeled_counter
    description: |
      We received a ping with non-scalar data on a field of this name.
      If this is existing pre-PingCentre-replacement data, you may need to
      augment the logic in
      `AboutWelcome.submitGleanPingForPing` like the other `handledKeys`.
      If this is for new, post-PingCentre-replacement data, you should
      probably prefer a flat structure.
      If you're unsure, please ask in
      [the #glean channel](https://chat.mozilla.org/#/room/#glean:mozilla.org).
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
      - chutten@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  message_request_time:
    type: timing_distribution
    description: >
      Firefox: Time in ms spent selecting and matching messages to user profile.

      This metric was generated to correspond to the Legacy Telemetry
      exponential histogram MS_MESSAGE_REQUEST_TIME_MS.
    time_unit: millisecond
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1600335
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1600335
    notification_emails:
      - omc-core@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    telemetry_mirror: MS_MESSAGE_REQUEST_TIME_MS

messaging_system.attribution:
  source: &attribution_source
    type: string
    lifetime: ping
    description: |
      Attribution's source, possibly derived from the utm parameter of the same
      name.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  medium: &attribution_medium
    type: string
    lifetime: ping
    description: |
      Attribution's medium, possibly derived from the utm parameter of the same
      name.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  campaign: &attribution_campaign
    type: string
    lifetime: ping
    description: |
      Attribution's campaign, possibly derived from the utm parameter of the
      same name.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  content: &attribution_content
    type: string
    lifetime: ping
    description: |
      Attribution's content, possibly derived from the utm parameter of the
      same name.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  experiment: &attribution_experiment
    type: string
    lifetime: ping
    description: |
      Attribution's experiment key.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  variation: &attribution_variation
    type: string
    lifetime: ping
    description: |
      Attribution's variation key.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  ua: &attribution_ua
    type: string
    lifetime: ping
    description: |
      Attribution's ua key.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  dltoken: &attribution_dltoken
    type: string
    lifetime: ping
    description: |
      String representation of the dltoken identifying the particular
      installer used to install this Firefox.
      Likely a UUID, if present.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  msstoresignedin: &attribution_msstoresignedin
    type: string
    lifetime: ping
    description: |
      Either the string "true" or the string "false" to indicate whether the
      attributed install came from the Microsoft store and, if so, whether the
      user was signed in at the time.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1756209
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1756209
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  msclkid: &attribution_msclkid
    type: string
    lifetime: ping
    description: |
      A string containing the attribution for a Microsoft Store Ads Campaign ID.
      This differs from a Campaign ID originating from a Microsoft Store URL
      containing attribution_
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2004494
    data_reviews:
      - https://phabricator.services.mozilla.com/D275328
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  dlsource: &attribution_dlsource
    type: string
    lifetime: ping
    description: |
      Mozilla-specific download "source" name. Could be something like
      "mozillaci" to identify that the installer came from
      `{archive|ftp}.mozilla.org`.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1819997
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1819997
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - interaction
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

  unknown_keys: &attribution_unknown_keys
    type: labeled_counter
    description: |
      Attribution keys supplied to the messaging system for which
      we did not have a corresponding metric, and the count of how
      often that happened.
      Either add this key to a list of known attribution keys in
      `AboutWelcomeTelemetry` to suppress or define an appropriate metric in
      `browser/components/newtab/metrics.yaml` to collect.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1825863
    data_sensitivity:
      - technical
    notification_emails:
      - dmosedale@mozilla.com
      - pmcmanis@mozilla.com
    expires: never
    send_in_pings:
      - messaging-system

# Most keys in microsurvey are alias nodes corresponding to those in
# messaging_system, to keep the two pings in sync. The main exceptions are
# event_input_value, which is unique to microsurvey, and client_id and
# browser_session_id, which are omitted from microsurvey for privacy reasons.
# Some other keys are excluded from microsurvey as they are not relevant there,
# e.g. message_request_time. These are used for high-level monitoring of the
# messaging system as a whole, rather than for analyzing individual messages.
microsurvey:
  event_input_value:
    type: text
    lifetime: ping
    description: |
      Text input by the user in a write-in textarea produced by the textarea
      tile type. Truncated to 8KB (though the textarea tile normally has a
      separate character limit enforced at display time).
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010984
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010984
    data_sensitivity:
      - web_activity
      - highly_sensitive
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey

  event_context_parse_error:
    <<: *event_context_parse_error
    send_in_pings:
      - microsurvey

  event_reason:
    <<: *event_reason
    send_in_pings:
      - microsurvey

  event_page:
    <<: *event_page
    send_in_pings:
      - microsurvey

  event_source:
    <<: *event_source
    send_in_pings:
      - microsurvey

  event_context:
    <<: *event_context
    send_in_pings:
      - microsurvey

  event_screen_family:
    <<: *event_screen_family
    send_in_pings:
      - microsurvey

  event_screen_id:
    <<: *event_screen_id
    send_in_pings:
      - microsurvey

  event_screen_initials:
    <<: *event_screen_initials
    send_in_pings:
      - microsurvey

  event_screen_index:
    <<: *event_screen_index
    send_in_pings:
      - microsurvey

  message_id:
    <<: *message_id
    send_in_pings:
      - microsurvey

  event:
    <<: *event
    send_in_pings:
      - microsurvey

  ping_type:
    <<: *ping_type
    send_in_pings:
      - microsurvey

  source:
    <<: *source
    send_in_pings:
      - microsurvey

  locale:
    <<: *locale
    send_in_pings:
      - microsurvey

  impression_id:
    <<: *impression_id
    send_in_pings:
      - microsurvey

  bucket_id:
    <<: *bucket_id
    send_in_pings:
      - microsurvey

  addon_version:
    <<: *addon_version
    send_in_pings:
      - microsurvey

  unknown_key_count:
    <<: *unknown_key_count
    send_in_pings:
      - microsurvey

  unknown_keys:
    <<: *unknown_keys
    send_in_pings:
      - microsurvey

  glean_ping_for_ping_failures:
    <<: *glean_ping_for_ping_failures
    send_in_pings:
      - microsurvey

  invalid_nested_data:
    <<: *invalid_nested_data
    send_in_pings:
      - microsurvey

  # These metrics are copies of certain metadata fields that get removed because
  # the microsurvey ping has `include_info_sections: false` (see pings.yaml).
  os:
    type: string
    lifetime: ping
    description: |
      The name of the operating system.
      Possible values:
      Android, iOS, Linux, Darwin, Windows,
      FreeBSD, NetBSD, OpenBSD, Solaris, Unknown
    bugs:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/1497894
      - https://bugzilla.mozilla.org/1944090
    data_reviews:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1512938#c3
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey

  os_version:
    type: string
    lifetime: ping
    description: |
      The user-visible version of the operating system (e.g. "1.2.3").
      If the version detection fails, this metric gets set to `Unknown`.
    bugs:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/1497894
      - https://bugzilla.mozilla.org/1944090
    data_reviews:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1512938#c3
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey

  windows_build_number:
    type: quantity
    unit: build_number
    lifetime: ping
    description: |
      The optional Windows build number, reported by Windows
      (e.g. 22000) and not set for other platforms.
    bugs:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/1802094
      - https://bugzilla.mozilla.org/1944090
    data_reviews:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/1802094
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey

  app_display_version:
    type: string
    lifetime: ping
    description: |
      The user visible version string (e.g. "1.0.3").
      If the value was not provided through configuration,
      this metric gets set to `Unknown`.
    bugs:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/1508305
      - https://bugzilla.mozilla.org/1944090
    data_reviews:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1508305#c9
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey

  app_channel:
    type: string
    lifetime: ping
    description: |
      The channel the application is being distributed on.
    bugs:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/1520741
      - https://bugzilla.mozilla.org/1944090
    data_reviews:
      - https://bugzilla.mozilla.org/2010984
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1520741#c18
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey

  app_build_id:
    type: string
    lifetime: ping
    description: |
      The build ID of the application. Included because the microsurvey ping
      uses OHTTP and excludes standard client_info metadata.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2036194
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2036194
    data_sensitivity:
      - technical
    notification_emails:
      - pmcmanis@mozilla.com
      - dmosedale@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey

microsurvey.smart_window:
  user_feedback_data:
    type: object
    description: |
      Session metadata submitted via the Smart Window feedback modal.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2036194
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2034541
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2036194
    data_sensitivity:
      - technical
    notification_emails:
      - firefox-ai-and-ml@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey
    structure:
      type: object
      properties:
        metadata:
          type: object
          description: Session metadata at the time of feedback submission.
          properties:
            model:
              type: string
              description: >
                The model used during the chat session. For example:
                "gemini-2.5-flash-lite". "custom-model" if a custom model
                override is set.
            turn_count:
              type: number
              description: >
                Number of user messages in the chat session at the time of
                feedback.
            prompt_version:
              type: number
              description: The prompt version used during the chat session.

  chat:
    type: object
    description: |
      The conversation log at the time of feedback submission.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2034541
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2034541
    data_sensitivity:
      - highly_sensitive
    notification_emails:
      - firefox-ai-and-ml@mozilla.com
    expires: never
    send_in_pings:
      - microsurvey
    structure:
      type: object
      properties:
        log:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                description: Unique message identifier (UUID).
              createdDate:
                type: number
                description: Unix timestamp when the message was created.
              parentMessageId:
                type: string
                description: ID of the preceding message in the conversation.
              revisionRootMessageId:
                type: string
                description: >
                  ID of the root message of this revision branch. Stays
                  constant across edits/regenerations of the same turn.
              ordinal:
                type: number
                description: Sequence position of the message in the conversation.
              isActiveBranch:
                type: boolean
                description: >
                  Whether this message is on the active branch. False for
                  messages superseded by an edit or regeneration.
              role:
                type: number
                description: >
                  The speaker role. 0 = user, 1 = assistant, 2 = system,
                  3 = tool.
              modelId:
                type: string
                description: The model that produced this message.
              content:
                type: object
                description: >
                  The message content. Varies by role: TextContent for
                  user/assistant/system messages, FunctionContent for tool
                  call messages, ToolResultContent for tool result messages.
                properties:
                  content_type:
                    type: string
                    description: >
                      Content type discriminator ("text" or "function").
                      Absent on tool result messages (role 3).
                  tool_call_id:
                    type: string
                    description: >
                      Tool call ID this result corresponds to. Present only
                      on tool result messages (role 3).
                  body:
                    type: object
                    description: >
                      Normalized message body. Text messages have
                      { text }, function messages have { tool_calls },
                      tool result messages have { result }.
                    properties:
                      text:
                        type: string
                        description: Body text for text content messages.
                      tool_calls:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              description: Tool call identifier.
                            call_type:
                              type: string
                              description: Tool call type.
                            function:
                              type: object
                              properties:
                                name:
                                  type: string
                                  description: Name of the function called.
                                arguments:
                                  type: string
                                  description: >
                                    JSON-encoded arguments passed to the
                                    function.
                        description: Tool calls issued by the model.
                      result:
                        type: array
                        items:
                          type: string
                        description: Tool result content, e.g. fetched page text.
                  name:
                    type: string
                    description: >
                      Function name for tool result messages (role 3).
                  userContext:
                    type: object
                    description: Real-time browser context injected for user messages.
                    properties:
                      realTimeContext:
                        type: string
                        description: >
                          Serialized browser context: locale, timezone,
                          active tab, and selected tab details.
                  contextMentions:
                    type: array
                    items:
                      type: object
                      properties:
                        mention_type:
                          type: string
                          description: >
                            Mention type, e.g. "currentTab" or "tab".
                        url:
                          type: string
                          description: URL of the mentioned tab.
                        label:
                          type: string
                          description: Display label for the mentioned tab.
                        iconSrc:
                          type: string
                          description: Favicon URL for the mentioned tab.
                    description: Tabs mentioned as context in user messages.
                  contextPageUrl:
                    type: string
                    description: URL of the page in context for user messages.
              convId:
                type: string
                description: ID of the conversation this message belongs to.
              pageUrl:
                type: string
                description: URL of the active tab when the user sent this message.
              turnIndex:
                type: number
                description: Zero-based turn index in the conversation.
              memoriesEnabled:
                type: boolean
                description: Whether memories were enabled for this message.
              memoriesFlagSource:
                type: number
                description: How the memoriesEnabled flag was determined.
              memoriesApplied:
                type: array
                items:
                  type: string
                description: Memory strings applied to this response.
              webSearchQueries:
                type: array
                items:
                  type: string
                description: Web search queries issued for this response.
              followUpSuggestions:
                type: array
                items:
                  type: string
                description: Follow-up question suggestions generated with this response.
              pageHistoryDeleted:
                type: boolean
                description: Whether the page URL was removed by a history deletion.
              tokens:
                type: object
                description: Response stream tokens grouped by label.
                properties:
                  search:
                    type: array
                    items:
                      type: string
                    description: Web search token values.
                  existing_memory:
                    type: array
                    items:
                      type: string
                    description: Memory token values applied to this response.
                  followup:
                    type: array
                    items:
                      type: string
                    description: Follow-up suggestion token values.
              toolUIData:
                type: object
                description: >
                  Data for rendering an interactive UI component alongside
                  this message, e.g. a tab-close confirmation dialog or a
                  retry prompt shown after a cancelled action.
                properties:
                  uiType:
                    type: string
                    description: >
                      The UI component to render, e.g.
                      "website-confirmation", "ai-action-result",
                      "cancelled-component", or "retry-component".
                  toolCallId:
                    type: string
                    description: The tool call ID this UI component is associated with.
                  properties:
                    type: object
                    description: >
                      Component-specific data. "website-confirmation"
                      includes tabs (proposed for closing) and
                      originalUserPrompt. "retry-component" includes
                      originalUserPrompt only.
                    properties:
                      originalUserPrompt:
                        type: string
                        description: >
                          The user prompt that triggered the tool action.
                          Used to re-submit after cancellation.
                      tabs:
                        type: array
                        items:
                          type: object
                          properties:
                            linkedPanel:
                              type: string
                              description: ID of the tab's linked panel.
                            url:
                              type: string
                              description: URL of the tab.
                            title:
                              type: string
                              description: Display title of the tab.
                            iconSrc:
                              type: string
                              description: Favicon URL of the tab.
                            checked:
                              type: boolean
                              description: >
                                Whether the tab is selected in the
                                confirmation UI.
                        description: Tabs proposed for a website confirmation action.

microsurvey.attribution:
  source:
    <<: *attribution_source
    send_in_pings:
      - microsurvey

  medium:
    <<: *attribution_medium
    send_in_pings:
      - microsurvey

  campaign:
    <<: *attribution_campaign
    send_in_pings:
      - microsurvey

  content:
    <<: *attribution_content
    send_in_pings:
      - microsurvey

  experiment:
    <<: *attribution_experiment
    send_in_pings:
      - microsurvey

  variation:
    <<: *attribution_variation
    send_in_pings:
      - microsurvey

  ua:
    <<: *attribution_ua
    send_in_pings:
      - microsurvey

  dltoken:
    <<: *attribution_dltoken
    send_in_pings:
      - microsurvey

  msstoresignedin:
    <<: *attribution_msstoresignedin
    send_in_pings:
      - microsurvey

  msclkid:
    <<: *attribution_msclkid
    send_in_pings:
      - microsurvey

  dlsource:
    <<: *attribution_dlsource
    send_in_pings:
      - microsurvey

  unknown_keys:
    <<: *attribution_unknown_keys
    send_in_pings:
      - microsurvey
