Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(telemetry): record signed_in for every sign-in, not only the first run (#4492)

ddupont41c34cb0d704
diff --git a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
index 5ab4927b83..09b1803f66 100644
--- a/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
+++ b/apps/cua-spaces-macos/Sources/CuaSpacesMacKit/Models/AppModel.swift
@@ -667,6 +667,13 @@ public final class AppModel {
identity = who ?? account.identity()
host.identity = identity
devices.signedIn = identity != nil
+ // Activation funnel: the first run records `signed_in` on its
+ // sign-in page; a sign-in from the main window (first run done or
+ // not showing, so its state is on Welcome) records it here.
+ if onboarding.state.step == .welcome, let who = identity, !who.isEmpty,
+ who != onboarding.state.identity {
+ telemetry?.record([.step(step: "signed_in", ok: true)])
+ }
onboarding.send(.signedIn(identity: identity ?? ""))
signIn = .idle
} catch {
diff --git a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
index 2d76bf2af2..f5c98b954b 100644
--- a/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
+++ b/apps/cua-spaces-macos/Tests/CuaSpacesMacTests/ViewModelTests.swift
@@ -356,6 +356,21 @@ struct ViewModelTests {
#expect(toggled == ["experiment_on cua_volume"])
}
+ /// A sign-in from the main window (the first run done or not showing)
+ /// still counts in the activation funnel, once.
+ @Test func mainWindowSignInRecordsSignedIn() async {
+ let telemetry = FixtureTelemetry()
+ let model = makeModel(account: FixtureAccount(), telemetry: telemetry)
+ #expect(model.onboarding.state.step == .welcome)
+ await model.beginSignIn()
+ #expect(model.identity == "[email protected]")
+ let steps = telemetry.recorded.compactMap { s -> String? in
+ if case let .step(step, ok) = s, ok { return step }
+ return nil
+ }
+ #expect(steps == ["signed_in"])
+ }
+
@Test func settingsPageAndAccountFromTheCore() async {
let account = FixtureAccount()
let agents = FixtureAgentSetup()
diff --git a/libs/cua/crates/cua-cli/src/auth.rs b/libs/cua/crates/cua-cli/src/auth.rs
index 59e4f6b6ee..54f7ad5779 100644
--- a/libs/cua/crates/cua-cli/src/auth.rs
+++ b/libs/cua/crates/cua-cli/src/auth.rs
@@ -199,6 +199,9 @@ pub async fn login(opts: &LoginOptions, out: &mut dyn Write) -> Result<i32, CuaE
let _ = out.flush();
let creds = pending.complete().await.map_err(auth_err)?;
let id = s.install(creds).await.map_err(auth_err)?;
+ // Activation funnel: a sign-in from the CLI (browser or device code)
+ // counts like one in the Spaces app's first run.
+ cua_telemetry::global().capture_step("signed_in", cua_telemetry::Outcome::Ok);
let who = match (&id.username, &id.email) {
(Some(u), Some(e)) if u != e => format!(" as {u} ({e})"),
(Some(u), _) | (None, Some(u)) => format!(" as {u}"),