Skip to content

Commit 08ce7df

Browse files
authored
Set Facebook Click to Load breakage flags (#610)
Take care to set the new Facebook Click to Load breakage flags, to give us a better idea how often the feature causes website breakage for our users.
1 parent ebbae7a commit 08ce7df

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

inject/android.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const allowedMessages = [
1212
'openShareFeedbackPage',
1313
'setYoutubePreviewsEnabled',
1414
'unblockClickToLoadContent',
15-
'updateYouTubeCTLAddedFlag'
15+
'updateYouTubeCTLAddedFlag',
16+
'updateFacebookCTLBreakageFlags'
1617
]
1718

1819
function initCode () {

inject/chrome.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const allowedMessages = [
1515
'openShareFeedbackPage',
1616
'setYoutubePreviewsEnabled',
1717
'unblockClickToLoadContent',
18-
'updateYouTubeCTLAddedFlag'
18+
'updateYouTubeCTLAddedFlag',
19+
'updateFacebookCTLBreakageFlags'
1920
]
2021
const messageSecret = randomString()
2122

inject/mozilla.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const allowedMessages = [
1212
'openShareFeedbackPage',
1313
'setYoutubePreviewsEnabled',
1414
'unblockClickToLoadContent',
15-
'updateYouTubeCTLAddedFlag'
15+
'updateYouTubeCTLAddedFlag',
16+
'updateFacebookCTLBreakageFlags'
1617
]
1718
const messageSecret = randomString()
1819

src/features/click-to-load.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@ class DuckWidget {
503503
// If this is a login button, show modal if needed
504504
if (this.replaceSettings.type === 'loginButton' && entityData[this.entity].shouldShowLoginModal) {
505505
return e => {
506+
// Even if the user cancels the login attempt, consider Facebook Click to
507+
// Load to have been active on the page if the user reports the page as broken.
508+
if (this.entity === 'Facebook, Inc.') {
509+
notifyFacebookLogin()
510+
}
511+
506512
handleUnblockConfirmation(
507513
this.platform.name, this.entity, handleClick, e
508514
)
@@ -656,6 +662,7 @@ function createPlaceholderElementAndReplace (widget, trackingElement) {
656662

657663
// Facebook
658664
if (widget.replaceSettings.type === 'dialog') {
665+
ctl.messaging.notify('updateFacebookCTLBreakageFlags', { ctlFacebookPlaceholderShown: true })
659666
if (widget.shouldUseCustomElement()) {
660667
/**
661668
* Creates a custom HTML element with the placeholder element for blocked
@@ -922,13 +929,26 @@ function handleUnblockConfirmation (platformName, entity, acceptFunction, ...acc
922929
}
923930
}
924931

932+
/**
933+
* Set the ctlFacebookLogin breakage flag for the page, to indicate that the
934+
* Facebook Click to Load login flow had started if the user should then report
935+
* the website as broken.
936+
*/
937+
function notifyFacebookLogin () {
938+
ctl.messaging.notify('updateFacebookCTLBreakageFlags', { ctlFacebookLogin: true })
939+
}
940+
925941
/**
926942
* Unblock the entity, close the login dialog and continue the Facebook login
927943
* flow. Called after the user clicks to proceed after the warning dialog is
928944
* shown.
929945
* @param {string} entity
930946
*/
931947
async function runLogin (entity) {
948+
if (entity === 'Facebook, Inc.') {
949+
notifyFacebookLogin()
950+
}
951+
932952
const action = entity === 'Youtube' ? 'block-ctl-yt' : 'block-ctl-fb'
933953
const response = await unblockClickToLoadContent({ entity, action, isLogin: true, isSurrogateLogin: true })
934954
// If user rejected confirmation modal and content was not unblocked, inform surrogate and stop.
@@ -1845,6 +1865,12 @@ export default class ClickToLoad extends ContentFeature {
18451865
}
18461866
// Handle login call
18471867
if (event.detail?.action === 'login') {
1868+
// Even if the user cancels the login attempt, consider Facebook Click to
1869+
// Load to have been active on the page if the user reports the page as broken.
1870+
if (entity === 'Facebook, Inc.') {
1871+
notifyFacebookLogin()
1872+
}
1873+
18481874
if (entityData[entity].shouldShowLoginModal) {
18491875
handleUnblockConfirmation(this.platform.name, entity, runLogin, entity)
18501876
} else {

0 commit comments

Comments
 (0)