Log sectionNumbers in PageIssues schema
Adds logging for the sectionNumbers field in the PageIssues schema. Additional changes: * createBanner now requires section number to be a string - this ensures consistency with how these are used. * fix a bug which meant createBanner was being called with undefined section number (due to table of contents) * Fix some indents in some JSDoc blocks * Change parameter in function signature from mixed type (int or string) to explicit string * update schema number Depends-On: Ia2696b86c6855d7b46a3f668585377d106d7af23 Bug: T202098 Change-Id: I20511a77258ea245f3d6fe93ade238e5df397a71
This commit is contained in:
parent
ee36bcfccf
commit
ae19031f8e
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
this.issues = issues;
|
this.issues = issues;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
this.section = section;
|
||||||
|
|
||||||
options = {};
|
options = {};
|
||||||
options.issues = issues;
|
options.issues = issues;
|
||||||
|
@ -68,7 +69,8 @@
|
||||||
onExit: function () {
|
onExit: function () {
|
||||||
this.logger.log( {
|
this.logger.log( {
|
||||||
action: 'modalClose',
|
action: 'modalClose',
|
||||||
issuesSeverity: this.issues.map( issueSummaryToSeverity )
|
issuesSeverity: this.issues.map( issueSummaryToSeverity ),
|
||||||
|
sectionNumbers: [ this.section ]
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -85,7 +87,8 @@
|
||||||
var severity = parseSeverity( this.$( ev.target ) );
|
var severity = parseSeverity( this.$( ev.target ) );
|
||||||
this.logger.log( {
|
this.logger.log( {
|
||||||
action: 'modalInternalClicked',
|
action: 'modalInternalClicked',
|
||||||
issuesSeverity: [ severity ]
|
issuesSeverity: [ severity ],
|
||||||
|
sectionNumbers: [ this.section ]
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -100,7 +103,8 @@
|
||||||
var severity = parseSeverity( this.$( ev.target ) );
|
var severity = parseSeverity( this.$( ev.target ) );
|
||||||
this.logger.log( {
|
this.logger.log( {
|
||||||
action: 'modalEditClicked',
|
action: 'modalEditClicked',
|
||||||
issuesSeverity: [ severity ]
|
issuesSeverity: [ severity ],
|
||||||
|
sectionNumbers: [ this.section ]
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
* will link section numbers to issues.
|
* will link section numbers to issues.
|
||||||
* @param {Page} page to search for page issues inside
|
* @param {Page} page to search for page issues inside
|
||||||
* @param {string} labelText what the label of the page issues banner should say
|
* @param {string} labelText what the label of the page issues banner should say
|
||||||
* @param {number|string} section that the banner and its issues belong to.
|
* @param {string} section that the banner and its issues belong to.
|
||||||
* If string KEYWORD_ALL_SECTIONS banner should apply to entire page.
|
* If string KEYWORD_ALL_SECTIONS banner should apply to entire page.
|
||||||
* @param {boolean} inline - if true the first ambox in the section will become the entry point for the issues overlay
|
* @param {boolean} inline - if true the first ambox in the section will become the entry point for the issues overlay
|
||||||
* and if false, a link will be rendered under the heading.
|
* and if false, a link will be rendered under the heading.
|
||||||
|
@ -161,20 +161,26 @@
|
||||||
var pageIssue = pageIssuesParser.parse( this );
|
var pageIssue = pageIssuesParser.parse( this );
|
||||||
pageIssuesLogger.log( {
|
pageIssuesLogger.log( {
|
||||||
action: 'issueClicked',
|
action: 'issueClicked',
|
||||||
issuesSeverity: [ pageIssue.severity ]
|
issuesSeverity: [ pageIssue.severity ],
|
||||||
|
sectionNumbers: [ section ]
|
||||||
} );
|
} );
|
||||||
overlayManager.router.navigate( issueUrl );
|
overlayManager.router.navigate( issueUrl );
|
||||||
return false;
|
return false;
|
||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
$link = createLinkElement( labelText );
|
$link = createLinkElement( labelText );
|
||||||
// In group B, we link to all issues no matter where the banner is.
|
// In group A, we link to all issues no matter where the banner is.
|
||||||
$link.attr( 'href', '#/issues/' + KEYWORD_ALL_SECTIONS );
|
$link.attr( 'href', '#/issues/' + KEYWORD_ALL_SECTIONS );
|
||||||
$link.click( function () {
|
$link.click( function () {
|
||||||
pageIssuesLogger.log( {
|
pageIssuesLogger.log( {
|
||||||
action: 'issueClicked',
|
action: 'issueClicked',
|
||||||
// empty array is passed for 'old' treatment.
|
issuesSeverity: [
|
||||||
issuesSeverity: []
|
pageIssuesParser.maxSeverity(
|
||||||
|
getIssues( '0' )
|
||||||
|
.map( function ( issue ) { return issue.severity; } )
|
||||||
|
)
|
||||||
|
],
|
||||||
|
sectionNumbers: getAllIssuesSections()
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
if ( $metadata.length ) {
|
if ( $metadata.length ) {
|
||||||
|
@ -208,6 +214,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of all the page sections that have issues.
|
||||||
|
* @return {array}
|
||||||
|
*/
|
||||||
|
function getAllIssuesSections() {
|
||||||
|
return Object.keys( allIssues ).filter( function ( section ) {
|
||||||
|
return allIssues[ section ].length;
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan an element for any known cleanup templates and replace them with a button
|
* Scan an element for any known cleanup templates and replace them with a button
|
||||||
* that opens them in a mobile friendly overlay.
|
* that opens them in a mobile friendly overlay.
|
||||||
|
@ -234,15 +250,20 @@
|
||||||
createBanner( page, label, KEYWORD_ALL_SECTIONS, inline, overlayManager );
|
createBanner( page, label, KEYWORD_ALL_SECTIONS, inline, overlayManager );
|
||||||
} else {
|
} else {
|
||||||
// parse lead
|
// parse lead
|
||||||
createBanner( page, label, 0, inline, overlayManager );
|
createBanner( page, label, '0', inline, overlayManager );
|
||||||
if ( newTreatmentEnabled ) {
|
if ( newTreatmentEnabled ) {
|
||||||
// parse other sections but only in group B. In treatment A no issues are shown for sections.
|
// parse other sections but only in group B. In treatment A no issues are shown for sections.
|
||||||
page.$( Page.HEADING_SELECTOR ).each( function ( i, headingEl ) {
|
page.$( Page.HEADING_SELECTOR ).each( function ( i, headingEl ) {
|
||||||
var $headingEl = $( headingEl ),
|
var $headingEl = $( headingEl ),
|
||||||
sectionNum = $headingEl.find( '.edit-page' ).data( 'section' );
|
sectionNum = $headingEl.find( '.edit-page' ).data( 'section' );
|
||||||
|
|
||||||
|
// Note certain headings matched using Page.HEADING_SELECTOR may not be headings
|
||||||
|
// and will not have a edit link
|
||||||
|
// e.g. table of contents
|
||||||
|
if ( sectionNum ) {
|
||||||
// Render banner for sectionNum associated with headingEl inside Page
|
// Render banner for sectionNum associated with headingEl inside Page
|
||||||
createBanner( page, label, sectionNum, inline, overlayManager );
|
createBanner( page, label, sectionNum.toString(), inline, overlayManager );
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +276,8 @@
|
||||||
pageIssuesLogger.newPageIssueSchemaData(
|
pageIssuesLogger.newPageIssueSchemaData(
|
||||||
newTreatmentEnabled,
|
newTreatmentEnabled,
|
||||||
CURRENT_NS,
|
CURRENT_NS,
|
||||||
getIssues( KEYWORD_ALL_SECTIONS ).map( formatPageIssuesSeverity )
|
getIssues( KEYWORD_ALL_SECTIONS ).map( formatPageIssuesSeverity ),
|
||||||
|
getAllIssuesSections()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,18 @@
|
||||||
* @param {boolean} newTreatmentEnabled
|
* @param {boolean} newTreatmentEnabled
|
||||||
* @param {number} namespaceId The namespace for the page that has issues.
|
* @param {number} namespaceId The namespace for the page that has issues.
|
||||||
* @param {string[]} pageIssueSeverities An array of PageIssue severities.
|
* @param {string[]} pageIssueSeverities An array of PageIssue severities.
|
||||||
|
* @param {array} pageIssuesSections
|
||||||
|
*
|
||||||
* @return {Object} A Partial<Schema:PageIssues> Object meant to be mixed with track data.
|
* @return {Object} A Partial<Schema:PageIssues> Object meant to be mixed with track data.
|
||||||
*/
|
*/
|
||||||
function newPageIssueSchemaData( newTreatmentEnabled, namespaceId, pageIssueSeverities ) {
|
function newPageIssueSchemaData( newTreatmentEnabled, namespaceId, pageIssueSeverities, pageIssuesSections ) {
|
||||||
return {
|
return {
|
||||||
pageTitle: mwConfig.get( 'wgTitle' ),
|
pageTitle: mwConfig.get( 'wgTitle' ),
|
||||||
namespaceId: namespaceId,
|
namespaceId: namespaceId,
|
||||||
pageIdSource: mwConfig.get( 'wgArticleId' ),
|
pageIdSource: mwConfig.get( 'wgArticleId' ),
|
||||||
issuesVersion: bucketToVersion( newTreatmentEnabled ),
|
issuesVersion: bucketToVersion( newTreatmentEnabled ),
|
||||||
issuesSeverity: pageIssueSeverities,
|
issuesSeverity: pageIssueSeverities,
|
||||||
|
sectionNumbers: pageIssuesSections,
|
||||||
isAnon: mwUser.isAnon(),
|
isAnon: mwUser.isAnon(),
|
||||||
editCountBucket: getUserEditBuckets(),
|
editCountBucket: getUserEditBuckets(),
|
||||||
sessionToken: mwUser.sessionId()
|
sessionToken: mwUser.sessionId()
|
||||||
|
@ -37,6 +40,13 @@
|
||||||
// intermediary event bus that extends the event data before being passed to event-logging.
|
// intermediary event bus that extends the event data before being passed to event-logging.
|
||||||
mwTrackSubscribe( EVENT_PAGE_ISSUE_LOG, function ( topic, data ) {
|
mwTrackSubscribe( EVENT_PAGE_ISSUE_LOG, function ( topic, data ) {
|
||||||
var mixedData = util.extend( {}, pageIssueSchemaData, data );
|
var mixedData = util.extend( {}, pageIssueSchemaData, data );
|
||||||
|
|
||||||
|
// Although we use strings inside the issues code (due to the usage of the key word
|
||||||
|
// `all`) - these need to be numbers to be validated by the schema
|
||||||
|
mixedData.sectionNumbers = ( mixedData.sectionNumbers || [] ).map( function ( sectionStr ) {
|
||||||
|
return parseInt( sectionStr, 10 );
|
||||||
|
} );
|
||||||
|
|
||||||
// Log readingDepth schema.(ReadingDepth is guarded against multiple enables).
|
// Log readingDepth schema.(ReadingDepth is guarded against multiple enables).
|
||||||
// See https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikimediaEvents/+/437686/
|
// See https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/WikimediaEvents/+/437686/
|
||||||
mwTrack( 'wikimedia.event.ReadingDepthSchema.enable', bucketToGroup( newTreatmentEnabled ) );
|
mwTrack( 'wikimedia.event.ReadingDepthSchema.enable', bucketToGroup( newTreatmentEnabled ) );
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"EventLoggingSchemas": {
|
"EventLoggingSchemas": {
|
||||||
"PageIssues": 18255016
|
"PageIssues": 18326688
|
||||||
},
|
},
|
||||||
"ResourceModules": {
|
"ResourceModules": {
|
||||||
"skins.minerva.base.reset": {
|
"skins.minerva.base.reset": {
|
||||||
|
|
|
@ -13,11 +13,10 @@
|
||||||
'</div>'
|
'</div>'
|
||||||
),
|
),
|
||||||
labelText = 'label text',
|
labelText = 'label text',
|
||||||
section = 0,
|
|
||||||
inline = true,
|
inline = true,
|
||||||
processedAmbox = createBanner(
|
processedAmbox = createBanner(
|
||||||
new Page( { el: $mockContainer } ),
|
new Page( { el: $mockContainer } ),
|
||||||
labelText, section, inline, overlayManager
|
labelText, '0', inline, overlayManager
|
||||||
);
|
);
|
||||||
|
|
||||||
QUnit.module( 'Minerva cleanuptemplates' );
|
QUnit.module( 'Minerva cleanuptemplates' );
|
||||||
|
|
Loading…
Reference in New Issue