Last modified: 2014-02-26 12:55:06 UTC
When you call mw.eventLog.logEvent() or efLogServerSideEvent(), EventLogging validates your event against its schema, but you don't know if it passed validation. One use case for needing this is campaign tracking: ?campaign=someName should only set a cookie if someName is an active campaign, which we track as an enum in the schema. As a workaround, browser clients can call mw.eventLog.isValid() and server clients can duplicate the code to get the RemoteSchema and pass it to efSchemaValidate() , but it's duplicating code and recalculating something EventLogging already knows. Re-fetching the schema seems expensive. Perhaps the log functions could have an optional out parameter that returns isValid(). Or, they could have an optional parameter to return the encapsulated event, which includes clientValidated. Or the functions could memoize the last validation they performed so a subsequent isValid()/efValidateEvent() of the same event is fast.
(In reply to comment #0) > When you call mw.eventLog.logEvent() or efLogServerSideEvent(), EventLogging > validates your event against its schema, but you don't know if it passed > validation. One use case for needing this is campaign tracking: > ?campaign=someName should only set a cookie if someName is an active > campaign, which we track as an enum in the schema. We should not track that as an enum, in my opinion. Are there any other use cases?
(In reply to comment #0) > When you call mw.eventLog.logEvent() or efLogServerSideEvent(), EventLogging > validates your event against its schema, but you don't know if it passed > validation. Yes, you do: mw.eventLog.logEvent('Echo', {foo: 'bar'}).done( function (event) { if ( event.clientValidated ) { console.log('It validated!'); } else { console.log('It did not validate!'); } } );
[moving from MediaWiki extensions to Analytics product - see bug 61946]