Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add Device Detection Support

Đang mở
#51 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu với các WIT bindings trong stubs/wit_world/imports/device_detection.py và kiểm tra triển khai device-detection của Viceroy để xác định các phản hồi kiểm thử hiện có. Thêm API lookup dựa trên hàm và dataclass DeviceInfo với các trường không xác định có khả năng tương thích với các phiên bản tương lai, sau đó kiểm thử việc phân tích, xử lý lỗi và các lookup không khớp bằng các phản hồi tổng hợp hoặc các trường hợp xfail phù hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 @dataclass with _extra field for forward compatibility
  • Return None for 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 xfail markers 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

Ngôn ngữ chính
Python
Star
5
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của fastly/compute-sdk-python

Tất cả issue của fastly/compute-sdk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.