Skip to content

Commit

Permalink
Revert "feat: add library context field (#76)" (#77)
Browse files Browse the repository at this point in the history
This reverts commit c874396.
  • Loading branch information
liuyang1520 authored Aug 25, 2022
1 parent c874396 commit 7d9e474
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 60 deletions.
15 changes: 0 additions & 15 deletions src/main/java/com/amplitude/Amplitude.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class Amplitude {
private Object eventQueueLock = new Object();
private Plan plan;
private long flushTimeout;
private String libraryContext;

/**
* A dictionary of key-value pairs that represent additional instructions for server save
Expand Down Expand Up @@ -164,16 +163,6 @@ public Amplitude setPlan(Plan plan) {
return this;
}

/**
* Set library context information.
*
* @param libraryContext String
*/
public Amplitude setLibraryContext(String libraryContext) {
this.libraryContext = libraryContext;
return this;
}

/**
* Set custom proxy for https requests
*
Expand Down Expand Up @@ -253,10 +242,6 @@ public void logEvent(Event event, AmplitudeCallbacks callbacks, MiddlewareExtra
event.plan = this.plan;
}

if (event.libraryContext == null) {
event.libraryContext = this.libraryContext;
}

if (!middlewareRunner.run(new MiddlewarePayload(event, extra))) {
return;
}
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/com/amplitude/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ public class Event {
*/
public Plan plan;

/**
* The library context information.
*/
public String libraryContext;

/**
* Callback for Event
*/
Expand Down Expand Up @@ -284,10 +279,6 @@ public JSONObject toJsonObject() {
if (plan != null) {
event.put("plan", plan.toJSONObject());
}

if (libraryContext != null) {
event.put("library_context", libraryContext);
}
} catch (JSONException e) {
e.printStackTrace();
}
Expand Down
35 changes: 0 additions & 35 deletions src/test/java/com/amplitude/AmplitudeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,41 +446,6 @@ public void testSetPlan()
assertEquals(versionId, result.getString(Constants.AMP_PLAN_VERSION_ID));
}

@Test
public void testSetLibraryContext()
throws NoSuchFieldException, IllegalAccessException, AmplitudeInvalidAPIKeyException,
InterruptedException {
Amplitude amplitude = Amplitude.getInstance("testSetLibraryContext");
amplitude.init(apiKey);

String libraryContext = "test_library_context/1.x";

amplitude.setLibraryContext(libraryContext);

amplitude.useBatchMode(false);
amplitude.setEventUploadThreshold(1);
HttpCall httpCall = getMockHttpCall(amplitude, false);
Response response = ResponseUtil.getSuccessResponse();
CountDownLatch latch = new CountDownLatch(1);

AtomicReference<List<Event>> sentEvents = new AtomicReference<>();
when(httpCall.makeRequest(anyList()))
.thenAnswer(
invocation -> {
sentEvents.set(invocation.getArgument(0));
latch.countDown();
return response;
});

amplitude.logEvent(new Event("test-event", "test-user"));

assertTrue(latch.await(1L, TimeUnit.SECONDS));
assertEquals(1, sentEvents.get().size());

Event sentEvent = sentEvents.get().get(0);
assertEquals(libraryContext, sentEvent.libraryContext);
}

private HttpCall getMockHttpCall(Amplitude amplitude, boolean useBatch)
throws NoSuchFieldException, IllegalAccessException {
HttpCall httpCall = mock(HttpCall.class);
Expand Down
1 change: 0 additions & 1 deletion src/test/java/com/amplitude/EventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void testToJsonObject() {
assertEquals(
Constants.SDK_LIBRARY + "/" + Constants.SDK_VERSION, truncatedEvent.getString("library"));
assertEquals(-1, truncatedEvent.getLong("session_id"));
assertFalse(truncatedEvent.has("library_context"));
}

@Test
Expand Down

0 comments on commit 7d9e474

Please sign in to comment.