Skip to content

Commit

Permalink
add check to disable for hardware wallets (#6247)
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat authored Nov 1, 2024
1 parent cb2b8a0 commit 384662a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/state/performance/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { OperationForScreen, PerformanceLog, Screen } from '@/state/performance/
import { analyticsV2 } from '@/analytics';
import { logger } from '@/logger';
import { runOnJS } from 'react-native-reanimated';
import store from '@/redux/store';

type AnyFunction = (...args: any[]) => any;

Expand All @@ -23,6 +24,12 @@ interface PerformanceTrackingState {
};
}

export function isEnabled() {
const isHardwareWallet = store.getState().wallets.selected?.deviceId;

return !isHardwareWallet;
}

// Helper function to log performance to Rudderstack
function logPerformance<S extends Screen>({
screen,
Expand All @@ -33,6 +40,11 @@ function logPerformance<S extends Screen>({
endOfOperation,
}: ExecuteFnParamsWithoutFn<S> & { startTime: number; endTime: number }) {
performanceTracking.setState(state => {
if (!isEnabled()) {
logger.debug('[performance]: Performance tracking is disabled');
return state;
}

const timeToCompletion = endTime - startTime;
const log: PerformanceLog<S> = {
completedAt: Date.now(),
Expand Down

0 comments on commit 384662a

Please sign in to comment.