Added PostHog
This commit is contained in:
@@ -14,7 +14,7 @@ import 'package:pshared/provider/recipient/pmethods.dart';
|
||||
import 'package:pshared/provider/recipient/provider.dart';
|
||||
|
||||
import 'package:pweb/pages/address_book/form/view.dart';
|
||||
// import 'package:pweb/services/amplitude.dart';
|
||||
import 'package:pweb/services/posthog.dart';
|
||||
import 'package:pweb/utils/error/snackbar.dart';
|
||||
import 'package:pweb/utils/payment/label.dart';
|
||||
import 'package:pweb/utils/snackbar.dart';
|
||||
@@ -105,11 +105,11 @@ class _AdressBookRecipientFormState extends State<AdressBookRecipientForm> {
|
||||
return;
|
||||
}
|
||||
|
||||
// AmplitudeService.recipientAddCompleted(
|
||||
// _type,
|
||||
// _status,
|
||||
// _methods.keys.toSet(),
|
||||
// );
|
||||
await PosthogService.recipientAddCompleted(
|
||||
_type,
|
||||
_status,
|
||||
_methods.keys.toSet(),
|
||||
);
|
||||
final recipient = await executeActionWithNotification(
|
||||
context: context,
|
||||
action: _doSave,
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:pshared/provider/account.dart';
|
||||
|
||||
import 'package:pweb/app/router/pages.dart';
|
||||
import 'package:pweb/widgets/error/snackbar.dart';
|
||||
import 'package:pweb/services/posthog.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
@@ -17,15 +18,38 @@ class AccountLoader extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Consumer<AccountProvider>(builder: (context, provider, _) {
|
||||
if (provider.isLoading) return const Center(child: CircularProgressIndicator());
|
||||
if (provider.error != null) {
|
||||
postNotifyUserOfErrorX(
|
||||
context: context,
|
||||
errorSituation: AppLocalizations.of(context)!.errorLogin,
|
||||
exception: provider.error!,
|
||||
);
|
||||
navigateAndReplace(context, Pages.login);
|
||||
if (provider.account != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final account = provider.account;
|
||||
if (account != null) {
|
||||
PosthogService.identify(account);
|
||||
}
|
||||
});
|
||||
return child;
|
||||
}
|
||||
|
||||
if (provider.error != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
postNotifyUserOfErrorX(
|
||||
context: context,
|
||||
errorSituation: AppLocalizations.of(context)!.errorLogin,
|
||||
exception: provider.error!,
|
||||
);
|
||||
navigateAndReplace(context, Pages.login);
|
||||
});
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (provider.restoreFuture == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
provider.restoreIfPossible().catchError((error, stack) {
|
||||
debugPrint('Account restore failed: $error');
|
||||
});
|
||||
});
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (provider.isLoading) return const Center(child: CircularProgressIndicator());
|
||||
if (provider.account == null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => navigateAndReplace(context, Pages.login));
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:pweb/widgets/password/password.dart';
|
||||
import 'package:pweb/widgets/username.dart';
|
||||
import 'package:pweb/widgets/vspacer.dart';
|
||||
import 'package:pweb/widgets/error/snackbar.dart';
|
||||
import 'package:pweb/services/posthog.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
@@ -43,10 +44,14 @@ class _LoginFormState extends State<LoginForm> {
|
||||
password: _passwordController.text,
|
||||
locale: context.read<LocaleProvider>().locale.languageCode,
|
||||
);
|
||||
await PosthogService.login(pending: outcome.isPending);
|
||||
if (outcome.isPending) {
|
||||
// TODO: fix context usage
|
||||
navigateAndReplace(context, Pages.sfactor);
|
||||
} else {
|
||||
if (outcome.account != null) {
|
||||
await PosthogService.identify(outcome.account!);
|
||||
}
|
||||
onLogin();
|
||||
}
|
||||
return 'ok';
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:pweb/providers/payment_flow.dart';
|
||||
import 'package:pweb/pages/payment_methods/payment_page/body.dart';
|
||||
import 'package:pweb/providers/wallets.dart';
|
||||
import 'package:pweb/widgets/sidebar/destinations.dart';
|
||||
import 'package:pweb/services/posthog.dart';
|
||||
|
||||
|
||||
class PaymentPage extends StatefulWidget {
|
||||
@@ -109,7 +110,7 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
|
||||
void _handleSendPayment() {
|
||||
// TODO: Handle Payment logic
|
||||
// AmplitudeService.paymentInitiated();
|
||||
PosthogService.paymentInitiated(method: _flowProvider.selectedType);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -195,4 +196,4 @@ class _PaymentPageState extends State<PaymentPage> {
|
||||
(method.description?.contains(wallet.walletUserID) ?? false),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pshared/provider/locale.dart';
|
||||
|
||||
// import 'package:pweb/services/amplitude.dart';
|
||||
import 'package:pweb/services/posthog.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
@@ -58,7 +58,7 @@ class LocalePicker extends StatelessWidget {
|
||||
onChanged: (locale) {
|
||||
if (locale != null) {
|
||||
localeProvider.setLocale(locale);
|
||||
// AmplitudeService.localeChanged(locale);
|
||||
PosthogService.localeChanged(locale);
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
|
||||
Reference in New Issue
Block a user