Page MenuHomePhabricator

clients can't tell if the event they logged was valid
Closed, DeclinedPublic

Description

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.


Version: unspecified
Severity: normal

Details

Reference
bz49094

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:45 AM
bzimport set Reference to bz49094.

(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]