Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -936,3 +936,5 @@ names, packages, service lists, paths, command arguments, CLI output or preferen
contents are attached. There are no background samplers or per-frame spans for
this feature. Benchmark process measurements are local report artifacts and are
not submitted to Sentry. Existing startup, stream and input coverage is retained.

Physical iPhone recording and replay add no metrics. Testing Studio timings (`ui.testing.*`) already carry `device_platform` and `device_kind` (`physical` for hardware) from the device workspace whenever one device is shown, so hardware series are separable from simulator ones. agent-device failures now include its `details.hint` in the user-facing message and, for signing, Developer Mode and locked-device classes, are reported as expected outcomes. Hints have local paths replaced with `<path>`; log paths, team IDs, identities and device identifiers are never sent.
4 changes: 3 additions & 1 deletion packages/core/src/agent-device-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { homedir, tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { SIGNING_ENV_KEYS } from "./ios-signing.ts";
import { startStorageMetrics } from "./storage-metrics.ts";
import { captureServerError } from "./telemetry.ts";

Expand Down Expand Up @@ -83,7 +84,8 @@ export class AgentDeviceRuntime {
private environment(directory: string) {
const env: Record<string, string> = {};
for (const [key, value] of Object.entries(process.env)) {
if (key.startsWith("AGENT_DEVICE_") === false && value !== undefined) env[key] = value;
// Signing variables are the user's (or Testing Studio's resolved team); the rest of AGENT_DEVICE_* is ours.
if (value !== undefined && (key.startsWith("AGENT_DEVICE_") === false || (SIGNING_ENV_KEYS as readonly string[]).includes(key))) env[key] = value;
}
env.AGENT_DEVICE_CONFIG = this.config;
env.AGENT_DEVICE_STATE_DIR = directory;
Expand Down
49 changes: 49 additions & 0 deletions packages/core/src/ios-device-build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { readdir, stat } from "node:fs/promises";
import { homedir } from "node:os";
import { join } from "node:path";
import type { Commands } from "./app-control/commands.ts";

/**
* A build of the app made for physical devices, found where Xcode and Expo leave them.
*
* Only `*-iphoneos` products qualify: a `Debug-iphonesimulator` app has the simulator slice and no
* provisioning profile, so it cannot run on hardware however it is installed. The newest build whose
* `CFBundleIdentifier` matches wins. Roots are the project's own `ios/build` (`expo run:ios --device`)
* and Xcode's DerivedData.
*/

async function modified(path: string): Promise<number> { return (await stat(path).catch(() => undefined))?.mtimeMs ?? 0; }

async function appsIn(directory: string): Promise<string[]> {
const entries = await readdir(directory).catch(() => [] as string[]);
return entries.filter(name => name.endsWith(".app")).map(name => join(directory, name));
}

/** The `*-iphoneos` product directories under the build roots. */
export async function deviceProductDirectories(projectPath?: string, home = homedir()): Promise<string[]> {
const products: string[] = [];
const productsOf = async (root: string) => {
for (const configuration of await readdir(root).catch(() => [] as string[])) {
if (configuration.endsWith("-iphoneos")) products.push(join(root, configuration));
}
};
if (projectPath) await productsOf(join(projectPath, "ios", "build", "Build", "Products"));
const derived = join(home, "Library", "Developer", "Xcode", "DerivedData");
for (const project of await readdir(derived).catch(() => [] as string[])) await productsOf(join(derived, project, "Build", "Products"));
return products;
}

export async function findDeviceBuild(appId: string, commands: Pick<Commands, "run">, projectPath?: string, home?: string): Promise<string | undefined> {
const candidates: { path: string; time: number }[] = [];
for (const directory of await deviceProductDirectories(projectPath, home)) {
for (const app of await appsIn(directory)) candidates.push({ path: app, time: await modified(app) });
}
candidates.sort((a, b) => b.time - a.time);
for (const { path } of candidates) {
try {
const identifier = (await commands.run("/usr/bin/plutil", ["-extract", "CFBundleIdentifier", "raw", "-o", "-", join(path, "Info.plist")], { timeout: 5_000 })).trim();
if (identifier === appId) return path;
} catch { /* an unreadable bundle is not a match */ }
}
return undefined;
}
Loading
Loading