Skip to content

Commit

Permalink
Revert "feat: Add metrics for provider calls coming from ppom on exte…
Browse files Browse the repository at this point in the history
…nsion (#21482)"

This reverts commit 0a261a8.
  • Loading branch information
seaona authored and danjm committed Nov 10, 2023
1 parent b2bf175 commit ce4e2d7
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 401 deletions.
10 changes: 0 additions & 10 deletions app/scripts/lib/createRPCMethodTrackingMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,6 @@ export default function createRPCMethodTrackingMiddleware({
const paramsExamplePassword = req?.params?.[2];

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
if (req.securityAlertResponse?.providerRequestsCount) {
Object.keys(req.securityAlertResponse.providerRequestsCount).forEach(
(key) => {
const metricKey = `ppom_${key}_count`;
eventProperties[metricKey] =
req.securityAlertResponse.providerRequestsCount[key];
},
);
}

eventProperties.security_alert_response =
req.securityAlertResponse?.result_type ??
BlockaidResultType.NotApplicable;
Expand Down
41 changes: 0 additions & 41 deletions app/scripts/lib/createRPCMethodTrackingMiddleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,47 +143,6 @@ describe('createRPCMethodTrackingMiddleware', () => {
});
});

it(`should track an event with correct blockaid parameters when providerRequestsCount is provided`, async () => {
const req = {
method: MESSAGE_TYPE.ETH_SIGN,
origin: 'some.dapp',
securityAlertResponse: {
result_type: BlockaidResultType.Malicious,
reason: BlockaidReason.maliciousDomain,
providerRequestsCount: {
eth_call: 5,
eth_getCode: 3,
},
},
};

const res = {
error: null,
};
const { next } = getNext();
await handler(req, res, next);
expect(trackEvent).toHaveBeenCalledTimes(1);
/**
* TODO:
* toMatchObject matches even if the the matched object does not contain some of the properties of the expected object
* I'm not sure why toMatchObject is used but we should probably check the other tests in this file for correctness in
* another PR.
*
*/
expect(trackEvent.mock.calls[0][0]).toStrictEqual({
category: 'inpage_provider',
event: MetaMetricsEventName.SignatureRequested,
properties: {
signature_type: MESSAGE_TYPE.ETH_SIGN,
security_alert_response: BlockaidResultType.Malicious,
security_alert_reason: BlockaidReason.maliciousDomain,
ppom_eth_call_count: 5,
ppom_eth_getCode_count: 3,
},
referrer: { url: 'some.dapp' },
});
});

it(`should track a ${MetaMetricsEventName.SignatureApproved} event if the user approves`, async () => {
const req = {
method: MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4,
Expand Down
Loading

0 comments on commit ce4e2d7

Please sign in to comment.