Jump to content

Talk:Event Platform/Instrumentation How To

From Wikitech

Adding console.log() to instrumentation example

Would it be okay to update the example instrument to help developers new to this stuff?

// 'a.extiw' will match anchors that have a extiw class.  extiw is used for interwiki links.
$( '#content' ).on( 'mouseover', 'a.extiw', function ( jqEvent ) {
	var link = jqEvent.target;
	var linkHoverEvent = {
		// $schema is required and must be set to the exact value of $id that you set in your schema.
		$schema: '/analytics/link_hover/1.0.0',
		link_href: link.href,
		link_title: link.title,
	};
        var streamName = 'analytics.interwiki_link_hover';
        console.log("logging event with data " + JSON.stringify(linkHoverEvent) + " to stream '" + streamName + "'"); // for testing
	mw.eventLog.submit( streamName, linkHoverEvent );
} );

- Bearloga (talk) 19:20, 4 June 2020 (UTC)Reply