// 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.
//
// Sync protocol datatype extension for user events.

// If you change or add any fields in this file, update proto_visitors.h and
// potentially proto_enum_conversions.{h, cc}.

syntax = "proto2";

option java_multiple_files = true;
option java_package = "org.chromium.components.sync.protocol";

option optimize_for = LITE_RUNTIME;

package sync_pb;

import "components/sync/protocol/gaia_password_reuse.proto";

message UserEventSpecifics {
  // Time of event, as measured by client in microseconds since Windows epoch.
  optional int64 event_time_usec = 1;

  // The `global_id` field of the associated navigation, if there is one.
  optional int64 navigation_id = 2;

  // On startup we generate a new random id to identify which FieldTrialEvents
  // other events belonged to.
  optional fixed64 session_id = 3;

  // 4-7 reserved for future scalars.

  // Used for testing and debugging EventLog system.
  message Test {}

  // Logged when the user logs into Google, and at least once per 28d.
  message GaiaPasswordCaptured {
    enum EventTrigger {
      UNSPECIFIED = 0;
      // Event added because user logged in.
      USER_LOGGED_IN = 1;
      // Event added because 28d timer fired.
      EXPIRED_28D_TIMER = 2;
    }
    optional EventTrigger event_trigger = 1;
  }

  message FlocIdComputed {
    enum EventTrigger {
      UNSPECIFIED = 0;
      // Event added because the floc id is computed for the 1st floc session.
      NEW = 1;
      // Event added because the floc id is re-computed due to a long period of
      // time has passed since the last computation.
      REFRESHED = 2;
      // Event added because the floc id is re-computed due to history deletion.
      HISTORY_DELETE = 3;
    }
    reserved 1;
    reserved "event_trigger";

    // If not set, it means that the floc is disabled.
    optional uint64 floc_id = 2;
  }

  oneof event {
    Test test_event = 8;
    // Happens when a user types their Google account password on another site.
    GaiaPasswordReuse gaia_password_reuse_event = 104;
    GaiaPasswordCaptured gaia_password_captured_event = 15;
    FlocIdComputed floc_id_computed_event = 16;
  }

  reserved "field_trial_event";
  reserved 9;

  reserved "user_consent";
  reserved 12;

  reserved "language_detection_event";
  reserved 10;

  reserved "translation_event";
  reserved 11;
}
