Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update payload of collection search analytics events #3957

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

zackkrida
Copy link
Member

Fixes

Fixes #3619 by @obulat

Description

This PR updates the payload of search-related analytics events to include collection information on collection searches. These collection-related values are null on other searches. It also adds the existing kind custom property to the LOAD_MORE_RESULTS and REACH_RESULT_END events.

One aspect of this PR I do not like is the accessing the search store inside of the image cell and audio result components. It does feel ideal to use a standardized approach to getting the current search strategy and the value (string of the name of the tag, source, or source/creator) from one centralized place, but I don't like accessing a global store in a component which is repeated several times on the page.

Testing Instructions

  1. Enable additional_search_views on http://localhost:8443/preferences
  2. Open your browser console
  3. Make a standard search and scroll to the bottom of the page. Confirm the logged REACH_RESULT_END event matches this partial payload { kind: "search", collectionType: null, collectionValue: null }
  4. Load more results. Confirm the logged LOAD_MORE_RESULTS event matches this partial payload { kind: "search", collectionType: null, collectionValue: null }.
  5. Select a result. Confirm the logged SELECT_SEARCH_RESULT event matches this partial payload { kind: "search", collectionType: null, collectionValue: null }.
  6. Click on the new creator link below the title of the current result to visit the new creator collection page. Scroll to the bottom of the page.
  7. Confirm the logged REACH_RESULT_END event matches this partial payload { kind: "collection", collectionType: "creator", collectionValue: {source}/{creatorName} }
  8. Load more results. Confirm the logged LOAD_MORE_RESULTS event matches this partial payload { kind: "collection", collectionType: "creator", collectionValue: {source}/{creatorName} }.
  9. Select a result. Confirm the logged SELECT_SEARCH_RESULT event matches this partial payload { kind: "collection", collectionType: "creator", collectionValue: {source}/{creatorName} }.
  10. Repeat steps 6-9 but for a tag page (by clicking on a tag). Repeat steps 6-9 for a source page (by clicking on a source button). Ensure the correct value for the type.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • 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).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if 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.

@zackkrida zackkrida requested a review from a team as a code owner March 22, 2024 22:45
@openverse-bot openverse-bot added 🟨 priority: medium Not blocking but should be addressed soon ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work labels Mar 22, 2024
@github-actions github-actions bot added the 🧱 stack: frontend Related to the Nuxt frontend label Mar 22, 2024
@zackkrida zackkrida removed the 🚦 status: awaiting triage Has not been triaged & therefore, not ready for work label Mar 22, 2024
Copy link
Member

@dhruvkb dhruvkb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +220 to +221
switch (this.collectionParams.collection) {
case "creator": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a while since I saw switch-case because the object access pattern {}[] appears so much more often. Nice!

Comment on lines -185 to +188
const { sendCustomEvent } = useAnalytics()
const { $sendCustomEvent } = useContext()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works really well. The additional types and store values make the code clean, too ✨

* on collection pages, added in the
* "Additional Search Views" project.
*/
type CollectionProperties = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -8,6 +8,7 @@ import type { FilterCategory } from "~/constants/filters"
import { ResultKind } from "~/types/result"

import { RequestKind } from "./fetch-state"
import { Collection } from "./search"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the previous imports use relative path, while we usually use absolute. I'd prefer to use absolute paths everywhere (and add import type if it's a type)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, it feels weird that ESLint didn't catch and report this. We should look into that, but separately from this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice catch! These were auto imports from vscode so I didn't even check them. I'll fix

@zackkrida zackkrida merged commit 1f6be82 into main Mar 25, 2024
39 checks passed
@zackkrida zackkrida deleted the fix-#3619_add_additional_search_analytics branch March 25, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Update REACH_RESULT_END, LOAD_MORE, SELECT_SEARCH_RESULT analytics events for additional search views
4 participants