1// Copyright 2022 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.discoveryengine.v1beta; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/cloud/discoveryengine/v1beta/common.proto"; 22import "google/protobuf/duration.proto"; 23import "google/protobuf/timestamp.proto"; 24 25option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta"; 26option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb"; 27option java_multiple_files = true; 28option java_outer_classname = "UserEventProto"; 29option java_package = "com.google.cloud.discoveryengine.v1beta"; 30option objc_class_prefix = "DISCOVERYENGINE"; 31option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta"; 32option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta"; 33 34// UserEvent captures all metadata information Discovery Engine API needs to 35// know about how end users interact with customers' website. 36message UserEvent { 37 // Required. User event type. Allowed values are: 38 // 39 // Generic values: 40 // 41 // * `search`: Search for Documents. 42 // * `view-item`: Detailed page view of a Document. 43 // * `view-item-list`: View of a panel or ordered list of Documents. 44 // * `view-home-page`: View of the home page. 45 // * `view-category-page`: View of a category page, e.g. Home > Men > Jeans 46 // 47 // Retail-related values: 48 // 49 // * `add-to-cart`: Add an item(s) to cart, e.g. in Retail online shopping 50 // * `purchase`: Purchase an item(s) 51 // 52 // Media-related values: 53 // 54 // * `media-play`: Start/resume watching a video, playing a song, etc. 55 // * `media-complete`: Finished or stopped midway through a video, song, etc. 56 string event_type = 1 [(google.api.field_behavior) = REQUIRED]; 57 58 // Required. A unique identifier for tracking visitors. 59 // 60 // For example, this could be implemented with an HTTP cookie, which should be 61 // able to uniquely identify a visitor on a single device. This unique 62 // identifier should not change if the visitor log in/out of the website. 63 // 64 // Do not set the field to the same fixed ID for different users. This mixes 65 // the event history of those users together, which results in degraded model 66 // quality. 67 // 68 // The field must be a UTF-8 encoded string with a length limit of 128 69 // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. 70 // 71 // The field should not contain PII or user-data. We recommend to use Google 72 // Analytics [Client 73 // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) 74 // for this field. 75 string user_pseudo_id = 2 [(google.api.field_behavior) = REQUIRED]; 76 77 // Only required for 78 // [UserEventService.ImportUserEvents][google.cloud.discoveryengine.v1beta.UserEventService.ImportUserEvents] 79 // method. Timestamp of when the user event happened. 80 google.protobuf.Timestamp event_time = 3; 81 82 // Information about the end user. 83 UserInfo user_info = 4; 84 85 // Should set to true if the request is made directly from the end user, in 86 // which case the 87 // [UserEvent.user_info.user_agent][google.cloud.discoveryengine.v1beta.UserInfo.user_agent] 88 // can be populated from the HTTP request. 89 // 90 // This flag should be set only if the API request is made directly from the 91 // end user such as a mobile app (and not if a gateway or a server is 92 // processing and pushing the user events). 93 // 94 // This should not be set when using the JavaScript tag in 95 // [UserEventService.CollectUserEvent][google.cloud.discoveryengine.v1beta.UserEventService.CollectUserEvent]. 96 bool direct_user_request = 5; 97 98 // A unique identifier for tracking a visitor session with a length limit of 99 // 128 bytes. A session is an aggregation of an end user behavior in a time 100 // span. 101 // 102 // A general guideline to populate the session_id: 103 // 104 // 1. If user has no activity for 30 min, a new session_id should be assigned. 105 // 2. The session_id should be unique across users, suggest use uuid or add 106 // [UserEvent.user_pseudo_id][google.cloud.discoveryengine.v1beta.UserEvent.user_pseudo_id] 107 // as prefix. 108 string session_id = 6; 109 110 // Page metadata such as categories and other critical information for certain 111 // event types such as `view-category-page`. 112 PageInfo page_info = 7; 113 114 // Token to attribute an API response to user action(s) to trigger the event. 115 // 116 // Highly recommended for user events that are the result of 117 // [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. 118 // This field enables accurate attribution of recommendation model 119 // performance. 120 // 121 // The value must be one of: 122 // 123 // * [RecommendResponse.attribution_token][google.cloud.discoveryengine.v1beta.RecommendResponse.attribution_token] for events that are the result of 124 // [RecommendationService.Recommend][google.cloud.discoveryengine.v1beta.RecommendationService.Recommend]. 125 // * [SearchResponse.attribution_token][google.cloud.discoveryengine.v1beta.SearchResponse.attribution_token] for events that are the result of 126 // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search]. 127 // 128 // This token enables us to accurately attribute page view or conversion 129 // completion back to the event and the particular predict response containing 130 // this clicked/purchased product. If user clicks on product K in the 131 // recommendation results, pass 132 // [RecommendResponse.attribution_token][google.cloud.discoveryengine.v1beta.RecommendResponse.attribution_token] 133 // as a URL parameter to product K's page. When recording events on product 134 // K's page, log the 135 // [RecommendResponse.attribution_token][google.cloud.discoveryengine.v1beta.RecommendResponse.attribution_token] 136 // to this field. 137 string attribution_token = 8; 138 139 // The filter syntax consists of an expression language for constructing a 140 // predicate from one or more fields of the documents being filtered. 141 // 142 // One example is for `search` events, the associated 143 // [SearchRequest][google.cloud.discoveryengine.v1beta.SearchRequest] may 144 // contain a filter expression in 145 // [SearchRequest.filter][google.cloud.discoveryengine.v1beta.SearchRequest.filter] 146 // conforming to https://google.aip.dev/160#filtering. 147 // 148 // Similarly, for `view-item-list` events that are generated from a 149 // [RecommendRequest][google.cloud.discoveryengine.v1beta.RecommendRequest], 150 // this field may be populated directly from 151 // [RecommendRequest.filter][google.cloud.discoveryengine.v1beta.RecommendRequest.filter] 152 // conforming to https://google.aip.dev/160#filtering. 153 // 154 // The value must be a UTF-8 encoded string with a length limit of 1,000 155 // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. 156 string filter = 9; 157 158 // List of [Document][google.cloud.discoveryengine.v1beta.Document]s 159 // associated with this user event. 160 // 161 // This field is optional except for the following event types: 162 // 163 // * `view-item` 164 // * `add-to-cart` 165 // * `purchase` 166 // * `media-play` 167 // * `media-complete` 168 // 169 // In a `search` event, this field represents the documents returned to the 170 // end user on the current page (the end user may have not finished browsing 171 // the whole page yet). When a new page is returned to the end user, after 172 // pagination/filtering/ordering even for the same query, a new `search` event 173 // with different 174 // [UserEvent.documents][google.cloud.discoveryengine.v1beta.UserEvent.documents] 175 // is desired. 176 repeated DocumentInfo documents = 10; 177 178 // Panel metadata associated with this user event. 179 PanelInfo panel = 11; 180 181 // [SearchService.Search][google.cloud.discoveryengine.v1beta.SearchService.Search] 182 // details related to the event. 183 // 184 // This field should be set for `search` event. 185 SearchInfo search_info = 12; 186 187 // [CompletionService.CompleteQuery][google.cloud.discoveryengine.v1beta.CompletionService.CompleteQuery] 188 // details related to the event. 189 // 190 // This field should be set for `search` event when autocomplete function is 191 // enabled and the user clicks a suggestion for search. 192 CompletionInfo completion_info = 13; 193 194 // The transaction metadata (if any) associated with this user event. 195 TransactionInfo transaction_info = 14; 196 197 // A list of identifiers for the independent experiment groups this user event 198 // belongs to. This is used to distinguish between user events associated with 199 // different experiment setups on the customer end. 200 repeated string tag_ids = 15; 201 202 // The promotion IDs if this is an event associated with promotions. 203 // Currently, this field is restricted to at most one ID. 204 repeated string promotion_ids = 16; 205 206 // Extra user event features to include in the recommendation model. 207 // These attributes must NOT contain data that needs to be parsed or processed 208 // further, e.g. JSON or other encodings. 209 // 210 // If you provide custom attributes for ingested user events, also include 211 // them in the user events that you associate with prediction requests. Custom 212 // attribute formatting must be consistent between imported events and events 213 // provided with prediction requests. This lets the Discovery Engine API use 214 // those custom attributes when training models and serving predictions, which 215 // helps improve recommendation quality. 216 // 217 // This field needs to pass all below criteria, otherwise an 218 // `INVALID_ARGUMENT` error is returned: 219 // 220 // * The key must be a UTF-8 encoded string with a length limit of 5,000 221 // characters. 222 // * For text attributes, at most 400 values are allowed. Empty values are not 223 // allowed. Each value must be a UTF-8 encoded string with a length limit of 224 // 256 characters. 225 // * For number attributes, at most 400 values are allowed. 226 // 227 // For product recommendations, an example of extra user information is 228 // `traffic_channel`, which is how a user arrives at the site. Users can 229 // arrive 230 // at the site by coming to the site directly, coming through Google 231 // search, or in other ways. 232 map<string, CustomAttribute> attributes = 17; 233 234 // Media-specific info. 235 MediaInfo media_info = 18; 236} 237 238// Detailed page information. 239message PageInfo { 240 // A unique ID of a web page view. 241 // 242 // This should be kept the same for all user events triggered from the same 243 // pageview. For example, an item detail page view could trigger multiple 244 // events as the user is browsing the page. The `pageview_id` property should 245 // be kept the same for all these events so that they can be grouped together 246 // properly. 247 // 248 // When using the client side event reporting with JavaScript pixel and Google 249 // Tag Manager, this value is filled in automatically. 250 string pageview_id = 1; 251 252 // The most specific category associated with a category page. 253 // 254 // To represent full path of category, use '>' sign to separate different 255 // hierarchies. If '>' is part of the category name, replace it with 256 // other character(s). 257 // 258 // Category pages include special pages such as sales or promotions. For 259 // instance, a special sale page may have the category hierarchy: 260 // `"pageCategory" : "Sales > 2017 Black Friday Deals"`. 261 // 262 // Required for `view-category-page` events. Other event types should not set 263 // this field. Otherwise, an `INVALID_ARGUMENT` error is returned. 264 string page_category = 2; 265 266 // Complete URL (window.location.href) of the user's current page. 267 // 268 // When using the client side event reporting with JavaScript pixel and Google 269 // Tag Manager, this value is filled in automatically. Maximum length 5,000 270 // characters. 271 string uri = 3; 272 273 // The referrer URL of the current page. 274 // 275 // When using the client side event reporting with JavaScript pixel and Google 276 // Tag Manager, this value is filled in automatically. However, some browser 277 // privacy restrictions may cause this field to be empty. 278 string referrer_uri = 4; 279} 280 281// Detailed search information. 282message SearchInfo { 283 // The user's search query. 284 // 285 // See 286 // [SearchRequest.query][google.cloud.discoveryengine.v1beta.SearchRequest.query] 287 // for definition. 288 // 289 // The value must be a UTF-8 encoded string with a length limit of 5,000 290 // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. 291 // 292 // At least one of 293 // [search_query][google.cloud.discoveryengine.v1beta.SearchInfo.search_query] 294 // or 295 // [PageInfo.page_category][google.cloud.discoveryengine.v1beta.PageInfo.page_category] 296 // is required for `search` events. Other event types should not set this 297 // field. Otherwise, an `INVALID_ARGUMENT` error is returned. 298 string search_query = 1; 299 300 // The order in which products are returned, if applicable. 301 // 302 // See 303 // [SearchRequest.order_by][google.cloud.discoveryengine.v1beta.SearchRequest.order_by] 304 // for definition and syntax. 305 // 306 // The value must be a UTF-8 encoded string with a length limit of 1,000 307 // characters. Otherwise, an `INVALID_ARGUMENT` error is returned. 308 // 309 // This can only be set for `search` events. Other event types should not set 310 // this field. Otherwise, an `INVALID_ARGUMENT` error is returned. 311 string order_by = 2; 312 313 // An integer that specifies the current offset for pagination (the 0-indexed 314 // starting location, amongst the products deemed by the API as relevant). 315 // 316 // See 317 // [SearchRequest.offset][google.cloud.discoveryengine.v1beta.SearchRequest.offset] 318 // for definition. 319 // 320 // If this field is negative, an `INVALID_ARGUMENT` is returned. 321 // 322 // This can only be set for `search` events. Other event types should not set 323 // this field. Otherwise, an `INVALID_ARGUMENT` error is returned. 324 optional int32 offset = 3; 325} 326 327// Detailed completion information including completion attribution token and 328// clicked completion info. 329message CompletionInfo { 330 // End user selected 331 // [CompleteQueryResponse.QuerySuggestion.suggestion][google.cloud.discoveryengine.v1beta.CompleteQueryResponse.QuerySuggestion.suggestion]. 332 string selected_suggestion = 1; 333 334 // End user selected 335 // [CompleteQueryResponse.QuerySuggestion.suggestion][google.cloud.discoveryengine.v1beta.CompleteQueryResponse.QuerySuggestion.suggestion] 336 // position, starting from 0. 337 int32 selected_position = 2; 338} 339 340// A transaction represents the entire purchase transaction. 341message TransactionInfo { 342 // Required. Total non-zero value associated with the transaction. This value 343 // may include shipping, tax, or other adjustments to the total value that you 344 // want to include. 345 optional float value = 1 [(google.api.field_behavior) = REQUIRED]; 346 347 // Required. Currency code. Use three-character ISO-4217 code. 348 string currency = 2 [(google.api.field_behavior) = REQUIRED]; 349 350 // The transaction ID with a length limit of 128 characters. 351 string transaction_id = 3; 352 353 // All the taxes associated with the transaction. 354 optional float tax = 4; 355 356 // All the costs associated with the products. These can be manufacturing 357 // costs, shipping expenses not borne by the end user, or any other costs, 358 // such that: 359 // 360 // * Profit = 361 // [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - 362 // [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - 363 // [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] 364 optional float cost = 5; 365 366 // The total discount(s) value applied to this transaction. 367 // This figure should be excluded from 368 // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] 369 // 370 // For example, if a user paid 371 // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] 372 // amount, then nominal (pre-discount) value of the transaction is the sum of 373 // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] 374 // and 375 // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] 376 // 377 // This means that profit is calculated the same way, regardless of the 378 // discount value, and that 379 // [TransactionInfo.discount_value][google.cloud.discoveryengine.v1beta.TransactionInfo.discount_value] 380 // can be larger than 381 // [TransactionInfo.value][google.cloud.discoveryengine.v1beta.TransactionInfo.value]: 382 // 383 // * Profit = 384 // [value][google.cloud.discoveryengine.v1beta.TransactionInfo.value] - 385 // [tax][google.cloud.discoveryengine.v1beta.TransactionInfo.tax] - 386 // [cost][google.cloud.discoveryengine.v1beta.TransactionInfo.cost] 387 optional float discount_value = 6; 388} 389 390// Detailed document information associated with a user event. 391message DocumentInfo { 392 // A required descriptor of the associated 393 // [Document][google.cloud.discoveryengine.v1beta.Document]. 394 // 395 // * If [id][google.cloud.discoveryengine.v1beta.DocumentInfo.id] is 396 // specified, then the default values for 397 // `{location}`, `{collection_id}`, `{data_store_id}`, and `{branch_id}` are 398 // used when annotating with the stored Document. 399 // 400 // * If [name][google.cloud.discoveryengine.v1beta.DocumentInfo.name] is 401 // specified, then the provided values (default values allowed) for 402 // `{location}`, `{collection_id}`, `{data_store_id}`, and 403 // `{branch_id}` are used when annotating with the stored Document. 404 oneof document_descriptor { 405 // The [Document][google.cloud.discoveryengine.v1beta.Document] resource ID. 406 string id = 1; 407 408 // The [Document][google.cloud.discoveryengine.v1beta.Document] resource 409 // full name, of the form: 410 // `projects/{project_id}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/branches/{branch_id}/documents/{document_id}` 411 string name = 2 [(google.api.resource_reference) = { 412 type: "discoveryengine.googleapis.com/Document" 413 }]; 414 415 // The [Document][google.cloud.discoveryengine.v1beta.Document] URI - only 416 // allowed for website data stores. 417 string uri = 6; 418 } 419 420 // Quantity of the Document associated with the user event. Defaults to 1. 421 // 422 // For example, this field will be 2 if two quantities of the same Document 423 // are involved in a `add-to-cart` event. 424 // 425 // Required for events of the following event types: 426 // 427 // * `add-to-cart` 428 // * `purchase` 429 optional int32 quantity = 3; 430 431 // The promotion IDs associated with this Document. 432 // Currently, this field is restricted to at most one ID. 433 repeated string promotion_ids = 4; 434} 435 436// Detailed panel information associated with a user event. 437message PanelInfo { 438 // Required. The panel ID. 439 string panel_id = 2 [(google.api.field_behavior) = REQUIRED]; 440 441 // The display name of the panel. 442 string display_name = 3; 443 444 // The ordered position of the panel, if shown to the user with other panels. 445 // If set, then 446 // [total_panels][google.cloud.discoveryengine.v1beta.PanelInfo.total_panels] 447 // must also be set. 448 optional int32 panel_position = 4; 449 450 // The total number of panels, including this one, shown to the user. 451 // Must be set if 452 // [panel_position][google.cloud.discoveryengine.v1beta.PanelInfo.panel_position] 453 // is set. 454 optional int32 total_panels = 5; 455} 456 457// Media-specific user event information. 458message MediaInfo { 459 // The media progress time in seconds, if applicable. 460 // For example, if the end user has finished 90 seconds of a playback video, 461 // then 462 // [MediaInfo.media_progress_duration.seconds][google.protobuf.Duration.seconds] 463 // should be set to 90. 464 google.protobuf.Duration media_progress_duration = 1; 465 466 // Media progress should be computed using only the 467 // [media_progress_duration][google.cloud.discoveryengine.v1beta.MediaInfo.media_progress_duration] 468 // relative to the media total length. 469 // 470 // This value must be between `[0, 1.0]` inclusive. 471 // 472 // If this is not a playback or the progress cannot be computed (e.g. ongoing 473 // livestream), this field should be unset. 474 optional float media_progress_percentage = 2; 475} 476