Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(mobile): show where the phone onboarding stalls, and count sign-ins under the account

Dev jacobaec92aa4c349
diff --git a/backend/src/analytics/dailyProductReview.test.ts b/backend/src/analytics/dailyProductReview.test.ts
index e4536178c..c1bd30cbc 100644
--- a/backend/src/analytics/dailyProductReview.test.ts
+++ b/backend/src/analytics/dailyProductReview.test.ts
@@ -94,3 +94,19 @@ it('reads Store and model-list reach only from the requests a person opened', ()
expect(r.features.find(f => f.action === 'model_list')).toMatchObject({ userRequests: 0, installationDays: null })
expect(r.features.find(f => f.action === 'history')).toMatchObject({ userRequests: null, installationDays: null })
})
+
+it("splits the phone onboarding's long waits past a minute and shows what happened on the way", () => {
+ const r = dailyProductReview([
+ row('2026-10-12', 'ui_phone_computer_wait_started', 4), row('2026-10-12', 'ui_phone_computer_wait_ok', 2),
+ row('2026-10-12', 'ui_phone_computer_wait_over_1m', 2), row('2026-10-12', 'ui_phone_computer_wait_15m_to_1h', 2),
+ row('2026-10-12', 'ui_phone_computer_wait_resumed', 1), row('2026-10-12', 'ui_phone_computer_wait_not_you', 1),
+ row('2026-10-12', 'ui_phone_session_open_blocked_password', 1),
+ ], new Date('2026-10-13'))
+ const wait = r.flows.find(f => f.channel === 'ui' && f.surface === 'phone' && f.flow === 'computer_wait')
+ expect(wait).toMatchObject({ started: 4, unmatchedStarts: 2,
+ over1mBuckets: { '1m_to_5m': 0, '15m_to_1h': 2 }, marks: { resumed: 1, not_you: 1, link_shared: 0 } })
+ expect(r.flows.find(f => f.channel === 'ui' && f.surface === 'phone' && f.flow === 'session_open'))
+ .toMatchObject({ marks: { blocked_password: 1, blocked_offline: 0 } })
+ expect(r.flows.find(f => f.channel === 'ui' && f.surface === 'phone' && f.flow === 'session_open')).not.toHaveProperty('over1mBuckets')
+ expect(r.flows.find(f => f.channel === 'ui' && f.surface === 'desktop' && f.flow === 'computer_wait')).not.toHaveProperty('marks')
+})
diff --git a/backend/src/analytics/dailyProductReview.ts b/backend/src/analytics/dailyProductReview.ts
index 80464b6b6..8d9ee0fb6 100644
--- a/backend/src/analytics/dailyProductReview.ts
+++ b/backend/src/analytics/dailyProductReview.ts
@@ -1,4 +1,4 @@
-import { PRODUCT_FEEDBACK, PRODUCT_FEEDBACK_REASONS, PRODUCT_FEEDBACK_OUTCOMES, PRODUCT_USAGE_ACTIONS, PRODUCT_USAGE_AUTOMATIC_ACTIONS, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_SETUP_FLOWS, PRODUCT_USAGE_SURFACES, PRODUCT_USAGE_USER_OPENED_ACTIONS } from '../types/productUsage.js'
+import { PRODUCT_FEEDBACK, PRODUCT_FEEDBACK_REASONS, PRODUCT_FEEDBACK_OUTCOMES, PRODUCT_USAGE_ACTIONS, PRODUCT_USAGE_AUTOMATIC_ACTIONS, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_LONG_FLOWS, PRODUCT_USAGE_LONG_MEASURES, PRODUCT_USAGE_ONBOARDING_MARKS, PRODUCT_USAGE_SETUP_FLOWS, PRODUCT_USAGE_SURFACES, PRODUCT_USAGE_USER_OPENED_ACTIONS } from '../types/productUsage.js'
import { DAILY_PRODUCT_METRICS } from './dailyProductUsage.js'
type Row = { dayUtc: Date; metric: string; value: number }
@@ -52,6 +52,10 @@ export function dailyProductReview(rows: Row[], now: Date) {
...PRODUCT_USAGE_ACTIONS.map(action => comparison(`${action}: request refusal`, [`${action}_failed`], [`${action}_ok`, `${action}_failed`])),
]
const c = recent.counters
+ const marksOf = (prefix: string) => {
+ const marks = PRODUCT_USAGE_ONBOARDING_MARKS.filter(metric => metric.startsWith(prefix))
+ return marks.length ? { marks: Object.fromEntries(marks.map(metric => [metric.slice(prefix.length), c[metric] ?? 0])) } : {}
+ }
const signals = [
{ area: 'Agent setup', count: c.launch_failed_setup ?? 0, next: 'Reproduce a first launch on a clean machine; verify engine installation, tmux and native hook preparation.' },
{ area: 'Sign-in or permission', count: c.launch_failed_auth ?? 0, next: 'Exercise expired sign-in and reconnect with a test account; verify recovery and the visible explanation.' },
@@ -99,6 +103,10 @@ export function dailyProductReview(rows: Row[], now: Date) {
outcomes: Object.fromEntries(['ok', 'failed', 'cancelled', 'unknown'].map(outcome => [outcome, c[`${prefix}${outcome}`] ?? (started ? 0 : null)])),
unmatchedStarts: started === null ? null : Math.max(0, started - observed),
durationBuckets: Object.fromEntries(['under_1s', '1s_to_10s', '10s_to_1m', 'over_1m'].map(bucket => [bucket, c[`${prefix}${bucket}`] ?? (started ? 0 : null)])),
+ // The phone's onboarding: over_1m split further, and what happened on the way (once per sign-in).
+ ...(channel === 'ui' && surface === 'phone' && (PRODUCT_USAGE_LONG_FLOWS as readonly string[]).includes(flow)
+ ? { over1mBuckets: Object.fromEntries(PRODUCT_USAGE_LONG_MEASURES.map(bucket => [bucket, c[`${prefix}${bucket}`] ?? (started ? 0 : null)])) } : {}),
+ ...(channel === 'ui' ? marksOf(prefix) : {}),
interpretation: channel === 'setup'
? 'Optional signed-out app-session counts, untrusted and self-selected. No cross-step linkage, unique people or signup conversion. Web pre-sign-in is not collected.'
: 'Observed app operations, possibly automatic. Missing outcomes include closed apps, offline reports and choice changes; absence is not failure. Viewer opening is not page rendering; update staging is not successful relaunch.',
diff --git a/backend/src/types/productUsage.ts b/backend/src/types/productUsage.ts
index 7301152cb..6b1b9b1f3 100644
--- a/backend/src/types/productUsage.ts
+++ b/backend/src/types/productUsage.ts
@@ -25,6 +25,19 @@ export const PRODUCT_USAGE_SETUP_FLOWS = ['setup', 'setup_harness', 'setup_tmux'
/** Phone onboarding after sign-in: waiting for a computer, opening its session, the first message
* sent there and the notification prompt that follows. Counts and duration buckets only. */
export const PRODUCT_USAGE_ONBOARDING_FLOWS = ['computer_wait', 'session_open', 'first_message', 'notify_permission'] as const
+/** Onboarding steps that can take hours (setting the computer up, the first message): the flow
+ * buckets stop at over_1m, so these also split that bucket. */
+export const PRODUCT_USAGE_LONG_FLOWS = ['computer_wait', 'first_message'] as const
+export const PRODUCT_USAGE_LONG_MEASURES = ['1m_to_5m', '5m_to_15m', '15m_to_1h', 'over_1h'] as const
+/** What happened on the way through a phone onboarding step, at most once per step per sign-in.
+ * `resumed`: the step started in an app run that did not sign in (reopened mid-step), so it is not a
+ * new person; the rest are the step's own ways out or walls. */
+export const PRODUCT_USAGE_ONBOARDING_MARKS = ['ui_phone_computer_wait_resumed', 'ui_phone_computer_wait_not_you',
+ 'ui_phone_computer_wait_link_shared', 'ui_phone_session_open_resumed', 'ui_phone_session_open_blocked_password',
+ 'ui_phone_session_open_blocked_offline', 'ui_phone_first_message_resumed'] as const
+export const PRODUCT_USAGE_ONBOARDING_METRICS = [...PRODUCT_USAGE_ONBOARDING_MARKS,
+ ...PRODUCT_USAGE_LONG_FLOWS.flatMap(flow => PRODUCT_USAGE_LONG_MEASURES.map(measure => `ui_phone_${flow}_${measure}` as const)),
+] as const
export const PRODUCT_USAGE_FLOWS = [...PRODUCT_USAGE_SETUP_FLOWS,
'workspace_connect', 'computer_link', 'remote_connect', 'viewer_open', 'update_check', 'update_stage',
...HEALTH_FLOWS, ...PRODUCT_USAGE_ONBOARDING_FLOWS] as const
@@ -66,6 +79,7 @@ export const PRODUCT_USAGE_METRICS = [
...PRODUCT_USAGE_USER_OPENED_ACTIONS.flatMap(action => (['requests', ...PRODUCT_USAGE_FEATURE_MEASURES] as const)
.map(measure => `${action}_user_${measure}` as const)),
...PRODUCT_USAGE_UI_METRICS,
+ ...PRODUCT_USAGE_ONBOARDING_METRICS,
] as const
export type ProductUsageMetric = typeof PRODUCT_USAGE_METRICS[number]
export interface ProductUsageReport {
diff --git a/cli/src/lib/productUsageContract.ts b/cli/src/lib/productUsageContract.ts
index 7301152cb..6b1b9b1f3 100644
--- a/cli/src/lib/productUsageContract.ts
+++ b/cli/src/lib/productUsageContract.ts
@@ -25,6 +25,19 @@ export const PRODUCT_USAGE_SETUP_FLOWS = ['setup', 'setup_harness', 'setup_tmux'
/** Phone onboarding after sign-in: waiting for a computer, opening its session, the first message
* sent there and the notification prompt that follows. Counts and duration buckets only. */
export const PRODUCT_USAGE_ONBOARDING_FLOWS = ['computer_wait', 'session_open', 'first_message', 'notify_permission'] as const
+/** Onboarding steps that can take hours (setting the computer up, the first message): the flow
+ * buckets stop at over_1m, so these also split that bucket. */
+export const PRODUCT_USAGE_LONG_FLOWS = ['computer_wait', 'first_message'] as const
+export const PRODUCT_USAGE_LONG_MEASURES = ['1m_to_5m', '5m_to_15m', '15m_to_1h', 'over_1h'] as const
+/** What happened on the way through a phone onboarding step, at most once per step per sign-in.
+ * `resumed`: the step started in an app run that did not sign in (reopened mid-step), so it is not a
+ * new person; the rest are the step's own ways out or walls. */
+export const PRODUCT_USAGE_ONBOARDING_MARKS = ['ui_phone_computer_wait_resumed', 'ui_phone_computer_wait_not_you',
+ 'ui_phone_computer_wait_link_shared', 'ui_phone_session_open_resumed', 'ui_phone_session_open_blocked_password',
+ 'ui_phone_session_open_blocked_offline', 'ui_phone_first_message_resumed'] as const
+export const PRODUCT_USAGE_ONBOARDING_METRICS = [...PRODUCT_USAGE_ONBOARDING_MARKS,
+ ...PRODUCT_USAGE_LONG_FLOWS.flatMap(flow => PRODUCT_USAGE_LONG_MEASURES.map(measure => `ui_phone_${flow}_${measure}` as const)),
+] as const
export const PRODUCT_USAGE_FLOWS = [...PRODUCT_USAGE_SETUP_FLOWS,
'workspace_connect', 'computer_link', 'remote_connect', 'viewer_open', 'update_check', 'update_stage',
...HEALTH_FLOWS, ...PRODUCT_USAGE_ONBOARDING_FLOWS] as const
@@ -66,6 +79,7 @@ export const PRODUCT_USAGE_METRICS = [
...PRODUCT_USAGE_USER_OPENED_ACTIONS.flatMap(action => (['requests', ...PRODUCT_USAGE_FEATURE_MEASURES] as const)
.map(measure => `${action}_user_${measure}` as const)),
...PRODUCT_USAGE_UI_METRICS,
+ ...PRODUCT_USAGE_ONBOARDING_METRICS,
] as const
export type ProductUsageMetric = typeof PRODUCT_USAGE_METRICS[number]
export interface ProductUsageReport {
diff --git a/docs/product-measurement.md b/docs/product-measurement.md
index 313dd6317..4a4ca84cf 100644
--- a/docs/product-measurement.md
+++ b/docs/product-measurement.md
@@ -18,6 +18,7 @@ automatically proven improvement. Changes still need review, tests and a deliber
| Which features get tried and used again? | First measured installations and daily first/repeat feature reach | Locally deduplicated installation-days, not unique accounts. Reads the apps make on their own (history, history paging, Store list, model list; `PRODUCT_USAGE_AUTOMATIC_ACTIONS`) count reliability only. The Store and model lists get reach only from the request an app marks `userAction` when a person opens them (`<action>_user_*`, `PRODUCT_USAGE_USER_OPENED_ACTIONS`); history has none. |
| Where do app flows break? | Setup, Harness/tmux/clipboard steps, sign-in, workspace/remote connections, computer linking, viewer-pane opening and manual update checking/staging | Fixed started/ok/failed/cancelled/unknown counts and coarse duration buckets. Opening a viewer pane is not rendering its content; staging an update is not a successful relaunch. |
+| Where does the phone's onboarding stall? | After sign-in: waiting for the first computer, opening its session, the first message, the notification prompt. A sign-in that went through, by button, counted again under the account's sharing. Waits past a minute split into 1–5 min, 5–15 min, 15 min–1 h and over 1 h for the computer and the first message. Once per step per sign-in: `resumed` (reopened in a run that did not sign in), "Not you? Sign out", the address sent from the share sheet, a joining computer that wants its password or is offline | Stage totals per day, not a linked funnel. Subtract `resumed` from starts for fresh starts; an unmatched start is a closed app or a step still waiting. A resumed step's duration starts at the reopening. Signed-in sign-in counts are successes only; failures and cancels before an account remain the signed-out opt-in's. |
| Is measurement losing coverage? | Updated collector installation-days, pruned queues, full observation maps, unmatched app starts | Loss signals warrant caution. No signal does not prove complete collection. |
| How many people use Harness, and do they come back? | People active / working / new per day and per app, and D1/D2/D3/D7 returns (backend rollup of 10-day pseudonymous marks) | Sharing accounts only, staff excluded; an app open across midnight counts on both days, so prefer working returns. Not available before `PRODUCT_USAGE_SUBJECT_KEY` is set. |
diff --git a/mobile/lib/measurement/onboarding_measurement.dart b/mobile/lib/measurement/onboarding_measurement.dart
index db7c8f0de..945cc873c 100644
--- a/mobile/lib/measurement/onboarding_measurement.dart
+++ b/mobile/lib/measurement/onboarding_measurement.dart
@@ -1,29 +1,75 @@
import 'product_measurement.dart';
+/// Mirrors `PRODUCT_USAGE_ONBOARDING_MARKS` in backend/src/types/productUsage.ts, with the steps
+/// each is listed under there ([flows]); another pairing would reject the whole report.
+enum OnboardingMark {
+ /// The step started in an app run that did not sign in: reopened mid-step, not a new start.
+ resumed('resumed', {
+ ProductFlow.computerWait,
+ ProductFlow.sessionOpen,
+ ProductFlow.firstMessage,
+ }),
+
+ /// "Not you? Sign out" under the account the computer has to sign in to.
+ notYou('not_you', {ProductFlow.computerWait}),
+
+ /// The computer's address sent from the phone (share sheet).
+ linkShared('link_shared', {ProductFlow.computerWait}),
+
+ /// The joining computer wants its password before its session can open.
+ blockedPassword('blocked_password', {ProductFlow.sessionOpen}),
+
+ /// The joining computer is offline, as the account says too.
+ blockedOffline('blocked_offline', {ProductFlow.sessionOpen});
+
+ const OnboardingMark(this.wire, this.flows);
+ final String wire;
+ final Set<ProductFlow> flows;
+}
+
/// The phone's onboarding after sign-in, as fixed flows that hand over to each other: waiting for a
/// computer → opening its session → the first message sent there → the notification prompt.
///
/// Counts and duration buckets only, through [ProductMeasurement]: no account, computer, session,
/// message or answer text, and nothing at all unless the account shares product usage.
///
-/// Each flow runs once per sign-in ([reset] on sign-out). A step that starts before the account's
-/// sharing choice has loaded — right after sign-in — waits here, and is counted from when it really
-/// started once sharing is confirmed; a step that ends before then is never counted.
+/// Each flow and each mark counts once per sign-in ([reset] on sign-out). Whatever happens before
+/// the account's sharing choice has loaded — right after sign-in — waits here: a step is counted
+/// from when it really started once sharing is confirmed, and nothing waiting is counted once the
+/// choice reads off. A step that ends before then is never counted; the sign-in itself, which
+/// always does, is the exception ([signedIn]).
class OnboardingMeasurement {
OnboardingMeasurement(this._usage) {
_usage.addListener(_admit);
}
final ProductMeasurement _usage;
- final _waiting = <ProductFlow, Stopwatch>{};
+ final _waiting = <ProductFlow, ({Stopwatch watch, bool resumed})>{};
final _running = <ProductFlow, void Function(ProductOutcome)>{};
final _seen = <ProductFlow>{};
+ final _signedIn = <ProductFlow, Duration>{};
+ final _marks = <(ProductFlow, OnboardingMark)>{};
+ final _marked = <(ProductFlow, OnboardingMark)>{};
+ bool _signedInThisRun = false;
+
+ /// A sign-in by [method] went through after [took]. Counted under the account's own sharing — a
+ /// far larger group than the signed-out opt-in — as `sign_in` and the button, both ok.
+ void signedIn(ProductFlow method, Duration took) {
+ _signedInThisRun = true;
+ _signedIn[ProductFlow.signIn] = took;
+ _signedIn[method] = took;
+ _admit();
+ }
/// Starts [flow] the first time it is asked for in this sign-in; build methods may call it on
- /// every frame.
+ /// every frame. Started in an app run that did not sign in, it is counted with
+ /// [OnboardingMark.resumed] as well.
void start(ProductFlow flow) {
if (!_seen.add(flow)) return;
- _waiting[flow] = Stopwatch()..start();
+ _waiting[flow] = (
+ watch: Stopwatch()..start(),
+ resumed: !_signedInThisRun && OnboardingMark.resumed.flows.contains(flow),
+ );
_admit();
}
@@ -33,6 +79,16 @@ class OnboardingMeasurement {
_running.remove(flow)?.call(outcome);
}
+ /// Counts [what] of [flow], once per sign-in; build methods may call it on every frame. Only for
+ /// a step this sign-in has [start]ed — the same screens outside the onboarding count nothing — and
+ /// one [what] is listed under.
+ void mark(ProductFlow flow, OnboardingMark what) {
+ if (!_seen.contains(flow) || !what.flows.contains(flow)) return;
+ if (!_marked.add((flow, what))) return;
+ _marks.add((flow, what));
+ _admit();
+ }
+
/// Asks the OS for notifications through [ask], counting the answer: allowed is `ok`, refused is
/// `cancelled`, no answer is `unknown`.
Future<void> askNotifications(Future<bool?> Function() ask) async {
@@ -50,21 +106,39 @@ class OnboardingMeasurement {
for (final flow in [..._running.keys]) {
end(flow, ProductOutcome.cancelled);
}
- _waiting.clear();
+ _clearWaiting();
_seen.clear();
+ _marked.clear();
+ _signedInThisRun = false;
+ }
+
+ void _clearWaiting() {
+ _waiting.clear();
+ _signedIn.clear();
+ _marks.clear();
}
void _admit() {
- if (!_usage.sharing || _waiting.isEmpty) return;
- for (final MapEntry(key: flow, value: watch) in [..._waiting.entries]) {
+ if (_usage.declined) return _clearWaiting();
+ if (!_usage.sharing) return;
+ for (final MapEntry(key: flow, value: step) in [..._waiting.entries]) {
_waiting.remove(flow);
- _running[flow] = _usage.begin(flow, elapsed: watch.elapsed);
+ _running[flow] = _usage.begin(flow, elapsed: step.watch.elapsed);
+ if (step.resumed) _usage.mark(flow, OnboardingMark.resumed.wire);
+ }
+ for (final MapEntry(key: flow, value: took) in [..._signedIn.entries]) {
+ _signedIn.remove(flow);
+ _usage.begin(flow, elapsed: took)(ProductOutcome.ok);
+ }
+ for (final (flow, what) in [..._marks]) {
+ _marks.remove((flow, what));
+ _usage.mark(flow, what.wire);
}
}
void dispose() {
_usage.removeListener(_admit);
- _waiting.clear();
+ _clearWaiting();
_running.clear();
}
}
diff --git a/mobile/lib/measurement/product_measurement.dart b/mobile/lib/measurement/product_measurement.dart
index 48beddb24..71dcd66e9 100644
--- a/mobile/lib/measurement/product_measurement.dart
+++ b/mobile/lib/measurement/product_measurement.dart
@@ -31,6 +31,9 @@ enum ProductFlow {
/// Whether a signed-out session that opted in may count it.
bool get beforeSignIn => index <= ProductFlow.signIn.index;
+
+ /// Mirrors `PRODUCT_USAGE_LONG_FLOWS`: a step that can take hours, whose over_1m is split further.
+ bool get long => this == computerWait || this == firstMessage;
}
enum ProductOutcome { ok, failed, cancelled, unknown }
@@ -78,6 +81,9 @@ class ProductMeasurement extends ChangeNotifier {
final _setupFacts = <ProductFlow, String>{};
bool get sharing => _account != null && _enabled == true;
+
+ /// The account's choice has read off: what waits to be counted for it never is.
+ bool get declined => _account != null && _enabled == false;
bool get _setupAllowed =>
surface != 'web' &&
signedOutSharing &&
@@ -183,9 +189,28 @@ class ProductMeasurement extends ChangeNotifier {
? '10s_to_1m'
: 'over_1m'}',
);
+ if (!flow.long || ms < 60000) return;
+ _count(
+ channel,
+ day,
+ '$prefix${ms < 300000
+ ? '1m_to_5m'
+ : ms < 900000
+ ? '5m_to_15m'
+ : ms < 3600000
+ ? '15m_to_1h'
+ : 'over_1h'}',
+ );
};
}
+ /// Counts [measure] of [flow] — one of `PRODUCT_USAGE_ONBOARDING_MARKS` — for an account that shares.
+ void mark(ProductFlow flow, String measure) {
+ if (_disposed || !sharing) return;
+ final day = _now().toUtc().toIso8601String().substring(0, 10);
+ _count('ui', day, 'ui_${surface}_${flow.wire}_$measure');
+ }
+
/// One attempt counted under several flows at once — `sign_in` and the button that started it.
void Function(ProductOutcome) beginEach(List<ProductFlow> flows) {
final finishers = [for (final flow in flows) begin(flow)];
diff --git a/mobile/lib/phone/agent_home.dart b/mobile/lib/phone/agent_home.dart
index e8c1e38c5..5c3897e9f 100644
--- a/mobile/lib/phone/agent_home.dart
+++ b/mobile/lib/phone/agent_home.dart
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:harness_mobile/demo/sample_mode.dart';
import 'package:harness_mobile/logging/startup_trace.dart';
import 'package:harness_mobile/logging/typing_trace.dart';
+import 'package:harness_mobile/measurement/onboarding_measurement.dart';
import 'package:harness_mobile/measurement/product_measurement.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/core/models.dart';
@@ -1136,6 +1137,10 @@ class _AgentHomeState extends State<AgentHome>
child: GoToComputer(
account: notifier.currentUser?.email,
notYou: NotYouSignOut(notifier: notifier),
+ onSent: () => notifier.onboardingMeasurement.mark(
+ ProductFlow.computerWait,
+ OnboardingMark.linkShared,
+ ),
),
),
status: const OnboardingStatus(OnboardingCopy.looking),
@@ -1207,15 +1212,27 @@ class _AgentHomeState extends State<AgentHome>
final machine = notifier.stateOf(joining.machineId);
if (machine == null) return false;
return switch (phoneMachineStatusOf(machine)) {
- PhoneMachineStatus.needsPassword => notifier.deviceTrustSettling,
- PhoneMachineStatus.offline => phoneAccountSaysOnline(
- machine.machine.status,
+ PhoneMachineStatus.needsPassword => _holdUnless(
+ notifier.deviceTrustSettling,
+ OnboardingMark.blockedPassword,
+ ),
+ PhoneMachineStatus.offline => _holdUnless(
+ phoneAccountSaysOnline(machine.machine.status),
+ OnboardingMark.blockedOffline,
),
PhoneMachineStatus.connecting => true,
PhoneMachineStatus.ready => _waitForFirstSession(),
};
}
+ /// [holding] as it is; letting go, the session will not open by itself, and [why] is counted.
+ bool _holdUnless(bool holding, OnboardingMark why) {
+ if (!holding) {
+ widget.notifier.onboardingMeasurement.mark(ProductFlow.sessionOpen, why);
+ }
+ return holding;
+ }
+
/// The onboarding hands over to a session — its computer's own, or one picked meanwhile — and
/// the first message there is next.
void _measureHandOver() {
diff --git a/mobile/lib/phone/welcome/your_computer.dart b/mobile/lib/phone/welcome/your_computer.dart
index af45b79c3..c325d1051 100644
--- a/mobile/lib/phone/welcome/your_computer.dart
+++ b/mobile/lib/phone/welcome/your_computer.dart
@@ -6,6 +6,8 @@ import 'package:lucide_icons_flutter/lucide_icons.dart';
import 'package:share_plus/share_plus.dart';
import 'package:harness_mobile/core/handoff.dart';
+import 'package:harness_mobile/measurement/onboarding_measurement.dart';
+import 'package:harness_mobile/measurement/product_measurement.dart';
import 'package:harness_mobile/shared/theme/app_theme.dart';
import 'package:harness_mobile/state/app_state.dart';
@@ -144,7 +146,12 @@ class _YourComputerPageState extends State<YourComputerPage>
/// Signed in there with it, the computer joins the account, and the screen moves on by itself
/// ([ComputerWatch]): no Add Phone, nothing to scan.
class GoToComputer extends StatelessWidget {
- const GoToComputer({super.key, required this.account, this.notYou});
+ const GoToComputer({
+ super.key,
+ required this.account,
+ this.notYou,
+ this.onSent,
+ });
/// The account the computer has to sign in to — this phone's.
final String? account;
@@ -153,12 +160,15 @@ class GoToComputer extends StatelessWidget {
/// none with no account to name — "Not you?" would ask about nobody.
final Widget? notYou;
+ /// The address went out through the share sheet ([GoAddressButton.onSent]).
+ final VoidCallback? onSent;
+
@override
Widget build(BuildContext context) => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- const GoAddressButton(),
+ GoAddressButton(onSent: onSent),
const SizedBox(height: OnboardingFrame.stepsAbove),
StepsTimeline(
steps: goToSteps(account),
@@ -193,6 +203,10 @@ class NotYouSignOut extends StatelessWidget {
behavior: HitTestBehavior.opaque,
onTap: () {
HapticFeedback.selectionClick();
+ notifier.onboardingMeasurement.mark(
+ ProductFlow.computerWait,
+ OnboardingMark.notYou,
+ );
unawaited(confirmSignOut(context, notifier));
},
child: ConstrainedBox(
@@ -272,7 +286,10 @@ class _ComputerWatchState extends State<ComputerWatch> {
/// While it is up it also offers the page to a Mac nearby by Handoff ([Handoff]): signed in to the
/// same Apple account, the Mac shows it in its Dock, and nothing is typed at all.
class GoAddressButton extends StatefulWidget {
- const GoAddressButton({super.key});
+ const GoAddressButton({super.key, this.onSent});
+
+ /// The share sheet sent the address somewhere — not merely opened and dismissed.
+ final VoidCallback? onSent;
@override
State<GoAddressButton> createState() => _GoAddressButtonState();
@@ -309,13 +326,14 @@ class _GoAddressButtonState extends State<GoAddressButton> {
? null
: box.localToGlobal(Offset.zero) & box.size;
try {
- await SharePlus.instance.share(
+ final result = await SharePlus.instance.share(
ShareParams(
uri: _url,
subject: 'Get Harness for your computer',
sharePositionOrigin: origin,
),
);
+ if (result.status == ShareResultStatus.success) widget.onSent?.call();
} catch (_) {
// No share sheet came up: the address is still there to type, and can be pressed again.
}
diff --git a/mobile/lib/state/app_state.dart b/mobile/lib/state/app_state.dart
index 8e6e7e2c7..08bba062c 100644
--- a/mobile/lib/state/app_state.dart
+++ b/mobile/lib/state/app_state.dart
@@ -1738,9 +1738,19 @@ class AppNotifier extends ChangeNotifier {
/// `viewer/email_code_api.dart`.
Future<void> sendLoginCode(String email) => viewer.emailLogin.sendCode(email);
- /// A sign-in attempt, counted as `sign_in` and under the welcome-screen button that started it.
- void Function(ProductOutcome) _measureSignIn(ProductFlow method) =>
- productMeasurement.beginEach([ProductFlow.signIn, method]);
+ /// A sign-in attempt, counted as `sign_in` and under the welcome-screen button that started it:
+ /// every outcome for a signed-out session that opted in, and a success once more under the
+ /// account's own sharing ([OnboardingMeasurement.signedIn]).
+ void Function(ProductOutcome) _measureSignIn(ProductFlow method) {
+ final finish = productMeasurement.beginEach([ProductFlow.signIn, method]);
+ final watch = Stopwatch()..start();
+ return (outcome) {
+ finish(outcome);
+ if (outcome == ProductOutcome.ok) {
+ onboardingMeasurement.signedIn(method, watch.elapsed);
+ }
+ };
+ }
/// The phone's sign-in, second step: trade the emailed [code] for a session
/// and go in.
diff --git a/mobile/test/onboarding_measurement_test.dart b/mobile/test/onboarding_measurement_test.dart
index 3ff624879..0063f45c0 100644
--- a/mobile/test/onboarding_measurement_test.dart
+++ b/mobile/test/onboarding_measurement_test.dart
@@ -40,29 +40,40 @@ void main() {
await usage.flush();
}
- Map<String, dynamic> counters() => {
- for (final r in reports) ...(r['counters'] as Map<String, dynamic>),
+ Map<String, dynamic> counters([String prefix = '']) => {
+ for (final r in reports)
+ for (final MapEntry(:key, :value)
+ in (r['counters'] as Map<String, dynamic>).entries)
+ if (key.startsWith(prefix)) key: value,
};
+ /// This run's sign-in, which the onboarding's steps follow.
+ void signedInHere() =>
+ onboarding.signedIn(ProductFlow.signInEmail, Duration.zero);
+
test('a step started before sharing loads is counted once it does', () async {
+ signedInHere();
onboarding.start(ProductFlow.computerWait);
await signIn();
onboarding.end(ProductFlow.computerWait, ProductOutcome.ok);
await usage.flush();
- expect(counters(), {
+ expect(counters('ui_phone_computer_wait_'), {
'ui_phone_computer_wait_started': 1,
'ui_phone_computer_wait_ok': 1,
'ui_phone_computer_wait_under_1s': 1,
});
});
- test('a step that ends before sharing is confirmed is never counted', () async {
- onboarding.start(ProductFlow.computerWait);
- onboarding.end(ProductFlow.computerWait, ProductOutcome.ok);
- await signIn();
- await usage.flush();
- expect(counters(), isEmpty);
- });
+ test(
+ 'a step that ends before sharing is confirmed is never counted',
+ () async {
+ onboarding.start(ProductFlow.computerWait);
+ onboarding.end(ProductFlow.computerWait, ProductOutcome.ok);
+ await signIn();
+ await usage.flush();
+ expect(counters(), isEmpty);
+ },
+ );
test('nothing is counted while the account does not share', () async {
choice = {'enabled': false, 'revision': 1};
@@ -75,13 +86,15 @@ void main() {
test('each step runs once per sign-in; signing out abandons it', () async {
await signIn();
+ signedInHere();
onboarding.start(ProductFlow.sessionOpen);
onboarding.start(ProductFlow.sessionOpen);
onboarding.reset();
onboarding.end(ProductFlow.sessionOpen, ProductOutcome.ok);
+ signedInHere();
onboarding.start(ProductFlow.sessionOpen);
await usage.flush();
- expect(counters(), {
+ expect(counters('ui_phone_session_open_'), {
'ui_phone_session_open_started': 2,
'ui_phone_session_open_cancelled': 1,
'ui_phone_session_open_under_1s': 1,
@@ -102,42 +115,133 @@ void main() {
test('time spent waiting for sharing lands in the duration', () async {
await signIn();
- usage.begin(
- ProductFlow.firstMessage,
- elapsed: const Duration(seconds: 12),
- )(ProductOutcome.ok);
+ usage.begin(ProductFlow.firstMessage, elapsed: const Duration(seconds: 12))(
+ ProductOutcome.ok,
+ );
await usage.flush();
expect(counters()['ui_phone_first_message_10s_to_1m'], 1);
});
- test('a sign-in counts the total and the button, without identifiers', () async {
+ test(
+ 'a sign-in counts the total and the button, without identifiers',
+ () async {
+ await signIn();
+ usage.beginEach([ProductFlow.signIn, ProductFlow.signInGoogle])(
+ ProductOutcome.ok,
+ );
+ await usage.flush();
+ expect(reports.single.keys.toSet(), {
+ 'schemaVersion',
+ 'id',
+ 'day',
+ 'counters',
+ 'revision',
+ });
+ expect(counters(), {
+ 'ui_phone_sign_in_started': 1,
+ 'ui_phone_sign_in_ok': 1,
+ 'ui_phone_sign_in_under_1s': 1,
+ 'ui_phone_sign_in_google_started': 1,
+ 'ui_phone_sign_in_google_ok': 1,
+ 'ui_phone_sign_in_google_under_1s': 1,
+ });
+ expect(jsonEncode(reports), isNot(contains('PRIVATE_ACCOUNT')));
+ },
+ );
+
+ test(
+ 'a sign-in that went through counts under the account once it shares',
+ () async {
+ onboarding.signedIn(ProductFlow.signInApple, const Duration(seconds: 3));
+ await signIn();
+ await usage.flush();
+ expect(counters(), {
+ 'ui_phone_sign_in_started': 1,
+ 'ui_phone_sign_in_ok': 1,
+ 'ui_phone_sign_in_1s_to_10s': 1,
+ 'ui_phone_sign_in_apple_started': 1,
+ 'ui_phone_sign_in_apple_ok': 1,
+ 'ui_phone_sign_in_apple_1s_to_10s': 1,
+ });
+ },
+ );
+
+ test(
+ 'a step reopened in a run that did not sign in is marked resumed',
+ () async {
+ await signIn();
+ onboarding.start(ProductFlow.computerWait);
+ onboarding.reset();
+ signedInHere();
+ onboarding.start(ProductFlow.computerWait);
+ await usage.flush();
+ expect(counters()['ui_phone_computer_wait_started'], 2);
+ expect(counters()['ui_phone_computer_wait_resumed'], 1);
+ },
+ );
+
+ test(
+ 'a mark counts once per sign-in, only on a started step it is listed under',
+ () async {
+ await signIn();
+ signedInHere();
+ onboarding.mark(ProductFlow.computerWait, OnboardingMark.notYou);
+ onboarding.start(ProductFlow.computerWait);
+ onboarding.mark(ProductFlow.computerWait, OnboardingMark.notYou);
+ onboarding.mark(ProductFlow.computerWait, OnboardingMark.notYou);
+ onboarding.mark(ProductFlow.computerWait, OnboardingMark.blockedOffline);
+ await usage.flush();
+ expect(
+ counters().keys.where((k) => k.startsWith('ui_phone_computer_wait_')),
+ ['ui_phone_computer_wait_started', 'ui_phone_computer_wait_not_you'],
+ );
+ expect(counters()['ui_phone_computer_wait_not_you'], 1);
+ },
+ );
+
+ test('a long step also splits its over_1m', () async {
await signIn();
- usage.beginEach([ProductFlow.signIn, ProductFlow.signInGoogle])(
+ usage.begin(ProductFlow.computerWait, elapsed: const Duration(minutes: 20))(
+ ProductOutcome.ok,
+ );
+ usage.begin(ProductFlow.sessionOpen, elapsed: const Duration(minutes: 20))(
ProductOutcome.ok,
);
await usage.flush();
- expect(reports.single.keys.toSet(), {
- 'schemaVersion',
- 'id',
- 'day',
- 'counters',
- 'revision',
- });
- expect(counters(), {
- 'ui_phone_sign_in_started': 1,
- 'ui_phone_sign_in_ok': 1,
- 'ui_phone_sign_in_under_1s': 1,
- 'ui_phone_sign_in_google_started': 1,
- 'ui_phone_sign_in_google_ok': 1,
- 'ui_phone_sign_in_google_under_1s': 1,
- });
- expect(jsonEncode(reports), isNot(contains('PRIVATE_ACCOUNT')));
+ expect(counters()['ui_phone_computer_wait_over_1m'], 1);
+ expect(counters()['ui_phone_computer_wait_15m_to_1h'], 1);
+ expect(counters()['ui_phone_session_open_over_1m'], 1);
+ expect(
+ counters().keys.where((k) => k.startsWith('ui_phone_session_open_15m')),
+ isEmpty,
+ );
+ });
+
+ test('nothing waiting is counted once the choice reads off', () async {
+ choice = {'enabled': false, 'revision': 1};
+ onboarding.start(ProductFlow.computerWait);
+ onboarding.signedIn(ProductFlow.signInGoogle, Duration.zero);
+ await signIn();
+ usage.savedChoice({'enabled': true, 'revision': 2});
+ onboarding.end(ProductFlow.computerWait, ProductOutcome.ok);
+ await usage.flush();
+ expect(counters(), isEmpty);
+ });
+
+ test('every mark is in the backend vocabulary under each step it names', () {
+ final vocabulary = File('../backend/src/types/productUsage.ts')
+ .readAsStringSync();
+ for (final mark in OnboardingMark.values) {
+ for (final flow in mark.flows) {
+ final metric = 'ui_phone_${flow.wire}_${mark.wire}';
+ expect(vocabulary, contains("'$metric'"), reason: metric);
+ }
+ }
});
test('every flow is in the backend vocabulary', () {
- final vocabulary = File(
- '../backend/src/types/productUsage.ts',
- ).readAsStringSync();
+ final vocabulary = File('../backend/src/types/productUsage.ts')
+ .readAsStringSync();
for (final flow in ProductFlow.values) {
expect(vocabulary, contains("'${flow.wire}'"), reason: flow.wire);
}