Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into PE-5254
Browse files Browse the repository at this point in the history
  • Loading branch information
matibat committed Jan 5, 2024
2 parents 2e44a74 + a01d1e2 commit 076b424
Show file tree
Hide file tree
Showing 71 changed files with 6,336 additions and 3,206 deletions.
3 changes: 3 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/87.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Improves existing Plausible event tracking to increase clarity
- Fix image preview size for long file names.
- Temporary CLI file download fix: Bypass validation
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
ruby
cocoapods
fastlane
nodejs
yarn-berry
nodePackages.typescript-language-server
];
shellHook = ''
export PATH="$PWD/.fvm/flutter_sdk/bin:$PATH"
Expand Down
36 changes: 32 additions & 4 deletions lib/authentication/login/blocs/login_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:ardrive/services/arconnect/arconnect_wallet.dart';
import 'package:ardrive/user/repositories/user_repository.dart';
import 'package:ardrive/user/user.dart';
import 'package:ardrive/utils/logger/logger.dart';
import 'package:ardrive/utils/plausible_event_tracker/plausible_custom_event_properties.dart';
import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart';
import 'package:ardrive_io/ardrive_io.dart';
import 'package:ardrive_utils/ardrive_utils.dart';
import 'package:arweave/arweave.dart';
Expand Down Expand Up @@ -35,6 +37,8 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
@visibleForTesting
ProfileType? profileType;

bool usingSeedphrase = false;

LoginBloc({
required ArDriveAuth arDriveAuth,
required ArConnectService arConnectService,
Expand Down Expand Up @@ -91,8 +95,8 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
} catch (e) {
logger.e('Failed to unlock user with biometrics.', e);

usingSeedphrase = false;
emit(LoginFailure(e));

emit(previousState);
}
}
Expand Down Expand Up @@ -130,6 +134,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
emit(LoginOnBoarding(wallet));
}
} catch (e) {
usingSeedphrase = false;
emit(LoginFailure(e));
emit(previousState);
}
Expand All @@ -144,14 +149,15 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
try {
emit(LoginLoading());

await _verifyArConnectWalletAddressAndLogin(
await _verifyArConnectWalletAddressAndLogIn(
wallet: event.wallet,
password: event.password,
emit: emit,
previousState: previousState,
profileType: profileType!,
);
} catch (e) {
usingSeedphrase = false;
emit(LoginFailure(e));
emit(previousState);
}
Expand Down Expand Up @@ -202,10 +208,14 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
try {
final user = await _arDriveAuth.unlockUser(password: event.password);

final type = usingSeedphrase ? LoginType.seedphrase : LoginType.json;
PlausibleEventTracker.trackLogin(type: type);

emit(LoginSuccess(user));
} catch (e) {
logger.e('Failed to unlock user with password', e);

usingSeedphrase = false;
emit(LoginFailure(e));
emit(previousState);

Expand All @@ -222,14 +232,15 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
emit(LoginLoading());

try {
await _verifyArConnectWalletAddressAndLogin(
await _verifyArConnectWalletAddressAndLogIn(
wallet: event.wallet,
password: event.password,
emit: emit,
previousState: previousState,
profileType: profileType!,
);
} catch (e) {
usingSeedphrase = false;
emit(LoginFailure(e));
emit(previousState);
}
Expand All @@ -240,6 +251,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
Emitter<LoginState> emit,
) async {
final previousState = state;
usingSeedphrase = false;

try {
emit(LoginLoading());
Expand Down Expand Up @@ -286,6 +298,8 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
await _arDriveAuth.logout();
}

usingSeedphrase = false;

emit(LoginInitial(
isArConnectAvailable: _arConnectService.isExtensionPresent(),
));
Expand All @@ -300,7 +314,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
return lastKnownWalletAddress == await _arConnectService.getWalletAddress();
}

Future<void> _verifyArConnectWalletAddressAndLogin({
Future<void> _verifyArConnectWalletAddressAndLogIn({
required Wallet wallet,
required String password,
required ProfileType profileType,
Expand All @@ -311,6 +325,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
final isArConnectAddressValid = await _verifyArConnectWalletAddress();

if (!isArConnectAddressValid) {
usingSeedphrase = false;
emit(const LoginFailure(WalletMismatchException()));
emit(previousState);

Expand All @@ -324,6 +339,13 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
profileType,
);

final type = profileType == ProfileType.arConnect
? LoginType.arConnect
: usingSeedphrase
? LoginType.seedphrase
: LoginType.json;
PlausibleEventTracker.trackLogin(type: type);

emit(LoginSuccess(user));
}

Expand Down Expand Up @@ -365,6 +387,8 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
final user = await _arDriveAuth.unlockWithBiometrics(
localizedReason: 'Login using credentials stored on this device');

const type = LoginType.json;
PlausibleEventTracker.trackLogin(type: type);
emit(LoginSuccess(user));

return;
Expand All @@ -380,6 +404,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
Future<void> _handleAddWalletFromMnemonicEvent(
AddWalletFromMnemonic event, Emitter<LoginState> emit) async {
profileType = ProfileType.json;
usingSeedphrase = true;

emit(const LoginGenerateWallet());

Expand All @@ -392,6 +417,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
Emitter<LoginState> emit,
) async {
profileType = ProfileType.json;
usingSeedphrase = true;

Completer<Wallet> completer = event.walletCompleter;
Wallet wallet;
Expand All @@ -416,6 +442,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
Emitter<LoginState> emit,
) async {
profileType = ProfileType.json;
usingSeedphrase = true;
final mnemonic = bip39.generateMnemonic();
emit(LoginCreateNewWallet(mnemonic));
}
Expand All @@ -436,6 +463,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
emit(LoginOnBoarding(wallet));
}
} catch (e) {
usingSeedphrase = false;
emit(LoginFailure(e));
emit(previousState);
}
Expand Down
64 changes: 40 additions & 24 deletions lib/authentication/login/views/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'package:ardrive/utils/app_localizations_wrapper.dart';
import 'package:ardrive/utils/io_utils.dart';
import 'package:ardrive/utils/logger/logger.dart';
import 'package:ardrive/utils/open_url.dart';
import 'package:ardrive/utils/plausible_event_tracker.dart';
import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart';
import 'package:ardrive/utils/pre_cache_assets.dart';
import 'package:ardrive/utils/show_general_dialog.dart';
import 'package:ardrive/utils/split_localizations.dart';
Expand Down Expand Up @@ -58,7 +58,11 @@ class _LoginPageState extends State<LoginPage> {
void initState() {
super.initState();

PlausibleEventTracker.track(event: PlausibleEvent.welcomePage);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.welcomePage,
).then(
(value) => PlausibleEventTracker.trackAppLoaded(),
);
}

@override
Expand Down Expand Up @@ -127,11 +131,12 @@ class _LoginPageState extends State<LoginPage> {
),
);
} else if (loginState is LoginSuccess) {
final profileType = loginState.user.profileType;
logger.d('Login Success, unlocking default profile');

context.read<ProfileCubit>().unlockDefaultProfile(
loginState.user.password,
loginState.user.profileType,
profileType,
);
}
},
Expand Down Expand Up @@ -734,7 +739,8 @@ class _PromptPasswordViewState extends State<PromptPasswordView> {
void initState() {
super.initState();

PlausibleEventTracker.track(event: PlausibleEvent.welcomeBackPage);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.welcomeBackPage);
}

@override
Expand Down Expand Up @@ -862,8 +868,8 @@ class _CreatePasswordViewState extends State<CreatePasswordView> {
void initState() {
super.initState();

PlausibleEventTracker.track(
event: PlausibleEvent.createAndConfirmPasswordPage,
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.createAndConfirmPasswordPage,
);
}

Expand Down Expand Up @@ -1082,8 +1088,8 @@ class _CreatePasswordViewState extends State<CreatePasswordView> {
return;
}

PlausibleEventTracker.track(
event: PlausibleEvent.createdAndConfirmedPassword,
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.createdAndConfirmedPassword,
);

context.read<LoginBloc>().add(
Expand Down Expand Up @@ -1113,9 +1119,11 @@ class OnBoardingViewState extends State<OnBoardingView> {
void initState() {
super.initState();

PlausibleEventTracker.track(event: PlausibleEvent.onboardingPage).then(
PlausibleEventTracker.trackPageview(page: PlausiblePageView.onboardingPage)
.then(
(value) {
PlausibleEventTracker.track(event: PlausibleEvent.tutorialsPage1);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.tutorialsPage1);
},
);
}
Expand All @@ -1134,7 +1142,8 @@ class OnBoardingViewState extends State<OnBoardingView> {
wallet: widget.wallet,
),
);
PlausibleEventTracker.track(event: PlausibleEvent.tutorialSkipped);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.tutorialSkipped);
},
title: appLocalizationsOf(context).onboarding1Title,
description: appLocalizationsOf(context).onboarding1Description,
Expand Down Expand Up @@ -1186,11 +1195,14 @@ class OnBoardingViewState extends State<OnBoardingView> {
});

if (_currentPage == 0) {
PlausibleEventTracker.track(event: PlausibleEvent.tutorialsPage1);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.tutorialsPage1);
} else if (_currentPage == 1) {
PlausibleEventTracker.track(event: PlausibleEvent.tutorialsPage2);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.tutorialsPage2);
} else if (_currentPage == 2) {
PlausibleEventTracker.track(event: PlausibleEvent.tutorialsPage3);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.tutorialsPage3);
}
}

Expand Down Expand Up @@ -1466,7 +1478,8 @@ class _EnterSeedPhraseViewState extends State<EnterSeedPhraseView> {
void initState() {
super.initState();

PlausibleEventTracker.track(event: PlausibleEvent.enterSeedPhrasePage);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.enterSeedPhrasePage);
}

@override
Expand Down Expand Up @@ -1628,7 +1641,8 @@ class _GenerateWalletViewState extends State<GenerateWalletView> {
void initState() {
super.initState();

PlausibleEventTracker.track(event: PlausibleEvent.walletGenerationPage);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.walletGenerationPage);

// TODO: create/update localization key
_message = 'Did you know?\n\n${_messages[0]}';
Expand Down Expand Up @@ -1742,7 +1756,8 @@ class _DownloadWalletViewState extends State<DownloadWalletView> {
void initState() {
super.initState();

PlausibleEventTracker.track(event: PlausibleEvent.walletDownloadPage);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.walletDownloadPage);
}

@override
Expand Down Expand Up @@ -1799,8 +1814,8 @@ class _DownloadWalletViewState extends State<DownloadWalletView> {
child: GestureDetector(
onTap: () {
_onDownload();
PlausibleEventTracker.track(
event: PlausibleEvent.walletDownloaded,
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.walletDownloaded,
);
},
child: Container(
Expand Down Expand Up @@ -1974,13 +1989,13 @@ class CreateNewWalletViewState extends State<CreateNewWalletView> {
void _trackPlausible() {
switch (_currentPage) {
case 1:
PlausibleEventTracker.track(
event: PlausibleEvent.writeDownSeedPhrasePage,
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.writeDownSeedPhrasePage,
);
break;
case 2:
PlausibleEventTracker.track(
event: PlausibleEvent.verifySeedPhrasePage,
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.verifySeedPhrasePage,
);
break;
}
Expand Down Expand Up @@ -2595,7 +2610,8 @@ class CreateNewWalletViewState extends State<CreateNewWalletView> {
}

Widget _buildGettingStarted() {
PlausibleEventTracker.track(event: PlausibleEvent.gettingStartedPage);
PlausibleEventTracker.trackPageview(
page: PlausiblePageView.gettingStartedPage);

// TODO: create/update localization keys
var cardInfos = [
Expand Down
Loading

0 comments on commit 076b424

Please sign in to comment.