Skip to content

Commit

Permalink
feat: support calibrate local timestamp (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu-xiaowei authored Mar 6, 2024
1 parent 5082af4 commit 60857e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private static Response request(@NonNull String eventJson, @NonNull ClickstreamC
.addQueryParameter("appId", appId)
.addQueryParameter("hashCode", StringUtil.getHashCode(curStr))
.addQueryParameter("event_bundle_sequence_id", String.valueOf(bundleSequenceId))
.addQueryParameter("upload_timestamp", String.valueOf(System.currentTimeMillis()))
.addQueryParameter("compression", compression)
.build();
Request.Builder builder = request.newBuilder().url(url).post(body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import static com.github.dreamhead.moco.Moco.and;
import static com.github.dreamhead.moco.Moco.by;
import static com.github.dreamhead.moco.Moco.eq;
import static com.github.dreamhead.moco.Moco.exist;
import static com.github.dreamhead.moco.Moco.httpServer;
import static com.github.dreamhead.moco.Moco.query;
import static com.github.dreamhead.moco.Moco.status;
Expand All @@ -76,6 +77,7 @@ public class EventRecorderTest {
private static final String COLLECT_SUCCESS = "/collect/success";
private static final String COLLECT_FAIL = "/collect/fail";
private static final String COLLECT_FOR_VERIFY_HASH_CODE = "/collect/hashcode";
private static final String COLLECT_FOR_VERIFY_UPLOAD_TIMESTAMP = "/collect/timestamp";
private static Runner runner;
private static String jsonString;
private static HttpServer server;
Expand Down Expand Up @@ -553,6 +555,21 @@ public void testRecordEventRequestWithHashCode() throws Exception {
assertTrue(requestResult);
}

/**
* test record event with request parameter upload timestamp.
*
* @throws Exception exception.
*/
@Test
public void testRecordEventRequestUploadTimestamp() throws Exception {
setRequestPath(COLLECT_FOR_VERIFY_UPLOAD_TIMESTAMP);
server.request(
and(by(uri(COLLECT_FOR_VERIFY_UPLOAD_TIMESTAMP)), exist(query("upload_timestamp"))))
.response(status(200), text("success"));
boolean requestResult = NetRequest.uploadEvents("[]", clickstreamContext.getClickstreamConfiguration(), 1);
assertTrue(requestResult);
}

/**
* common method to set request path.
*
Expand Down

0 comments on commit 60857e5

Please sign in to comment.