Commit graph

847 commits

Author SHA1 Message Date
Adam Wight 07aa0f3ae9 Don't record Popups actions on non-content pages
We found that Popups was overcounted approximately 2.5x relative to Cite.
This patch attempts to nearly match the circumstances under which Cite
(and its tracking) is loaded.

Bug: T214493
Change-Id: Ib31df3c33879f4ea63d9808ffd260861069a8977
2019-11-14 16:52:05 +01:00
Adam Wight 0c1e628edb Ensure that pageviews are recorded at most once
The Popups pageviews were suspiciously high, about 2.5x higher than
Cite counts which should have reported the same number.  This patch
attempts to deduplicate pageview events.

Bug: T214493
Change-Id: I51bf6d1909d65ecd9d3ef28eda285852897343ec
2019-11-08 11:23:02 +01:00
Adam Wight b7331a6e66 Record pageviews where Reference Previews is enabled
We want to know the side of this population in pageviews, in order to
produce proportional metrics later.

Bug: T214493
Change-Id: I940872870754e85d19688f3855d6857e65b982b1
2019-10-24 23:34:56 +02:00
Adam Wight fed99e7cb5 Inline eventlogging call
This isn't messy enough to justify encapsulation in a function.

Change-Id: Idfa6581d30709f1a58ff8c83ead08e1bfda81c1c
2019-10-24 22:52:48 +02:00
Adam Wight 171e1b7dbf Sample ReferencePreviewsPopups 1:1
We're getting a few dozen records per day at 1:10, so let's stop sampling.
We need enough data to get significance on events happening at 0.1% or less.

Bug: T214493
Change-Id: I8a913fe1ee1e5b72d84914e183ac2386ddb20d84
2019-10-22 12:14:17 +02:00
Thiemo Kreuz 76e02fae98 Remove obsolete mediaWiki and jQuery aliases
Notice how this actually reduces the size of the final, compiled index.js.
It's not much, but still.

One issue I noticed is that the coverage reports for the JS code stopped
working. I have no idea why.

Bug: T208951
Change-Id: I2fe92579574b3b1ba4d2dd064899eee944045a96
2019-10-22 09:30:46 +02:00
Thiemo Kreuz c7595e54f6 Replace deprecated mw.RegExp.escape() with mw.util.escapeRegExp()
The signature mw.RegExp.escape() is deprecated since MediaWiki 1.34.

By the way, this is the 4th or even 5th time in my short career this
tiny, single line (!) helper function is moved around and I need to
update all my code. This felt already ridiculous when it happened the
2nd time.

Change-Id: I4d05a49120aff64ebc316d0af7736c62385d9307
2019-10-21 15:00:36 -07:00
Thiemo Kreuz a63a1cf91c Split user preferences for Page and Reference previews
Bug: T233813
Change-Id: I89205658c561961b90abaa133a004e54beebfab5
2019-10-17 11:21:21 +02:00
Adam Wight f6defd5fbc Tune referencePreviews sampling from 1:1000 to 1:10
We've logged zero events after 12hr of deployment, so it should be
safe to increase sampling by 100x.

Bug: T214493
Change-Id: Icd67aed448269f603dd4465f7e46eac9a64bd1ab
2019-10-11 10:52:43 +02:00
Thiemo Kreuz 95c80dcb3e Fix code detecting horizontal scrollbar in reference previews
Bug: T234602
Change-Id: I5994b6e8cb15374bb2c0a31dd4e4549005a619cf
2019-10-09 15:38:35 +02:00
Adam Wight 76a34618c3 Tracking for Reference Previews interactions
Logs events to the ReferencePreviewsPopups EventLogging schema, in
order to understand whether Reference Previews is helpful for
end-users.

This will be removed along with the older tracking, as soon as our analysis
phase is finished.

Incidentally disables a lint rule for the generated JS, it's about
readability so irrelevant to the minified code.

Bug: T214493
Change-Id: I2638611ba67b785338f7e98a1c4b08a5e829812d
2019-10-07 11:22:00 +02:00
Adam Wight aa6972c277 Collect metrics for logged-in users as well as anons
The eventlogging `isEnabled` function determines when to sample,
this patch removes the `isAnon` conditional so that we can measure
reference reading habits for all users.

Also guards against a non-function navigator.sendBeacon, which was
previously intended but incorrectly tested.

Bug: T214493
Change-Id: I42cb3082fb85c7900426a2055dfa3c2f6ecfd968
2019-09-27 12:07:11 +02:00
Thiemo Kreuz 065a8e9631 Fix action reducer forgetting *all* duplicate dwell actions
I was able to track the issue down to the changes made in this patch:
https://gerrit.wikimedia.org/r/331563

This patch is mostly a simplification of ce8a2d4
(I9a73b3086fc8fb0edd897a347b5497d5362e20ef):

- Don't make wait#wait() abortable. This adds complexity and isn't
  needed since the token is rechecked in the .then() of
  actions#linkDwell(). The request is permitted to continue and fetch if
  that token still matches and is never issued otherwise.

  Once a request has been issued, that request is still abortable.
  However, note that calling XHR.abort() is just a request to abort and
  may not be granted. Whether or not XHR.catch() is invoked is what
  dispatches the FETCH_ABORTED action (or doesn't if the request to
  abort was denied).

- Remove the abort tests for wait#wait() since the functionality is no
  longer provided.

- Pass the preview token in the FETCH_ABORTED action and reduce
  FETCH_ABORTED the same way as ABANDON_COMPLETE in reducers/preview.

The follow-up patch, I3597b8025f7a12db0cf5d83cce5a77abace9bae3, adds
integration tests for the specific bug fix. Note that these Selenium
tests are incompatible with the content proxy, so it is probably best to
simply unset $wgPopupsRestGatewayEndpoint and $wgPopupsGateway and allow
the defaults to be used. Also note that the tests are incompatible with
recent versions of Node.js (so use NVM) and emit many deprecation
warnings (so set deprecationWarnings to false in
tests/selenium/wdio.conf.js) An example run of the tests looks something
like:

  chromedriver --url-base=wd/hub --port=4444 &
  # If any changes are made locally, also run `npm -s start &`.
  MW_SERVER=http://localhost:8181 \
  MEDIAWIKI_USER=foo \
  MEDIAWIKI_PASSWORD=bar \
  DISPLAY= \
  npm -s run selenium-test

Live testing may be performed as well. Remember that RESTBase requests
are incompatible with MobileFrontend's content proxy hack so ensure to
comment it out if $wgPopupsGateway is configured for RESTBase (see
T218159).

1. Open the DevTools network tab.
2. Disable the browser cache. Chromium, at least, won't abort requests
   coming form the cache.
3. Hover back and forth quickly over a preview. In Chromium, canceled
   requests are labeled and appear red. This is a good scenario to test.
   With the patch, a preview should always be shown when ultimately
   resting on a link. Without the patch, it is possible to rest upon the
   link with no preview showing. This may require several attempts.

Bug: T219434
Change-Id: I9da84b0296dd14e9ce69cb35f1ca475272fb249a
2019-08-23 10:08:19 +02:00
Ed Sanders 4d885286a3 eslint: Enforce template-curly-spacing
Change-Id: I5640e86cba25f6100c7814c2ef8a845941f73497
2019-08-15 10:24:43 +02:00
Ed Sanders cfa0b100ad eslint: Enforce no-prototype-builtins
Change-Id: I4244f0576e48c233d24533b45a28c07b2531d6da
2019-08-15 08:00:35 +00:00
Ed Sanders 2687d12c52 eslint: Remove valid-jsdoc override
Change-Id: I6a9936743a74afb528713f21e016838947fa1914
2019-08-15 08:00:24 +00:00
Ed Sanders a17be78b3d build: Update linters
Change-Id: I9b32f412e7e75918a59bdb239d3a42670177be70
2019-08-15 09:55:57 +02:00
Dan Andreescu 27a95517b7 Remove dependencies on deprecated schema modules
As mentioned in T205744, EventLogging schema ResourceLoader modules have
been deprecated.  This removes those modules from loader calls.

Bug: T221281
Change-Id: I1b7355c69e09756f50ccd1c1955b45cae4a64b9e
2019-06-19 09:51:30 -06:00
Volker E d1fc6786bf Remove wrong ARIA role=tooltip from container
Removing wrong ARIA `role=tooltip`. Those are meant only for static
text content on short `title` like dynamic tooltips.

Bug: T223827
Change-Id: Ib4f490c7ad421e516fb0cf47eff4335bcaf26c43
2019-05-29 15:27:08 -07:00
Thiemo Kreuz 59a5e4e981 Fix fade-out gradient not disappearing when page is zoomed
We did a strict === comparison before. This works fine when the page
zoom is either 100% or 200%. Other zoom factors produce fractional
numbers. Comparing them with === is doomed to fail because these numbers
are IEEE representations, not necessarily being identical in situations
where you would expect them to be identical.

This applies two fixes: Change the comparison to a >=, and always ignore
1 extra pixel. If we are so close to the bottom, the gradient is not
helpful any more.

Change-Id: Idf4c604142de8d2a803e1d94f3093cec8a8abb72
2019-05-20 11:02:19 +00:00
WMDE-Fisch a498423f90 Avoid popups on self links with file extension
This fixes page previews appearing when there is self link to a page
that has a file extension in it's name.

Bug: T222869
Change-Id: I5caf610fa76986026948a5b7b55537723752b755
2019-05-10 18:02:50 +02:00
Thiemo Kreuz ac65bd3082 referencePreview: No event bubbling on inner child elements
This is relevant in case the HTML looks like this:
<… class="reference"><a><span>[</span>2<span>]</span></a></…>
The additional <span> cause many additional mouseover and mouseout
events. The code already tries to filter these duplicate events that
are all triggered on the same link, but gets confused, especially when
the multiple chains of events overlap each other in unexpected ways.
It's a timing issue. This change does not fix the fundamental issue,
but does make it much less painfull.

This patch also removes the > from the selector. This is in case the
HTML looks like this:
<… class="reference"><span><a>[2]</a></span></…>
The additional inner <span> would prevent any reference preview from
being shown.

Bug: T214693
Change-Id: If2554ba78072245c27a1f85c46f33e3c58582c1d
2019-05-09 13:23:45 +02:00
WMDE-Fisch 1879a4d59e Show referencePreviews on click
Introducing the REFERENCE_CLICK action that will fetch and show the
preview for the clicked reference right away without any delay.

The main goal of the new chain of events introduced with the reference
click is showing the reference preview right away. The actions triggered
by the dwelling include delays in multiple parts of the process.

If there's a dwell action-chain in progress when the click action is
executed, the related promise ( that might still include steps with
delays ) and the reference preview is retrieved and shown right away
re-using the token. 

In the case where there's no dwell action running ( e.g. when the click
was triggered via touch ) we create a new token and start from scratch.

In either case we want to avoid, that multiple clicks trigger multiple
actions and abort early when there's already a click action in progress.

Bug: T218765
Change-Id: I073a93be2d17a21178aebe12267765f60a2811b9
2019-04-29 17:46:49 +00:00
Thiemo Kreuz 3ca2709cfe Streamline code calculating fade-out bottom position
I actually tried to bring the animation for the "bottom" property back.
When finished, I realized this animation is done on *top* of the
horizontal scrollbar. This looks fancy, but is not what we want. We
need to keep animating the opacity.

This patch here contains a bit of refactoring that was left after I
went back animating the opacity.

Bug: T220200
Change-Id: Icf613f72f3baa3de86f8aa319667c8e8f16593fd
2019-04-26 18:14:30 +02:00
WMDE-Fisch d72ef0fa65 Avoid fade-out above horizontal scrollbars
The changes in the patch check if a horizontal scrollbar is present
and move the absolute positioned fade overlay above that scrollbar.

Since we cannot change the CSS of the :after element via JS a new div
element was introduced.

Bug: T220200
Change-Id: Ia69c9be0facaf3ecebdb9f76d36f7cb3412c0816
2019-04-26 18:02:06 +02:00
Thiemo Kreuz 8305eb8634 Minimize createStubTitle() helper method
Pretty much all usages of this function do *not* use the second
parameter to pass a page name prefixed with a namespace, but pass the
page name only.

This patch here removes the redundancy. The namespace prefix is now a
generated one, saying "Namespace <number>:…". It turns out no test
relies on this so far.

Bug: T220097
Change-Id: Ibd45d49c91e86a2647afe676a5e3bb07dfeab6ed
2019-04-26 07:45:13 -06:00
WMDE-Fisch 6c535739bf Use title.getNameText() to compare selflinks
config.get( 'wgTitle' ) returns the unnormalized title of the current
page while title.getName() gets the normalized title (e.g. with underscores ).

On pages with spaces in the check failed before this patch.

Bug: T220097
Change-Id: I58a532627bb27be030cbc553f1181a89109edd80
2019-04-26 13:58:08 +02:00
WMDE-Fisch 35aa05afee Use title and namespace id to check if link is current page
Bug: T220097
Change-Id: Ieffd6a02b4126f6713610e968d662516499d4998
2019-04-23 15:17:06 +02:00
Adam Wight 0acc8db529 Decode fragment, needed for multilingual named references
Named references may include non-ascii characters, so we decode the fragment before matching against reference IDs.

Bug: T220196
Change-Id: I63bba59fa8f0f6aa95aeadbb1f85745d480988bd
2019-04-23 11:39:30 +02:00
WMDE-Fisch f8562a89d6 svgmin optimizations on updated OOUI icons
Icons were updated in I8feea1b526ff85c4ffdee21ef42c616e72881e76 the
pre-commit svgmin optimizer does these minor changes in the two files.

Pushing these to avoid constantly changed but uncommited SVGs in the 
images directory when working.

Change-Id: Ib8a66df12dc692eb356a33815f5aade1983f625c
2019-04-18 19:21:48 +00:00
jenkins-bot 459942a305 Merge "Update OOUI icons to latest versions" 2019-04-17 19:03:14 +00:00
Ed Sanders 78cbb02191 Update OOUI icons to latest versions
* web.svg was deprecated in favour of browser.svg.
* Update sad-face.svg based on OOUI speechBubble-ltr/rtl
* Apply preview-generic/disambiguation grey colour using CSS.

Change-Id: I8feea1b526ff85c4ffdee21ef42c616e72881e76
2019-04-17 12:11:08 +01:00
Timo Tijhof 81b94eff0a Remove redundant wgPopupsShouldSendModuleToUser variable
It is set based on the same conditional that loads the code,
thus checking it inside the loaded code is a no-op and adds
extra HTML to the <head> that blocks text/layout rendering and
delays fetching of Popups JS.

Bug: T219342
Change-Id: I9c1f4b3861ce2cecb654eb0a78469a616730a40b
2019-04-09 18:31:35 +00:00
Thiemo Kreuz 511c74bf72 Make sure to never trigger multiple events
I had to disable ESLint to be allowed to upload this patch. It starts
complaining about something in code I did not even touched. The error
message does not make any sense to me (something about globals being
forbidden in code where I can not spot anything that would be remotely
global).

Change-Id: I6d4b178a65126c4b81b87d99142a6cdc845ae5ee
2019-03-26 12:39:28 -06:00
Andrew Kostka 522829c43a Add a fade out to reference content
This will only be applied when the height of the content exceeds four
lines of text.

Bug: T217139
Change-Id: If15952c9886c23827873812bb63e8e3127776709
2019-03-25 13:30:52 +01:00
Andrew Kostka 42ee00fe37 Improve popup pointer positioning
Bug: T217737
Change-Id: Id478b8cc8dc7aefdd07dde5d5567aa0a1d8ee970
2019-03-20 10:39:18 +00:00
Jan Drewniak 8aad5981e4 Fix double pokey bug
When a thumbnail in portrait-mode is narrower than the 200px
expected width, the SVG clip-path should be shifted on the x-axis
in order to align with the thumbnail image.

Adds extra test-cases to validate this logic.

Bug: T204627
Change-Id: I9359c9fb335e5fad3f7d5ba33ee89d2a1f26b8b2
2019-03-20 01:29:46 +00:00
Thiemo Kreuz 4792151769 Split PreviewModel documentation into subclasses
See T218105 for discussion.

Bug: T218105
Change-Id: I0fde5de6e573e219f0937797bf10c20a01021a6a
2019-03-19 14:56:21 +01:00
Ed Sanders 1627dadcab build: Update eslint-config-wikimedia to 0.11.0
Change-Id: I80e2707d9954f8549aa0241f4c7f64eb2644ec93
2019-03-18 15:48:01 -06:00
Thiemo Kreuz 43b6b89ce6 Avoid use of eslint-disable-… in another case
Most other code in this codebase already uses the /* global … */
syntax.

Change-Id: I00bd4d0490fa6976099f5a182cad6c7253b8e1ac
2019-03-18 12:50:35 +01:00
Thiemo Kreuz 932271b6db Add missing escaping for jQuery ID selector
We run into this issue already one time, see Ifb5fe89 (T214710). The
exact same applies here.

The effect of this bug is that for certain references (typically ones
with a colon character in their name) the "jump down" link will be
broken.

Change-Id: Ic6723bd910cb5e5e1e1872ce39f2e271012245de
2019-03-14 20:03:15 +01:00
Thiemo Kreuz 3f7f0cc91b Mention concatenated message keys in a comment for easy grep
Bug: T215063
Change-Id: I3cc87846974ef942181ebdaa1b024cd5ee523529
2019-03-13 15:28:54 +01:00
Thiemo Kreuz 1d2becc25a Consistently talk about "Reference" instead of "Footnote"
During story time on 2019-03-12 it was decided to consistently talk
about "References" in all messages. Main motivation is that this is
the term the community is most familiar with, and it is also the term
that is used in reference section headings most of the time.

Bug: T215063
Change-Id: Iaab8d2c0da1546a3c9d27bc8e2e1c784050ed135
2019-03-13 09:29:26 +01:00
WMDE-Fisch 0d2d6d4c9b Move getPreviewType form gateway to model
The method itself has not much to do with gateways as such, it's
more about the general preview type selection. Since the preview
types "live" in the model, I thought it might good to move it there.

Doing that the "original" getPreviewType method in the model was renamed
to avoid conflicts. If I get this right, that method is quite specific to
page previews, since it processes the output from the TextExtracts API-
request. - Therefore I also removed the TYPE_REFERENCE there, because this
code path will never be reached with that type afaik.

Inspired by the comments in Id1fa7dad59d8fe80bc60c1e2d7c3fb4087e52d1f and
as preparation for that patch.

Bug: T215420
Change-Id: Ic9e24a73e945c7d56435c656ecfdb42b65601d22
2019-03-12 08:28:46 -06:00
WMDE-Fisch 3915dd166f Remove unused parameter
As far as I can see this is not used in the method.

Change-Id: I0d6373ba5697fbc228552465e1e8d95c05720132
2019-03-11 16:51:49 -06:00
WMDE-Fisch 4803a717ad Change delay for ReferencePreviews to 150ms
Bug: T215420
Change-Id: Id1fa7dad59d8fe80bc60c1e2d7c3fb4087e52d1f
2019-03-11 16:37:53 -06:00
WMDE-Fisch b6c1ea3f03 Minor code optimizations in SVG files
Change-Id: I8c9b1a7c2cc11690d72f4c851d598b68560bcf36
2019-03-05 19:29:20 +00:00
WMDE-Fisch 5da1009d4b Fix shade of blue in beta feature images
Bug: T215896
Change-Id: I19b7098afc176f929951c8a51a000393eabd6f32
2019-02-27 14:19:11 +01:00
Thiemo Kreuz 0beabf2bdf Bring reference type detection in sync with RESTbased endpoint
The RESTbased references endpoint accepts multiple <cite> tags, as long
as they do not have conflicting types.

As specified at
https://www.mediawiki.org/wiki/Page_Content_Service/References#Decisions

Bug: T215281
Change-Id: I8a7d2d6da8a8d9746b971417833b954d1f1d6041
2019-02-26 14:51:53 +01:00
jenkins-bot f812611470 Merge "Add reference type detection to HTML scraping gateway" 2019-02-26 12:23:47 +00:00