Slack thread: https://wikimedia.slack.com/archives/C06M4A3SYMQ/p1788385976290989
We need a way for experiments in Test Kitchen to send thanks_given and thanks_received events to enable calculation of an engagement metric.
There are two approaches:
- Hooks (deprecated?)
- DomainEvents (pending confirmation in T437053#12290055 that we can use PubSub in the context of Test Kitchen experiments)
Notes
@Mooeypoo mentioned:
https://github.com/wikimedia/mediawiki-extensions-Thanks/blob/master/includes/Api/ApiCoreThank.php#L231 <-- probably best to insert this here, this seems to be the place a "thank" notification is created and a log is made.
However, we should not be partially instrumenting experiments in the Thanks extension code. It would be best if there was a hook (e.g. onThanksLogEntryInsertion) that would allow us to keep DE1.2 experiment instrumentation contained to WikimediaEvents extension.
As @phuedx said:
Updating MediaWiki\Extension\Thanks\Storage\LogStore to run a hook post log entry insertion would keep the domain logic and any instrumentation cleanly separated
This hook should expose two users: the thanker (the current user) and the thankee (the recipient of the thanks). We would then be able to leverage T436960: Allow sending experiment events and looking up experiment enrollment for another user to initialize two experiment managers – one for each of those users – and produce those events if the thanker and/or the recipient are enrolled in an active experiment.
For example, in /includes/WikimediaEventsHooks.php:
public function onThanksLogEntryInsertion( $thanker, $thankee ) { $experimentManager1 = $this->experimentManagerFactory->newForUser( $thanker ); $experiment1 = $experimentManager1->getExperiment( 'my-experiment' ); $experiment1->send( 'thanks_given' ); $experimentManager2 = $this->experimentManagerFactory->newForUser( $thankee ); $experiment2 = $experimentManager2->getExperiment( 'my-experiment' ); $experiment2->send( 'thanks_received' ); }
Acceptance criteria
- A way for a TK experiment instrumented in WikimediaEvents (or any other extension) to send thanks_given and thanks_received analytics events when one user thanks another