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

syntax = "proto3";

package enterprise_companion.proto;

option optimize_for = LITE_RUNTIME;

// Canonical view of statuses used across the application. Statuses are defined
// by spaces and codes, which are defined by the EnterpriseCompanionStatus type
// in the app. Space zero indicates success.
message Status {
  // Indicates the status space for the code. Status spaces are defined in
  // chromium-src in enterprise_companion_status.h. Any non-zero value indicates
  // an error space.
  int32 space = 1;
  // Indicates the type of status, any non-zero value indicates an error.
  int32 code = 2;
}

message BrowserEnrollmentEvent {}

message PolicyFetchEvent {}

message PolicyFreshnessEvent {
  // The age of each policy residing in the on-disk cache as measured by the
  // system's clock.
  repeated int64 policy_age_ms = 1;
}

message EnterpriseCompanionEvent {
  // The outcome of the operation.
  Status status = 1;
  // The duration of the operation in milliseconds.
  int64 duration_ms = 2;

  oneof event {
    BrowserEnrollmentEvent browser_enrollment_event = 3;
    PolicyFetchEvent policy_fetch_event = 4;
    PolicyFreshnessEvent policy_freshness_event = 5;
  }
}

enum Architecture {
  ARCHITECTURE_UNSPECIFIED = 0;
  X86 = 1;
  X86_64 = 2;
  ARM64 = 3;
}

enum Platform {
  PLATFORM_UNSPECIFIED = 0;
  LINUX = 1;
  MAC = 2;
  WINDOWS = 3;
}

message EnterpriseCompanionMetadata {
  // The version of the enterprise companion.
  string app_version = 1;

  // The Omaha cohort ID of the enterprise companion.
  string omaha_cohort_id = 2;

  // The build architecture of the application.
  Architecture application_arch = 3;

  // The operating system platform (e.g. Mac or Windows).
  Platform os_platform = 4;

  // The operating system version; truncated to major.minor.build on Windows,
  // major.minor on Mac, and not transmitted on other platforms.
  string os_version = 5;

  // The operating system architecture.
  Architecture os_arch = 6;
}

// The message to serialize and include in the log request.
message ChromeEnterpriseCompanionAppExtension {
  repeated EnterpriseCompanionEvent event = 1;
  EnterpriseCompanionMetadata metadata = 2;
}
