Skip to content

Commit

Permalink
fix: type for auth events and typo (#8861)
Browse files Browse the repository at this point in the history
- type for auth events
- fix typo

Fixes #8860
  • Loading branch information
NicolasMassart authored Mar 7, 2024
1 parent 92c9521 commit c02483c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
13 changes: 8 additions & 5 deletions app/core/SecureKeychain.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const defaultOptions = {
fingerprintPromptCancel: strings('authentication.fingerprint_prompt_cancel'),
};
import AUTHENTICATION_TYPE from '../constants/userProperties';
import { AUTHENTICATION_TYPE as NATIVE_AUTH_TYPE } from 'react-native-keychain';
import { UserProfileProperty } from '../util/metrics/UserSettingsAnalyticsMetaData/UserProfileAnalyticsMetaData.types';

/**
* Class that wraps Keychain from react-native-keychain
* abstracting metamask specific functionality and settings
Expand Down Expand Up @@ -81,7 +82,7 @@ export default {
await AsyncStorage.removeItem(PASSCODE_CHOICE);
// This is called to remove other auth types and set the user back to the default password login
await MetaMetrics.getInstance().addTraitsToUser({
[NATIVE_AUTH_TYPE]: AUTHENTICATION_TYPE.PASSWORD,
[UserProfileProperty.AUTHENTICATION_TYPE]: AUTHENTICATION_TYPE.PASSWORD,
});
return Keychain.resetGenericPassword(options);
},
Expand Down Expand Up @@ -118,16 +119,18 @@ export default {
if (type === this.TYPES.BIOMETRICS) {
authOptions.accessControl = Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET;
await metrics.addTraitsToUser({
[NATIVE_AUTH_TYPE]: AUTHENTICATION_TYPE.BIOMETRIC,
[UserProfileProperty.AUTHENTICATION_TYPE]:
AUTHENTICATION_TYPE.BIOMETRIC,
});
} else if (type === this.TYPES.PASSCODE) {
authOptions.accessControl = Keychain.ACCESS_CONTROL.DEVICE_PASSCODE;
await metrics.addTraitsToUser({
[NATIVE_AUTH_TYPE]: AUTHENTICATION_TYPE.PASSCODE,
[UserProfileProperty.AUTHENTICATION_TYPE]: AUTHENTICATION_TYPE.PASSCODE,
});
} else if (type === this.TYPES.REMEMBER_ME) {
await metrics.addTraitsToUser({
[NATIVE_AUTH_TYPE]: AUTHENTICATION_TYPE.REMEMBER_ME,
[UserProfileProperty.AUTHENTICATION_TYPE]:
AUTHENTICATION_TYPE.REMEMBER_ME,
});
//Don't need to add any parameter
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum UserProfilePropery {
export enum UserProfileProperty {
ENABLE_OPENSEA_API = 'Enable OpenSea API',
NFT_AUTODETECTION = 'NFT Autodetection',
THEME = 'Theme',
Expand All @@ -11,10 +11,10 @@ export enum UserProfilePropery {
}

export interface UserProfileMetaData {
[UserProfilePropery.ENABLE_OPENSEA_API]: string;
[UserProfilePropery.NFT_AUTODETECTION]: string;
[UserProfilePropery.THEME]: string;
[UserProfilePropery.TOKEN_DETECTION]: string;
[UserProfilePropery.MULTI_ACCOUNT_BALANCE]: string;
[UserProfilePropery.SECURITY_PROVIDERS]: string;
[UserProfileProperty.ENABLE_OPENSEA_API]: string;
[UserProfileProperty.NFT_AUTODETECTION]: string;
[UserProfileProperty.THEME]: string;
[UserProfileProperty.TOKEN_DETECTION]: string;
[UserProfileProperty.MULTI_ACCOUNT_BALANCE]: string;
[UserProfileProperty.SECURITY_PROVIDERS]: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Appearance } from 'react-native';
import { store } from '../../../store';
import {
UserProfileMetaData,
UserProfilePropery,
UserProfileProperty,
} from './UserProfileAnalyticsMetaData.types';

/**
Expand All @@ -19,24 +19,24 @@ const generateUserProfileAnalyticsMetaData = (): UserProfileMetaData => {
appTheme === 'os' ? Appearance.getColorScheme() : appTheme;

return {
[UserProfilePropery.ENABLE_OPENSEA_API]:
[UserProfileProperty.ENABLE_OPENSEA_API]:
preferencesController?.displayNftMedia
? UserProfilePropery.ON
: UserProfilePropery.OFF,
[UserProfilePropery.NFT_AUTODETECTION]:
? UserProfileProperty.ON
: UserProfileProperty.OFF,
[UserProfileProperty.NFT_AUTODETECTION]:
preferencesController?.useNftDetection
? UserProfilePropery.ON
: UserProfilePropery.OFF,
[UserProfilePropery.THEME]: appThemeStyle,
[UserProfilePropery.TOKEN_DETECTION]:
? UserProfileProperty.ON
: UserProfileProperty.OFF,
[UserProfileProperty.THEME]: appThemeStyle,
[UserProfileProperty.TOKEN_DETECTION]:
preferencesController.useTokenDetection
? UserProfilePropery.ON
: UserProfilePropery.OFF,
[UserProfilePropery.MULTI_ACCOUNT_BALANCE]:
? UserProfileProperty.ON
: UserProfileProperty.OFF,
[UserProfileProperty.MULTI_ACCOUNT_BALANCE]:
preferencesController.isMultiAccountBalancesEnabled
? UserProfilePropery.ON
: UserProfilePropery.OFF,
[UserProfilePropery.SECURITY_PROVIDERS]:
? UserProfileProperty.ON
: UserProfileProperty.OFF,
[UserProfileProperty.SECURITY_PROVIDERS]:
preferencesController?.securityAlertsEnabled ? 'blockaid' : '',
};
};
Expand Down

0 comments on commit c02483c

Please sign in to comment.