feat(events): enrich session event details

Merged
SZ
4mo ago
+1582-178

Summary

  • Enrich session events with compact summaries and typed details for device/app inventory, boot/shutdown, install/reinstall, screenshot, scroll, navigation, viewport/orientation, clipboard/keyboard actions, gestures, TV remote input, traces, and recordings.
  • Preserve useful product data such as app identifiers and requested artifact basenames. Inventory output is bounded to three entries in summaries and five in details; user-controlled labels and basenames are bounded to 120 Unicode code points.
  • Treat the durable event stream as an external privacy boundary. Event fields are projected from per-command allowlists instead of copying daemon requests or responses:
    • typed/fill text, clipboard contents, push/event payloads, selector queries, raw positionals, and their lengths are omitted or replaced with content-free placeholders
    • free-form flags such as launch arguments, headers, environment values, and output paths are omitted
    • generic response messages, request/runner log paths, tenant metadata, device IDs, and provider stdout/stderr are omitted
    • device names that alias an ID, serial, or UDID are replaced with structural labels such as iOS device or Android emulator
    • unknown commands fall back to the command name and safe placeholders instead of forwarding unknown data
  • Keep the version 1 event contract additive. Command behavior, daemon responses, platform/provider implementations, and event collection are unchanged.

The screenshot projection uses the original client artifact path before remote transport rewrites it, then records only the basename. The same basename-only rule applies to trace and recording artifacts.

Validation

Automated

  • pnpm check:affected --base origin/main --run
    • formatting, lint, typecheck, layering, Fallow, and build passed
    • 2,174 tests passed across 213 test files
    • regressions cover Android/Apple/provider identifier-derived device names and malformed provider scroll output reaching the durable NDJSON route

Manual iOS simulator

Environment: this branch's CLI, an iPhone 17 Pro simulator, and ~/Downloads/testapp.app (com.expo.testapp.szymon).

I exercised boot, install, open, clipboard write, screenshot, scroll, devices, apps, and close with shutdown. The open command received manual-private-launch-arg, and clipboard write received manual-private-clipboard-value, as sentinel secrets.

Selected emitted events:

[
  {
    "command": "boot",
    "status": "ok",
    "summary": "Booted iPhone 17 Pro (ios, simulator, mobile)",
    "details": {
      "durationMs": 9260,
      "device": "iPhone 17 Pro",
      "platform": "ios",
      "kind": "simulator",
      "target": "mobile",
      "booted": true
    }
  },
  {
    "command": "install",
    "status": "ok",
    "summary": "Installed testapp (com.expo.testapp.szymon)",
    "details": {
      "durationMs": 4996,
      "appName": "testapp",
      "bundleId": "com.expo.testapp.szymon",
      "platform": "ios"
    }
  },
  {
    "kind": "action.recorded",
    "command": "open",
    "summary": "Opened com.expo.testapp.szymon",
    "details": {
      "positionals": ["<arg>"],
      "flags": { "platform": "ios" },
      "appBundleId": "com.expo.testapp.szymon"
    }
  },
  {
    "kind": "action.recorded",
    "command": "clipboard",
    "summary": "Updated clipboard",
    "details": {
      "positionals": ["write", "<text>"],
      "action": "write"
    }
  },
  {
    "kind": "action.recorded",
    "command": "screenshot",
    "summary": "Captured screenshot safe-home.png",
    "details": {
      "positionals": ["<arg>"],
      "requestedFileName": "safe-home.png"
    }
  },
  {
    "kind": "action.recorded",
    "command": "scroll",
    "summary": "Scrolled down by 437px",
    "details": {
      "direction": "down",
      "amount": 0.5,
      "pixels": 437,
      "x1": 201,
      "y1": 656,
      "x2": 201,
      "y2": 218
    }
  },
  {
    "command": "devices",
    "status": "ok",
    "summary": "Found 11 devices: iPhone 17 Pro (ios, simulator, mobile, booted), iPhone 17 (ios, simulator, mobile, stopped), iPhone 17 Pro Max (ios, simulator, mobile, stopped), +8 more",
    "details": {
      "deviceCount": 11,
      "omittedDeviceCount": 6
    }
  },
  {
    "command": "apps",
    "status": "ok",
    "summary": "Found 3 apps: AgentDeviceRunnerUITests-Runner (com.callstack.agentdevice.runner.uitests.xctrunner), testapp (com.expo.testapp.szymon), Expo Go (host.exp.Exponent)",
    "details": {
      "appCount": 3,
      "filter": "user-installed"
    }
  }
]

After the final flush, I scanned the NDJSON for both sentinel secrets and for textLength, local user/temp paths, request/runner log paths, tenant metadata, and launch-argument field names. The scan returned no matches. The event stream retained the intended app/device labels and artifact basename only.