[PHP] Allow MetricsClient#submitInteraction() to accept custom data
Background
Per David Martin's report on Slack (WMF-only):
- I'm using the schema in this patch, installed locally according to the instructions here.
- In mediawiki-eventlogging-1, I see
Loading schema at /analytics/mediawiki/product_metrics/wikilambda/api/1.0.0
- followed by the entire schema, including the declarations of my
function
andsuccess
properties- I also see
Validating event...
, followed by the event generated by my PHP instrument, but it's missingfunction
andsuccess
.- Then, because it's missing those 2 properties I've declared as required, the event fails validation.
- If I change my instrument to generate
action_context
instead offunction
thenaction_context
does show up in the generated event.3 is the puzzling part.
Explanation
The issue occurs because MetricsClient#submitInteraction()
has an internal allowlist for $interactionData
properties, which is enforced by InteractionDataTrait#getInteractionData()
. When that method is called, the function
and success
properties are removed from $interactionData
and the event is submitted to the event ingestion service.
Fix
Update MetricsClient#submitInteraction()
to mimic the method of the same name in the JS implementation.
Supporting changes:
- Remove
InteractionDataTrait
as it is unused - Ensure the
$schema
anddt
properties are added to the event after all other data has been added and add a test