Add Device Detection Support
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the WIT bindings in stubs/wit_world/imports/device_detection.py and inspect Viceroy's device-detection implementation to determine available test responses. Add the function-based lookup API and DeviceInfo dataclass with forward-compatible unknown fields, then test parsing, error handling, and unmatched lookups using synthetic responses or appropriate xfail cases.
Written by the indexing model from the issue text.
Description
Overview
Add support for Fastly's Device Detection API, which provides device capabilities and characteristics based on User-Agent strings.
WIT Interface
interface device-detection {
use types.{error};
/// Returns JSON-encoded device data for a User-Agent string
lookup: func(user-agent: string, max-len: u64) -> result<option<string>, error>;
}
WIT bindings: stubs/wit_world/imports/device_detection.py
API Design
- Simple function-based API:
lookup(user_agent: str) -> Optional[DeviceInfo] - Parse JSON response into
@dataclasswith_extrafield for forward compatibility - Return
Nonefor lookups that don't match any known device - Fields typically include:
is_mobile,is_desktop,is_tablet,is_bot,device_type,brand,model, etc.
Forward Compatibility: Use @dataclass with _extra: dict field to capture unknown fields (same pattern as Geo). Provides type hints for known fields while allowing future fields to be accessible.
Cross-SDK Comparison: All SDKs expose simple lookup(user_agent) returning parsed JSON. Rust returns DeviceInfo struct, Go returns *DeviceDetection, JS returns object. All have similar field structure (device type, name, vendor, etc.).
Viceroy Testing
Device detection support in Viceroy is limited or stubbed. The WIT interface exists but may not have full test data support via test.toml configuration like other features.
Tests should either:
- Use
xfailmarkers for functionality that requires production device detection data - Mock the User-Agent lookup if Viceroy provides stub/default responses
- Focus on API wrapper behavior (parsing, error handling) with synthetic responses
Check Viceroy's device detection implementation to determine exact testing capabilities.
Reference
- Dominant language
- Python
- Stars
- 5
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fastly/compute-sdk-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
fastly/compute-sdk-python#116 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
fastly/compute-sdk-python#98 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
fastly/compute-sdk-python#74 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
fastly/compute-sdk-python#61 ·
-
fastly/compute-sdk-python#60 · 1 assignee ·
All issues in fastly/compute-sdk-python
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
canonical/paas-charm#368 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
StevenBlack/hosts#3256 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
qualcomm/qai-appbuilder#275 ·