Page MenuHomePhabricator

[S] SearchPreview Instrumentation - Trigger an event when SearchPreview is closed.
Closed, ResolvedPublic

Description

As a developer, I would like to record any time the user is closing a SearchPreview

AC:

  • When a user clicks the "x" to close the popup, trigger an event with action "close-searchpreview"
  • When a user clicks away and the clickview closes, trigger the same action
  • When an user clicks on another result (on desktop) and the popup closes, trigger the same action
  • When an user clicks on the same search result and the clickview closes, Trigger the same action
  • When a user leaves the page (while quickview was still open), trigger the same action

Note:

Event Timeline

@cchen I assume we also want this 'quickview-close' event to be captured when a user leaves the page (while quickview was still open)?

MarkTraceur renamed this task from SearchPreview Instrumentation - Trigger an event when SearchPreview is closed. to [S] SearchPreview Instrumentation - Trigger an event when SearchPreview is closed..Oct 19 2022, 5:56 PM

@cchen I assume we also want this 'quickview-close' event to be captured when a user leaves the page (while quickview was still open)?

Yes!

@cchen , @matthiasmullie
By leaving the page you mean closing the tab/browser or just being prompted to another page in Wikipedia (for instance, clicking the link to another page)?

I was essentially implying the window beforeunload event (so anything that causes the user to navigate away from the page that has quickview open)

As per docs :

The beforeunload event suffers from the same problems as the unload event.
Especially on mobile, the beforeunload event is not reliably fired. For example, the beforeunload event is not fired at all in the following scenario:

1. A mobile user visits your page.
2. The user then switches to a different app.
3. Later, the user closes the browser from the app manager.

So we can't rely too much on this event in terms of gathering statistics, especially for mobiles.

I set the patch to the review - https://gerrit.wikimedia.org/r/c/mediawiki/extensions/SearchVue/+/850546
There is one concern that I want to discuss:

AC for SearchPreview is closed

When a user leaves the page (while quickview was still open), trigger the same action

AC for SearchPreview is open ( https://phabricator.wikimedia.org/T321071 )

When an user refresh a page that has Search preview already open (auto open on load) do not trigger an event

Problem: current beforeunload event triggers on both refreshing and closing page, so we send simultaneously close-searchpreview and open-searchpreview events which is incorrect. These ACs have to be aligned after code review if we don't find a proper way to distinguish refreshing / closing the page in the browser.

cc: @matthiasmullie, @SimoneThisDot

I personally think this is the correct behaviour.. the code is "unloading" and "reloading", so trigger a close and open seem to be the correct behaviour for my opinion.

I am sure that we are going to review and check this before they go out in production and in that case we may make small amendment (like in this case) if needed, but for now I think the initial proposed approach seems correct.

Etonkovidova closed this task as Resolved.EditedDec 20 2022, 12:53 AM
Etonkovidova subscribed.

Checked in betalabs (on https://stream-beta.wmflabs.org/v2/ui/#/?streams=mediawiki.searchpreview and in the Console with mw.loader.using( 'mediawiki.api' ).then( function () { new mw.Api().saveOption( 'eventlogging-display-web', '1' ); } ); - close-searchpreview event will be recorded for all scenarios listed in the ticket.

"$schema":
"/analytics/mediawiki/searchpreview/1.0.0",
"action": "close-searchpreview"