NOTE: you may be tempted to resolve this ticket, but please make sure that all the subtickets have been resolved and it has passed through a sprint board first, as we are using it to make sure we remember to do a full QA of instrumentation before we launch
== Background
In T397532 we are planning to measure the usage of the new reading list feature on web. In order to do this, we need to implement click tracking instrumentation that measures the overall usage of this feature.
=== User story
//As a product team, we need to make data-driven decisions of the direct of the reading list feature on web.//
=== Design requirements
- [[ https://docs.google.com/presentation/d/18G3jExkwKo9iNI35KrppcDVoAz9NjQDb4J0463RisdA/edit?slide=id.g37524e7e1e2_0_0#slide=id.g37524e7e1e2_0_0 | Instrumentation workflow ]]
- [[ https://docs.google.com/document/d/1gsBpCQXFz3aCgidMBYkzijtnaaHq5b8yf-zRENXmIfc/edit?tab=t.0 | Measurement plan ]]
- [[ https://docs.google.com/spreadsheets/d/1zbz52jUbSGteSUvNmZBlKaGXWJUf9pRnbARz1wtKP9M/edit?gid=0#gid=0 | Instrumentation spec ]]
| {F65779852 width=400} | {F65779851 width=400} |
| clicks on article view | clicks on reading list view |
---
== Requirements
- [] A custom instrument is written to enable click tracking for the initial Reading list on web experiment
- [] Implement the following instrumentation events:
[] **Common contextual attributes for all events** - //stream configuration should capture these//
```
- agent_client_platform
- agent_client_platform_family
- page_content_language
- page_namespace_id
- mediawiki_skin
- mediawiki.database
- performer.is_logged_in
- performer.is_temp
- performer.is_bot
- performer.edit_count_bucket
- performer.session_id
- dt
- meta.dt
```
[x] **Page load event** - //Whenever a page loads and the user is in the experiment//
```
action: page_load
action_source: internal_referer / external_referer
```
[x] **Save/remove entry point clicks** - //When user clicks the bookmark button from either toolbar, sticky header or page tools.//
```
action: click
action_subtype: save_to_reading_list / remove_from_reading_list
action_source:sticky_header / toolbar
action_context={article_count: <INT>}
```
[x] **Views of reading list from article page** - //User clicks to view reading list icon on the top of the page//
```
action: click
action_subtype: view_reading_list
action_source: top_right
```
[] **Views of reading list from on the "article saved" popup** - //User clicks on the 'view list' on the article saved popup//
```
action: click
action_subtype: view_reading_list
action_source: article_saved_popup
```
[] **Views of an article from the reading list** - //User clicks on an article link in the reading list//
```
action: click
action_subtype: view_article
action_source:reading_list
action_context={article_count: <INT>}
```
=== Acceptance criteria
- [] //Add clear acceptance criteria.//
== BDD
```
Feature: Click tracking for Reading List interactions
Scenario: Page load event tracking
Given I am a user in the Reading List experiment
When I load a page
Then a `page_load` event is sent with the correct contextual attributes
And the `action_source` reflects internal or external referer
Scenario: Save and remove clicks
Given I am viewing an article in the experiment
When I click the bookmark icon in the toolbar or sticky header
Then a `click` event is sent
And the event includes `action_subtype` and `action_source` matching the UI element clicked
And the `action_context` contains the current `article_count`
Scenario: Viewing reading list from top-right icon
Given I am on an article page
When I click the top-right reading list icon
Then a `click` event is sent with `action_subtype: view_reading_list` and `action_source: top_right`
Scenario: Viewing reading list from article saved popup
Given I have just saved an article
When I click “view list” in the saved popup
Then a `click` event is sent with `action_source: article_saved_popup`
Scenario: Viewing article from reading list
Given I am on the Reading List page
When I click an article link in the list
Then a `click` event is sent with `action_subtype: view_article`
And `action_context` includes the total number of saved articles
```
== Test Steps
__Test Case 1: Page load event__
1. Log in and enable Reading List experiment.
2. Load an article page.
3. Inspect network requests for the instrumentation endpoint.
4. **AC1:** `action: page_load` event is logged.
5. **AC2:** `action_source` is correctly set to `internal_referer` or `external_referer`.
6. **AC3:** Common contextual attributes are included.
__Test Case 2: Save/remove clicks__
7. Click the bookmark icon in the toolbar.
8. **AC4:** A `click` event logs `action_subtype: save_to_reading_list` and `action_source: toolbar`.
9. Click again to remove the article.
10. **AC5:** A `click` event logs `action_subtype: remove_from_reading_list` and `action_source: toolbar`.
11. **AC6:** `action_context` includes `{article_count: <INT>}`.
__Test Case 3: View Reading List from top-right__
12. Click the Reading List icon in the top-right corner.
13. **AC7:** `click` event logs `action_subtype: view_reading_list` and `action_source: top_right`.
__Test Case 4: View Reading List from article saved popup__
14. Save an article, then click “view list” in the popup.
15. **AC8:** `click` event logs `action_subtype: view_reading_list` and `action_source: article_saved_popup`.
__Test Case 5: View article from Reading List__
16. Navigate to Special:ReadingLists.
17. Click an article title from the list.
18. **AC9:** `click` event logs `action_subtype: view_article` and `action_source: reading_list`.
19. **AC10:** `action_context` contains the total number of saved articles.
=== Communication criteria
//Add if this needs an announcement or discussion.//
=== Rollback plan
//Describe the rollback plan in production for this task if something goes wrong.//
//This task was created by Version 1.0.0 of the Reader Experience team task template using [[ https://phabulous.toolforge.org/ | phabulous ]].//