Cashfree Device Intelligence SDK Documentation
The Device Intelligence SDK is a user-friendly solution that allows businesses to gather important data directly from users' browsers. This SDK seamlessly captures essential information about users' browsing behavior, device characteristics, and security properties, providing businesses with valuable insights. By leveraging this comprehensive data collection, businesses can optimize their services, personalize user experiences, enhance fraud detection, and make informed decisions based on accurate and reliable information.
Key Features
- Modern Agent-based API: Efficient agent-based architecture similar to FingerprintJS with intelligent caching
- Unified Data Collection: Single API that collects both device data (browser info, system info, etc.) and risk data (bot detection, tampering detection, etc.)
- Configurable: Fine-grained control over which data points to collect
- Comprehensive: Collects 80+ data points covering device, browser, and security characteristics
- Performance Optimized: Built-in caching, timeout controls, and performance metrics
- Error Resilient: Comprehensive error handling with fallback mechanisms
- TypeScript Support: Full TypeScript support with comprehensive type definitions
- Backward Compatible: Legacy API support for existing implementations
Architecture
The SDK has been designed with a modern agent-based architecture where all device intelligence data is collected through a single, comprehensive data type called BrowserInfo
. This approach provides:
Agent-based Design
- Efficient Caching: Intelligent caching system that reduces redundant data collection
- Performance Optimization: Built-in performance metrics and timeout controls
- Error Resilience: Comprehensive error handling with multiple fallback strategies
- Resource Management: Optimized resource usage with proper cleanup mechanisms
Unified Data Structure
The unified approach combines:
- Device & Browser Data: OS, browser version, screen resolution, hardware info, etc.
- Security & Risk Data: Bot detection, tampering detection, VM detection, privacy settings, etc.
- User Experience Data: Timezone, language, installed fonts, plugins, etc.
- Network Data: IP address, WebRTC IPs, connection type, etc.
- Performance Metrics: Data collection timing, cache hit rates, visitor ID generation strategies
- Error Tracking: Comprehensive error logging and diagnostics
All methods now return this unified data structure, eliminating the need for separate device and risk data APIs.
Installation
Using NPM package
npm install @cashfreepayments/deviceintel-js-sdk
Using CDN URL
<script src="https://vssdk-prod.cashfree.com/device-intel-js-sdk/1.1.5/index.mjs"></script>
ES Module Import
import DeviceIntelligence from 'https://vssdk-prod.cashfree.com/device-intel-js-sdk/1.1.5/index.mjs'
Note: Make sure only one of the above is present in your application
Installation & Usage
The SDK provides two main usage patterns:
1. Modern Agent-based API (Recommended)
The modern API uses an agent-based approach similar to FingerprintJS, which is more efficient and provides better caching:
Import via URL (ES Module)
import DeviceIntelligence from 'https://vssdk-prod.cashfree.com/device-intel-js-sdk/1.1.5/index.mjs'
// Initialize the agent
const agent = await DeviceIntelligence.load()
// Get unified device and risk data
const data = await agent.get({
taskTimeout: 500,
overallTimeout: 1000,
options: { user_ip: false }
})
console.log(data) // Contains all 80+ unified data fields
Import via Script Tag
<script src="https://vssdk-prod.cashfree.com/device-intel-js-sdk/1.1.5/index.mjs"></script>
<script>
(async () => {
// Initialize the agent
const agent = await window.DeviceIntelligence.load()
// Collect comprehensive unified device intelligence data
const data = await agent.get({
taskTimeout: 500,
overallTimeout: 1000,
options: { user_ip: false }
})
console.log(data) // 80+ unified fields including device, browser, and risk data
})()
</script>
Using NPM Package
import { load } from '@cashfreepayments/deviceintel-js-sdk'
// Initialize the agent
const agent = await load()
// Collect comprehensive unified device intelligence data
const data = await agent.get({
taskTimeout: 500,
overallTimeout: 1000,
options: { user_ip: false }
})
console.log(data) // Complete unified data structure
2. Legacy Direct API (For Backward Compatibility)
For existing implementations, the legacy API is still supported:
import { getBrowserData } from '@cashfreepayments/deviceintel-js-sdk'
// Direct method call (legacy approach)
const data = await getBrowserData(500, 1000, { user_ip: false })
console.log(data) // Complete unified data structure
Agent-based API Configuration
The modern Agent-based API provides better performance and more configuration options:
Load Options
const agent = await DeviceIntelligence.load({
delayFallback: 50, // Fallback delay in milliseconds (default: 50)
debug: false // Enable debug mode (default: false)
})
Get Options
const data = await agent.get({
taskTimeout: 500, // Individual task timeout (default: 500ms)
overallTimeout: 1000, // Overall timeout (default: 1000ms)
options: { // Data collection options
user_ip: false,
location: false,
// ... other options
},
debug: false // Enable debug mode for this call
})
Agent Methods
Method | Description |
---|---|
agent.get(options) |
Collects comprehensive device intelligence data with configurable options. Returns unified BrowserInfo type. |
agent.getEncoded(options) |
Returns the unified data from get() as a Base64-encoded string, suitable for transmission or storage. |
agent.generateSessionID() |
Generates a unique session identifier for tracking user activity within a single browsing session. |
agent.clearCache() |
Clears the internal data cache, forcing fresh data collection on the next call. |
agent.isReady() |
Returns true if the SDK is ready to collect data (i.e., running in a browser environment). |
Timeout Configuration
Both the agent-based and legacy APIs support timeout configuration for optimal performance:
Parameters:
taskTimeout: Specifies the maximum allowed time (in milliseconds) for individual tasks within the method to complete. Default: 500ms
overallTimeout: Specifies the maximum allowed time (in milliseconds) for the entire execution of the method, including all tasks, to complete. Default: 1000ms
Example Usage
// Agent-based API
const agent = await DeviceIntelligence.load()
const data = await agent.get({
taskTimeout: 500,
overallTimeout: 1000,
options: { user_ip: false }
})
// Legacy API
const data = await getBrowserData(500, 1000, { user_ip: false })
Example with Custom Timeout Values
// Agent-based API with custom timeouts
const agent = await DeviceIntelligence.load()
const data = await agent.get({
taskTimeout: 500,
overallTimeout: 1000,
options: { user_ip: false }
})
// Legacy API with custom timeouts
const data = await getBrowserData(500, 1000, { user_ip: false })
Optional Parameters
Both the agent-based and legacy APIs accept an optional configuration object that allows you to control which data points are collected. Each property in this configuration object can be set to false
to skip collecting that specific information.
const options = {
user_ip: false, // Skip collecting IP address
location: false, // Skip collecting geolocation data
browser_info: false, // Skip collecting browser information
screen_info: false, // Skip collecting screen resolution and color depth
plugins: false, // Skip collecting browser plugin information
timezone: false, // Skip collecting timezone information
canvas_device_fingerprint: false, // Skip canvas fingerprinting
audio_fingerprint: false, // Skip audio fingerprinting
webgl_fingerprint: false, // Skip WebGL fingerprinting
// ... any other BrowserInfo field can be disabled
}
// Agent-based API
const agent = await DeviceIntelligence.load()
const data = await agent.get({ options })
// Legacy API
const data = await getBrowserData(500, 1000, options)
By default, all data points are collected (equivalent to setting all options to true
). Setting any option to false
will:
- Skip the associated data collection tasks
- Potentially reduce overall execution time
- Return
'NA'
for those specific properties in the result object
Methods Exposed
Method | Description |
---|---|
DeviceIntelligence.load(options) |
Creates and initializes an agent for efficient data collection. Returns a promise that resolves to an Agent instance. |
agent.get(options) |
Collects comprehensive device intelligence data including browser info, system details, and security characteristics. Returns unified BrowserInfo type. |
agent.getEncoded(options) |
Returns the unified data from get() as a Base64-encoded string, suitable for transmission or storage. |
agent.generateSessionID() |
Generates a unique session identifier for tracking user activity within a single browsing session. |
agent.clearCache() |
Clears the internal data cache, forcing fresh data collection on the next call. |
agent.isReady() |
Returns true if the SDK is ready to collect data (i.e., running in a browser environment). |
getBrowserData() (legacy) |
Legacy method - Direct collection of comprehensive device intelligence data. Use agent-based API for new implementations. |
getEncodedBrowserData() (legacy) |
Legacy method - Returns encoded browser data as Base64 string. Use agent-based API for new implementations. |
generateSessionID() (legacy) |
Legacy method - Generates a unique session identifier. Use agent-based API for new implementations. |
clearDeviceDataCache() (legacy) |
Legacy method - Clears the device data cache. Use agent-based API for new implementations. |
isReady() (legacy) |
Legacy method - Checks if SDK is ready. Use agent-based API for new implementations. |
Note: Visitor ID generation is handled automatically by the SDK during data collection and is available in the visitor_id
field of the returned BrowserInfo
object. There is no separate generateVisitorID()
method in the current API.
Unified Data Structure
All methods now return a unified BrowserInfo
type containing comprehensive device intelligence data. This includes all the fields previously split between device and risk data:
Complete Data Fields with Types (80+ fields)
The SDK collects comprehensive data across multiple categories with strict TypeScript typing:
Core Identification
Field | Type | Description | Example Value |
---|---|---|---|
visitor_id |
string | 'NA' |
Primary unique visitor identifier - Persistent across sessions using entropy or cookie-based generation | "bb890aa2a2963e45b5a2f16fe9b93756" |
session_id |
string | 'NA' |
Session identifier - Unique ID for current browsing session, regenerated each visit | "21194a86ba3d6cee80c1aaf47269d1e7" |
device_hash |
string | 'NA' |
Device hash - Computed hash of device characteristics for device identification | "bb890aa2a2963e45b5a2f16fe9b93756" |
cookie_visitor_id |
string | 'NA' |
Cookie visitor ID - Visitor ID stored in cookies | "0cb8a5a8b6f0826cae620291d635b9b4" |
sdk_version |
number | 'NA' |
SDK version - Version number of the Device Intelligence SDK used | 101 |
Device & Hardware Information
Field | Type | Description | Example Value |
---|---|---|---|
device_type |
string | 'NA' |
Device type - Mobile, Desktop, Tablet classification based on user agent | "Desktop" |
architecture |
number | 'NA' |
System architecture - CPU architecture identifier (x64, ARM, etc.) | 142 |
hardware_concurrency |
number | 'NA' |
Logical processors - Number of CPU cores/threads available to the browser | 10 |
device_memory |
number | 'NA' |
Device RAM - Amount of device memory in GB (Chrome only) | 8 |
battery_percentage |
string | 'NA' |
Battery level - Current battery percentage with % symbol (if available) | "82.00%" |
Operating System
Field | Type | Description | Example Value |
---|---|---|---|
os_name |
string | 'NA' |
OS name - Windows, macOS, Linux, Android, iOS, etc. | "MacOS" |
os_version |
string | 'NA' |
OS version - Detailed operating system version | "MacOS 10.15.7" |
platform |
string | 'NA' |
Platform string - Browser-reported platform identifier | "MacIntel" |
cpu_class |
string | 'NA' |
CPU class - Processor class information (legacy browsers) | "x86" |
os_cpu |
string | 'NA' |
OS CPU info - CPU information reported by the operating system | "Intel Mac OS X 10_15_7" |
Browser Information
Field | Type | Description | Example Value |
---|---|---|---|
browser_name |
string | 'NA' |
Browser name - Chrome, Firefox, Safari, Edge, Brave, etc. | "GoogleChrome" |
browser_version |
string | 'NA' |
Browser version - Detailed browser version string | "138.0" |
user_agent |
string | 'NA' |
User agent - Complete browser user agent string | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36..." |
browser_hash |
string | 'NA' |
Browser hash - Hash of browser-specific information | "99e74527faea92b2a3820d48d804bcef43df9ec4336f82b44de6b823b8f01733" |
vendor |
string | 'NA' |
Browser vendor - Browser vendor string | "Google Inc." |
vendor_flavors |
string[] | 'NA' |
Vendor flavors - Browser vendor-specific characteristics | ["chrome"] |
browser_build_info |
object | 'NA' |
Build info - Browser build information | {"product": "Gecko", "productSub": "20030107", "buildID": "20231201"} |
Display & Screen
Field | Type | Description | Example Value |
---|---|---|---|
screen_width |
string | 'NA' |
Screen width - Display width in pixels | "1920" |
screen_height |
string | 'NA' |
Screen height - Display height in pixels | "1080" |
color_depth |
number | 'NA' |
Color depth - Number of bits per color component | 30 |
pixel_depth |
number | 'NA' |
Pixel depth - Number of bits per pixel | 30 |
pixel_ratio |
number | 'NA' |
Device pixel ratio - Ratio of physical to logical pixels | 2 |
screen_metrics |
object | 'NA' |
Screen metrics - Comprehensive screen measurement data | {"width": 1512, "height": 982, "meta": {"isPrimaryDisplay": false, "orientation": "landscape-primary"}} |
gpu_renderer |
string | 'NA' |
GPU renderer - Graphics card renderer string | "ANGLE (Apple, ANGLE Metal Renderer: Apple M1 Pro, Unspecified Version)" |
monochrome_depth |
number | 'NA' |
Monochrome depth - Bits per pixel in monochrome mode | 0 |
color_gamut |
string | 'NA' |
Color gamut - Supported color space | "p3" |
contrast_preference |
number | 'NA' |
Contrast preference - User's contrast preference setting | 0 |
motion_reduced |
boolean | 'NA' |
Reduced motion - User prefers reduced motion | false |
inverted_colors |
boolean | 'NA' |
Inverted colors - Whether colors are inverted | false |
forced_colors |
boolean | 'NA' |
Forced colors - Whether forced colors mode is active | false |
hdr |
boolean | 'NA' |
HDR support - High dynamic range display support | true |
Location & Language
Field | Type | Description | Example Value |
---|---|---|---|
region_timezone |
string | 'NA' |
Timezone - IANA timezone identifier | "Asia/Calcutta" |
region_timezone_offset |
string | 'NA' |
Timezone offset - UTC offset in format "+05:30" | "+05:30" |
region_language |
string | 'NA' |
Language - Browser language setting | "en-GB" |
timezone |
string | 'NA' |
IANA timezone - Detailed timezone string | "Asia/Calcutta" |
languages |
string | 'NA' |
Languages - Comma-separated list of supported languages | "en-GB" |
Network & Connectivity
Field | Type | Description | Example Value |
---|---|---|---|
user_ip |
string | 'NA' |
IP address - User's public IP address | "203.192.115.42" |
web_rtc_ips |
string | 'NA' |
WebRTC IPs - Local IP addresses detected via WebRTC | "192.168.1.105, 10.0.0.15" |
internet_type |
string | 'NA' |
Connection type - WiFi, Mobile, LAN, 2G, 3G, 4G | "4g" |
connection_info |
object | 'NA' |
Connection details - Network connection information | {"effectiveType": "4g", "rtt": 50, "saveData": false} |
Browser Features & Capabilities
Field | Type | Description | Example Value |
---|---|---|---|
cookie_enabled |
boolean | 'NA' |
Cookies enabled - Whether cookies are enabled | true |
cookie_hash |
string | 'NA' |
Cookie hash - Hash of current cookies | "4d4c7348a52da239a97c2bcacfdb7330b4dde9dfeafa995e46964e67423e2f3f" |
installed_fonts |
string | 'NA' |
Fonts - Comma-separated list of detected fonts | "Arial, Helvetica, Times New Roman, Courier New, Verdana" |
installed_plugins |
string | 'NA' |
Plugins - Comma-separated list of browser plugins | "Chrome PDF Plugin, Chrome PDF Viewer, Native Client" |
browser_features |
object | 'NA' |
Features - Object with boolean flags for browser capabilities | {"clipboard": true, "credentials": true, "geolocation": true, "bluetooth": true} |
http_accept_headers |
string | 'NA' |
Accept headers - HTTP Accept header content | "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" |
accept_encoding_header |
string | 'NA' |
Accept-Encoding - Supported compression formats | "gzip, deflate, br, zstd" |
mime_types |
array | 'NA' |
MIME types - Array of supported MIME types | [{"type": "application/pdf", "description": "Portable Document Format", "suffixes": "pdf"}] |
storage_support |
object | 'NA' |
Storage support - localStorage, sessionStorage, indexedDB support | {"localStorage": true, "sessionStorage": true, "indexedDB": true} |
pdf_viewer_enabled |
boolean | 'NA' |
PDF viewer - Built-in PDF viewer availability | true |
pointer_support |
boolean | 'NA' |
Pointer events - PointerEvent API support | true |
touch_support |
object | 'NA' |
Touch support - Touch capabilities and max touch points | {"maxTouchPoints": 0, "touchEvent": false, "touchStart": false} |
webgl_supported |
boolean | 'NA' |
WebGL support - WebGL rendering context availability | true |
dnt_enabled |
boolean | 'NA' |
Do Not Track - DNT header setting | true |
Privacy & Security
Field | Type | Description | Example Value |
---|---|---|---|
private_mode |
boolean | 'NA' |
Incognito mode - Private/incognito browsing detection | false |
installed_bots |
boolean | 'NA' |
Bot detection - Automated browser/bot detection | false |
high_activity |
boolean | 'NA' |
High activity - Unusual activity pattern detection | false |
tampering_detection |
boolean | 'NA' |
Tampering - Browser modification detection | false |
private_browser |
boolean | 'NA' |
Privacy browser - Tor, Brave, or other privacy-focused browser | false |
virtual_machine_detection |
string | 'NA' |
VM detection - Virtual machine environment detection | "DETECTED" or "NA" |
privacy_settings |
string | 'NA' |
Privacy settings - Browser privacy configuration (JSON string) | "{\"doNotTrack\":true,\"localStorageDisabled\":false,\"cookiesDisabled\":false}" |
browser_anti_finger_printing_extension |
string | 'NA' |
Anti-fingerprinting - Detection of privacy extensions | "uBlock Origin Detected, Privacy Badger Detected" |
flash_or_java_detected |
boolean | 'NA' |
Flash/Java - Legacy plugin detection | false |
is_dev_tool_open |
boolean | 'NA' |
Developer tools - DevTools open detection | false |
Fingerprinting Components
Field | Type | Description | Example Value |
---|---|---|---|
canvas_device_fingerprint |
string | 'NA' |
Canvas fingerprint - Canvas rendering fingerprint | "bf0d3531fe67f1cebc7d05e0bc437df9" |
audio_fingerprint |
number | 'NA' |
Audio fingerprint - AudioContext fingerprint | 124.04348155876505 |
webgl_fingerprint |
object | 'NA' |
WebGL fingerprint - WebGL rendering characteristics | {"version": "WebGL 1.0", "vendor": "WebKit", "renderer": "WebKit WebGL"} |
audio_base_latency |
number | 'NA' |
Audio latency - AudioContext base latency | 0.02 |
high_entropy_values |
object | 'NA' |
High entropy values - User-Agent Client Hints data | {"bitness": "64", "brands": [{"brand": "Google Chrome", "version": "138"}], "mobile": false} |
math_tan |
number | 'NA' |
Math fingerprint - Math.tan calculation result | -1.5574077246549023 |
math_fingerprint |
object | 'NA' |
Math operations - Various mathematical calculations | {"acos": 1.4473588658278522, "acosh": 709.889355822726, "sin": 0.8178819121159085} |
keyboard_fingerprint |
string | 'NA' |
Keyboard layout - Keyboard layout and input method detection | "qwerty-us-mac-nonumpad-cmd-opt" |
Advanced Entropy
Field | Type | Description | Example Value |
---|---|---|---|
css_entropy |
number | 'NA' |
CSS entropy - CSS rendering characteristics | 443579207 |
dom_blockers |
string | 'NA' |
DOM blockers - Ad blocker and content blocker detection | "uBlock Origin: true, AdBlock Plus: false, Ghostery: true" |
font_preferences |
string | 'NA' |
Font preferences - System font rendering preferences | "anti-aliasing: true, hinting: medium, subpixel: rgb" |
pointing_methods |
object | 'NA' |
Pointing methods - Mouse, touch, and pointer input detection | {"hasMouse": true, "hasTouch": false, "primaryInput": "mouse"} |
apple_pay_state |
number | 'NA' |
Apple Pay - Apple Pay availability and state | -1 |
screen_frame |
number[] | 'NA' |
Screen frame - Display frame and bezels information | [40, 0, 0, 50] |
indexed_db |
boolean | 'NA' |
IndexedDB - IndexedDB API availability | true |
private_click_measurement |
string | 'NA' |
PCM - Privacy-preserving ad measurement | "enabled" |
transparency_reduced |
boolean | 'NA' |
Reduced transparency - System transparency preference | false |
Device Classification
Field | Type | Description | Example Value |
---|---|---|---|
is_desktop |
boolean | 'NA' |
Desktop device - Desktop computer detection | true |
is_mobile |
boolean | 'NA' |
Mobile device - Mobile phone detection | false |
is_tablet |
boolean | 'NA' |
Tablet device - Tablet device detection | false |
is_windows |
boolean | 'NA' |
Windows OS - Microsoft Windows detection | false |
is_linux |
boolean | 'NA' |
Linux OS - Linux distribution detection | false |
is_linux_64 |
boolean | 'NA' |
64-bit Linux - 64-bit Linux detection | false |
is_mac |
boolean | 'NA' |
macOS - Apple macOS detection | true |
is_ipad |
boolean | 'NA' |
iPad - Apple iPad detection | false |
is_iphone |
boolean | 'NA' |
iPhone - Apple iPhone detection | false |
is_ipod |
boolean | 'NA' |
iPod - Apple iPod detection | false |
is_smart_tv |
boolean | 'NA' |
Smart TV - Smart TV browser detection | false |
is_kindle_fire |
boolean | 'NA' |
Kindle Fire - Amazon Kindle Fire detection | false |
silk_accelerated |
boolean | 'NA' |
Silk acceleration - Amazon Silk browser acceleration | false |
is_authoritative |
boolean | 'NA' |
Authoritative detection - High-confidence device type detection | true |
Performance Metrics
Field | Type | Description | Example Value |
---|---|---|---|
performance_metrics |
object |
Performance data - Collection timing and caching information | {"data_collection_time": 266.8999999985099, ...} |
performance_metrics.data_collection_time |
number |
Collection time - Total time spent collecting data (milliseconds) | 266.8999999995099 |
performance_metrics.cache_hit |
boolean |
Cache status - Whether data was retrieved from cache | false |
performance_metrics.visitor_id_strategy |
string |
ID strategy - Method used to generate visitor ID | "entropy" |
performance_metrics.entropy_evaluation_time |
number |
Entropy time - Time spent evaluating entropy quality | 0 |
performance_metrics.visitor_id_generation_time |
number |
ID generation time - Time spent generating visitor ID | 0.599999999627471 |
performance_metrics.cookie_generation_time |
number |
Cookie time - Time spent on cookie-based operations | 0 |
Error Tracking & Diagnostics
Field | Type | Description | Example Value |
---|---|---|---|
error_tracking |
object |
Error information - Comprehensive error tracking and diagnostics | {"has_errors": true, "total_errors": 5, ...} |
error_tracking.has_errors |
boolean |
Error status - Whether any errors occurred during collection | true |
error_tracking.total_errors |
number |
Error count - Total number of errors encountered | 5 |
error_tracking.recent_errors |
string[] |
Recent errors - Array of recent error messages (last 5) | ["Collector getPrivateClickMeasurement: No error details provided", ...] |
error_tracking.failed_collectors |
string[] |
Failed collectors - Names of data collectors that failed | ["Collector getPrivateClickMeasurement", "Collector getDomBlockers", ...] |
TypeScript Support
The SDK provides full TypeScript support with these verified types:
import {
BrowserInfo,
BrowserDataOptions,
LoadOptions,
GetOptions,
Agent
} from '@cashfreepayments/deviceintel-js-sdk'
// Example of accessing the actual data structure
const data: BrowserInfo = await agent.get()
// Verified field access patterns
const visitorId: string | 'NA' = data.visitor_id // "bb890aa2a2963e45b5a2f16fe9b93756"
const browserName: string | 'NA' = data.browser_name // "GoogleChrome"
const deviceType: string | 'NA' = data.device_type // "Desktop"
const hardwareConcurrency: number | 'NA' = data.hardware_concurrency // 10
const webglFingerprint: object | 'NA' = data.webgl_fingerprint // Complex object
const performanceMetrics = data.performance_metrics // Always present object
const errorTracking = data.error_tracking // Always present object
// Privacy settings (returned as JSON string)
const privacySettings: string | 'NA' = data.privacy_settings
if (privacySettings !== 'NA') {
const parsedSettings = JSON.parse(privacySettings)
console.log(parsedSettings.doNotTrack) // true
}
// WebGL fingerprint access
if (data.webgl_fingerprint !== 'NA') {
const webgl = data.webgl_fingerprint as any
console.log(webgl.version) // "WebGL 1.0 (OpenGL ES 2.0 Chromium)"
console.log(webgl.vendor) // "WebKit"
}
Error Handling and Diagnostics
const agent = await DeviceIntelligence.load()
const data = await agent.get()
// Check if any errors occurred during data collection
if (data.error_tracking?.has_errors) {
console.log('Failed collectors:', data.error_tracking.failed_collectors)
console.log('Error categories:', data.error_tracking.error_categories)
}
// Check visitor ID generation strategy
console.log('Visitor ID strategy:', data.performance_metrics?.visitor_id_strategy)
Selective Data Collection
const agent = await DeviceIntelligence.load()
// Collect only essential data for faster performance
const minimalData = await agent.get({
taskTimeout: 200,
overallTimeout: 300,
options: {
// Disable resource-intensive collectors
canvas_device_fingerprint: false,
audio_fingerprint: false,
webgl_fingerprint: false,
installed_fonts: false,
// Keep essential fields enabled (default: true)
visitor_id: true,
device_type: true,
browser_name: true,
user_agent: true
}
})