Skip to content

Commit ab5e28d

Browse files
Merge pull request #54 from reclaimprotocol/device-detection-fix
Add device detection debug page and Jest config
2 parents 7f4f170 + 59bf41d commit ab5e28d

File tree

10 files changed

+1530
-120
lines changed

10 files changed

+1530
-120
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
node_modules/
22
.DS_Store
33
dist
4+
coverage
45

56
.env*

example/package-lock.json

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/app/debug/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Device Detection Debug Page
2+
3+
This debug page helps developers troubleshoot device detection issues in the Reclaim SDK.
4+
5+
## Usage
6+
7+
### Access the Debug Page
8+
Navigate to `/debug` in your example app:
9+
```
10+
http://localhost:3000/debug
11+
```
12+
13+
### Features
14+
15+
1. **Real-time Detection Results**
16+
- Shows current device type (mobile/desktop)
17+
- Mobile OS detection (iOS/Android)
18+
- Live updates on window resize
19+
20+
2. **Detection Factors**
21+
- All scoring factors used in detection
22+
- Visual indicators for each factor
23+
- Screen dimensions and capabilities
24+
25+
3. **Environment Information**
26+
- User agent string
27+
- Platform and vendor details
28+
- Screen resolution and window size
29+
- Touch points and orientation
30+
31+
4. **Browser Capabilities**
32+
- Touch support
33+
- Geolocation, notifications, service workers
34+
- WebGL, WebRTC support
35+
- Device motion/orientation APIs
36+
37+
5. **Export Options**
38+
- Copy debug info as JSON
39+
- Download complete debug report
40+
- Share with issue reports
41+
42+
## Adding to Your App
43+
44+
To add this debug page to your own app:
45+
46+
1. Copy the debug page component to your app
47+
2. Import the device detection functions from the SDK:
48+
```typescript
49+
import {
50+
getDeviceType,
51+
getMobileDeviceType,
52+
isMobileDevice,
53+
isDesktopDevice
54+
} from '@reclaimprotocol/js-sdk'
55+
```
56+
57+
3. Add a route to access the debug page (keep it hidden in production)
58+
59+
## Reporting Issues
60+
61+
If you find a device that's incorrectly detected:
62+
63+
1. Visit the debug page on that device
64+
2. Click "Download Report"
65+
3. Include the JSON file in your GitHub issue
66+
4. Describe the expected vs actual behavior
67+
68+
## Common Detection Patterns
69+
70+
### Desktop with Touchscreen
71+
- Touch Device: Yes
72+
- Has Mouse: Yes
73+
- Large Screen: Yes
74+
- Can Hover: Yes
75+
- **Result**: Desktop ✓
76+
77+
### iPad Pro in Desktop Mode
78+
- User Agent: Contains "Macintosh"
79+
- Touch Device: Yes
80+
- Mobile APIs: Yes
81+
- **Result**: Mobile (iOS) ✓
82+
83+
### Android Tablet
84+
- User Agent: Contains "Android"
85+
- Touch Device: Yes
86+
- Screen Size: Variable
87+
- **Result**: Mobile (Android) ✓
88+
89+
### iPhone/Android Phone
90+
- Small Screen: Yes
91+
- Touch Device: Yes
92+
- Mobile User Agent: Yes
93+
- **Result**: Mobile ✓
94+
95+
## Privacy Note
96+
97+
The debug page only collects browser information locally. No data is sent to external servers unless you explicitly export and share it.

0 commit comments

Comments
 (0)