openverse icon indicating copy to clipboard operation
openverse copied to clipboard

Add BACK_TO_TOP event and fire when button is clicked

Open d3jawu opened this issue 1 year ago • 4 comments

Fixes

Resolves #2276 by @fcoveram.

Fixes #4948 by @d3jawu.

Description

Adds a new analytics event, BACK_TO_TOP, and fires it when the "back to top" button in the bottom-right corner is clicked.

Fixes the behavior of the "back to top" button, which had stopped working on the search page. Verified that the behavior still works on other pages.

Testing Instructions

  1. Run a search.
  2. Click the "back to top" caret button in the bottom-right corner.
  3. See that an analytics event for BACK_TO_TOP is logged.
  4. See that the page scrolls back to the top instead of remaining in place.

Checklist

  • [x] My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • [x] My pull request targets the default branch of the repository (main) or a parent feature branch.
  • [ ] My commit messages follow best practices.
  • [x] My code follows the established code style of the repository.
  • [ ] I added or updated tests for the changes I made (if applicable).
  • [ ] I added or updated documentation (if applicable).
  • [x] I tried running the project locally and verified that there are no visible errors.
  • [ ] I ran the DAG documentation generator (ov just catalog/generate-docs for catalog PRs) or the media properties generator (ov just catalog/generate-docs media-props for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

d3jawu avatar Sep 17 '24 23:09 d3jawu

I think the params should be similar to the once sent by REACH_RESULT_END:

Hi @obulat what exactly do you mean by this? Should they match them exactly, or include them in addition to the ones listed in the issue?

d3jawu avatar Sep 19 '24 21:09 d3jawu

I think the params should be similar to the once sent by REACH_RESULT_END:

Hi @obulat what exactly do you mean by this? Should they match them exactly, or include them in addition to the ones listed in the issue?

It's the latter, they should contain

  • searchType: SupportedSearchType
  • kind: ResultKind
  • query: string
  • resultPage: number
  • collectionType: Collection | "null"
  • collectionValue: string | "null"

and

  • page
  • scrollPixels
  • maxScroll

Here's the way we get those properties for REACH_RESULT_END event:

https://github.com/WordPress/openverse/blob/499276274e05ca893e8cd0833eb5228a6a4b3797/frontend/src/components/VLoadMore.vue#L38-L50

Plausible does not allow us to send undefined as the value for a parameter. The values here could be non-number. Maybe we should use -1 instead of undefined, @WordPress/openverse-frontend ?

obulat avatar Sep 20 '24 13:09 obulat

A couple little things:

  • I've used -1 instead of undefined for the numeric values.
  • For unsupported search types (video and model-3d) I've defaulted to all.

Let me know if you'd rather I use other values!

d3jawu avatar Sep 20 '24 20:09 d3jawu

Based on the contributor urgency of this PR, the following reviewers are being gently reminded to review this PR:

@dhruvkb This reminder is being automatically generated due to the urgency configuration.

Excluding weekend[^1] days, this PR was ready for review 5 day(s) ago. PRs labelled with contributor urgency are expected to be reviewed within 3 weekday(s)[^2].

@d3jawu, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

[^1]: Specifically, Saturday and Sunday. [^2]: For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

openverse-bot avatar Sep 25 '24 00:09 openverse-bot