HomePhabricator

Refactor client-side API and RL modules for banner display

Authored by AndyRussG.

Description

Refactor client-side API and RL modules for banner display

This patch refactors client-side code sent to all subscribing wikis.
Code previously in RL modules ext.centralNotice.bannerController and
ext.centralNotice.bannerController.mobile is removed. Almost
identical functionality is provided by ext.centralNotice.startUp and
its dependencies.

Provides client-side API features needed by upcoming patches to log a
sample of banner history, improve banner hide logic (currently in JS
in banners), and eventually remove calls to Special:RecordImpression.

Performance improvements are expected, since code for processing
campaigns and banners is not loaded if the server does not have any
possible campaigns for this user. Upcoming hide logic changes are
also expected to help performance.

Code to set window.Geo and handle GeoIP cookies has been moved to its
own RL module and is no longer dependent on CentralNoice-related
logic, in preparation for its removal from CentralNotice.

A number of unused features and Javascript API endpoints have been
removed.

More details:

  • In legacy code, bannerController execution is wrapped in a $( )

function. This is maintained, but it is expected that in the future,
only code that operates on the DOM will be delayed in that way.

  • Special:RecordImpression now defaults to sampling. Banners that

need unsampled data must call
mw.centralNotice.setRecordImpressionSampleRate().

  • Special:RecordImpression is no longer called for users that are not

targeted by a campaign.

  • The data sent to Special:RecordImpression has changed, and mirrors

the data available at mw.centralNotice.data.

  • Built-in hide cookie logic is now preformed before a banner is

selected.

  • Support for the 'old cookie apocalypse' and 'old cookie epoch' has

been removed. (However, the related global variables have been left
in, in case this change needs to be rolled back.)

  • Does _not_ fix an issue with GeoIP cookie handling related to the

domain the cookie is attached to. (See TODO in
ext.CentralNotice.geoIP.js.)

  • Changes the directory structure of RL modules.
  • The strategy for deprecating old RL modules is as follows: old

modules no longer have scripts or css associated with them, and
depend on ext.centralNotice.startUp. However, the old modules are
still added to HTML, instead of the new one, in case a rollback is
necessary. This patch does not change HTML output. Old RL modules
will be removed from HTML in a follow-on patch. See
https://www.mediawiki.org/wiki/Extension:CentralNotice/Notes/Banner_controller_refactoring#Stage_1:_New_modules_only_as_dependencies.2C_rollback_is_possible

  • The global wgMobileDeviceName (clients-side only) is removed (no

longer needed).

  • New tests for re-implemented functionality will be added in

follow-on patches.

Bug: T100686
Bug: T100372
Bug: T102848
Change-Id: Ifbecceba41363c2ccd4fb3cfff96f7756d90bf06

Details

Committed
AndyRussGAug 4 2015, 1:37 AM
Parents
rECNO2f7d839cf782: Remove automatic landing page links feature
Branches
Unknown
Tags
Unknown
ChangeId
Ifbecceba41363c2ccd4fb3cfff96f7756d90bf06