-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fixed an issue with applyResponse #914
Conversation
…ed content if it was called after a sendEvent
@@ -113,7 +114,7 @@ export default ({ | |||
.onBeforeEvent({ | |||
event, | |||
renderDecisions, | |||
decisionScopes: [], | |||
decisionScopes: [PAGE_WIDE_SCOPE], |
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.
I see how this solves the problem, but it's not technically accurate. I suppose an empty array of decision scopes was also inaccurate though.... so 🤷♂️
Since we have the responseBody
here, you could instead iterate over the payload
array of the personalization:decisions
handle to construct a Set of scope
s found in the list. then provide the list in the decisionScopes array here.
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.
In my opinion renderDecisions
and decisionScopes
should be passed by the customer in the applyResponses
command as options. If they need the __view__
decisions to be rendered, then they would pass them in the command options. Otherwise, we make the assumption that the customer have fetched them and wants them to be rendered.
The special scope __view__
is attached to decisionScopes
by Web SDK. In cases of server-side call, it is up to the customer to fetch the __view__
decisions or not.
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.
Probably as a quick fix, @jasonwaters idea to extract the scopes from handles will work. Although with @XDex PR related to surfaces, we should think of how we should handle personalization
object here as well.
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.
We will go ahead and merge this, and work on testing it more thoroughly later. If we find a bug we can patch later.
Description
Fixed an issue with applyResponse where it would not apply personalized content if it was called after a sendEvent. There is a condition here:
alloy/src/components/Personalization/createComponent.js
Line 62 in 6194f1b
alloy/src/components/Personalization/createPersonalizationDetails.js
Line 65 in 6194f1b
which makes it so that the personalized content from an applyResponse command is only processed if the cache is not initialized. This is because for applyResponse commands, the scopes are always empty. In this PR, I add the page wide scope (
__view__
) to the applyResponse calls so that "shouldFetchData()" is always true for applyResponse commands.Related Issue
Motivation and Context
Screenshots (if appropriate):
Types of changes
Checklist: