Skip to content

feat: Add support for inline contexts for custom events #296

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 3 commits into from
May 19, 2025
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 @@ -34,7 +34,7 @@ public class TestService extends NanoHTTPD {
"strongly-typed",
"tags",
"auto-env-attributes",
"inline-context",
"inline-context-all",
"anonymous-redaction",
"client-prereq-events"
};
Expand Down
2 changes: 1 addition & 1 deletion launchdarkly-android-client-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ext.versions = [
"jacksonDatabind": "2.10.5.1",
"junit": "4.13",
"launchdarklyJavaSdkCommon": "2.1.1",
"launchdarklyJavaSdkInternal": "1.3.0",
"launchdarklyJavaSdkInternal": "1.4.0",
"launchdarklyLogging": "1.1.1",
"okhttp": "4.9.2",
"timber": "5.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

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

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

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

private void assertCustomEvent(LDValue event, LDContext context, String eventKey) {
assertEquals("custom", event.get("kind").stringValue());
assertContextKeys(event, context);
assertContext(event, context);
assertEquals(eventKey, event.get("key").stringValue());
}

Expand Down