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

chore: Emit externalLinkInteracted events for buttons #1367

Merged
merged 3 commits into from
Jul 27, 2023

Conversation

connorlanigan
Copy link
Member

@connorlanigan connorlanigan commented Jul 25, 2023

Description

We're already emitting the externalLinkInteracted in the Link component, when the external prop is enabled:

const fireFunnelEvent = (funnelInteractionId: string) => {
if (variant === 'info') {
const stepName = getNameFromSelector(stepNameSelector);
const subStepName = getNameFromSelector(subStepNameSelector);
FunnelMetrics.helpPanelInteracted({
funnelInteractionId,
stepNumber,
stepName,
stepNameSelector,
subStepSelector,
subStepName,
subStepNameSelector,
elementSelector: getFunnelValueSelector(uniqueId),
subStepAllSelector: getSubStepAllSelector(),
});
} else if (external) {
const stepName = getNameFromSelector(stepNameSelector);
const subStepName = getNameFromSelector(subStepNameSelector);
FunnelMetrics.externalLinkInteracted({
funnelInteractionId,
stepNumber,
stepName,
stepNameSelector,
subStepSelector,
subStepName,
subStepNameSelector,
elementSelector: getFunnelValueSelector(uniqueId),
subStepAllSelector: getSubStepAllSelector(),
});
}
};
const fireFollowEvent = (event: React.SyntheticEvent) => {
if (funnelInteractionId) {
fireFunnelEvent(funnelInteractionId);
}

There are also instances where the Button component is used to build an external link. The Button component does not have an external prop, but it allows to set the iconName and target to replicate the behaviour.
When these properties are set, we will now send the same externalLinkInteracted event as in the Link component.

Related links, issue #, if available: n/a

How has this been tested?

Added unit test

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@connorlanigan connorlanigan marked this pull request as ready for review July 25, 2023 11:51
@connorlanigan connorlanigan requested a review from a team as a code owner July 25, 2023 11:51
@connorlanigan connorlanigan requested review from rubencarvalho and removed request for a team July 25, 2023 11:51
@codecov
Copy link

codecov bot commented Jul 25, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (85117c2) 93.47% compared to head (568a0be) 93.47%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1367   +/-   ##
=======================================
  Coverage   93.47%   93.47%           
=======================================
  Files         623      623           
  Lines       16769    16777    +8     
  Branches     5550     5551    +1     
=======================================
+ Hits        15674    15682    +8     
  Misses       1022     1022           
  Partials       73       73           
Files Changed Coverage Δ
src/button/internal.tsx 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

expect(FunnelMetrics.externalLinkInteracted).not.toHaveBeenCalled();
});

test('sends an externalLinkInteracted metric within a Funnel Context with iconName=external', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we maybe add a test for when iconName="external" but no href is present?

Copy link
Contributor

@rubencarvalho rubencarvalho left a comment

Choose a reason for hiding this comment

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

LGTM, just left a comment about an additional test, to cover the case when isAnchor is false :)

@connorlanigan connorlanigan merged commit 33458e3 into main Jul 27, 2023
24 checks passed
@connorlanigan connorlanigan deleted the funnel/button-link-events branch July 27, 2023 13:05
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