Skip to content

Commit 43cf1f9

Browse files
committed
Setup bug fix
1 parent 3b9e121 commit 43cf1f9

File tree

3 files changed

+58
-29
lines changed

3 files changed

+58
-29
lines changed

lib/app/layouts/setup/pages/rustpush/hw_inp.dart

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ class HwInpState extends OptimizedState<HwInp> {
365365
} catch (e, s) {
366366
Get.back();
367367
showSnackbar("Failure handling subscription! Please try again", e.toString());
368+
pushService.mixpanel.track("hosted-device-failure");
368369
rethrow;
369370
}
370371
Get.back();
@@ -596,6 +597,7 @@ class HwInpState extends OptimizedState<HwInp> {
596597
hosted,
597598
() async {
598599
if (hosted) {
600+
pushService.mixpanel.track("choose-hosted");
599601
wrapSubscriptionPromise<void>((() async {
600602
await controller.ensureToken();
601603
pushService.client.runWithClientNonRetryable<void>((client) async {
@@ -952,42 +954,47 @@ class HwInpState extends OptimizedState<HwInp> {
952954
ss.settings.cachedCodes.remove(items.key);
953955
}
954956
ss.saveSettings();
957+
if (isHosted) {
958+
pushService.mixpanel.track("hosted-device-configured");
959+
}
955960
}
956961

957962
var state = await api.getDeviceInfoState(state: pushService.state);
958963
controller.supportsPhoneReg.value = state.name.contains("iPhone") || state.name.contains("iPod") || state.name.contains("iPad");
959964
// controller.updatePhoneReg();
960-
showDialog(
961-
context: context,
962-
barrierDismissible: false,
963-
builder: (context) => AlertDialog(
964-
title: const Column(
965-
crossAxisAlignment: CrossAxisAlignment.center,
966-
children: [
967-
Icon(
968-
Icons.security,
969-
size: 40,
970-
color: Colors.blue,
965+
Future.delayed(const Duration(milliseconds: 200), () {
966+
showDialog(
967+
context: context,
968+
barrierDismissible: false,
969+
builder: (context) => AlertDialog(
970+
title: const Column(
971+
crossAxisAlignment: CrossAxisAlignment.center,
972+
children: [
973+
Icon(
974+
Icons.security,
975+
size: 40,
976+
color: Colors.blue,
977+
),
978+
SizedBox(height: 12),
979+
Text("You're in control"),
980+
],
981+
),
982+
content: const Text('A new Apple device will appear on your Apple Account.\n\nAll keys and account credentials are generated and stored locally on this device. The new device does not have any access to your Apple Account or Messages.'),
983+
actions: [
984+
TextButton(
985+
onPressed: () {
986+
Navigator.of(context).pop();
987+
controller.pageController.nextPage(
988+
duration: const Duration(milliseconds: 300),
989+
curve: Curves.easeInOut,
990+
);
991+
},
992+
child: const Text('Next'),
971993
),
972-
SizedBox(height: 12),
973-
Text("You're in control"),
974994
],
975995
),
976-
content: const Text('A new Apple device will appear on your Apple Account.\n\nAll keys and account credentials are generated and stored locally on this device. The new device does not have any access to your Apple Account or Messages.'),
977-
actions: [
978-
TextButton(
979-
onPressed: () {
980-
Navigator.of(context).pop();
981-
controller.pageController.nextPage(
982-
duration: const Duration(milliseconds: 300),
983-
curve: Curves.easeInOut,
984-
);
985-
},
986-
child: const Text('Next'),
987-
),
988-
],
989-
),
990-
);
996+
);
997+
});
991998
} catch (e) {
992999
if (e is AnyhowException) {
9931000
controller.updateConnectError(e.message);

lib/app/layouts/setup/setup_view.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class SetupViewController extends StatefulController {
7373
String? currentWaitlist;
7474
RxString noCapErrorMsg = "Currently full. If you got an invite, enter your code from your email. Otherwise, sign up to get notified!".obs;
7575

76+
bool errorIsProblem() {
77+
return error.isNotEmpty && !error.contains("Enter the correct password") && !error.contains("Your account information was entered incorrectly") && (!error.contains("Relay device offline") || !ss.settings.deviceIsHosted.value);
78+
}
79+
7680
bool hasValidToken() {
7781
return !tokenExpiry.isBefore(DateTime.now());
7882
}
@@ -359,6 +363,9 @@ class SetupViewController extends StatefulController {
359363
// persisting SMS auth certs is actually really useful
360364
// ss.settings.cachedCodes.clear();
361365
Logger.debug("Success registered!");
366+
if (ss.settings.deviceIsHosted.value) {
367+
pushService.mixpanel.track("hosted-setup-success");
368+
}
362369
await pushService.configured();
363370

364371
var handles = await api.getHandles(state: pushService.state);
@@ -450,6 +457,9 @@ class SetupViewController extends StatefulController {
450457
newError += " Make sure Contact Key Verification and Advanced Data Protection are off.";
451458
}
452459
error = newError;
460+
if (ss.settings.deviceIsHosted.value && errorIsProblem()) {
461+
pushService.mixpanel.track("hosted-setup-error");
462+
}
453463
updateWidgets<ErrorText>(newError);
454464
}
455465
}
@@ -768,7 +778,7 @@ class _ErrorTextState extends CustomState<ErrorText, String, SetupViewController
768778
.copyWith(height: 2)),
769779
),
770780
),
771-
if (controller.error.isNotEmpty && !controller.error.contains("Enter the correct password") && !controller.error.contains("Your account information was entered incorrectly") && (!controller.error.contains("Relay device offline") || !ss.settings.deviceIsHosted.value))
781+
if (controller.errorIsProblem())
772782
TextButton(
773783
onPressed: () async {
774784
final TextEditingController participantController = TextEditingController();

lib/services/rustpush/rustpush_service.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ class RustPushService extends GetxService {
12521252
var findMy = false;
12531253
var sharedStreams = false;
12541254

1255+
late Mixpanel mixpanel;
12551256

12561257
var disableOutgoingSms = false;
12571258

@@ -2683,9 +2684,15 @@ class RustPushService extends GetxService {
26832684
var state = push.field0;
26842685
if (state is api.RegisterState_Registered) {
26852686
notifiedFailed = false;
2687+
if (ss.settings.deviceIsHosted.value) {
2688+
mixpanel.track("hosted-register-success");
2689+
}
26862690
handleRegistered();
26872691
}
26882692
if (state is api.RegisterState_Failed && !notifiedFailed) {
2693+
if (ss.settings.deviceIsHosted.value) {
2694+
mixpanel.track("hosted-register-failure");
2695+
}
26892696
notif.createRegisterFailed(state.retryWait == null);
26902697
if (state.retryWait == null) {
26912698
(backend as RustPushBackend).markFailedToLogin(hw: false);
@@ -3688,6 +3695,7 @@ class RustPushService extends GetxService {
36883695
validateSubState();
36893696
})();
36903697
initAppLinks();
3698+
initMixPanel();
36913699
await initFuture;
36923700
// pre-cache next FT link
36933701
api.getFtLink(state: pushService.state, usage: "next");
@@ -3705,6 +3713,10 @@ class RustPushService extends GetxService {
37053713
Logger.info("finishInit");
37063714
}
37073715

3716+
void initMixPanel() async {
3717+
mixpanel = await Mixpanel.init("d66dc2d8f2ad649fac2640ff059dc9f4", trackAutomaticEvents: false);
3718+
}
3719+
37083720
Future reset(bool hw, bool logout) async {
37093721
await api.resetState(state: state, resetHw: hw, logout: logout);
37103722
}

0 commit comments

Comments
 (0)