Following up on @Tgr's comment in T296818#7544212:
The way we tag edits (based on the Tracker class, ie. essentially setting an "in progress" flag on the page when the user clicks on the task card, clearing it when the article is saved or after 7 days, and looking at that flag for adding change tags) is inherently fragile. For non-structured edits that's unavoidable - they are just normal edits, so we don't really have a better way of detecting them. For structured edits, we might want to fix that and rely on onVisualEditorApiVisualEditorEditPreSave (a fairly reliable indicator of whether something was a structured edit) instead.
This has been brittle for a long time, I'd like to propose we scrap the current implementation and do something like the following instead:
- Remove the Tracker (includes/NewcomerTasks/Tracker/Tracker.php) class entirely.
- Create a generic ext.growthExperiments.NewcomerTask module with NewcomerTaskDesktopArticleTarget and NewcomerTaskMobileArticleTarget classes.
- Those classes can inherit from the corresponding VisualEditor article target classes and override the save method, so that when a user has an active SuggestedEditSession, we can pass along data via the options array.
- Load the NewcomerTask article target when the user starts an unstructured task, or if the user switches from structured editing to VE in AddLink/AddImage, load NewcomerTaskDesktopArticleTarget / NewcomerTaskMobileArticleTarget.
- Then in includes/VisualEditorHooks.php in onVisualEditorApiVisualEditorEditPostSave, we can check if the save was associated with a NewcomerTask, and add the relevant tags.
- This might also be a good time to make change tags that are specific for each task type (e.g. "Newcomer task: copyedit") in additon to the generic "Newcomer task" tag.
- For newcomers who are not using VisualEditor, we could either decide to not care about tracking those edits (from an analytics perspective, is this important to us?), or we could hook into the 'postEdit' and 'postEditMobile' hooks and POST some data from the SuggestedEdit to an API endpoint which would then handle applying the relevant change tags