-
Notifications
You must be signed in to change notification settings - Fork 5k
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
base: main
Are you sure you want to change the base?
Conversation
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. |
Builds ready [b22bea6]
Page Load Metrics (1619 ± 44 ms)
Bundle size diffs
|
Builds ready [a3f8f6d]
Page Load Metrics (1705 ± 74 ms)
Bundle size diffs
|
@@ -45,6 +45,7 @@ function ReportLink({ | |||
<Text marginTop={1} display={Display.Flex}> | |||
{t('somethingDoesntLookRight', [ | |||
<ButtonLink | |||
data-testid="alert-provider-report-link" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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!
...unapprovedTypedMessage, | ||
}; | ||
|
||
console.log(state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log(state); |
export const getMetamaskStateWithMaliciousPermit = (accountAddress: string) => { | ||
const pendingPermitId = '48a75190-45ca-11ef-9001-f3886ec2397c'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor nit] we can move this out to avoid reinstantiating for each getMetamaskStateWithMaliciousPermit call
export const getMetamaskStateWithMaliciousPermit = (accountAddress: string) => { | |
const pendingPermitId = '48a75190-45ca-11ef-9001-f3886ec2397c'; | |
const pendingPermitId = '48a75190-45ca-11ef-9001-f3886ec2397c'; | |
export const getMetamaskStateWithMaliciousPermit = (accountAddress: string) => { |
await waitFor(() => { | ||
updateSignatureEventFragment = | ||
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(updateSignatureEventFragment).toBeDefined(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use Jest's matchers rather than relying on string comparisons?
await waitFor(() => { | |
updateSignatureEventFragment = | |
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(updateSignatureEventFragment).toBeDefined(); | |
}); | |
expect( | |
mockedBackgroundConnection.submitRequestToBackground, | |
).toHaveBeenCalledWith( | |
'updateEventFragment', | |
expect.arrayContaining([ | |
expect.objectContaining({ | |
properties: expect.objectContaining({ | |
external_link_clicked: 'security_alert_support_link', | |
}), | |
}), | |
]), | |
); |
...unapprovedTypedMessage, | ||
}; | ||
|
||
console.log(state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guessing this is forgotten
const onClickSupportLink = () => { | ||
const properties = { | ||
properties: { | ||
external_link_clicked: 'security_alert_support_link', | ||
}, | ||
}; | ||
updateSignatureEventFragment(properties); | ||
updateTransactionEventFragment(properties, ownerId); | ||
}; | ||
|
There was a problem hiding this comment.
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?
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]); |
…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
Related issues
Fixes: #23995
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist