Skip to content
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

Do not send bottom of page events after a redirect #1066

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
Loading