Page MenuHomePhabricator

[M] Editing personalized slide: “You edited Wikipedia X times”
Closed, ResolvedPublic3 Estimated Story Points

Assigned To
None
Authored By
HNordeenWMF
Oct 2 2024, 6:01 PM
Referenced Files
F57613408: CleanShot 2024-10-14 at 18.24.59@2x.png
Oct 14 2024, 4:26 PM
F57613402: image.png
Oct 14 2024, 4:23 PM
F57613395: image.png
Oct 14 2024, 4:23 PM
F57598612: image.png
Oct 8 2024, 6:09 PM
F57588791: Screenshot 2024-10-04 at 10.08.30 AM
Oct 4 2024, 3:15 PM
F57584075: image.png
Oct 2 2024, 10:22 PM
F57583385: image.png
Oct 2 2024, 6:01 PM

Description

Background

The Apps team plans to explore if a personalized Wikipedia in Review feature that displays insights about a user's reading history, editing history, and donation history is engaging for App users, and inspires them to make a donation to the Wikimedia Foundation.

Requirements
  • Show total edits for 2024 up to 500, for their primary language wiki in the App
  • Display 500+ if they have more than 500 edits
  • Reverted edits do not need to be removed
  • Only display edits from the article namespace
  • Only display if user has 1 or more edits
  • Only show to logged-in users
  • If user has no edits, or is not logged in, show collective slide

Nice to have

  • Show primary language code in dynamic illustration
  • Additional sentence that mentions up to 3 article names: Articles you edited included: "Polar Bear", "Swiss Alps", "Goat"
Designs
Engineering Notes
  • (data half, part 1) In the WMFYearInReviewDataController, add a method that fetches the user's contributions from their primary wiki, calculates a total count of edits for the year and returns that count.
    • The method should allow passing in username and the primary app project from the app-side.
    • The method should construct correct API url parameters using the username. Also pass in a ucstart date of November 1st 2024 and a ucend date of January 1st 2024. Bonus points if you can pull these dates from the WMFDeveloperSettingsDataController's remote config dataPopulationStartDateString and dataPopulationEndDateString values. You should also send ucnamespace of 0 and ucprop values of ids|title|timestamp|tags|flags (here we are asking only for edits in the Article namespace, i.e. not talk page edits. Also explicitly asking for edit tags and flags in case we eventually need to filter out certain edits from the count.)
      • Example API call - https://en.wikipedia.org/w/api.php?action=query&format=json&list=usercontribs&formatversion=2&uclimit=10&ucstart=2024-11-01T22%3A20%3A13.000Z&ucend=2024-01-01T22%3A20%3A13.000Z&ucuser=TSevener%20(WMF)&ucnamespace=0&ucprop=ids%7Ctitle%7Ctimestamp%7Ctags%7Cflags
      • You can reference the WMFGrowthTasksDataController getImageRecommendationsCombined method as an example of how to construct an API url with parameters and fetch it using our mediawiki service class.
    • The method should use our media wiki service to fetch the data. Use Codable to parse through the response.
    • The method should get a count of all edits returned in the usercontribs array.
    • The method should also check to see if there are more edits or not. Do this by checking to see if a "uccontinue" key and value is returned at the top of the response. You can see what this object looks like if you change the uclimit to 10 in the above API call.
    • The method should return the final edit count and a boolean whether there are more edits or not.
  • (data part 2, blocked on T376041) Upon app resume, pull persisted slide item object for this slide identifier. If evaluated = no, they are logged in, AND remote config does not have a personalized slide kill switch, call method in previous bullet point. Store returned data in persisted report model from T376041. Then set evaluated = yes for persisted report model. If edit count > 0, set display = yes for persisted report model. Save model.
  • (UI half, blocked on previous bullet point) Ensure that when we create the view models before presenting slides (see T376044), fetch the persisted model from previous bullet point. If display = yes, build a slide view model with this data (using the report model's metadata). Ensure slide view model is inserted into the correct order, and that associated collective "fallback" slide is NOT inserted.

Test Steps

The latest Wikipedia (white icon) TestFlight build should have this slide in place.

  1. Put device settings region into an accepted location (Italy, Mexico).
  2. In onboarding, choose a primary app language of Spanish, English, or Italian.
  3. Log into an account that has edits on primary app language
  4. Go to app Settings and enable feature flag in Developer Settings menu
  5. Background/foreground the app to trigger YiR report creation
  6. Entry point should appear in Profile menu.
  7. Go through slideshow as normal, comparing the third slide to desired outcome

Details

Related Changes in Gerrit:

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

@HNordeenWMF

Is it easier to total for all languages? or just primary app language? Designs can be updated to clarify what total is referring to.

Just primary app language is easier. I had assumed this edit count is aggregated from Jan 1st - Nov 1st. Would you be open to a scope cut of their total edit count since account registration? That is a much easier count to get for us.

@HNordeenWMF

Show primary language code in dynamic illustration

I see two language codes in the illustration, is the background one a static Chinese character that everyone sees?

Also, here's a screenshot of wiki languages on Search. I'm curious which one we should use...the code in the box? (This example shows en.wikipedia.org, zh-classical.wikipedia.org, and zh.wikipedia.org with a Traditional Chinese (Hong Kong) variant.

Screenshot 2024-10-04 at 10.08.30 AM (1×559 px, 207 KB)

Just primary app language is easier. I had assumed this edit count is aggregated from Jan 1st - Nov 1st. Would you be open to a scope cut of their total edit count since account registration? That is a much easier count to get for us.

Actually this comment was incorrect. If you are ok with getting their edit count since registration date, their global edit count is just as easy as their primary wiki edit count.

Global edit count: https://en.wikipedia.org/w/api.php?action=query&format=json&meta=globaluserinfo&formatversion=2&guiprop=editcount
Primary Wiki Edit count: https://en.wikipedia.org/w/api.php?action=query&format=json&meta=userinfo&formatversion=2&uiprop=editcount

If you want an edit count from Jan 1 - Nov 1 2024, that is significantly harder on either option.

Thanks for noting the scope cut @Tsevener. We can go with edit count since registration for this since it's a MVP. Could we mention both Global edit count & join date? Something like "You've made 19379 edits globally since joining on August, 8 2021."

The dynamic illustration can be moved to "nice-to-have". I was seeing it as the prefix to the Wikipedia, so all Chinese variants would be (ZH). @scblr
is the character in the background supposed to be dynamic? Could you also create a back-up illustration that doesn't depend on being dynamic?

Please move this into "ready for next sprint" after estimation!

HNordeenWMF raised the priority of this task from Low to Medium.Oct 7 2024, 11:14 PM

@Tsevener, for Global contributions, is it all Wikimedia projects, all namespaces? If so we will need to update the copy

Tsevener renamed this task from Editing personalized slide: “You edited Wikipedia X times” to [M] Editing personalized slide: “You edited Wikipedia X times”.Oct 8 2024, 7:00 PM

for Global contributions, is it all Wikimedia projects, all namespaces? If so we will need to update the copy

@HNordeenWMF I believe so. The documentation does not state that specifically but from my testing that is how it is working. I made an edit to my own talk pages on EN Wiki, a test article on Test Wiki, and a talk page on Meta Wiki. All edits updated the edit count. I'll let you know if I get a confirmation to that assumption from someone else.

@HNordeenWMF

Answer:

All Wikimedia projects but some projects are not connected to SUL (like officewiki) so those or other private wikis aren't counted. All namespaces are counted. Deleted edits may not be counted, but unsure on that. Also noting that the values are not that accurate, there are many failure scenarios.

For our future selves, documenting my reasoning for wanting to fall back to the globaluserinfo API as an edit count here instead of something more accurate to the year. There are three potential endpoints we could use here:

  1. If we were to use an accurate production MW endpoint, we would need to use the user contributions API. When the app is resumed, if a user is logged in, we would need to page through this endpoint (because it returns 500 results at a time) and import edits from the year into a local database. We would also need to repeat this across multiple wikis. This could cause a heavier load on the servers, so we would need to add throttling via a remote config for safety. The thinking is that when the user hits a max number of pages (according to the remote config), we pause on importing and pick back up where we left off the next time they start the app again. Then to calculate the final edit count, we would need to evaluate the local edits and count up any non-main namespace edits.
  2. Another option is to use the Xtools simple edit counter API call. We would need to repeat this call across multiple wikis and persist the counts locally. This would more simple since there would be no paging. This is not a production endpoint, so there is even more of a load concern (see https://phabricator.wikimedia.org/T373569#10198471). Because of this we would also need to add throttling via the remote config for this approach, to make sure we don't overload the server.
  3. The most simple approach is the globaluserinfo edit count API. This single endpoint is a production endpoint and already considers counts across all projects. Because it's a production endpoint and there's no paging, server load is not a concern, so we do not need to add any throttling logic. We also already have some plumbing in the app to call this endpoint from a past design of the diff screen, where we displayed a user's edit count. The downside of this endpoint is that it returns a count since the user's registration date and includes all namespaces - there's no way to get a main-namespace-only count for the 2023 - 2024 year.

@scblr hi Robin, please update this task once you have updated the illustration to address the backwards Chinese character. Also please provide a fallback for what the engineers should show in the dynamic language code spot for the collective slide / if they are not able to do to the dynamic language code for personalized.

HNordeenWMF updated the task description. (Show Details)
HNordeenWMF added a subscriber: GOlson-WMF.

@scblr hi Robin, please update this task once you have updated the illustration to address the backwards Chinese character. Also please provide a fallback for what the engineers should show in the dynamic language code spot for the collective slide / if they are not able to do to the dynamic language code for personalized.

Updated the task’s description with:

The fallback is to use Wikipedia’s language icon, known from e.g. from Web Wikipedia:

CleanShot 2024-10-14 at 18.24.59@2x.png (1×2 px, 829 KB)

Going to move this back into Ready for Dev, just a couple of minor PR Feedback bits need to be added in a followup PR. This should not block design review.

Change #1083256 had a related patch set uploaded (by GOlson; author: GOlson):

[analytics/refinery@master] Updated variable name

https://gerrit.wikimedia.org/r/1083256

Change #1083256 abandoned by GOlson:

[analytics/refinery@master] Updated variable name

https://gerrit.wikimedia.org/r/1083256

Despite the illustrations we’re updating, this looks good to me.

Looks good for accounts under 500 edits.
Once this is in external beta, we should ask a few folks with 500+ edits on Spanish or Italian Wikis to try it out.