# 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:
  - 'Toolkit :: Startup and Profile System'

startup:
  profile_selection_reason:
    type: string
    description: >
      How the profile was selected during startup. One of the following reasons:
        unknown:
          Generally should not happen, set as a default in case no other reason
          occured.
        profile-manager:
          The profile was selected by the profile manager.
        profile-selector:
          The profile was selected by the profile selector window.
        profile-reset:
          The profile was selected for reset, normally this would mean a restart.
        restart:
          The user restarted the application, the same profile as previous will
          be used.
        argument-profile:
          The profile was selected by the --profile command line argument.
        argument-p:
          The profile was selected by the -p command line argument.
        firstrun-claimed-default:
          A first run of a dedicated profiles build chose the old default
          profile to be the default for this install.
        firstrun-skipped-default:
          A first run of a dedicated profiles build skipped over the old default
          profile and created a new profile.
        restart-claimed-default:
          A first run of a dedicated profiles build after a restart chose the
          old default profile to be the default for this install.
        restart-skipped-default:
          A first run of a dedicated profiles build after a restart skipped over
          the old default profile and created a new profile.
        firstrun-created-default:
          A first run of the application created a new profile to use.
        default:
          The default profile was selected as normal.
      This metric was generated to correspond to the Legacy Telemetry
      scalar startup.profile_selection_reason.
    bugs:
      - https://bugzil.la/1522934
      - https://bugzil.la/1570652
      - https://bugzil.la/1623406
      - https://bugzil.la/1749887
      - https://bugzil.la/1893667
    data_reviews:
      - https://bugzil.la/1522934
      - https://bugzil.la/1570652
      - https://bugzil.la/1623406
      - https://bugzil.la/1749887
      - https://bugzil.la/1893667
    notification_emails:
      - dtownsend@mozilla.com
      - rtestard@mozilla.com
      - gkaberere@mozilla.com
      - jhollek@mozilla.com
      - echo@mozilla.com
      - shong@mozilla.com
      - jhirsch@mozilla.com
    expires: never
    telemetry_mirror: STARTUP_PROFILE_SELECTION_REASON
    send_in_pings:
      - metrics
      - baseline
      - new-profile
    no_lint:
      - BASELINE_PING

  profile_database_version:
    type: string
    description: >
      The version of the profiles.ini database loaded during startup. A
      value of "0" is used to indicate that no file was present during
      startup.
      This metric was generated to correspond to the Legacy Telemetry
      scalar startup.profile_database_version.
    bugs:
      - https://bugzil.la/1878339
      - https://bugzil.la/1916867
      - https://bugzil.la/1958163
      - https://bugzil.la/1994608
      - https://bugzil.la/2010455
    data_reviews:
      - https://bugzil.la/1878339
      - https://bugzil.la/1916867
      - https://bugzil.la/1958163
      - https://bugzil.la/1994608
      - https://bugzil.la/2010455
    send_in_pings:
      - metrics
      - new-profile
    notification_emails:
      - dtownsend@mozilla.com
      - jhirsch@mozilla.com
      - kbryant@mozilla.com
    expires: 156
    telemetry_mirror: STARTUP_PROFILE_DATABASE_VERSION

  profiles_ini_status:
    type: string
    description: >
      Records the status of parsing the profiles.ini file during startup:
        ok:
          The ini file parsed correctly
        ini-failed:
          Parsing the ini file completely failed, normally this would indicate
          an out of memory issue.
        ini-error:
          The ini parser recorded some kind of failure during parsing
        missing-name:
          A profile section was missing the name
        missing-path:
          A profile section was missing the path
        invalid-path:
          A profile section's path was invalid
      Note that if multiple profile sections contain errors then only the last
      will be reported.
    bugs:
      - https://bugzil.la/2038187
    data_reviews:
      - https://bugzil.la/2038187
    notification_emails:
      - dtownsend@mozilla.com
      - jhirsch@mozilla.com
    expires: never

  profile_count:
    type: quantity
    description: >
      This records the number of known profiles after startup completes.
      This includes any profiles that were created during startup.
      This metric was generated to correspond to the Legacy Telemetry
      scalar startup.profile_count.
    bugs:
      - https://bugzil.la/1878339
      - https://bugzil.la/1916867
      - https://bugzil.la/1958163
      - https://bugzil.la/1994608
      - https://bugzil.la/2010455
    data_reviews:
      - https://bugzil.la/1878339
      - https://bugzil.la/1916867
      - https://bugzil.la/1958163
      - https://bugzil.la/1994608
      - https://bugzil.la/2010455
    send_in_pings:
      - metrics
      - new-profile
    notification_emails:
      - dtownsend@mozilla.com
      - jhirsch@mozilla.com
      - kbryant@mozilla.com
    expires: 156
    unit: profiles
    telemetry_mirror: STARTUP_PROFILE_COUNT

profiles:
  creation_date:
    type: quantity
    unit: days since Jan 1 1970
    lifetime: application
    description: |
      The day the profile was created,
      as determined by checking various file metadata in the profile directory.
      Not considered to be particularly reliable in practice.
      Prefer `client_info.first_run_date` in most cases.
      e.g. 16446
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_sensitivity:
      - technical
    notification_emails:
      - dtownsend@mozilla.com
    expires: never
    send_in_pings:
      - metrics
      - heartbeat
      - update

  creation_place:
    type: labeled_counter
    description: |
      Tracking where profiles have been created.  The `legacy_forced` refers to
      usage of `MOZ_LEGACY_HOME=1` while `legacy_existing` is for the case an
      existing legacy profile was detected. The `xdg_default` accounts for lack
      of `XDG_CONFIG_HOME` value defaulting to `$HOME/.config` when
      `xdg_config` refers to existing `XDG_CONFIG_HOME`.
    bugs:
      - https://bugzilla.mozilla.org/259356
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=259356
    data_sensitivity:
      - technical
    notification_emails:
      - me@mozilla.com
    expires: never
    labels:
      - legacy_forced
      - legacy_existing
      - xdg_default
      - xdg_config
    send_in_pings:
      - metrics
      - new-profile

  reset_date:
    type: quantity
    unit: days since Jan 1 1970
    lifetime: application
    description: |
      Optional.
      The day the profile was most recently reset,
      persisted in `times.json`.
      e.g. 16446
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_sensitivity:
      - technical
    notification_emails:
      - dtownsend@mozilla.com
    expires: never
    send_in_pings:
      - metrics
      - update

  first_use_date:
    type: quantity
    unit: days since Jan 1 1970
    lifetime: application
    description: |
      Optional.
      The day the profile was first used,
      as determined by noticing that `times.json` wasn't present.
      Prefer `client_info.first_run_date` in most cases.
      e.g. 16446
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_sensitivity:
      - technical
    notification_emails:
      - dtownsend@mozilla.com
    expires: never
    send_in_pings:
      - metrics
      - heartbeat
      - update

  recovered_from_backup:
    type: quantity
    unit: days since Jan 1 1970
    lifetime: application
    description: |
      Optional.
      The day the profile was recovered from backup,
      persisted in `times.json`.
      e.g. 16446
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=1950400
    data_sensitivity:
      - technical
    notification_emails:
      - mconley@mozilla.com
      - dtownsend@mozilla.com
    expires: never
    send_in_pings:
      - metrics
      - update

  source:
    type: string
    description: |
      The original creation source of the profile:
        firstrun-created-default
          Matches the meaning in startup.profile_selection_reason
        firstrun-skipped-default
          Matches the meaning in startup.profile_selection_reason
        restart-skipped-default
          Matches the meaning in startup.profile_selection_reason
        cmdline
          Created by the --createprofile command line argument
        downgrade
          Created from the profile downgrade UI
        legacy
          Created to support versions of Firefox prior to 47
        aboutprofiles
          Created from about:profiles
        profile-manager
          Created from the legacy startup profile manager
        selector-startup
          Created from the selectable profiles profile selector during startup
        selector-runtime
          Created from the selectable profiles profile selector at runtime
        profiles-panel
          Created from the profiles panel in the application menu
        main-menu
          Created from the OS main menu
        replace-last
          Created when deleting the last profile in the group of selectable profiles
        reset
          Created by profile reset
        backup
          Created by restoring a profile from a backup
        copy
          Created by copying a profile from the selectable profiles UI
        sync-warning
          Created when warning the user about signing into a different account
        asrouter
          Created from the messaging system.
        backgroundtasks
          A profile created for a background task
        unknown
          The profile was created without supplying a source
    bugs:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2026972
    data_reviews:
      - https://bugzilla.mozilla.org/show_bug.cgi?id=2026972
    data_sensitivity:
      - technical
    notification_emails:
      - dtownsend@mozilla.com
    expires: never
    send_in_pings:
      - metrics
      - first-startup
      - new-profile
