镜像自地址
https://github.com/wikimedia/mediawiki-extensions-SearchVue
已同步 2024-05-25 08:42:55 +08:00
Track how long it takes to open a preview
The search platform is working on creating SLI's around various search use cases, including search previews. Add a metric that times how long it takes between initiating and finishing a preview load. Bug: T335499 Change-Id: I79ffae7155ab99180c8cd2d4d7503a1593a5daca
这个提交包含在:
父节点
13aebf0927
当前提交
64821c96a5
|
@ -73,6 +73,7 @@
|
|||
"resources/stores/Query.js",
|
||||
"resources/stores/Root.js",
|
||||
"resources/stores/Dom.js",
|
||||
"resources/stores/Timing.js",
|
||||
{
|
||||
"name": "codex-icons.json",
|
||||
"callback": "MediaWiki\\ResourceLoader\\CodexModule::getIcons",
|
||||
|
|
|
@ -27,7 +27,8 @@ const AppViewMobile = require( './AppViewMobile.vue' ),
|
|||
useEventStore = require( '../stores/Event.js' ),
|
||||
useRootStore = require( '../stores/Root.js' ),
|
||||
useDomStore = require( '../stores/Dom.js' ),
|
||||
useRequestStatusStore = require( '../stores/RequestStatus.js' );
|
||||
useRequestStatusStore = require( '../stores/RequestStatus.js' ),
|
||||
useTimingStore = require( '../stores/Timing.js' );
|
||||
|
||||
// @vue/component
|
||||
module.exports = exports = {
|
||||
|
@ -54,7 +55,8 @@ module.exports = exports = {
|
|||
mapState( useRootStore, [
|
||||
'isMobile',
|
||||
'title',
|
||||
'results'
|
||||
'results',
|
||||
'visible'
|
||||
] ),
|
||||
mapState( useRequestStatusStore, [
|
||||
'loading'
|
||||
|
@ -130,6 +132,8 @@ module.exports = exports = {
|
|||
watch: {
|
||||
title: {
|
||||
handler( title ) {
|
||||
const timingStore = useTimingStore();
|
||||
timingStore.reset();
|
||||
if ( title ) {
|
||||
this.setQueryQuickViewTitle();
|
||||
}
|
||||
|
@ -138,12 +142,22 @@ module.exports = exports = {
|
|||
},
|
||||
loading: {
|
||||
handler( loading ) {
|
||||
// We re-calculate the tabbable element everytime the loading is complete.
|
||||
if ( !loading ) {
|
||||
if ( loading ) {
|
||||
useTimingStore().start();
|
||||
} else {
|
||||
// We re-calculate the tabbable element everytime the loading is complete.
|
||||
this.updateTabbableElements();
|
||||
useTimingStore().complete();
|
||||
}
|
||||
},
|
||||
flush: 'post'
|
||||
},
|
||||
visible: {
|
||||
handler( visible ) {
|
||||
if ( !visible ) {
|
||||
useTimingStore().reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
|
38
resources/stores/Timing.js
普通文件
38
resources/stores/Timing.js
普通文件
|
@ -0,0 +1,38 @@
|
|||
'use strict';
|
||||
|
||||
const Pinia = require( 'pinia' );
|
||||
|
||||
const useTimingStore = Pinia.defineStore( 'timing', {
|
||||
state: () => ( {
|
||||
startTime: 0
|
||||
} ),
|
||||
getters: {
|
||||
},
|
||||
actions: {
|
||||
/**
|
||||
* Marks when loading started
|
||||
*/
|
||||
start() {
|
||||
this.startTime = performance.now();
|
||||
},
|
||||
/**
|
||||
* Reports load timing, if available
|
||||
*/
|
||||
complete() {
|
||||
if ( !this.startTime ) {
|
||||
return;
|
||||
}
|
||||
const took = performance.now() - this.startTime;
|
||||
mw.track( 'timing.SearchVue.LoadPreview', took );
|
||||
this.reset();
|
||||
},
|
||||
/**
|
||||
* Reset the current timing
|
||||
*/
|
||||
reset() {
|
||||
this.startTime = 0;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
module.exports = useTimingStore;
|
正在加载...
在新工单中引用
屏蔽一个用户