Inform anonymous A/B test by tracking time from navigationStart
This will inform us on the approach taken in I315ea30b88e43f3df29b0a0b37907272ec77d0a7 Additional change: Flesh out TypeScript with eventLogging interface Bug: T275807 Change-Id: I9789cd1dfab5181fa093bce46c5c9b0d338339f5
This commit is contained in:
parent
c84d5d38d5
commit
b183ac3bf3
|
@ -9,9 +9,16 @@ interface MwUri {
|
|||
toString(): string;
|
||||
}
|
||||
|
||||
interface MwEventLog {
|
||||
eventInSample( population: Object ): () => boolean;
|
||||
inSample( num: Number ): () => boolean;
|
||||
logEvent( schema: string, data: Object ): () => void;
|
||||
}
|
||||
|
||||
type UriConstructor = new( uri: string ) => MwUri;
|
||||
|
||||
interface MediaWiki {
|
||||
eventLog?: MwEventLog,
|
||||
util: {
|
||||
/**
|
||||
* @param {string} id of portlet
|
||||
|
@ -80,6 +87,11 @@ interface MediaWiki {
|
|||
*/
|
||||
msg( messageName: string|null ): string;
|
||||
|
||||
/**
|
||||
* Get current timestamp
|
||||
*/
|
||||
now(): number,
|
||||
|
||||
/**
|
||||
* Track an analytic event.
|
||||
*
|
||||
|
|
|
@ -42,6 +42,27 @@ function enableCssAnimations( document ) {
|
|||
* @return {void}
|
||||
*/
|
||||
function main( window ) {
|
||||
var now = mw.now();
|
||||
// This is the earliest time we can run JS for users (and bucket anonymous
|
||||
// users for A/B tests).
|
||||
// Where the browser supports it, for a 10% sample of users
|
||||
// we record a value to give us a sense of the expected delay in running A/B tests or
|
||||
// disabling JS features. This will inform us on various things including what to expect
|
||||
// with regards to delay while running A/B tests to anonymous users.
|
||||
// When EventLogging is not available this will reject.
|
||||
// This code can be removed by the end of the Desktop improvements project.
|
||||
// https://www.mediawiki.org/wiki/Desktop_improvements
|
||||
mw.loader.using( 'ext.eventLogging' ).then( function () {
|
||||
if (
|
||||
mw.eventLog &&
|
||||
mw.eventLog.eventInSample( 100 /* 1 in 100 */ ) &&
|
||||
window.performance &&
|
||||
window.performance.timing &&
|
||||
window.performance.timing.navigationStart
|
||||
) {
|
||||
mw.track( 'timing.Vector.ready', now - window.performance.timing.navigationStart ); // milliseconds
|
||||
}
|
||||
} );
|
||||
enableCssAnimations( window.document );
|
||||
collapsibleTabs.init();
|
||||
sidebar.init( window );
|
||||
|
|
Loading…
Reference in New Issue