// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file was exported from google3, do not edit manually.
// See README.chromium for details.

edition = "2023";

option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.metrics";

package ukm;

import "third_party/metrics_proto/ukm/aggregate.proto";
import "third_party/metrics_proto/ukm/entry.proto";
import "third_party/metrics_proto/ukm/source.proto";
import "third_party/metrics_proto/ukm/web_features.proto";
import "third_party/metrics_proto/chrome_user_metrics_extension.proto";
import "third_party/metrics_proto/system_profile.proto";
import "third_party/metrics_proto/user_demographics.proto";

// This is the message type sent from Chrome to the UKM collector.
// Next tag: 15
message Report {
  // A unique identifier for a Chrome install. This ID should be used only
  // in UKM reports, and not linked to any other data sources.
  fixed64 client_id = 1;

  // The product corresponding to this log. Note: The default value is Chrome,
  // so Chrome products will not transmit this field.
  metrics.ChromeUserMetricsExtension.Product product = 12 [default = CHROME];

  // The session id for this record. This id is unique within a
  // particular Chrome session. The client keeps track of the session id
  // and sends it with each record. The session id is simply an integer
  // that is incremented each time the user relaunches Chrome.
  int32 session_id = 5;

  // The report id for this record.  Report ids increase sequentially from
  // one within a session.
  int32 report_id = 6;

  // Indicates that recording was continuously enabled for the period of time
  // captured in this report.
  bool is_continuous = 8;

  enum LogRotationReason {
    option features.enum_type = CLOSED;

    UNKNOWN = 0;
    SCHEDULED_ROTATION = 1;
    BACKGROUNDED = 2;
    SHUTDOWN = 3;
  }

  LogRotationReason log_rotation_reason = 9;

  // Information about the user's browser and system configuration.
  metrics.SystemProfileProto system_profile = 2;

  // The user's demographic information that consists of their noised birth year
  // and gender. This data is made available to Chrome via syncable priority
  // pref, so is only available if the user is signed-in and syncing.
  metrics.UserDemographicsProto user_demographics = 11;

  // A list of the top-level navigations that data was collected for.
  repeated Source sources = 3;

  // Counts of different types of sources in this interval, including sources
  // which may not be in the report due to dropping or deferral.
  message SourceCounts {
    // Number of unique sources that URLs were observed for. This counts
    // includes sources which were dropped or deferred, but not sources
    // carried over from a previous interval.
    int32 observed = 1;

    // Number of navigation sources that URLs were observed for, including
    // sources dropped due to limits.
    int32 navigation_sources = 2;

    // Number of sources discarded due to not matching a navigation URL.
    int32 unmatched_sources = 3;

    // Number of sources deferred from a previous interval.
    int32 carryover_sources = 4;

    // Number of sources deferred to the next interval. Sources corresponding to
    // opened tabs that could emit more events in the future are kept in memory
    // and deferred to the next interval for inclusion in next reports, up to a
    // max limit on number of sources.
    int32 deferred_sources = 5;

    // Number of sources deferred to the next interval due to lack of events.
    int32 entryless_sources = 6;

    // Time elapsed in seconds from the moment the newest truncated source was
    // created to the moment it was discarded from memory, if pruning happened
    // due to number of sources exceeding the max threshold.
    int32 pruned_sources_age_seconds = 7;
  }

  SourceCounts source_counts = 10;

  // List of Entries containing the main UKM data.
  repeated Entry entries = 4;

  // Web features used on pages during this reporting interval.
  repeated HighLevelWebFeatures web_features = 13;

  // List of Entries containing aggregated UKM data.
  repeated Aggregate aggregates = 7;

  // Downsampling rates applied to events in this report.
  // Next tag: 4
  message DownsamplingRate {
    // Hash of the event name to identify the event type. This field should
    // always be set when any other field in this message is set.
    fixed64 event_hash = 1;

    // Rate computed by standard UKM downsampling.
    // A value of N means that this event type is downsampled at a rate of
    // 1-in-N, meaning this event type is only recorded for every 1 in N page
    // loads. Unset means that the user didn't receive a parameter to
    // downsample this event when events are collected in this reporting
    // interval, thus no downsampling is applied.
    uint32 standard_rate = 2;

    // Any other further downsampling logic by custom client-side
    // implementation.
    // A value of M means that this event type is downsampled at a rate of
    // 1-in-M, in addition to the standard downsampling rate by the UKM infra at
    // the page load level.
    uint32 custom_rate = 3;
  }

  // Rates at which each event type is downsampled. This field is populated
  // since Chrome version 150.0.7830.0.
  repeated DownsamplingRate downsampling_rates = 14;
}
