HomePhabricator

ext.navigationTiming: Only load eventlogging when needed

Authored by Krinkle on Mar 14 2017, 6:41 PM.

Description

ext.navigationTiming: Only load eventlogging when needed

Previously the schema modules (and their eventlogging client dependency)
were unconditionally loaded on all page views. This is an anti-pattern
because most metrics happen on user interaction, not on all page views.

In case of Navigation Timing, the metric is the page load itself,
however we still have sampling, so we should lazy-load here as well.

Fix by removing the dependencies and instead using the standard pattern
of mw.loader.using() and then calling mw.eventLog.logEvent().

As optimization, check inSample() early and preload the required
modules.

Bug: T159911
Change-Id: I00495ab8cacc2b9cc67ff8376bc1e047e561818b