diff --git a/src/components/Personalization/dom-actions/createRedirect.js b/src/components/Personalization/dom-actions/createRedirect.js index 3d6c692ac..e76d8912f 100644 --- a/src/components/Personalization/dom-actions/createRedirect.js +++ b/src/components/Personalization/dom-actions/createRedirect.js @@ -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); +}; diff --git a/src/components/Personalization/handlers/createProcessRedirect.js b/src/components/Personalization/handlers/createProcessRedirect.js index 722034c6a..47ebdc951 100644 --- a/src/components/Personalization/handlers/createProcessRedirect.js +++ b/src/components/Personalization/handlers/createProcessRedirect.js @@ -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. }); }; diff --git a/test/functional/specs/Personalization/C205528.js b/test/functional/specs/Personalization/C205528.js index 53a6b38d3..b86b01d68 100644 --- a/test/functional/specs/Personalization/C205528.js +++ b/test/functional/specs/Personalization/C205528.js @@ -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); +});