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

feat: log search interactions to APM #2036

Merged
merged 19 commits into from
Aug 30, 2023

Conversation

rwd
Copy link
Contributor

@rwd rwd commented Aug 9, 2023

Summary:

  • Logs two user search interactions: performing a search, with number of results; clicking on a search result
  • When loading a search by SSR, defers logging to the client-side so that session ID may always be logged

Detail:

  • Adds a new custom pkg vue-session-id which generates a session ID with uuid and stores it in sessionStorage
  • Adds a new mixin elasticApmReporter which:
    • provides a method logApmTransaction which:
      • accepts an optional object argument with name and labels properties for the transaction to log to APM, and stores it to the component data
      • if client-side, and a transaction object is stored in the component data:
        • adds session ID to the transaction labels
        • send the transaction to APM
        • waits 100 ms before closing the APM transaction, as otherwise the agent appears to discard the almost-immediate transaction
        • clears the transaction object from the component data
    • when mounted, calls logApmTransaction to log any transaction object already stored in the component data, e.g. from server-side hydration
  • In SearchInterface:
    • changes the API params from a computed property to one derived on-demand, so that they don't change when the user clicks a search result, which would prevent them being used in that interaction logging
    • uses the elasticApmReporter mixin to log search interactions for fetching results and clicking a result
  • In ItemPreviewCard:
    • adds props to support custom event listeners for the click and auxclick events on the cards, used for the search result click logging
  • In the Record API search plugin:
    • stop adding the contentTier filter there, and instead have all callers of the search method add them (via an exported function) if needed. (So that the contentTier filter gets logged to APM.)

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

JIRA ticket: EC-6318

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Preview deployment: https://pr-2036.portal-js.dev.eanadev.org/

@rwd rwd requested a review from lbiedinger August 9, 2023 13:50
@rwd rwd changed the title feat: log to APM search interactions feat: log search interactions to APM Aug 25, 2023
Copy link
Member

@lbiedinger lbiedinger left a comment

Choose a reason for hiding this comment

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

The user buttons and the copyright and type info section in the list view also cause events to fire when they're clicked on.

Adding an @click.stop="" attribute to the wrapper div in portal/src/components/user/UserButtons.vue looks like it successfully prevents this from happening.

packages/vue-session-id/README.md Outdated Show resolved Hide resolved
@rwd
Copy link
Contributor Author

rwd commented Aug 29, 2023

@lbiedinger to prevent clicking the user buttons from logging the search interaction, I have used @click.stop as you suggested, but put it into ItemPreviewCard instead of within UserButtons.

@sonarcloud
Copy link

sonarcloud bot commented Aug 29, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

95.5% 95.5% Coverage
0.0% 0.0% Duplication

@lbiedinger lbiedinger merged commit 63c4d95 into master Aug 30, 2023
17 of 18 checks passed
@lbiedinger lbiedinger deleted the feat/EC-6318-APM-log-search-interactions branch August 30, 2023 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants