Reimplement event handler for mobile sticky slot#2421
Conversation
|
|
Size Change: +213 B (+0.05%) Total Size: 388 kB
ℹ️ View Unchanged
|
d5a3d9d to
0a5ebfc
Compare
| const handleBannerEvent = (event: Event) => { | ||
| log('commercial', '🪵 Handle Banner Event:', event.type); | ||
| const handleBannerEvent = (event: Event): void => { | ||
| log('commercial', `📲 Handling event ${event.type}`); |
There was a problem hiding this comment.
Nice touch with the enhanced logging - great addition for debugging and monitoring, as well as coupled to the event
| // We only try to load the mobile-sticky slot when one of the following events has been received | ||
| document.addEventListener('banner:close', handleBannerEvent); | ||
| document.addEventListener('banner:none', handleBannerEvent); | ||
| document.addEventListener('banner:sign-in-gate', handleBannerEvent); |
There was a problem hiding this comment.
This addition makes sense and aligns with the banner:sign-in-gate event handling introduced in the DCR codebase.
1154054 to
b506bae
Compare
Co-authored-by: Demetrios Skamiotis <[email protected]>
…f generating fake custom events
…ead of dispatching the custom event directly
This reverts commit b5de8df.
b506bae to
291fa20
Compare
… queue flush implementation
| const bannerSelector = '[name="StickyBottomBanner"]'; | ||
| const mobileStickySelector = '#dfp-ad--mobile-sticky'; | ||
|
|
||
| /** TODO: Enable this when the event handling mobile-sticky logic goes live */ |
There was a problem hiding this comment.
Couldn't opt into AB tests in playwright with a query parameter as the GET requests are updated to POST requests for interaction with the DCR prod server (as this is what runs in the container)
Once we go live to 100%, we can fully enable this test
What does this change?
Re-introduces event handlers for launching the mobile-sticky ad slot from #2351.
This is being launched as an AB test while we understand the impact of the change.
The variant group of the AB test will implement the logic below. The control group will keep the existing logic in place.
We now listen to the following three events in order to determine whether we can render the mobile sticky slot:
banner:nonebanner:closebanner:sign-in-gatecmp:banner-closeThe page is not eligible for mobile-sticky until we receive one of these events on a given page view. We also still need to check the existing criteria before rendering the mobile-sticky ad slot but these event listeners now act as an additional check.
After receiving an event, we double check whether the CMP is still on the screen just in case the
cmp:banner-closeevent did not actually result in the dismissal of the CMP.This PR adds logging and event handling for these three scenarios as well as a Playwright test to monitor this moving forward.
Note
Companion PR in dotcom-rendering guardian/dotcom-rendering#15380
Why?
The mobile-sticky slot can sometimes launch at the same time as the CMP and supporter revenue banners. When this happens, the slot is present in the DOM but sits underneath these elements. We can't continue to allow this to happen as impressions are counted against the advert in the slot even though it can't be seen by the end user
We have decided to only allow the mobile-sticky to launch after certain events as well as the existing page conditions.
It is worth noting that we deliberately allow display of the mobile-sticky slot when the sign in gate is the chosen message from the
StickyBottomBannercomponent. The sign in gate currently appears most often obscuring the article body and does not look like a banner or a modal. Another version of the sign in gate appears as a modal and we may want to look into preventing ads running when this is present on the screen.Co-authored by: @dskamiotis
Document link for extra information