Commit 4db398e7 authored by Alexia's avatar Alexia

Merge branch 'cleanup/NavigationTiming' into 'master'

Remove NavigationTiming

See merge request !73
parents 82389526 6876fb7f
.svn
*~
*.kate-swp
.*.swp
node_modules/
[gerrit]
host=gerrit.wikimedia.org
port=29418
project=mediawiki/extensions/NavigationTiming.git
defaultbranch=master
{
"preset": "wikimedia",
"excludeFiles": [
"{node_modules}/**"
]
}
{
"predef": [
"Geo",
"jQuery",
"mediaWiki",
"mediaWikiLoadStart",
"performance",
"chrome"
],
// Enforcing
"bitwise": true,
"eqeqeq": true,
"es3": true,
"freeze": true,
"latedef": true,
"noarg": true,
"nonew": true,
"undef": true,
"unused": true,
// Environment
"browser": true
}
This diff is collapsed.
/*jshint node:true */
module.exports = function ( grunt ) {
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-jscs' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.initConfig( {
jshint: {
options: {
jshintrc: true
},
all: [ '*.js', 'modules/**/*.js' ]
},
jscs: {
all: [ '*.js', 'modules/**/*.js' ]
},
banana: {
all: 'i18n/'
},
jsonlint: {
all: [
'**/*.json',
'!node_modules/**'
]
}
} );
grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] );
grunt.registerTask( 'default', 'test' );
};
<?php
class NavigationTimingHooks {
public static function onBeforePageDisplay ( &$out, &$skin ) {
$out->addModules( 'ext.navigationTiming' );
return true;
}
public static function onResourceLoaderGetConfigVars ( &$vars ) {
global $wgNavigationTimingSamplingFactor;
$vars[ 'wgNavigationTimingSamplingFactor' ] = $wgNavigationTimingSamplingFactor;
return true;
}
}
<?php
/**
* Navigation Timing extension
*
* @file
* @ingroup Extensions
*
* @author Asher Feldman <afeldman@wikimedia.org>
* @author Ori Livneh <ori@wikimedia.org>
* @author Patrick Reilly <preilly@php.net>
*
* @license GPL v2 or later
* @version 1.0
*/
if ( function_exists( 'wfLoadExtension' ) ) {
wfLoadExtension( 'NavigationTiming' );
// Keep i18n globals so mergeMessageFileList.php doesn't break
$wgMessagesDirs['NavigationTiming'] = __DIR__ . '/i18n';
/*wfWarn(
'Deprecated PHP entry point used for NavigationTiming extension. ' .
'Please use wfLoadExtension instead, see ' .
'https://www.mediawiki.org/wiki/Extension_registration for more details.'
);*/
return;
} else {
die( 'This version of the NavigationTiming extension requires MediaWiki 1.25+' );
}
\ No newline at end of file
NavigationTiming
----------------
NavigationTiming is a MediaWiki extension for logging perceived latency
measurements, exposed by browsers as part of the proposed Navigation
Timing API.
Sample configuration:
```
require_once "$IP/extensions/EventLogging/EventLogging.php"; // dependency
require_once "$IP/extensions/NavigationTiming/NavigationTiming.php";
$wgNavigationTimingSamplingFactor = 10000; // log 1:10,000 requests
```
For more information, see the extension's documentation on MediaWiki.org:
https://www.mediawiki.org/wiki/Extension:NavigationTiming
{
"name": "NavigationTiming",
"version": "1.0",
"author": [
"Asher Feldman",
"Ori Livneh",
"Patrick Reilly"
],
"url": "https://www.mediawiki.org/wiki/Extension:NavigationTiming",
"descriptionmsg": "navigationtiming-desc",
"license-name": "GPL-2.0+",
"type": "other",
"MessagesDirs": {
"NavigationTiming": [
"i18n"
]
},
"AutoloadClasses": {
"NavigationTimingHooks": "NavigationTiming.hooks.php"
},
"ResourceModules": {
"ext.navigationTiming": {
"scripts": [
"ext.navigationTiming.js"
],
"dependencies": [
"schema.NavigationTiming",
"schema.SaveTiming",
"json",
"jquery.cookie"
],
"targets": [
"desktop",
"mobile"
]
}
},
"ResourceFileModulePaths": {
"localBasePath": "modules",
"remoteExtPath": "NavigationTiming/modules"
},
"Hooks": {
"BeforePageDisplay": [
"NavigationTimingHooks::onBeforePageDisplay"
],
"ResourceLoaderGetConfigVars": [
"NavigationTimingHooks::onResourceLoaderGetConfigVars"
]
},
"EventLoggingSchemas": {
"NavigationTiming": 15485142,
"SaveTiming": 15396492
},
"config": {
"NavigationTimingSamplingFactor": false
},
"manifest_version": 1
}
{
"@metadata": {
"authors": [
"Xuacu"
]
},
"navigationtiming-desc": "Amiesta'l rexistru de midíes de latencia nel llau del cliente"
}
{
"@metadata": {
"authors": [
"Red Winged Duck"
]
},
"navigationtiming-desc": "Дадае запіс вымярэньняў затрымак на баку кліенту"
}
{
"@metadata": {
"authors": [
"Умар"
]
},
"navigationtiming-desc": "ТӀетуху дустаран протокол клиентан хьедалар"
}
{
"@metadata": {
"authors": [
"Mormegil"
]
},
"navigationtiming-desc": "Poskytuje zaznamenávání zpoždění na klientské straně"
}
{
"@metadata": {
"authors": [
"Metalhead64",
"Purodha"
]
},
"navigationtiming-desc": "Fügt dem Wiki die Protokollierung von gemessenen clientseitigen Zeitverzögerungen hinzu"
}
{
"@metadata": {
"authors": [
"Patrick Reilly"
]
},
"navigationtiming-desc": "Adds client-side latency measurements logging"
}
\ No newline at end of file
{
"@metadata": {
"authors": [
"Armin1392"
]
},
"navigationtiming-desc": "افزودن اندازه‌گیری‌های سمت-مشتری پنهانی ورود"
}
{
"@metadata": {
"authors": [
"Gomoko"
]
},
"navigationtiming-desc": "Ajouter une trace des mesures de latence côté client"
}
{
"@metadata": {
"authors": [
"Toliño"
]
},
"navigationtiming-desc": "Engade un rexistro das medidas de latencia"
}
{
"@metadata": {
"authors": [
"Amire80"
]
},
"navigationtiming-desc": "הוספת רישום יומן למדידות של זמן המתנה בצד הלקוח"
}
{
"@metadata": {
"authors": [
"Michawiki"
]
},
"navigationtiming-desc": "Přidawa protokolowanje měrjenjow ze strony klienta a z časowym zastatkom"
}
{
"@metadata": {
"authors": [
"Lam-ang"
]
},
"navigationtiming-desc": "Aginayon ti panangilista kadagiti panagrukod ti pannakamalmeng ti bangir ti kliente"
}
{
"@metadata": {
"authors": [
"Beta16"
]
},
"navigationtiming-desc": "Aggiunge la registrazione delle misurazioni per la latenza lato client"
}
{
"@metadata": {
"authors": [
"Shirayuki"
]
},
"navigationtiming-desc": "クライアント側での待機時間を測定して記録する機能を追加する"
}
{
"@metadata": {
"authors": [
"아라"
]
},
"navigationtiming-desc": "클라이언트 측 대기 시간을 측정하고 기록하는 기능을 추가합니다"
}
{
"@metadata": {
"authors": [
"Purodha"
]
},
"navigationtiming-desc": "Deiht et Faßhallde vun jemäße Latänze op der Sigg vum Aanwänder en et Wikki."
}
{
"@metadata": {
"authors": [
"Bjankuloski06"
]
},
"navigationtiming-desc": "Додава заведување на измерени задоцнувања од клиентска страна"
}
{
"@metadata": {
"authors": [
"Praveenp"
]
},
"navigationtiming-desc": "ക്ലയന്റ്-ഭാഗത്ത് ഉണ്ടാകുന്ന വൈകലുകൾ ശേഖരിക്കൽ കൂട്ടിച്ചേർക്കുന്നു."
}
{
"@metadata": {
"authors": [
"Anakmalaysia"
]
},
"navigationtiming-desc": "Menambahkan pencatatan ukuran kependaman sebelah klien"
}
{
"@metadata": {
"authors": [
"Konovalov",
"Siebrand"
]
},
"navigationtiming-desc": "Maakt het vastleggen van tijdsmetingen voor clientbewerkingen mogelijk"
}
{
"@metadata": {
"authors": [
"Cedric31"
]
},
"navigationtiming-desc": "Apondre una traça de las mesuras de laténcia costat client"
}
{
"@metadata": {
"authors": [
"Araceletorres"
]
},
"navigationtiming-desc": "Adiciona registro de medidas de latência do cliente"
}
{
"@metadata": {
"authors": [
"Asher Feldman",
"Patrick Reilly",
"Shirayuki",
"Umherirrender"
]
},
"navigationtiming-desc": "{{desc|name=Navigation Timing|url=https://www.mediawiki.org/wiki/Extension:NavigationTiming}}"
}
{
"@metadata": {
"authors": [
"Joetaras"
]
},
"navigationtiming-desc": "Aggiunge 'n'archivihe de le mesure de latenze late cliente"
}
{
"@metadata": {
"authors": [
"Okras"
]
},
"navigationtiming-desc": "Добавляет протоколирование измерения задержки на стороне клиента"
}
{
"@metadata": {
"authors": [
"John Reid"
]
},
"navigationtiming-desc": "Eiks client-side latencie measurements loggin"
}
{
"@metadata": {
"authors": [
"Lokal Profil"
]
},
"navigationtiming-desc": "Lägger till loggning för latens mätningar på klientsidan"
}
{
"@metadata": {
"authors": [
"AnakngAraw"
]
},
"navigationtiming-desc": "Nagdaragdag ng pagtatala ng mga sukat ng kawalan ng galaw sa kinaroroonan ng kliyente"
}
{
"@metadata": {
"authors": [
"Andriykopanytsia"
]
},
"navigationtiming-desc": "Додає журналювання клієнтської затримки вимірювань"
}
{
"@metadata": {
"authors": [
"Minh Nguyen"
]
},
"navigationtiming-desc": "Thêm nhật trình đo độ trễ trên trình khách"
}
{
"@metadata": {
"authors": [
"Ktchankt"
]
},
"navigationtiming-desc": "加客戶端嘅延遲測量紀錄"
}
{
"@metadata": {
"authors": [
"Yfdyh000"
]
},
"navigationtiming-desc": "添加客户端的延迟测量记录"
}
{
"@metadata": {
"authors": [
"Justincheng12345",
"Cwlin0416"
]
},
"navigationtiming-desc": "新增客戶端的延遲測量記錄"
}
/*!
* JavaScript module for logging client-side latency measurements.
* @see https://mediawiki.org/wiki/Extension:NavigationTiming
*
* @licence GNU GPL v2 or later
* @author Ori Livneh <ori@wikimedia.org>
*/
( function ( mw, $ ) {
'use strict';
var timing, navigation, mediaWikiLoadEnd,
TYPE_NAVIGATE = 0;
if ( window.performance ) {
timing = performance.timing;
navigation = performance.navigation;
}
function inSample() {
var factor = mw.config.get( 'wgNavigationTimingSamplingFactor' );
if ( !$.isNumeric( factor ) || factor < 1 ) {
return false;
}
return Math.floor( Math.random() * factor ) === 0;
}
function getDevicePixelRatio() {
if ( window.screen && screen.logicalXDPI ) {
// IE10 mobile; see <http://stackoverflow.com/q/16383503/582542>
return screen.deviceXDPI / screen.logicalXDPI;
} else if ( window.devicePixelRatio ) {
return window.devicePixelRatio;
} else {
return 1;
}
}
/**
* Check if the order of Navigation Timing marker values conforms
* to the specification.
*
* Markers may be undefined or zero if they are not implemented or not
* applicable to the current page. Markers which have a value must be
* in ascending order.
*
* @return {boolean}
*/
function isCompliant() {
var sequences, markers, curr, prev;
if ( !timing ) {
return false;
}
sequences = [ [
'navigationStart',
'fetchStart',
'domainLookupStart',
'domainLookupEnd',
'connectStart',
'connectEnd',
'requestStart',
'responseStart',
'responseEnd',
'domInteractive',
'domContentLoadedEventStart',
'domContentLoadedEventEnd',
'loadEventStart',
'loadEventEnd'
], [
'secureConnectionStart',
'requestStart'
], [
'fetchStart',
'domLoading'
], [
'domContentLoadedEventEnd',
'domComplete'
] ];
while ( sequences.length ) {
markers = sequences.shift();
prev = null;
while ( markers.length ) {
curr = timing[ markers.shift() ];
if ( curr ) {
if ( curr < prev ) {
return false;
}
prev = curr;
}
}
}
return true;
}
function getNavTiming() {
var navStart, timingData, chromeLoadTimes;
// Only record data on TYPE_NAVIGATE (e.g. ignore TYPE_RELOAD)
// Only record data if implementation is compliant
if ( !navigation || navigation.type !== TYPE_NAVIGATE || !isCompliant() ) {
return {};
}
// Workaround for IE 9 bug: IE 9 sets a default value of zero for
// navigationStart, rather than use fetchStart as the specification
// requires. See <https://bugzilla.wikimedia.org/46474> for details.
navStart = timing.navigationStart || timing.fetchStart;
timingData = {};
$.each( [
'connectEnd',
'connectStart',
'domComplete',
'domInteractive',
'fetchStart',
'loadEventEnd',
'loadEventStart',
'requestStart',
'responseEnd',
'responseStart',
'secureConnectionStart'
], function ( i, marker ) {
var measure = timing[ marker ] - navStart;
if ( $.isNumeric( measure ) && measure > 0 ) {
timingData[ marker ] = measure;
}
} );
if ( timing.domainLookupStart ) {
timingData.dnsLookup = timing.domainLookupEnd - timing.domainLookupStart;
}
if ( timing.redirectStart ) {
timingData.redirectCount = performance.navigation.redirectCount;
timingData.redirecting = timing.redirectEnd - timing.redirectStart;
}
if ( timing.msFirstPaint > navStart ) {
timingData.firstPaint = timing.msFirstPaint - navStart;
} else if ( window.chrome && $.isFunction( chrome.loadTimes ) ) {
chromeLoadTimes = chrome.loadTimes();
if ( chromeLoadTimes.firstPaintTime > chromeLoadTimes.startLoadTime ) {
timingData.firstPaint = Math.round( 1000 *
( chromeLoadTimes.firstPaintTime - chromeLoadTimes.startLoadTime ) );
}
}
return timingData;
}
function emitNavigationTiming() {
var event = {
isHttp2: /H2/.test( $.cookie( 'CP' ) ),
isHiDPI: getDevicePixelRatio() > 1,
isAnon: mw.config.get( 'wgUserId' ) === null,
mediaWikiVersion: mw.config.get( 'wgVersion' )
},
page = {
pageId: mw.config.get( 'wgArticleId' ),
namespaceId: mw.config.get( 'wgNamespaceNumber' ),
revId: mw.config.get( 'wgCurRevisionId' ),
action: mw.config.get( 'wgAction' ) // view, submit, etc.
},
isSpecialPage = !!mw.config.get( 'wgCanonicalSpecialPageName' ),
mobileMode = mw.config.get( 'wgMFMode' );
if ( mw.config.get( 'wgMFLazyLoadImages' ) ) {
event.lazyLoadImages = 'A';
}
if ( window.mediaWikiLoadStart ) {
event.mediaWikiLoadComplete = Math.round( mediaWikiLoadEnd - mediaWikiLoadStart );
}
if ( window.Geo ) {
if ( typeof Geo.country === 'string' ) {
event.originCountry = Geo.country;
}
if ( typeof Geo.region === 'string' ) {
event.originRegion = Geo.region;
}
}
// Omit page information for special pages: they don't have real page
// IDs or revisions. (They appear as 0 to client-side code.)
if ( !isSpecialPage ) {
$.extend( event, page );