The Various teams (Wikidata team and the Wikimedia Exec, Wikimedia Execs, Audiences, Research) are interested in running surveys that could target:
* Editors only
* Editors with certain edit counts
** ~~Bucketed in the same way that we do with [[ https://meta.wikimedia.org/wiki/Schema:Popups | the Popups schema ]] (see the `editCountBucket` property)?~~ @Jdlrobson points out that this is already the case.
* Non-editors only
## AC
A survey can be configured to:
[X] Target a non-editornonymous users (`wgEditCount === null`) and logged-in users without edits (`wgEditCount === 0`)
[X] Target an non-editor (`wgEditCount === 0`)
[X] Target an editor (`wgEditCount > 0`)
[X] Target a user with an edit count that falls into one of a set of predefined buckets,a given range -- e.g., 5-995-20 edits
### Descoped
[] The user's bucketed edit count will be recorded when the user answers the survey.
** Right now this can only happen for InternalSurvey's. I'm not sure if it's needed for ExternalSurvey's but if it is, this is quite a significant change and requires its own task.
Right now this can only happen for InternalSurvey's.*** Note from @Isaac : The [[ https://meta.wikimedia.org/wiki/Schema:QuickSurveysResponses | QuickSurveysResponses schema ]] does record a bucketed edit count for all surveys. For InternalSurveys, this edit count is directly associated with a respondent's answer to the survey. For ExternalSurveys, I'm not sure if it's needed for ExternalSurvey's but if it is,this edit count is just associated with a respondent selecting "Yes" to take the survey. this is quite a significant change and requires its own taskThe information can then be joined post-hoc via pageview tokens that are passed along to the survey.
##Notes
# Answers to "internal" surveys are recorded via [[ https://meta.wikimedia.org/wiki/Schema:QuickSurveysResponses | the QuickSurveysResponses schema ]].
# There are really three classes of users that can be sampled via this functionality: anonymous users (not logged in), non-editors (logged in but no edits associated with their account), and editors (logged in and at least one edit). Anonymous users are treated as having zero edits unless `minEdits` is set, in which case anonymous users are excluded. See T186737 for functionality aimed more directly at logged-in vs. not logged-in.
## Developer notes
The users bucketed edit count is already inspected and recorded in the schema, so this change would only need to update the behavior for showing the survey.
To support this kind of surveys we'd need to add an optional field to a survey definition inside QuickSurveysConfig that sets a minimum edit count.
This field would then need to be inspected inside the [[ https://github.com/wikimedia/mediawiki-extensions-QuickSurveys/blob/master/resources/ext.quicksurveys.lib/lib.js#L229 | showSurvey method ]].
Given the team hasn't worked on this code, there is likely to be an added tax as we regain familiarity with the codebase and how it works including setup/testing which may bump the estimation.
While working on this code, it might be a good opportunity to modernise some of the code - for instance replace $.each usages with Array.prototype.forEach.
## Comments
@JKatzWMF: If it's trivial, being able to target by edit bucket would also be very useful for future surveys (on {T197631}).
## QA steps
**Make sure to test these on __desktop site__. There is a bug with mobile (T218243)!**
A survey has been setup to only show for users with edit count between 1 and 22
Visit https://reading-web-staging.wmflabs.org/wiki/Test_the_diff in an **incognito window**
- Verify the survey doesn't show if you are logged out
- Verify the survey doesn't show if you are logged in and have an edit count of 0
- Verify the survey DOES show if you are logged in and have an edit count of 1
- Verify the survey DOES show if you are logged in and have an edit count of 20
- Verify the survey doesn't show if you are logged in and have an edit count of 23
Survey should look like
{F28377006}
== QA Results
| **Status** | **Details**|
| ✅ Passed |T139317#5023065|
NOTE: This only works with the desktop site. It fails with mobile.