| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
ve.init.mw.ArticleTargetEvents = function VeInitMwArticleTargetEvents( target ) { |
| 17 |
this.target = target; |
| 18 |
this.timings = { saveRetries: 0 }; |
| 19 |
|
| 20 |
this.target.connect( this, { |
| 21 |
saveWorkflowBegin: 'onSaveWorkflowBegin', |
| 22 |
saveWorkflowEnd: 'onSaveWorkflowEnd', |
| 23 |
saveInitiated: 'onSaveInitiated', |
| 24 |
save: 'onSaveComplete', |
| 25 |
saveReview: 'onSaveReview', |
| 26 |
saveError: 'trackSaveError', |
| 27 |
surfaceReady: 'onSurfaceReady', |
| 28 |
showChanges: 'onShowChanges', |
| 29 |
showChangesError: 'onShowChangesError', |
| 30 |
noChanges: 'onNoChanges', |
| 31 |
serializeComplete: 'onSerializeComplete', |
| 32 |
serializeError: 'onSerializeError' |
| 33 |
} ); |
| 34 |
}; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
ve.init.mw.ArticleTargetEvents.prototype.track = function ( topic, data ) { |
| 43 |
ve.track( topic, ve.extendObject( { |
| 44 |
mode: this.target.surface ? this.target.surface.getMode() : this.target.getDefaultMode() |
| 45 |
}, data ) ); |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
ve.init.mw.ArticleTargetEvents.prototype.trackTiming = function ( topic, data ) { |
| 55 |
if ( topic.indexOf( 'performance.system.serializeforcache' ) === 0 ) { |
| 56 |
|
| 57 |
this.timings.serializeForCache = data.duration; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
if ( topic === 'performance.user.saveError' ) { |
| 62 |
topic = topic + '.' + data.type; |
| 63 |
} |
| 64 |
|
| 65 |
topic = 'timing.ve.' + this.target.constructor.static.trackingName + '.' + topic; |
| 66 |
|
| 67 |
mw.track( topic, data.duration ); |
| 68 |
}; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
ve.init.mw.ArticleTargetEvents.prototype.onFirstTransaction = function () { |
| 74 |
this.track( 'editAttemptStep', { action: 'firstChange' } ); |
| 75 |
|
| 76 |
this.trackTiming( 'behavior.firstTransaction', { |
| 77 |
duration: ve.now() - this.timings.surfaceReady |
| 78 |
} ); |
| 79 |
}; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
ve.init.mw.ArticleTargetEvents.prototype.onSaveWorkflowBegin = function () { |
| 85 |
this.timings.saveWorkflowBegin = ve.now(); |
| 86 |
this.trackTiming( 'behavior.lastTransactionTillSaveDialogOpen', { |
| 87 |
duration: this.timings.saveWorkflowBegin - this.timings.lastTransaction |
| 88 |
} ); |
| 89 |
this.track( 'editAttemptStep', { action: 'saveIntent' } ); |
| 90 |
}; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
ve.init.mw.ArticleTargetEvents.prototype.onSaveWorkflowEnd = function () { |
| 96 |
this.trackTiming( 'behavior.saveDialogClose', { duration: ve.now() - this.timings.saveWorkflowBegin } ); |
| 97 |
this.timings.saveWorkflowBegin = null; |
| 98 |
}; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
ve.init.mw.ArticleTargetEvents.prototype.onSaveInitiated = function () { |
| 104 |
this.timings.saveInitiated = ve.now(); |
| 105 |
this.timings.saveRetries++; |
| 106 |
this.trackTiming( 'behavior.saveDialogOpenTillSave', { |
| 107 |
duration: this.timings.saveInitiated - this.timings.saveWorkflowBegin |
| 108 |
} ); |
| 109 |
this.track( 'editAttemptStep', { action: 'saveAttempt' } ); |
| 110 |
}; |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
ve.init.mw.ArticleTargetEvents.prototype.onSaveComplete = function ( data ) { |
| 118 |
this.trackTiming( 'performance.user.saveComplete', { duration: ve.now() - this.timings.saveInitiated } ); |
| 119 |
this.timings.saveRetries = 0; |
| 120 |
this.track( 'editAttemptStep', { |
| 121 |
action: 'saveSuccess', |
| 122 |
timing: ve.now() - this.timings.saveInitiated + ( this.timings.serializeForCache || 0 ), |
| 123 |
|
| 124 |
revision_id: data.newrevid |
| 125 |
} ); |
| 126 |
}; |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
ve.init.mw.ArticleTargetEvents.prototype.trackSaveError = function ( code ) { |
| 134 |
|
| 135 |
const typeMap = { |
| 136 |
badtoken: 'userBadToken', |
| 137 |
assertanonfailed: 'userNewUser', |
| 138 |
assertuserfailed: 'userNewUser', |
| 139 |
assertnameduserfailed: 'userNewUser', |
| 140 |
'abusefilter-disallowed': 'extensionAbuseFilter', |
| 141 |
'abusefilter-warning': 'extensionAbuseFilter', |
| 142 |
captcha: 'extensionCaptcha', |
| 143 |
spamblacklist: 'extensionSpamBlacklist', |
| 144 |
'titleblacklist-forbidden': 'extensionTitleBlacklist', |
| 145 |
pagedeleted: 'editPageDeleted', |
| 146 |
editconflict: 'editConflict' |
| 147 |
}, |
| 148 |
|
| 149 |
|
| 150 |
specialTypes = [ 'editconflict' ]; |
| 151 |
|
| 152 |
let key = 'performance.user.saveError'; |
| 153 |
if ( specialTypes.indexOf( code ) !== -1 ) { |
| 154 |
key += '.' + code; |
| 155 |
} |
| 156 |
this.trackTiming( key, { |
| 157 |
duration: ve.now() - this.timings.saveInitiated, |
| 158 |
type: code |
| 159 |
} ); |
| 160 |
|
| 161 |
this.track( 'editAttemptStep', { |
| 162 |
action: 'saveFailure', |
| 163 |
message: code, |
| 164 |
type: typeMap[ code ] || 'responseUnknown', |
| 165 |
timing: ve.now() - this.timings.saveInitiated + ( this.timings.serializeForCache || 0 ) |
| 166 |
} ); |
| 167 |
}; |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
ve.init.mw.ArticleTargetEvents.prototype.trackActivationStart = function ( startTime ) { |
| 175 |
this.timings.activationStart = startTime || ve.now(); |
| 176 |
}; |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
ve.init.mw.ArticleTargetEvents.prototype.trackActivationComplete = function () { |
| 182 |
this.trackTiming( 'performance.system.activation', { duration: ve.now() - this.timings.activationStart } ); |
| 183 |
}; |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
ve.init.mw.ArticleTargetEvents.prototype.recordLastTransactionTime = function () { |
| 189 |
this.timings.lastTransaction = ve.now(); |
| 190 |
}; |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
ve.init.mw.ArticleTargetEvents.prototype.onSaveReview = function () { |
| 196 |
this.timings.saveReview = ve.now(); |
| 197 |
this.trackTiming( 'behavior.saveDialogOpenTillReview', { |
| 198 |
duration: this.timings.saveReview - this.timings.saveWorkflowBegin |
| 199 |
} ); |
| 200 |
}; |
| 201 |
|
| 202 |
ve.init.mw.ArticleTargetEvents.prototype.onSurfaceReady = function () { |
| 203 |
this.timings.surfaceReady = ve.now(); |
| 204 |
this.target.surface.getModel().getDocument().connect( this, { |
| 205 |
transact: 'recordLastTransactionTime' |
| 206 |
} ).once( 'transact', this.onFirstTransaction.bind( this ) ); |
| 207 |
}; |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
ve.init.mw.ArticleTargetEvents.prototype.onShowChanges = function () { |
| 213 |
this.trackTiming( 'performance.user.reviewComplete', { duration: ve.now() - this.timings.saveReview } ); |
| 214 |
}; |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
ve.init.mw.ArticleTargetEvents.prototype.onShowChangesError = function () { |
| 220 |
this.trackTiming( 'performance.user.reviewError', { duration: ve.now() - this.timings.saveReview } ); |
| 221 |
}; |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
ve.init.mw.ArticleTargetEvents.prototype.onNoChanges = function () { |
| 227 |
this.trackTiming( 'performance.user.reviewComplete', { duration: ve.now() - this.timings.saveReview } ); |
| 228 |
}; |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
ve.init.mw.ArticleTargetEvents.prototype.onSerializeComplete = function () { |
| 234 |
this.trackTiming( 'performance.user.reviewComplete', { duration: ve.now() - this.timings.saveReview } ); |
| 235 |
}; |
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
ve.init.mw.ArticleTargetEvents.prototype.onSerializeError = function () { |
| 241 |
if ( this.timings.saveWorkflowBegin ) { |
| 242 |
|
| 243 |
|
| 244 |
this.trackTiming( 'performance.user.reviewError', { duration: ve.now() - this.timings.saveReview } ); |
| 245 |
} |
| 246 |
}; |