Skip to content

feat: support calibrate local timestamp #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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