Skip to content

Commit

Permalink
Merge pull request #1066 from adobe/fixRedirectBottomOfPageEvent
Browse files Browse the repository at this point in the history
Do not send bottom of page events after a redirect
  • Loading branch information
jonsnyder authored Oct 27, 2023
2 parents 8ab989f + 39eed43 commit 735b663
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/Personalization/dom-actions/createRedirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

export default window => url => window.location.replace(url);
export default window => url => {
window.location.replace(url);
// Return a promise that never resolves because redirects never complete
// within the current page.
return new Promise(() => undefined);
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ export default ({ logger, executeRedirect, collect }) => item => {
decisionsMeta: [item.getProposition().getNotification()],
documentMayUnload: true
}).then(() => {
executeRedirect(content);
// We've already sent the display notification, so don't return anything
return executeRedirect(content);
// Execute redirect will never resolve. If there are bottom of page events that are waiting
// for display notifications from this request, they will never run because this promise will
// not resolve. This is intentional because we don't want to run bottom of page events if
// there is a redirect.
});
};

Expand Down
20 changes: 20 additions & 0 deletions test/functional/specs/Personalization/C205528.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,23 @@ test("Test C205528: A redirect offer should not redirect if renderDecisions is f
await new Promise(resolve => setTimeout(resolve, 1000));
await t.expect(redirectLogger.count(() => true)).eql(0);
});

test("Test 205528: When there is a redirect offer web sdk should not send a bottom of page event", async () => {
const alloy = createAlloyProxy();
await alloy.configure(config);
await alloy.sendEventAsync({
renderDecisions: true,
personalization: {
sendDisplayEvent: false
}
});
await alloy.sendEventAsync({
personalization: {
includeRenderedPropositions: true
}
});

await t.expect(redirectLogger.count(() => true)).eql(1);
// 1 for the initial request, 1 for the redirect display notification
await t.expect(networkLogger.edgeEndpointLogs.requests.length).eql(2);
});

0 comments on commit 735b663

Please sign in to comment.