This task is about implementing the necessary event logging the Structured Data team will need to answer the questions defined in T259308. //These questions are also listed in the "Application" section below.//
=== Background
The SD team will be integrating its new MediaSearch API into Visual Editor (see T259896). We need to measure the success of this change, and to do so we need image search in VE to be instrumented, which it is not currently (see T259308).
=== Application
Per T259308, we want to be able to answer the following:
- What percentage of image searches in VE lead to the subsequent addition of an image to the article?
- Where within the image grid was the selected image located?
- How often do people use VE's image search?
//Note: If location in the image grid of the image that is chosen is more difficult to measure, that could wait. We'd love to be able to measure this both before and after the change to using the new MediaSearch API.//
=== Requirements
//This section should contain an exhaustive list of the events ("Event name") that are being implemented to fulfill the "Applications" defined above, the action(s) ("Trigger action(s)") that should cause said events to be emitted and the schema in which these events should be logged.[i] Unless a specific schema is mentioned, it is assumed that the events are captured in the VisualEditorFeatureUse schema with `feature` set to `media` and `action` set to the event name. //
|Trigger action(s)|Event name|Schema|
|---|---|---
| User clicks "Insert > Images and Media" in toolbar | `window-open-from-tool` |
| User clicks on an existing image and then clicks on "Edit" | `window-open-from-context` |
| User enters a search term in the mwMediaDialog search input | `search-change-query` |
| User clears a search term in the mwMediaDialog search input | `search-clear-query` |
| User expands a result image by clicking on it | `search-choose-image` |
| User clicks "use this image" in the mwMediaDialog | `search-confirm-image` |
| User clicks back arrow to return to grid of results | `search-change-image` |
| User clicks "change image" after they have previously clicked "use this image", taking them back to the results grid | `search-change-image` |
| User inserts image into the page, closing the dialog | `dialog-insert` |
| User clicks "Apply changes" to close the dialog and update an existing image | `dialog-done` |
| User clicks the "X" icon before finishing, closing the dialog | `dialog-abort` |
| User hits the ESC key, closing the dialog | `dialog-abort` |
| User uploads their own image | `search-upload-image` |
=== Done
- [ ] Structured Data to complete the "Requirements" section above
- [ ] Editing to approve the drafted "Requirements"
- [ ] Structured Data to implement the approved "Requirements"
- [ ] Editing Team to provide code review for newly instrumented events
- [ ] Structured Data to verify the newly-implemented events are being emitted as expected by clients
- [ ] Structured Data/Product Analytics to verify the newly-implemented events are being logged in the database in the ways we expect, once the new instrumentation has landed on production.
- [ ] Structured Data/Product Analytics to update documentation [ii] with the events spec'd in this task once they have been verified to be implemented as expected. //Read: clients are emitting events as expected and said events are being logged in the database as expected as well.//
---
i. E.g. https://meta.wikimedia.org/wiki/Schema:VisualEditorFeatureUse
ii. https://www.mediawiki.org/wiki/VisualEditor/FeatureUse_data_dictionary