Skip to content
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

Exclude hardware wallets from TTS tracking #6247

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
walmat marked this conversation as resolved.
Show resolved Hide resolved

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
Loading