// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.ads.datamanager.v1;

import "google/ads/datamanager/v1/cart_data.proto";
import "google/ads/datamanager/v1/consent.proto";
import "google/ads/datamanager/v1/device_info.proto";
import "google/ads/datamanager/v1/experimental_field.proto";
import "google/ads/datamanager/v1/user_data.proto";
import "google/ads/datamanager/v1/user_properties.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Ads.DataManager.V1";
option go_package = "google.golang.org/genproto/googleapis/ads/datamanager/v1;datamanager";
option java_multiple_files = true;
option java_outer_classname = "EventProto";
option java_package = "com.google.ads.datamanager.v1";
option php_namespace = "Google\\Ads\\DataManager\\V1";
option ruby_package = "Google::Ads::DataManager::V1";

// An event representing a user interaction with an advertiser's website or app.
message Event {
  // Optional. Reference string used to determine the destination. If empty, the
  // event will be sent to all
  // [destinations][google.ads.datamanager.v1.IngestEventsRequest.destinations]
  // in the request.
  repeated string destination_references = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Required. The unique identifier for this event.
  string transaction_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The time the event occurred.
  google.protobuf.Timestamp event_timestamp = 3
      [(google.api.field_behavior) = REQUIRED];

  // Optional. The last time the event was updated.
  google.protobuf.Timestamp last_updated_timestamp = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Pieces of user provided data, representing the user the event is
  // associated with.
  UserData user_data = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Information about whether the associated user has provided
  // different types of consent.
  Consent consent = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Identifiers and other information used to match the conversion
  // event with other online activity (such as ad clicks).
  AdIdentifiers ad_identifiers = 7 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The currency code associated with all monetary values within this
  // event.
  string currency = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The conversion value associated with the event, for value-based
  // conversions.
  double conversion_value = 9 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Signal for where the event happened (web, app, in-store, etc.).
  EventSource event_source = 10 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Information gathered about the device being used (if any) when
  // the event happened.
  DeviceInfo event_device_info = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Information about the transaction and items associated with the
  // event.
  CartData cart_data = 12 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Additional key/value pair information to send to the conversion
  // containers (conversion action or FL activity).
  repeated CustomVariable custom_variables = 13
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. A list of key/value pairs for experimental fields that may
  // eventually be promoted to be part of the API.
  repeated ExperimentalField experimental_fields = 14
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Advertiser-assessed information about the user at the time that
  // the event happened.
  UserProperties user_properties = 15 [(google.api.field_behavior) = OPTIONAL];
}

// Identifiers and other information used to match the conversion event with
// other online activity (such as ad clicks).
message AdIdentifiers {
  // Optional. Session attributes for event attribution and modeling.
  string session_attributes = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The Google click ID (gclid) associated with this event.
  string gclid = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The click identifier for clicks associated with app events and
  // originating from iOS devices starting with iOS14.
  string gbraid = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The click identifier for clicks associated with web events and
  // originating from iOS devices starting with iOS14.
  string wbraid = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Information gathered about the device being used (if any) at the
  // time of landing onto the advertiser’s site after interacting with the ad.
  DeviceInfo landing_page_device_info = 5
      [(google.api.field_behavior) = OPTIONAL];
}

// Custom variable for ads conversions.
message CustomVariable {
  // Optional. The name of the custom variable to set. If the variable is not
  // found for the given destination, it will be ignored.
  string variable = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The value to store for the custom variable.
  string value = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Reference string used to determine which of the
  // [Event.destination_references][google.ads.datamanager.v1.Event.destination_references]
  // the custom variable should be sent to. If empty, the
  // [Event.destination_references][google.ads.datamanager.v1.Event.destination_references]
  // will be used.
  repeated string destination_references = 3
      [(google.api.field_behavior) = OPTIONAL];
}

// The source of the event.
enum EventSource {
  // Unspecified EventSource. Should never be used.
  EVENT_SOURCE_UNSPECIFIED = 0;

  // The event was generated from a web browser.
  WEB = 1;

  // The event was generated from an app.
  APP = 2;

  // The event was generated from an in-store transaction.
  IN_STORE = 3;

  // The event was generated from a phone call.
  PHONE = 4;

  // The event was generated from other sources.
  OTHER = 5;
}
