Skip to content

Commit

Permalink
fix: Phishing page metrics (#28364)
Browse files Browse the repository at this point in the history
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28364?quickstart=1)

## **Related issues**

Fixes:
https://github.com/orgs/MetaMask/projects/103/views/1?pane=issue&itemId=86413189

## **Manual testing steps**

See Issue attached in Related Issues.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.

---------

Co-authored-by: AugmentedMode <31675118+AugmentedMode@users.noreply.github.com>
  • Loading branch information
mindofmar and AugmentedMode authored Nov 27, 2024
1 parent c0574f4 commit 080d005
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,27 @@ function maybeDetectPhishing(theController) {

// Determine the block reason based on the type
let blockReason;
let blockedUrl = hostname;
if (phishingTestResponse?.result && blockedRequestResponse.result) {
blockReason = `${phishingTestResponse.type} and ${blockedRequestResponse.type}`;
} else if (phishingTestResponse?.result) {
blockReason = phishingTestResponse.type;
} else {
blockReason = blockedRequestResponse.type;
blockedUrl = details.initiator;
}

theController.metaMetricsController.trackEvent({
// should we differentiate between background redirection and content script redirection?
event: MetaMetricsEventName.PhishingPageDisplayed,
category: MetaMetricsEventCategory.Phishing,
properties: {
url: hostname,
url: blockedUrl,
referrer: {
url: hostname,
url: blockedUrl,
},
reason: blockReason,
requestDomain: blockedRequestResponse.result ? hostname : undefined,
},
});
const querystring = new URLSearchParams({ hostname, href });
Expand Down

0 comments on commit 080d005

Please sign in to comment.