Skip to content

Commit 96dd29a

Browse files
Cyndysgimeno
Cyndy
authored andcommitted
metrics: Migrate GrowthExperiments client code to statslib
Bug: T382003 Change-Id: I1f3229a9cef1ecf451085eb17709c00cf0748872
1 parent 2e69b50 commit 96dd29a

File tree

6 files changed

+90
-15
lines changed

6 files changed

+90
-15
lines changed

bundlesize.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
33
"resourceModule": "ext.growthExperiments.SuggestedEditSession",
4-
"maxSize": "4.5 kB"
4+
"maxSize": "4.7 kB"
55
}
66
]

modules/ext.growthExperiments.DataStore/GrowthTasksApi.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,30 @@
486486
};
487487

488488
/**
489-
* Log time spent since startTime to Statsd.
489+
* Log time spent since startTime to Statsd and Prometheus.
490490
*
491491
* @param {string} name Name of the thing (e.g. method call) that's timed.
492492
* @param {number} startTime Start timestamp, e.g. from mw.now().
493493
* @param {string} [contextOverride] Overrides the context provided in the constructor.
494494
* @private
495495
*/
496496
GrowthTasksApi.prototype.logTiming = function ( name, startTime, contextOverride ) {
497+
const duration = mw.now() - startTime;
498+
const platform = this.isMobile ? 'mobile' : 'desktop';
497499
mw.track(
498500
'timing.growthExperiments.specialHomepage.growthTasksApi.' + name + '.' +
499-
( contextOverride || this.logContext ) + '.' + ( this.isMobile ? 'mobile' : 'desktop' ),
500-
mw.now() - startTime
501+
( contextOverride || this.logContext ) + '.' + platform, duration );
502+
503+
mw.track(
504+
'stats.mediawiki_GrowthExperiments_special_homepage_seconds',
505+
duration,
506+
{
507+
module: 'growthTasksApi',
508+
operation: name,
509+
context: contextOverride || this.logContext,
510+
platform: platform,
511+
wiki: mw.config.get( 'wgDBname' )
512+
}
501513
);
502514
};
503515

modules/ext.growthExperiments.Homepage.Impact/App.vue

+11-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,17 @@ module.exports = exports = {
7676
},
7777
methods: {
7878
impactMounted: function () {
79-
mw.track( 'timing.growthExperiments.newImpact.' + inject( 'RENDER_MODE' ) + '.mounted', mw.now() - startTime );
79+
const duration = mw.now() - startTime;
80+
mw.track( 'timing.growthExperiments.newImpact.' + inject( 'RENDER_MODE' ) + '.mounted', duration );
81+
mw.track(
82+
'stats.mediawiki_GrowthExperiments_homepage_impact_mounted_seconds',
83+
duration,
84+
{
85+
// eslint-disable-next-line camelcase
86+
render_mode: inject( 'RENDER_MODE' ),
87+
wiki: mw.config.get( 'wgDBname' )
88+
}
89+
);
8090
}
8191
}
8292
};

modules/ext.growthExperiments.Homepage.SuggestedEdits/index.js

+21-8
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,39 @@
6565
}
6666

6767
suggestedEditsModule.updateControls();
68+
69+
const clientSideLoadDuration = mw.now() - initTime, // Time since module init
70+
serverDuration = mw.now() - mw.config.get( 'GEHomepageStartTime' );
6871
// Track the TTI on client-side.
6972
mw.track(
7073
'timing.growthExperiments.specialHomepage.modules.suggestedEditsTimeToInteractive.' +
7174
( OO.ui.isMobile() ? 'mobile' : 'desktop' ),
72-
mw.now() - initTime
75+
clientSideLoadDuration
76+
);
77+
mw.track(
78+
'stats.mediawiki_GrowthExperiments_suggested_edits_tti_seconds',
79+
clientSideLoadDuration,
80+
{
81+
platform: OO.ui.isMobile() ? 'mobile' : 'desktop',
82+
// eslint-disable-next-line camelcase
83+
includes_server_response_time: false
84+
}
7385
);
7486
// Track the server side render start time (first line in SpecialHomepage#execute()) to
7587
// TTI on client-side.
7688
mw.track(
7789
'timing.growthExperiments.specialHomepage.modules.suggestedEditsTimeToInteractive.serverSideStartInclusive.' +
7890
( OO.ui.isMobile() ? 'mobile' : 'desktop' ),
79-
mw.now() - mw.config.get( 'GEHomepageStartTime' )
91+
serverDuration
8092
);
81-
// FIXME: suggestedEditsLoadingComplete could probably be removed as it is now a duplicate of
82-
// suggestedEditsTimeToInteractive. We can leave it for now in case we decide to rollback this change
83-
// or make other adjustments in loading behavior.
8493
mw.track(
85-
'timing.growthExperiments.specialHomepage.modules.suggestedEditsLoadingComplete.' +
86-
( OO.ui.isMobile() ? 'mobile' : 'desktop' ),
87-
mw.now() - initTime
94+
'stats.mediawiki_GrowthExperiments_suggested_edits_server_tti_seconds',
95+
serverDuration,
96+
{
97+
platform: OO.ui.isMobile() ? 'mobile' : 'desktop',
98+
// eslint-disable-next-line camelcase
99+
includes_server_response_time: true
100+
}
88101
);
89102
return $.Deferred().resolve();
90103
}

modules/ext.growthExperiments.SuggestedEditSession/index.js

+26-2
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,22 @@
620620
if ( !this.startTime || !this.shouldTrackPerformance ) {
621621
return;
622622
}
623+
const duration = window.performance.now() - this.startTime;
623624
mw.track(
624625
'timing.growthExperiments.suggestedEdits.taskEditorReady.' + this.taskType +
625626
( OO.ui.isMobile() ? '.mobile' : '.desktop' ),
626-
window.performance.now() - this.startTime
627+
duration
628+
);
629+
mw.track(
630+
'stats.mediawiki_GrowthExperiments_task_editor_ready_seconds',
631+
duration,
632+
{
633+
// eslint-disable-next-line camelcase
634+
task_type: this.taskType,
635+
platform: ( OO.ui.isMobile() ? 'mobile' : 'desktop' ),
636+
operation: 'editor_shown',
637+
wiki: mw.config.get( 'wgDBname' )
638+
}
627639
);
628640
};
629641

@@ -639,10 +651,22 @@
639651
if ( this.shouldOpenArticleInEditMode || !this.startTime || !this.shouldTrackPerformance ) {
640652
return;
641653
}
654+
const guidanceDisplayDuration = window.performance.now() - this.startTime;
642655
mw.track(
643656
'timing.growthExperiments.suggestedEdits.guidanceShown.' + this.taskType +
644657
( OO.ui.isMobile() ? '.mobile' : '.desktop' ),
645-
window.performance.now() - this.startTime
658+
guidanceDisplayDuration
659+
);
660+
mw.track(
661+
'stats.mediawiki_GrowthExperiments_suggested_edits_session_seconds',
662+
guidanceDisplayDuration,
663+
{
664+
// eslint-disable-next-line camelcase
665+
task_type: this.taskType,
666+
platform: ( OO.ui.isMobile() ? 'mobile' : 'desktop' ),
667+
operation: 'guidance_shown',
668+
wiki: mw.config.get( 'wgDBname' )
669+
}
646670
);
647671
};
648672

modules/homepage.init.js

+16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@
2222
'timing.growthExperiments.specialHomepage.navigationDuration',
2323
navigationEntries[ 0 ].duration
2424
);
25+
mw.track(
26+
'stats.mediawiki_GrowthExperiments_navigation_duration_seconds',
27+
navigationEntries[ 0 ].duration,
28+
{
29+
// eslint-disable-next-line camelcase
30+
navigation_type: navigationEntries[ 0 ].type,
31+
wiki: mw.config.get( 'wgDBname' )
32+
}
33+
);
2534
mw.track(
2635
// Using 'timing' for transfer size sounds conceptually wrong, but we want
2736
// the various features that statsd timing gives us (see
@@ -35,6 +44,13 @@
3544
'timing.growthExperiments.specialHomepage.paintStartTime',
3645
performanceEntries[ 0 ].startTime
3746
);
47+
mw.track(
48+
'stats.mediawiki_GrowthExperiments_paint_start_seconds',
49+
performanceEntries[ 0 ].startTime,
50+
{
51+
platform: OO.ui.isMobile() ? 'mobile' : 'desktop'
52+
}
53+
);
3854
}
3955
}
4056

0 commit comments

Comments
 (0)