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

fix: Clicking on report link does not add external_link_clicked to si… #29969

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

pnarayanaswamy
Copy link
Contributor

@pnarayanaswamy pnarayanaswamy commented Jan 29, 2025

…gnature events

Description

Fixes the bug that the external_link_clicked property is not added to the Signature approved, signature rejected , transaction approved and transaction rejected events
Adds integration tests to verify the property is added to the metrics

Open in GitHub Codespaces

Related issues

Fixes: #23995

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@pnarayanaswamy pnarayanaswamy requested a review from a team as a code owner January 29, 2025 15:30
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-qa QA team label Jan 29, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [b22bea6]
Page Load Metrics (1619 ± 44 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint46617701564266128
domContentLoaded1435171815918842
load1445176816199144
domInteractive2378422110
backgroundConnect86124189
firstReactRender1599372814
getState47116189
initialActions00000
loadScripts1020130311668139
setupStore781172110
uiStartup166724321903212102
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 399 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@pnarayanaswamy pnarayanaswamy added the team-confirmations Push issues to confirmations team label Jan 30, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [a3f8f6d]
Page Load Metrics (1705 ± 74 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30020661643342164
domContentLoaded14652056168214771
load14742069170515574
domInteractive23171453316
backgroundConnect887272412
firstReactRender15100412713
getState45615178
initialActions01000
loadScripts10341510121611053
setupStore68015189
uiStartup17012440195919996
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 667 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

@@ -45,6 +45,7 @@ function ReportLink({
<Text marginTop={1} display={Display.Flex}>
{t('somethingDoesntLookRight', [
<ButtonLink
data-testid="alert-provider-report-link"
Copy link
Contributor

Choose a reason for hiding this comment

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

We avoid adding data-testid in extension, in case its possible to query using button text it may be better.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this suggestion. I do like using findByText to also test text expectations simultaneously

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But text can change, making tests flaky and prone to failure due to content updates. Coupling tests to specific text, especially when supporting multiple languages is not recommended. Why do we not want to use test-ids? it supports testing and makes things stable.

Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

one thing, I think we should remove the console.log before merging. other than this, Lgtm!

test/integration/confirmations/signatures/permit.test.tsx Outdated Show resolved Hide resolved
Comment on lines 39 to 48
const onClickSupportLink = () => {
const properties = {
properties: {
external_link_clicked: 'security_alert_support_link',
},
};
updateSignatureEventFragment(properties);
updateTransactionEventFragment(properties, ownerId);
};

Copy link
Member

Choose a reason for hiding this comment

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

Should we create this callback with useCallback if it has ownerId dependency?

Suggested change
const onClickSupportLink = () => {
const properties = {
properties: {
external_link_clicked: 'security_alert_support_link',
},
};
updateSignatureEventFragment(properties);
updateTransactionEventFragment(properties, ownerId);
};
const onClickSupportLink = useCallback(() => {
const properties = {
properties: {
external_link_clicked: 'security_alert_support_link',
},
};
updateSignatureEventFragment(properties);
updateTransactionEventFragment(properties, ownerId);
}, [ownerId]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is already done in ui/pages/confirmations/hooks/useTransactionEventFragment.js, so adding it here won't make any difference right?

Copy link
Member

Choose a reason for hiding this comment

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

I think only fallback is settling in the updateTransactionEventFragment not the given transactionId (in this case ownerId) In my opinion, it's good practice to have it right in order to prevent any side effects.

@metamaskbot
Copy link
Collaborator

Builds ready [79a2a4f]
Page Load Metrics (1745 ± 74 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint25220881676358172
domContentLoaded14892075172115575
load14992092174515474
domInteractive24164453115
backgroundConnect999312311
firstReactRender1696402713
getState45912126
initialActions01000
loadScripts10351473124612560
setupStore886212311
uiStartup171525452005227109
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 667 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

Comment on lines +525 to +541
await waitFor(() => {
updateTransactionEventFragment =
mockedBackgroundConnection.submitRequestToBackground.mock.calls?.find(
(call) =>
call[0] === 'updateEventFragment' &&
JSON.stringify(call[1]).includes(
JSON.stringify({
properties: {
external_link_clicked: 'security_alert_support_link',
},
}),
),
);

expect(updateTransactionEventFragment).toBeDefined();
});
});
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to change this to use jest matchers as well?

@metamaskbot
Copy link
Collaborator

Builds ready [9ece707]
Page Load Metrics (1562 ± 60 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint13991836156312460
domContentLoaded13821822154411957
load13911839156212460
domInteractive236735157
backgroundConnect85427199
firstReactRender1595472814
getState410621
initialActions01000
loadScripts9661337110410651
setupStore75210105
uiStartup16082191178817283
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 667 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-confirmations Push issues to confirmations team team-qa QA team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Clicking on false positive, Blockaid link does not add external_link_clicked to signature events
7 participants