Skip to content

Commit

Permalink
chore: add network logs to start page
Browse files Browse the repository at this point in the history
  • Loading branch information
iGroza committed Feb 7, 2025
1 parent 8cc4993 commit ef69883
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 60 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haqq",
"version": "1.10.1",
"version": "1.10.2",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
3 changes: 2 additions & 1 deletion src/contexts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dynamicLinks from '@react-native-firebase/dynamic-links';
import {GoogleSignin} from '@react-native-google-signin/google-signin';
import {subMinutes} from 'date-fns';
import {Alert, AppState, Appearance, Platform, StatusBar} from 'react-native';
import Config from 'react-native-config';
import Keychain, {
STORAGE_TYPE,
getGenericPassword,
Expand Down Expand Up @@ -176,7 +177,7 @@ class App extends AsyncEventEmitter {
}

get isCustomSigninSupported() {
return IS_DETOX;
return IS_DETOX || Config.IS_DEVELOPMENT === 'true';
}

get isOathSigninSupported() {
Expand Down
3 changes: 3 additions & 0 deletions src/event-actions/on-deep-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export async function onDeepLink(
case DeeplinkUrlKey.enableDeveloperMode:
AppStore.isDeveloperModeEnabled = true;
return true;
case DeeplinkUrlKey.enableNetworkLogger:
AppStore.networkLoggerEnabled = true;
return true;
}
}
} catch (error) {
Expand Down
3 changes: 3 additions & 0 deletions src/models/app/app.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class AppStore {
}

get networkLoggerEnabled() {
if (Config.IS_DEVELOPMENT === 'true') {
return true;
}
// only for developer mode
if (!this.isAdditionalFeaturesEnabled) {
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/screens/WelcomeStack/SignUpStack/signup-networks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export const SignupNetworksScreen = observer(() => {
switch (provider) {
case SssProviders.apple:
logger.log('Logging in with Apple');
creds = await onLoginApple({resetShares: true});
creds = await onLoginApple();
break;
case SssProviders.google:
logger.log('Logging in with Google');
creds = await onLoginGoogle({resetShares: true});
creds = await onLoginGoogle();
break;
case SssProviders.custom:
logger.log('Logging in with Custom provider');
creds = await onLoginCustom({resetShares: true});
creds = await onLoginCustom();
break;
}
} catch (err) {
Expand Down
10 changes: 2 additions & 8 deletions src/screens/welcome-news.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@ export const WelcomeNewsScreen = memo(() => {
});
}, []);

const onPressSignup = () => {
Logger.log('Sign Up (create account)');
navigation.navigate(WelcomeStackRoutes.SignUp);
};
const onPressSignIn = () => {
Logger.log('Sign In (already have account)');
navigation.navigate(WelcomeStackRoutes.SignIn);
};
const onPressSignup = () => navigation.navigate(WelcomeStackRoutes.SignUp);
const onPressSignIn = () => navigation.navigate(WelcomeStackRoutes.SignIn);

const onPressRow = useCallback(
(id: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/services/backend/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Backend {
};

getRemoteUrl() {
if (IS_DETOX) {
if (IS_DETOX || Config.IS_DEVELOPMENT === 'true') {
return Config.HAQQ_BACKEND_DEV;
}

Expand Down
52 changes: 6 additions & 46 deletions src/services/provider-sss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,8 @@ const loggerCustom = Logger.create('onLoginCustom', {
enabled: AppStore.isLogsEnabled,
});

export type SSSLoginOptions = {
resetShares: boolean;
};

function extractLoginOptions(
opts: SSSLoginOptions | undefined,
): SSSLoginOptions {
const {resetShares} = opts || {
resetShares: false,
};

return {
resetShares,
} as SSSLoginOptions;
}

export async function onLoginCustom(opts?: SSSLoginOptions) {
export async function onLoginCustom() {
loggerCustom.log('Starting onLoginCustom function');
const {resetShares} = extractLoginOptions(opts);

const email = await new Promise(resolve => {
loggerCustom.log('Awaiting for popup to be closed');
Expand Down Expand Up @@ -96,24 +79,15 @@ export async function onLoginCustom(opts?: SSSLoginOptions) {
loggerCustom.log(
'Calling onAuthorized with verifier, authInfo.sub, and idToken',
);
return await onAuthorized(
verifier,
authInfo.sub,
authState.idToken,
resetShares,
);
return await onAuthorized(verifier, authInfo.sub, authState.idToken);
}

const loggerGoogle = Logger.create('onLoginGoogle', {
enabled: AppStore.isLogsEnabled,
});

export async function onLoginGoogle(
opts?: SSSLoginOptions,
): Promise<Creds | null> {
export async function onLoginGoogle(): Promise<Creds | null> {
loggerGoogle.log('Starting onLoginGoogle function');
const {resetShares} = extractLoginOptions(opts);

let authState = {
idToken: '',
};
Expand Down Expand Up @@ -144,24 +118,15 @@ export async function onLoginGoogle(
loggerGoogle.log(
'Calling onAuthorized with verifier, authInfo.email, and idToken',
);
return await onAuthorized(
verifier,
authInfo.email,
authState.idToken,
resetShares,
);
return await onAuthorized(verifier, authInfo.email, authState.idToken);
}

const loggerApple = Logger.create('onLoginApple', {
enabled: AppStore.isLogsEnabled,
});

export async function onLoginApple(
opts?: SSSLoginOptions,
): Promise<Creds | null> {
export async function onLoginApple(): Promise<Creds | null> {
loggerApple.log('Starting onLoginApple function');
const {resetShares} = extractLoginOptions(opts);

try {
loggerApple.log('Performing Apple auth request');
const appleAuthRequestResponse = await appleAuth.performRequest({
Expand Down Expand Up @@ -201,12 +166,7 @@ export async function onLoginApple(
loggerApple.log(
'Calling onAuthorized with verifier, authInfo.email, and identityToken',
);
return await onAuthorized(
verifier,
authInfo.email,
identityToken,
resetShares,
);
return await onAuthorized(verifier, authInfo.email, identityToken);
} catch (e: any) {
if (e.code.toString() !== '1001') {
loggerApple.error('Error in Apple login', {error: e});
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,7 @@ export enum DeeplinkUrlKey {
web3browser = 'web3browser',
back9test = 'back9test',
enableDeveloperMode = 'enableDeveloperMode',
enableNetworkLogger = 'enableNetworkLogger',
}

export type Eventable = Required<{
Expand Down

0 comments on commit ef69883

Please sign in to comment.