send timestamp of actions to the server

PiperOrigin-RevId: 248199693
Change-Id: I5ad7d260734e45449fe13fb52c4913d445f83638
diff --git a/src/main/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilder.java b/src/main/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilder.java
index d6ecaa0..eae7f88 100644
--- a/src/main/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilder.java
+++ b/src/main/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilder.java
@@ -77,9 +77,14 @@
       }
       for (StreamUploadableAction action : uploadableActions) {
         String contentId = action.getFeatureContentId();
-        FeedAction.Builder feedAction = FeedAction.newBuilder();
         ActionPayload payload = action.getPayload();
-        feedAction.setActionPayload(payload);
+        FeedAction.Builder feedAction =
+            FeedAction.newBuilder()
+                .setActionPayload(payload)
+                .setClientData(
+                    FeedAction.ClientData.newBuilder()
+                        .setTimestampSeconds(action.getTimestampSeconds())
+                        .build());
         ActionProperties properties = actionPropertyMap.get(contentId);
         if (properties != null) {
           feedAction.setActionProperties(properties);
diff --git a/src/main/proto/search/now/wire/feed/feed_action.proto b/src/main/proto/search/now/wire/feed/feed_action.proto
index 8038f1d..7fbe45d 100644
--- a/src/main/proto/search/now/wire/feed/feed_action.proto
+++ b/src/main/proto/search/now/wire/feed/feed_action.proto
@@ -32,6 +32,14 @@
   optional ActionProperties action_properties = 3;
   // Additional logging data that is on a per-action level
   optional ActionPayload action_payload = 4;
-  // Next Id: 5
+  // Client-generated data that pertains to the action.
+  optional ClientData client_data = 5;
+  // Next Id: 6
   reserved 2;
+
+  // The data the client provides to the server.
+  message ClientData {
+    // When the action was recorded on the client
+    optional int64 timestamp_seconds = 1;
+  }
 }
diff --git a/src/test/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilderTest.java b/src/test/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilderTest.java
index 338075c..6affa74 100644
--- a/src/test/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilderTest.java
+++ b/src/test/java/com/google/android/libraries/feed/feedrequestmanager/UploadableActionsRequestBuilderTest.java
@@ -41,6 +41,7 @@
 @RunWith(RobolectricTestRunner.class)
 public class UploadableActionsRequestBuilderTest {
   private static final String CONTENT_ID = "contentId";
+  private static final int TIME = 100;
   private final ActionPayload payload =
       ActionPayload.newBuilder()
           .setExtension(
@@ -75,6 +76,7 @@
         StreamUploadableAction.newBuilder()
             .setFeatureContentId(CONTENT_ID)
             .setPayload(payload)
+            .setTimestampSeconds(TIME)
             .build());
     requestBuilder =
         ActionRequest.newBuilder()
@@ -84,12 +86,14 @@
 
   @Test
   public void testUploadableActionsRequest_noToken() throws Exception {
- 
+
     FeedAction.Builder feedAction =
         FeedAction.newBuilder()
             .setActionProperties(ActionProperties.newBuilder().setActionData(data).build());
     feedAction.setContentId(ContentId.getDefaultInstance());
     feedAction.setActionPayload(payload);
+
+    feedAction.setClientData(FeedAction.ClientData.newBuilder().setTimestampSeconds(TIME).build());
     feedActionRequestBuilder.addFeedAction(feedAction);
     requestBuilder.setExtension(
         FeedActionRequest.feedActionRequest, feedActionRequestBuilder.build());
@@ -117,6 +121,7 @@
             .setActionProperties(ActionProperties.newBuilder().setActionData(data).build());
     feedAction.setContentId(ContentId.getDefaultInstance());
     feedAction.setActionPayload(payload);
+    feedAction.setClientData(FeedAction.ClientData.newBuilder().setTimestampSeconds(TIME).build());
     feedActionRequestBuilder.addFeedAction(feedAction);
     feedActionRequestBuilder.setConsistencyToken(token);
     requestBuilder.setExtension(