# 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:
  - 'Core :: DOM: Geolocation'

geolocation:
  accuracy:
    type: custom_distribution
    description: >
      Accuracy returned by the Geolocation API
    range_min: 1
    range_max: 66355200
    bucket_count: 50
    histogram_type: exponential
    unit: accuracy radius
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    notification_emails:
      - krosylight@mozilla.com
    expires: never
  request_result:
    type: labeled_counter
    description: >
      The result for each geolocation request. Success label will only happen
      once for each request, even if it's a watch request.
    labels:
      - success
      - permission_denied
      - position_unavailable
      - timeout
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    notification_emails:
      - krosylight@mozilla.com
    expires: never
  fallback:
    type: labeled_counter
    description: >
      Whether the default provider falled back to NetworkGeolocationProvider.
    labels:
      - none
      - on_error
      - on_timeout
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    notification_emails:
      - krosylight@mozilla.com
    expires: never
  linux_provider:
    type: labeled_boolean
    description: >
      Which system provider are we using on Linux
    labels:
      - none
      - portal
      - geoclue
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1905928
    notification_emails:
      - krosylight@mozilla.com
    expires: never
  geolocation_service:
    type: labeled_counter
    description: >
      How many geolocation requests were issued to the system provider, the
      network wifi-lookup provider, the network ip-lookup provider, and the
      Linux GeoClue service?  Wifi and IP currently use the same provider.
    labels:
      - system
      - network_wifi_and_ip
      - network_ip
      - geoclue
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    notification_emails:
      - daparks@mozilla.com
    expires: never
  network_failures:
    type: labeled_counter
    description: >
      How many network geolocation requests received an error response.  The
      number of successful network geolocation requests should resemble the
      the values for these labels in the geolocation_service probe, minus
      these failure counts.  Not all failures can be known.
    labels:
      - network_wifi_and_ip
      - network_ip
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2046658
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2046658
    notification_emails:
      - daparks@mozilla.com
    expires: never
  geolocation_cache_hit:
    type: labeled_counter
    description: >
      How many times was a geolocation request serviced by the given cache.
    labels:
      - nsGeolocationRequest
      - NetworkGeolocationProvider
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    notification_emails:
      - daparks@mozilla.com
    expires: never
  macos_error_code:
    type: labeled_counter
    description: >
      Records the error code when MacOS CoreLocation geolocation fails.
      The CoreLocation error domain is kCLErrorDomain and can usually be used
      to get a human readable error for these values.  Records up to 16 codes.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    notification_emails:
      - daparks@mozilla.com
    expires: never
  geoclue_error_code:
    type: labeled_counter
    description: >
      Records the error code when Linux GeoClue geolocation fails.
      The GeoClue DBUS error domain is G_DBUS_ERROR and can usually be used
      to get a human readable error for these values.  Records up to 16 codes.
      Note that errors G_DBUS_ERROR_LIMITS_EXCEEDED (8),
      G_DBUS_ERROR_ACCESS_DENIED(9), and G_DBUS_ERROR_AUTH_FAILED (10) are
      considered by Firefox to mean that permission is not granted, as opposed
      to an internal error.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    notification_emails:
      - daparks@mozilla.com
    expires: never
  linux_portal_error:
    type: labeled_counter
    description: >
      Records the reason for failures in the PortalLocationProvider.
    labels:
      - empty_response
      - cant_read_response
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    notification_emails:
      - daparks@mozilla.com
    expires: never
  windows_failure:
    type: dual_labeled_counter
    description: >
      Records the reason the WindowsLocationChild reported failure to
      get location.
    dual_labels:
      key:
        description: >
          Is this for the WindowsLegacy or WindowsRuntime (winrt) implementation?
        labels:
          - legacy
          - winrt
      category:
        description: >
          Reason for the failure
        labels:
          - permission denied
          - geoservice error
          - not supported
          - creation error
          - requestpermissions denied
          - requestpermissions canceled
          - not registered
          - failed to register
          - unexpected error
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2010958
    notification_emails:
      - daparks@mozilla.com
    expires: never
