Skip to content

Commit

Permalink
feat(onboarding): hook metrics to the new onboarding
Browse files Browse the repository at this point in the history
Fixes #17047
  • Loading branch information
jrainville committed Jan 23, 2025
1 parent 638676e commit 476e752
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/app/modules/onboarding/module.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import NimQml, chronicles, json
import logging

import io_interface
import view, controller
Expand Down Expand Up @@ -26,7 +27,8 @@ type SecondaryFlow* {.pure} = enum
CreateProfileWithKeycardExistingSeedphrase,
LoginWithSeedphrase,
LoginWithSyncing,
LoginWithKeycard
LoginWithKeycard,
ActualLogin, # TODO get the real name and value for this when it's implemented on the front-end

type
Module*[T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
Expand All @@ -35,6 +37,7 @@ type
viewVariant: QVariant
controller: Controller
localPairingStatus: LocalPairingStatus
currentFlow: SecondaryFlow

proc newModule*[T](
delegate: T,
Expand Down Expand Up @@ -99,15 +102,15 @@ method inputConnectionStringForBootstrapping*[T](self: Module[T], connectionStri

method finishOnboardingFlow*[T](self: Module[T], flowInt: int, dataJson: string): string =
try:
let flow = SecondaryFlow(flowInt)
self.currentFlow = SecondaryFlow(flowInt)

let data = parseJson(dataJson)
let password = data["password"].str
let seedPhrase = data["seedphrase"].str

var err = ""

case flow:
case self.currentFlow:
# CREATE PROFILE FLOWS
of SecondaryFlow.CreateProfileWithPassword:
err = self.controller.createAccountAndLogin(password)
Expand Down Expand Up @@ -147,7 +150,7 @@ method finishOnboardingFlow*[T](self: Module[T], flowInt: int, dataJson: string)
# TODO implement keycard function
discard
else:
raise newException(ValueError, "Unknown flow: " & $flow)
raise newException(ValueError, "Unknown flow: " & $self.currentFlow)

return err
except Exception as e:
Expand All @@ -158,13 +161,11 @@ proc finishAppLoading2[T](self: Module[T]) =
self.delegate.appReady()

# TODO get the flow to send the right metric
# let currStateObj = self.view.currentStartupStateObj()
# if not currStateObj.isNil:
# var eventType = "user-logged-in"
# if currStateObj.flowType() != FlowType.AppLogin:
# eventType = "onboarding-completed"
# singletonInstance.globalEvents.addCentralizedMetricIfEnabled(eventType,
# $(%*{"flowType": currStateObj.flowType()}))
var eventType = "user-logged-in"
if self.currentFlow != SecondaryFlow.ActualLogin:
eventType = "onboarding-completed"
singletonInstance.globalEvents.addCentralizedMetricIfEnabled(eventType,
$(%*{"flowType": repr(self.currentFlow)}))

self.delegate.finishAppLoading()

Expand Down
8 changes: 8 additions & 0 deletions ui/app/AppLayouts/Onboarding2/OnboardingLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Page {
readonly property alias stack: stack

signal shareUsageDataRequested(bool enabled)
signal pageNavigated(string pageName)

// flow: Onboarding.SecondaryFlow
signal finished(int flow, var data)
Expand Down Expand Up @@ -108,6 +109,13 @@ Page {
readonly property bool backAvailable:
stack.currentItem ? (stack.currentItem.backAvailableHint ?? true)
: false


onCurrentItemChanged: {
if (!!stack.currentItem && !!stack.currentItem.pageName) {
root.pageNavigated(stack.currentItem.pageName)
}
}
}

// needs to be on top of the stack
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/BackupSeedphraseAcks.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import StatusQ.Core.Theme 0.1
OnboardingPage {
id: root

pageName: "BackupSeedphraseAcks"

signal backupSeedphraseContinue()

contentItem: Item {
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/BackupSeedphraseIntro.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import StatusQ.Core.Theme 0.1
OnboardingPage {
id: root

pageName: "BackupSeedphraseIntro"

signal backupSeedphraseRequested()

contentItem: Item {
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/BackupSeedphraseOutro.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import AppLayouts.Onboarding2.components 1.0
OnboardingPage {
id: root

pageName: "BackupSeedphraseOutro"

signal backupSeedphraseRemovalConfirmed()

contentItem: Item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ OnboardingPage {

required property var seedWords

pageName: "BackupSeedphraseReveal"

signal mnemonicWasShown()
signal backupSeedphraseConfirmed()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ OnboardingPage {

required property var seedWordsToVerify // [{seedWordNumber:int, seedWord:string}, ...]

pageName: "BackupSeedphraseVerify"

signal backupSeedphraseVerified()

QtObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ OnboardingPage {

title: qsTr("Create profile on empty Keycard")

pageName: "CreateKeycardProfilePage"

signal createKeycardProfileWithNewSeedphrase()
signal createKeycardProfileWithExistingSeedphrase()

Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/CreatePasswordPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ OnboardingPage {

property var passwordStrengthScoreFunction: (password) => { console.error("passwordStrengthScoreFunction: IMPLEMENT ME") }

pageName: "CreatePasswordPage"

signal setPasswordRequested(string password)

title: qsTr("Create profile password")
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/CreateProfilePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ OnboardingPage {

title: qsTr("Create profile")

pageName: "CreateProfilePage"

signal createProfileWithPasswordRequested()
signal createProfileWithSeedphraseRequested()
signal createProfileWithEmptyKeycardRequested()
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/EnableBiometricsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ OnboardingPage {

title: qsTr("Enable biometrics")

pageName: "EnableBiometricsPage"

property string subtitle: qsTr("Would you like to enable biometrics to fill in your password? You will use biometrics for signing in to Status and for signing transactions.")

signal enableBiometricsRequested(bool enable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ OnboardingPage {

title: qsTr("Help us improve Status")

pageName: "HelpUsImproveStatusPage"

signal shareUsageDataRequested(bool enabled)
signal privacyPolicyRequested()

Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardAddKeyPairPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ OnboardingPage {
signal reloadKeycardRequested()
signal createProfilePageRequested()

pageName: "KeycardAddKeyPairPage"

states: [
State {
name: "inprogress"
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardBasePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ OnboardingPage {
property alias infoText: infoText
property alias buttons: buttonsWrapper.children

pageName: "KeycardBasePage"

contentItem: Item {
ColumnLayout {
anchors.centerIn: parent
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardCreatePinPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ KeycardBasePage {

signal keycardPinCreated(string pin)

pageName: "KeycardCreatePinPage"

image.source: Theme.png("onboarding/keycard/reading")

QtObject {
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardEmptyPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import AppLayouts.Onboarding2.controls 1.0
KeycardBasePage {
id: root

pageName: "KeycardEmptyPage"

signal createProfileWithEmptyKeycardRequested()
signal reloadKeycardRequested()

Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardEnterPinPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ KeycardBasePage {
required property int remainingAttempts
property bool unlockUsingSeedphrase

pageName: "KeycardEnterPinPage"

signal keycardPinEntered(string pin)
signal reloadKeycardRequested()
signal unlockWithSeedphraseRequested()
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardIntroPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ KeycardBasePage {
property bool displayPromoBanner
property bool unlockUsingSeedphrase

pageName: "KeycardIntroPage"

signal keycardFactoryResetRequested()
signal unlockWithSeedphraseRequested()
signal reloadKeycardRequested()
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/KeycardNotEmptyPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import AppLayouts.Onboarding2.controls 1.0
KeycardBasePage {
id: root

pageName: "KeycardNotEmptyPage"

signal reloadKeycardRequested()
signal loginWithThisKeycardRequested()
signal keycardFactoryResetRequested()
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/LoginBySyncingPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ OnboardingPage {

property var validateConnectionString: (stringValue) => { console.error("validateConnectionString IMPLEMENT ME"); return false }

pageName: "LoginBySyncingPage"

signal syncProceedWithConnectionString(string connectionString)

title: qsTr("Log in by syncing")
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/NewAccountLoginPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ OnboardingPage {

title: qsTr("Log in")

pageName: "LoginPage"

signal loginWithSeedphraseRequested()
signal loginWithSyncingRequested()
signal loginWithKeycardRequested()
Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/OnboardingPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Page {
signal openLink(string link)
signal openLinkWithConfirmation(string link, string domain)

required property string pageName

implicitWidth: 1200
implicitHeight: 700

Expand Down
2 changes: 2 additions & 0 deletions ui/app/AppLayouts/Onboarding2/pages/SeedphrasePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ OnboardingPage {

property var isSeedPhraseValid: (mnemonic) => { console.error("isSeedPhraseValid IMPLEMENT ME"); return false }

pageName: "SeedphrasePage"

signal seedphraseSubmitted(string seedphrase)

contentItem: Item {
Expand Down
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Onboarding2/pages/SyncProgressPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ OnboardingPage {
id: root

required property int syncState // Onboarding.SyncState.xxx
pageName: "SyncProgressPage"

signal loginToAppRequested()
signal restartSyncRequested()
Expand Down
1 change: 1 addition & 0 deletions ui/app/AppLayouts/Onboarding2/pages/WelcomePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ OnboardingPage {
id: root

title: qsTr("Welcome to Status")
pageName: "WelcomePage"

signal createProfileRequested()
signal loginRequested()
Expand Down
10 changes: 10 additions & 0 deletions ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,16 @@ StatusWindow {
stack.clear()
stack.push(splashScreenV2, { runningProgressAnimation: true })
}

onShareUsageDataRequested: {
applicationWindow.metricsStore.toggleCentralizedMetrics(enabled)
if (enabled) {
Global.addCentralizedMetricIfEnabled("usage_data_shared", {placement: Constants.metricsEnablePlacement.onboarding})
}
}
onPageNavigated: (pageName) => {
Global.addCentralizedMetricIfEnabled("navigation", {viewId: pageName})
}
}
}

Expand Down

0 comments on commit 476e752

Please sign in to comment.