# 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 :: Privacy: Anti-Tracking'

bounce.tracking.protection:
  purge_duration:
    type: timing_distribution
    description: >
      For every purge that is scheduled, we call the ClearDataService to
      purge persistent storage for each detected bounce tracker. This may
      do some blocking work on main thread and dispatch some cleanups to
      other threads.
      Collect telemetry on how long it takes to clear in the wild to
      determine whether we need to improve performance here.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1890582
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1922601
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1890582#c4
    data_sensitivity:
      - technical
    notification_emails:
      - emz@mozilla.com
      - bvandersloot@mozilla.com
      - manuel@mozilla.com
    expires: 140
  num_hosts_per_purge_run:
    type: custom_distribution
    unit: integer
    range_min: 1
    range_max: 99
    bucket_count: 100
    histogram_type: linear
    description: >
      Number of bounce trackers purged successfully per scheduled purge.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1899809
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1922601
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1899809
    data_sensitivity:
      - technical
    notification_emails:
      - emz@mozilla.com
      - bvandersloot@mozilla.com
      - manuel@mozilla.com
    expires: 140
  purge_count:
    type: labeled_counter
    description: >
      Counts how often we purge trackers. Giving a high level overview about
      the effectivness of bounce tracking protection. Allows determining error
      rate with failure/success label. When in dry mode, we count the purges
      that would have happened under the dry label.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1890578
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1922601
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1890578
    data_sensitivity:
      - technical
    notification_emails:
      - emz@mozilla.com
      - bvandersloot@mozilla.com
      - manuel@mozilla.com
    expires: 140
    labels:
      - success
      - failure
      - dry
  purge_action:
    type: event
    description: >
      Dispatched whenever a bounce tracker site is purged.
    bugs:
      - https://bugzilla.mozilla.org/1889444
      - https://bugzilla.mozilla.org/1922602
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1889444#c16
    data_sensitivity:
      - stored_content
    notification_emails:
      - emz@mozilla.com
      - bvandersloot@mozilla.com
      - manuel@mozilla.com
    send_in_pings:
      - bounce-tracking-protection
    expires: 140
    extra_keys:
      site_host:
        description: The site host of which the data has been purged.
        type: string
      bounce_time:
        description: Timestamp (seconds since epoch) of the last detected bounce.
        type: quantity
      is_dry_run:
        description: Whether we just pretended to purge since the client is in dry-run mode.
        type: boolean
      success:
        description: Whether the purge data call was successful. false indicates an error in ClearDataService.
        type: boolean
  mode:
    type: quantity
    lifetime: application
    unit: intPref
    description: >
      Records the pref value of privacy.bounceTrackingProtection.mode. Values
      are any of nsIBounceTrackingProtection#Modes.
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1928062
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1928062
    data_sensitivity:
      - technical
    notification_emails:
      - emz@mozilla.com
      - bvandersloot@mozilla.com
      - manuel@mozilla.com
    expires: 140
  purge_count_classified_tracker:
    type: counter
    description: >
      Counts sites purged from BTP that are classified as trackers as part of the following lists:
      [emailtracking-protection, fingerprinting-protection, socialtracking-protection, tracking-protection]
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1890580
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1922601
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1890580
    data_sensitivity:
      - technical
    notification_emails:
      - emz@mozilla.com
      - bvandersloot@mozilla.com
      - manuel@mozilla.com
    expires: 140
