Skip to content

Commit 7ea838f

Browse files
feat: Add support for inline contexts for custom events (#296)
**Requirements** - [x] I have added test coverage for new or changed functionality - [x] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [x] I have validated my changes against all supported platform versions **Describe the solution you've provided** Bumped `launchdarklyJavaSdkInternal` version to `1.4.0` in order to add support for inline contexts for custom events.
1 parent a482f1f commit 7ea838f

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

contract-tests/src/main/java/com/launchdarkly/sdktest/TestService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class TestService extends NanoHTTPD {
3434
"strongly-typed",
3535
"tags",
3636
"auto-env-attributes",
37-
"inline-context",
37+
"inline-context-all",
3838
"anonymous-redaction",
3939
"client-prereq-events"
4040
};

launchdarkly-android-client-sdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ext.versions = [
6666
"jacksonDatabind": "2.10.5.1",
6767
"junit": "4.13",
6868
"launchdarklyJavaSdkCommon": "2.1.1",
69-
"launchdarklyJavaSdkInternal": "1.3.0",
69+
"launchdarklyJavaSdkInternal": "1.4.0",
7070
"launchdarklyLogging": "1.1.1",
7171
"okhttp": "4.9.2",
7272
"timber": "5.0.1",

launchdarkly-android-client-sdk/src/androidTest/java/com/launchdarkly/sdk/android/LDClientEventTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.junit.Assert.assertEquals;
44
import static org.junit.Assert.assertFalse;
5+
import static org.junit.Assert.assertNotNull;
56
import static org.junit.Assert.assertTrue;
67
import static org.junit.Assert.fail;
78

@@ -366,13 +367,10 @@ private void assertIdentifyEvent(LDValue event, LDContext context) {
366367
assertEquals("identify", event.get("kind").stringValue());
367368
}
368369

369-
private void assertContextKeys(LDValue event, LDContext context) {
370-
ObjectBuilder o = LDValue.buildObject();
371-
for (int i = 0; i < context.getIndividualContextCount(); i++) {
372-
o.put(context.getIndividualContext(i).getKind().toString(),
373-
context.getIndividualContext(i).getKey());
374-
}
375-
assertEquals(o.build(), event.get("contextKeys"));
370+
private void assertContext(LDValue event, LDContext context) {
371+
assertNotNull(event.get("context"));
372+
assertEquals(context.getKind().toString(), event.get("context").get("kind").stringValue());
373+
assertEquals(context.getKey(), event.get("context").get("key").stringValue());
376374
}
377375

378376
private void assertFeatureEvent(LDValue event, LDContext context) {
@@ -381,7 +379,7 @@ private void assertFeatureEvent(LDValue event, LDContext context) {
381379

382380
private void assertCustomEvent(LDValue event, LDContext context, String eventKey) {
383381
assertEquals("custom", event.get("kind").stringValue());
384-
assertContextKeys(event, context);
382+
assertContext(event, context);
385383
assertEquals(eventKey, event.get("key").stringValue());
386384
}
387385

0 commit comments

Comments
 (0)