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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挕onFrustration or onRageClick callback #2501

Open
sators opened this issue Nov 12, 2023 · 1 comment
Open

馃挕onFrustration or onRageClick callback #2501

sators opened this issue Nov 12, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@sators
Copy link

sators commented Nov 12, 2023

Is your feature request related to a problem? Please describe.

It would be great if the library had a callback option for a function that could be run when a frustration/rage click is detected so that we could display a helpful popup/chat prompt to the user to try to help/gather more feedback as to what they are trying to do.

Describe the solution you'd like

A configuration option like 'onFrustration' or 'onRageClick'

Describe alternatives you've considered

None

@sators sators added the enhancement New feature or request label Nov 12, 2023
@BenoitZugmeyer
Copy link
Member

Thank you for your feedback, we'll considering it. In the meantime, you could imlement this via the beforeSend hook, something like this:

      DD_RUM.init({
        ...
        trackUserInteractions: true,
        beforeSend(event) {
          if (
            event.type === 'action' &&
            event.action.type === 'click' &&
            event.action.frustration?.type.includes('rage_click')
          ) {
            // got a rage click
            showFeedbackForm()
          }
        },
      })

Keep in mind that rageclick detection is subjective and the user might not perceive an action as "rage" even if we report it as such. You could fine-tune the condition by using context.events, example:

      DD_RUM.init({
        ...
        trackUserInteractions: true,
        beforeSend(event, context) {
          if (
            event.type === 'action' &&
            event.action.type === 'click' &&
            event.action.frustration?.type.includes('rage_click') &&
            // don't open the feedback form if a click is on the "Next Page" button
            !context.events.some(event => event.target.matches(".next-page"))
          ) {
            // got a rage click
            showFeedbackForm()
          }
        },
      })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants