-
Notifications
You must be signed in to change notification settings - Fork 371
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
[FIX] IAM with dynamic trigger showing forever #2137
Conversation
...l/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/InAppMessagesManager.kt
Outdated
Show resolved
Hide resolved
ba52ee5
to
49be2fc
Compare
...src/main/java/com/onesignal/inAppMessages/internal/triggers/impl/DynamicTriggerController.kt
Outdated
Show resolved
Hide resolved
...src/main/java/com/onesignal/inAppMessages/internal/triggers/impl/DynamicTriggerController.kt
Outdated
Show resolved
Hide resolved
30dc970
to
a3bc16c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This latest solution still looks like it would also break the "Every time trigger conditions are satisfied" behavior. We want to keep the behavior where the developer should be able to reshow the IAM by calling addTrigger
again with the same key. Can you test this scenario and add what you tested to the PR notes?
The latest change adds a set that stores evaluated combinations of trigger to prevent a certain combination of trigger from showing multiple time. The set will get cleared every time addTrigger or removeTrigger is called. And it appears in my test that the IAM will show up once per startup and every time I add a new trigger. |
a3bc16c
to
8b53cc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new logic has a lot of overlap with the pre-existing isTriggerChanged
and isDisplayedInSession
logic. I think we should remove these (if they cover everything) before merging in these changes so we don't have redundant logic that would much harder to reason about later.
...ssages/src/main/java/com/onesignal/inAppMessages/internal/triggers/impl/TriggerController.kt
Outdated
Show resolved
Hide resolved
Summary of changes: 1. When a time-based trigger is evaluated and 'onTriggerCompleted()' is called, we no longer make redisplay messages available to avoid duplicate redisplay of a same message. 2. Modify the logic of 'makeRedisplayMessagesAvailableWithTriggers()' so that a message can be redisplayed only if at least one trigger has changed or a new trigger is added. 3. 'onTriggerConditionChanged()' now accepts a new parameter 'triggerId' that indicates the time-based trigger that fires.
20678ea
to
7582adf
Compare
Yes, I also realized that this particular approach uses similar logic as 'isTriggerChanged' so I made a different approach that only alter the 'makeRedisplayMessagesAvailableWithTriggers' logic so that onTriggerCompleted no longer redisplay messages. Instead, it was done by onTriggerConditionChanged before trigger evaluation. I have updated the test part in the description to include some common IAM setup that is potentially affected by the change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- IAM with whatever = true AND Session_Time > 5 with Every time trigger conditions are satisfied checked:
There is still a bug with that IAM in the follow scenario.
- Call
addTriger("whatever", true)
- IAM displays as expected
- Call
addTriger("somethingElse", true)
- BUG: IAM displays again when it should not
- It is expected that it only re-display if
addTriger("whatever", true)
was called again.
- It is expected that it only re-display if
0f42d93
to
66df887
Compare
…r is added when there is only dynamic trigger
66df887
to
ea912ff
Compare
Nice found! I have fixed this bug and removed some unneeded code for the latest commit. |
...l/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/InAppMessagesManager.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No action needed in this PR, but noted here for the future. I think there is still more states the can be cleaned up to simplify this manager's logic. Some that come to mind are:
- I don't think
messageHasOnlyDynamicTriggers
needs to be a concept redisplayedInAppMessages
overlaps withmessage.isDisplayedInSession
if (!message.isTriggerChanged && redisplayedInAppMessages.contains(message) && | ||
_triggerController.isTriggerOnMessage(message, newTriggersKeys) | ||
) { | ||
val isMessageDisplayed = redisplayedInAppMessages.contains(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isMessageDisplayed
is an incorrect name for this, however the pre-existing redisplayedInAppMessages
is also a misleading name. A recommend a better name such as canRedisplay
instead of isMessageDisplayed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I just fixed this.
val isMessageDisplayed = redisplayedInAppMessages.contains(message) | ||
val isTriggerOnMessage = _triggerController.isTriggerOnMessage(message, newTriggersKeys) | ||
val isOnlyDynamicTriggers = _triggerController.messageHasOnlyDynamicTriggers(message) | ||
if (!message.isTriggerChanged && isMessageDisplayed && (isTriggerOnMessage || isNewTriggerAdded && isOnlyDynamicTriggers)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is acceptable for now, however keep in mind for the future ideally we won't want to have an if
statement with a nested &&
and ||
like this in most scenarios, including this one.
Description
One Line Summary
Fix an issue with IAM with dynamic triggers like "SESSION_TIME" showing up repetitively after being dismissed.
Details
Motivation
Fix the incorrect app behavior when IAM with both custom trigger and session_time trigger continues to show up even it was dismissed.
Scope
Manual testing
Before the fix:
IAM setting to reproduce the issue:
This IAM would show up 5 seconds after app start up and continue to show up after being dismissed.
After the fix:
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is