Skip to content

Commit cb538c0

Browse files
fix: gather all under one flag
1 parent 3d3ae24 commit cb538c0

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

sdk-java/src/main/java/ly/count/sdk/java/internal/SessionImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Future<Boolean> begin(Long now) {
118118
}
119119

120120
this.consents = SDKCore.instance.consents;
121-
if (config.isAutoSendUserPropertiesOnSessions() && config.sdk.userProfile() != null) {
121+
if (config.isAutoSendUserProperties() && config.sdk.userProfile() != null) {
122122
config.sdk.module(ModuleUserProfile.class).saveInternal();
123123
}
124124

@@ -160,7 +160,7 @@ Future<Boolean> update(Long now) {
160160
}
161161

162162
this.consents = SDKCore.instance.consents;
163-
if (config.isAutoSendUserPropertiesOnSessions() && config.sdk.userProfile() != null) {
163+
if (config.isAutoSendUserProperties() && config.sdk.userProfile() != null) {
164164
config.sdk.module(ModuleUserProfile.class).saveInternal();
165165
}
166166

@@ -198,7 +198,7 @@ Future<Boolean> end(Long now, final Tasks.Callback<Boolean> callback, String did
198198
ended = now == null ? System.nanoTime() : now;
199199

200200
this.consents = SDKCore.instance.consents;
201-
if (config.isAutoSendUserPropertiesOnSessions() && config.sdk.userProfile() != null) {
201+
if (config.isAutoSendUserProperties() && config.sdk.userProfile() != null) {
202202
config.sdk.module(ModuleUserProfile.class).saveInternal();
203203
}
204204

sdk-java/src/test/java/ly/count/sdk/java/internal/ModuleEventsTests.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,28 @@ public void eventsUserProps_propsSave() {
516516
Assert.assertEquals(TestUtils.json("custom", TestUtils.map("after_event", "value2")), RQ[1].get("user_details"));
517517
}
518518

519+
/**
520+
* Recording events with user properties and with flushing events
521+
* Validating that if a user property save called, it does not flush EQ before saving user properties
522+
*/
523+
@Test
524+
public void eventsUserProps_propsSave_reversed() {
525+
init(TestUtils.getConfigEvents(4).disableAutoSendUserProperties());
526+
527+
Countly.instance().events().recordEvent(eKeys[0]);
528+
529+
Map<String, String>[] RQ = TestUtils.getCurrentRQ();
530+
Assert.assertEquals(0, RQ.length);
531+
TestUtils.validateEventInEQ(eKeys[0], null, 1, null, null, 0, 1, "_CLY_", null, "", null);
532+
533+
Countly.instance().userProfile().setProperty("after_event", "value2");
534+
Countly.instance().userProfile().save();
535+
536+
RQ = TestUtils.getCurrentRQ();
537+
Assert.assertEquals(1, RQ.length);
538+
Assert.assertEquals(TestUtils.json("custom", TestUtils.map("after_event", "value2")), RQ[0].get("user_details"));
539+
}
540+
519541
/**
520542
* Validate that user properties are sent with timer tick if no events are recorded
521543
*/
@@ -534,6 +556,23 @@ public void eventsUserProps_timer() throws InterruptedException {
534556
Assert.assertEquals(TestUtils.json("custom", TestUtils.map("before_timer", "value1")), RQ[0].get("user_details"));
535557
}
536558

559+
/**
560+
* Validate that user properties does not send with timer tick if no events are recorded
561+
*/
562+
@Test
563+
public void eventsUserProps_timer_reversed() throws InterruptedException {
564+
init(TestUtils.getConfigEvents(4).setUpdateSessionTimerDelay(2).disableAutoSendUserProperties());
565+
566+
Countly.instance().userProfile().setProperty("before_timer", "value1");
567+
568+
Map<String, String>[] RQ = TestUtils.getCurrentRQ();
569+
Assert.assertEquals(0, RQ.length);
570+
571+
Thread.sleep(2500); // wait for the tick
572+
RQ = TestUtils.getCurrentRQ();
573+
Assert.assertEquals(0, RQ.length);
574+
}
575+
537576
private void validateTimedEventSize(int expectedQueueSize, int expectedTimedEventSize) {
538577
TestUtils.validateEQSize(expectedQueueSize, TestUtils.getCurrentEQ(), moduleEvents.eventQueue);
539578
Assert.assertEquals(expectedTimedEventSize, moduleEvents.timedEvents.size());

sdk-java/src/test/java/ly/count/sdk/java/internal/SessionImplTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ public void userPropsOnSessions() throws InterruptedException {
680680
*/
681681
@Test
682682
public void userPropsOnSessions_reversed() throws InterruptedException {
683-
Countly.instance().init(TestUtils.getConfigSessions(Config.Feature.UserProfiles).disableAutoSendUserPropertiesOnSessions());
683+
Countly.instance().init(TestUtils.getConfigSessions(Config.Feature.UserProfiles).disableAutoSendUserProperties());
684684
Countly.instance().userProfile().setProperty("name", "John Doe");
685685
Countly.instance().userProfile().setProperty("custom_key", "custom_value");
686686

0 commit comments

Comments
 (0)