ADFA-4394: Report attached input devices and external displays to analytics and GlitchTip - #1663
Conversation
…lytics and GlitchTip
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 Walkthrough
WalkthroughThe change collects counts for supported attached devices and external displays. It reports the snapshot through analytics and GlitchTip diagnostics. It adds Android-version handling, failure isolation, and focused tests. ChangesAttached device analytics
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DeviceProtectedApplicationLoader
participant AttachedDevicesCollector
participant AttachedDevicesMetric
DeviceProtectedApplicationLoader->>AttachedDevicesCollector: collect(application context)
AttachedDevicesCollector-->>DeviceProtectedApplicationLoader: AttachedDevicesSnapshot
DeviceProtectedApplicationLoader->>AttachedDevicesMetric: report snapshot counts
AttachedDevicesMetric-->>DeviceProtectedApplicationLoader: attached_devices event
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt (1)
9-26: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the public attached-device contract.
The new public types and functions expose classification and telemetry semantics without KDoc.
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt#L9-L26: Document each device class and each snapshot count.app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt#L37-L63: Document classification rules, API-level fallback behavior, and the meaning ofisExternal = null.app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt#L5-L18: Document the event contract and Bundle parameter units.As per coding guidelines, "Public classes, functions, and non-obvious logic must have KDoc or Javadoc documenting contracts, rationale, threading, nullability, side effects, or units."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt` around lines 9 - 26, Document the public attached-device contract with KDoc: in app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt lines 9-26, describe each AttachedDeviceClass value and each AttachedDevicesSnapshot count; in lines 37-63, document classification rules, API-level fallback behavior, and the meaning of isExternal = null; in app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt lines 5-18, document the event contract and Bundle parameter units.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt`:
- Around line 64-67: Update the classCounts and externalDisplays collection in
AttachedDevicesCollector to replace runCatching with narrow catches for the
expected recoverable platform exception types only. Log each handled failure
through the existing SLF4J logger before returning the respective emptyMap() or
0 fallback, and allow fatal or unexpected throwables to propagate.
In
`@app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt`:
- Around line 189-195: Update initializeAnalytics in the startup path so
AttachedDevicesMetric collection and tracking occur only after application
startup completes, not during load(). Schedule the work asynchronously without
blocking the main thread, and isolate analytics scheduling, collection, and
reporting failures so they cannot affect startup.
In
`@app/src/test/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContextTest.kt`:
- Around line 101-105: Update the test method `attached devices context is
included on every event` to mock `AttachedDevicesCollector.collect(app)` with
six distinct counts, then assert that `event.contexts["attached_devices"]`
contains exactly the six expected keys and their corresponding values.
---
Nitpick comments:
In
`@app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt`:
- Around line 9-26: Document the public attached-device contract with KDoc: in
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.kt
lines 9-26, describe each AttachedDeviceClass value and each
AttachedDevicesSnapshot count; in lines 37-63, document classification rules,
API-level fallback behavior, and the meaning of isExternal = null; in
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.kt lines
5-18, document the event contract and Bundle parameter units.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 952d6255-2d86-4140-9d68-f158e7eccf0c
📒 Files selected for processing (7)
app/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesCollector.ktapp/src/main/java/com/itsaky/androidide/analytics/AttachedDevicesMetric.ktapp/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.ktapp/src/main/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContext.ktapp/src/test/java/com/itsaky/androidide/analytics/AttachedDevicesCollectorTest.ktapp/src/test/java/com/itsaky/androidide/analytics/AttachedDevicesMetricTest.ktapp/src/test/java/com/itsaky/androidide/handlers/GlitchTipDiagnosticsContextTest.kt
Narrow the collector guards to RuntimeException and log fallbacks, move metric collection and tracking off the main dispatcher, and assert the exact attached_devices context map in the test.
No description provided.