Skip to content

Commit cf4fa09

Browse files
fix: missing call
1 parent acdc4a7 commit cf4fa09

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ public void stop(InternalConfig config, boolean clearData) {
300300

301301
@Override
302302
protected void onTimer() {
303-
saveInternal();
303+
if (internalConfig.isAutoSendUserProperties()) {
304+
saveInternal();
305+
}
304306
}
305307

306308
@Override

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,30 @@ public void eventsUserProps() throws InterruptedException {
469469
Assert.assertEquals(TestUtils.json("custom", TestUtils.map("after_event", "value2")), RQ[2].get("user_details"));
470470
}
471471

472+
/**
473+
* Recording events with user properties and with flushing events will not work because reversed
474+
*
475+
* @throws InterruptedException when sleep is interrupted
476+
*/
477+
@Test
478+
public void eventsUserProps_reversed() throws InterruptedException {
479+
init(TestUtils.getConfigEvents(4).setUpdateSessionTimerDelay(2).disableAutoSendUserProperties());
480+
481+
Countly.instance().userProfile().setProperty("before_event", "value1");
482+
Countly.instance().events().recordEvent(eKeys[0]);
483+
484+
Map<String, String>[] RQ = TestUtils.getCurrentRQ();
485+
Assert.assertEquals(0, RQ.length);
486+
TestUtils.validateEventInEQ(eKeys[0], null, 1, null, null, 0, 1, "_CLY_", null, "", null);
487+
488+
Countly.instance().userProfile().setProperty("after_event", "value2");
489+
Thread.sleep(2500); // wait for the tick
490+
RQ = TestUtils.getCurrentRQ();
491+
492+
Assert.assertEquals(1, RQ.length);
493+
Assert.assertTrue(RQ[0].containsKey("events"));
494+
}
495+
472496
/**
473497
* Recording events with user properties and with flushing events
474498
* Validating that if a user property save called, it flushes EQ before saving user properties

0 commit comments

Comments
 (0)