Skip to content

Commit

Permalink
Onboarding: metrics handling externalized
Browse files Browse the repository at this point in the history
  • Loading branch information
micieslak committed Jan 13, 2025
1 parent fa29f4e commit 35b8620
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 73 deletions.
32 changes: 0 additions & 32 deletions storybook/pages/OnboardingLayoutPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import AppLayouts.Onboarding2.pages 1.0
import AppLayouts.Onboarding2.stores 1.0

import shared.panels 1.0
import shared.stores 1.0 as SharedStores
import utils 1.0

import Storybook 1.0
Expand Down Expand Up @@ -98,28 +97,8 @@ SplitView {
}
}

metricsStore: SharedStores.MetricsStore {
readonly property var d: QtObject {
id: d
property bool isCentralizedMetricsEnabled
}

function toggleCentralizedMetrics(enabled) {
d.isCentralizedMetricsEnabled = enabled
}

function addCentralizedMetricIfEnabled(eventName, eventValue = null) {}

readonly property bool isCentralizedMetricsEnabled : d.isCentralizedMetricsEnabled
}

biometricsAvailable: ctrlBiometrics.checked

QtObject {
id: localAppSettings
property bool metricsPopupSeen
}

onFinished: (flow, data) => {
console.warn("!!! ONBOARDING FINISHED; flow:", flow, "; data:", JSON.stringify(data))
logs.logEvent("onFinished", ["flow", "data"], arguments)
Expand All @@ -130,17 +109,6 @@ SplitView {

flow.currentKeycardState = Onboarding.KeycardState.NoPCSCService
}
onKeycardFactoryResetRequested: {
logs.logEvent("onKeycardFactoryResetRequested")
console.warn("!!! FACTORY RESET; RESTARTING FLOW")
restartFlow()
flow.currentKeycardState = Onboarding.KeycardState.NoPCSCService
}
onKeycardReloaded: {
logs.logEvent("onKeycardReloaded")
console.warn("!!! RELOAD KEYCARD")
flow.currentKeycardState = Onboarding.KeycardState.NoPCSCService
}

Button {
text: "Paste password"
Expand Down
20 changes: 0 additions & 20 deletions storybook/qmlTests/tests/tst_OnboardingLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,6 @@ Item {
}
function inputConnectionStringForBootstrapping(connectionString: string) {}
}

metricsStore: SharedStores.MetricsStore {
readonly property var d: QtObject {
id: d
property bool isCentralizedMetricsEnabled
}

function toggleCentralizedMetrics(enabled) {
d.isCentralizedMetricsEnabled = enabled
}

function addCentralizedMetricIfEnabled(eventName, eventValue = null) {}

readonly property bool isCentralizedMetricsEnabled : d.isCentralizedMetricsEnabled
}

QtObject {
id: localAppSettings
property bool metricsPopupSeen
}
}
}

Expand Down
24 changes: 3 additions & 21 deletions ui/app/AppLayouts/Onboarding2/OnboardingLayout.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,24 @@ import AppLayouts.Onboarding2.pages 1.0
import AppLayouts.Onboarding2.stores 1.0
import AppLayouts.Onboarding.enums 1.0

import shared.stores 1.0 as SharedStores

import utils 1.0

Page {
id: root

required property OnboardingStore onboardingStore

// TODO backend: externalize the metrics handling too?
required property SharedStores.MetricsStore metricsStore

property bool biometricsAvailable: Qt.platform.os === Constants.mac
property bool networkChecksEnabled: true
property alias keycardPinInfoPageDelay: onboardingFlow.keycardPinInfoPageDelay

readonly property alias stack: stack

signal shareUsageDataRequested(bool enabled)

// flow: Onboarding.SecondaryFlow
signal finished(int flow, var data)

signal keycardFactoryResetRequested() // TODO integrate/switch to an external flow, needed?
signal keycardReloaded()

function restartFlow() {
stack.clear()
d.resetState()
Expand Down Expand Up @@ -95,7 +89,6 @@ Page {
anchors.fill: parent
acceptedButtons: Qt.BackButton
enabled: stack.depth > 1 && !stack.busy
cursorShape: undefined
onClicked: stack.pop()
}

Expand Down Expand Up @@ -148,23 +141,12 @@ Page {
}

onKeyPairTransferRequested: root.onboardingStore.startKeypairTransfer()

onShareUsageDataRequested: (enabled) => {
root.metricsStore.toggleCentralizedMetrics(enabled)
Global.addCentralizedMetricIfEnabled(
"usage_data_shared",
{ placement: Constants.metricsEnablePlacement.onboarding })
localAppSettings.metricsPopupSeen = true
}

onShareUsageDataRequested: (enabled) => root.shareUsageDataRequested(enabled)
onSyncProceedWithConnectionString: (connectionString) =>
root.onboardingStore.inputConnectionStringForBootstrapping(connectionString)

onSeedphraseSubmitted: (seedphrase) => d.seedphrase = seedphrase
onSetPasswordRequested: (password) => d.password = password

onEnableBiometricsRequested: (enabled) => d.enableBiometrics = enabled

onFinished: (flow) => d.finishFlow(flow)
}

Expand Down

0 comments on commit 35b8620

Please sign in to comment.