Skip to content

Commit

Permalink
refactor: rm getMetricsState createRPCMethodTrackingMiddleware param
Browse files Browse the repository at this point in the history
  • Loading branch information
digiwand committed Sep 9, 2024
1 parent ad65b1c commit 2fe0a90
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
6 changes: 2 additions & 4 deletions app/scripts/lib/createRPCMethodTrackingMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ let globalRateLimitCount = 0;
* signature requests
*
* @param {object} opts - options for the rpc method tracking middleware
* @param {Function} opts.getMetricsState - get the state of
* MetaMetricsController
* @param {number} [opts.rateLimitTimeout] - time, in milliseconds, to wait before
* allowing another set of events to be tracked for methods rate limited by timeout.
* @param {number} [opts.rateLimitSamplePercent] - percentage, in decimal, of events
Expand All @@ -149,7 +147,6 @@ let globalRateLimitCount = 0;
*/

export default function createRPCMethodTrackingMiddleware({
getMetricsState,
rateLimitTimeout = 60 * 5 * 1000, // 5 minutes
rateLimitSamplePercent = 0.001, // 0.1%
globalRateLimitTimeout = 60 * 5 * 1000, // 5 minutes
Expand Down Expand Up @@ -197,7 +194,8 @@ export default function createRPCMethodTrackingMiddleware({
// anything. This is extra redundancy because this value is checked in
// the metametrics controller's trackEvent method as well.
const userParticipatingInMetaMetrics =
getMetricsState().participateInMetaMetrics === true;
metaMetricsController.store.getMetricsState().participateInMetaMetrics ===
true;

// Get the event type, each of which has APPROVED, REJECTED and REQUESTED
// keys for the various events in the flow.
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/lib/createRPCMethodTrackingMiddleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const MOCK_ID = '123';
const expectedUniqueIdentifier = `signature-${MOCK_ID}`;

const metricsState = { participateInMetaMetrics: null };
const getMetricsState = () => metricsState;

const expectedMetametricsEventUndefinedProps = {
actionId: undefined,
Expand Down Expand Up @@ -77,10 +76,10 @@ const metaMetricsController = new MetaMetricsController({
},
},
});
metaMetricsController.store.getMetricsState = () => metricsState;

const createHandler = (opts) =>
createRPCMethodTrackingMiddleware({
getMetricsState,
rateLimitTimeout: 1000,
rateLimitSamplePercent: 0.1,
globalRateLimitTimeout: 0,
Expand Down
3 changes: 0 additions & 3 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5452,9 +5452,6 @@ export default class MetamaskController extends EventEmitter {

engine.push(
createRPCMethodTrackingMiddleware({
getMetricsState: this.metaMetricsController.store.getState.bind(
this.metaMetricsController.store,
),
getAccountType: this.getAccountType.bind(this),
getDeviceModel: this.getDeviceModel.bind(this),
isConfirmationRedesignEnabled,
Expand Down

0 comments on commit 2fe0a90

Please sign in to comment.