chromium/third_party/metrics_proto/ukm/source.proto

// 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.

syntax = "proto2";

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

package ukm;

// Types of source ids defined by
// https://cs.chromium.org/chromium/src/services/metrics/public/cpp/ukm_source_id.h
// WARNING: Please update both the internal version and the Chromium version of
// this file when new enum values are added.
enum SourceType {
  DEFAULT = 0;
  NAVIGATION_ID = 1;
  APP_ID = 2;
  HISTORY_ID = 3;
  WEBAPK_ID = 4;
  PAYMENT_APP_ID = 5;
  DESKTOP_WEB_APP_ID = 6;
  WORKER_ID = 7;
  NO_URL_ID = 8;
  REDIRECT_ID = 9;
  WEB_IDENTITY_ID = 10;
  CHROMEOS_WEBSITE_ID = 11;
  EXTENSION_ID = 12;
  NOTIFICATION_ID = 13;
}

// Android Activity Type defined by
// https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/flags/android/chrome_session_state.h?q=ActivityType
enum AndroidActivityType {
  TABBED = 0;
  CUSTOM_TAB = 1;
  TRUSTED_WEB_ACTIVITY = 2;
  WEB_APP = 3;
  WEB_APK = 4;
  PRE_FIRST_TAB = 5;
}

// This signifies if the reported source is a navigation to the same origin as
// the previous document.
// Its value is "unset" for error pages and same document navigations.
// It is "same origin" when the previous document is of the same origin as the
// one we're navigating to.
// Otherwise, it is "cross origin".
enum SameOriginStatus {
  SAME_ORIGIN_STATUS_UNSET = 0;
  SAME_ORIGIN = 1;
  CROSS_ORIGIN = 2;
}

enum UrlScheme {
  URL_SCHEME_UNSUPPORTED = 0;
  HTTP = 1;
  HTTPS = 2;
  FTP = 3;
  ABOUT = 4;
  CHROME = 5;
  CHROME_EXTENSION = 6;
  APP = 7;
}

message UrlInfo {
  optional string url = 1;

  // Number of URLs seen for this source before the current URL.
  // If unset, it’s equivalent to the count of the UrlInfo before it + 1,
  // or 0 if it’s the first UrlInfo.
  optional int32 previous_url_count = 2;
}

message NavigationMetadata {
  // Whether this is the same origin as the previous document, cross-origin or
  // unset.
  optional SameOriginStatus same_origin_status = 1;

  // Whether this navigation is initiated by the renderer.
  // Renderer-initiated navigations include navigations that were triggered
  // from Javascript, by users interacting with the content (e.g. clicking
  // on <a> links or submitting forms, or by client-side redirects.
  // On the other hand, we have browser-initiated navigations, e.g. ones
  // triggered by the user interacting with the browser's UI.
  optional bool is_renderer_initiated = 2;

  // Whether the navigation committed an error page, as a result of a network
  // error.
  optional bool is_error_page = 3;
}

// Next tag: 20
message Source {
  // An identifier for the source. This should be unique within a session.
  optional int64 id = 1;

  // The type, which is based on how the Source is created.
  optional SourceType type = 16;

  // Unique identifier (for a given client_id/session_id) for the tab this
  // source is associated with. Should only be set for navigation sources.
  optional int64 tab_id = 10;

  // The source id of the last committed non-same-document navigation for the
  // tab this source is in. Should only be set for navigation sources. For
  // backward compatibility, this field will never be set to the source id of a
  // same-document source. In cases where the last committed navigation was a
  // same-document navigation, previous_same_document_source_id will contain
  // the source id of that previous same document navigation, while
  // previous_source_id will contain the source id of the last committed
  // non-same-document navigation. For example, if a user starts on page A (a
  // non same document page load), then performs a same document navigation to
  // B, then navigates to C (which could be either a same document or a non same
  // document navigation), previous_source_id will reference A, and
  // previous_same_document_source_id will reference B.
  optional int64 previous_source_id = 11;

  // The source id for the previous same document navigation, if the
  // previously committed source was a same document navigation. If
  // the previously committed source was not a same document
  // navigation, this field will be unset.
  optional int64 previous_same_document_source_id = 14;

  // For sources representing the first navigation in a new tab, this id marks
  // the source which opened the tab. Should only be set for the first
  // navigation source in a tab.
  optional int64 opener_source_id = 12;

  // Data about each URL associated with the Source within the record's
  // scope, in the order that the URLs were encountered. Data may include full
  // or partial redirect chains for main frame navigations.
  repeated UrlInfo urls = 8;

  // Data about the URL of the Document, copied from the Source message whose
  // id matched the navigation source id of the DocumentCreated event.
  repeated UrlInfo resolved_urls = 15;

  // Whether this source is for a same document navigation. Examples of same
  // document navigations are fragment navigations, pushState/replaceState,
  // and same page history navigation.
  optional bool is_same_document_navigation = 13;

  // Metadata about the navigation that is set when the URL is recorded.
  optional NavigationMetadata navigation_metadata = 17;

  // The URL of the source, as recorded in history. If this URL has not been
  // discovered by Google's crawler, it should not be recorded.
  // Replaced by |urls| field.
  optional string deprecated_url = 2 [deprecated = true];
  reserved 5;
  reserved "deprecated_url_origin";
  reserved 9;
  reserved "deprecated_url_scheme";

  // The initial URL of the source. Set in cases where the source URL changed
  // (e.g. it was redirected), otherwise unset. If this URL has not been
  // discovered by Google's crawler, it should not be recorded.
  optional string deprecated_initial_url = 6 [deprecated = true];

  // Denotes the Chrome Android activity type when created. See
  // https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/flags/android/chrome_session_state.h;l=20;drc=c14f6f4b9c44fe479a8d004576b42723b2a5feb6
  optional AndroidActivityType android_activity_type = 18;

  // Relative time of navigation for this Source, as seen by the client, and is
  // set for sources of type ukm::SourceIdType::NAVIGATION_ID. Time of events
  // related to this Source will generally be relative to this timestamp. The
  // recorded navigation time is in TimeTicks, which is the relative time since
  // the origin. The origin is platform-specific but is guaranteed to be
  // monotonically increase within each session.
  optional int64 navigation_time_msec = 3;

  reserved 4;
  reserved 7;
}