Visitor identification system that analyzes browser characteristics and generates stable visitor identifiers with confidence assessment and detailed component analysis.
Generates a unique visitor identifier by analyzing browser and device characteristics.
/**
* Gets the visitor identifier and associated data
* @param options - Optional configuration for fingerprint generation
* @returns Promise resolving to complete fingerprint result
*/
get(options?: GetOptions): Promise<GetResult>;
interface GetOptions {
/**
* Whether to print debug messages (deprecated)
* @deprecated Use the debug option of load() instead
*/
debug?: boolean;
}
interface GetResult {
/** The unique visitor identifier string */
visitorId: string;
/** Confidence assessment for the identifier reliability */
confidence: Confidence;
/** Raw entropy components used to generate the identifier */
components: UnknownComponents;
/** Library version used for fingerprint generation */
version: string;
}Usage Examples:
import FingerprintJS from '@fingerprintjs/fingerprintjs';
const fp = await FingerprintJS.load();
// Basic fingerprint generation
const result = await fp.get();
console.log('Visitor ID:', result.visitorId);
console.log('Confidence:', result.confidence.score);
console.log('Version:', result.version);
// Access individual components
Object.entries(result.components).forEach(([name, component]) => {
if ('value' in component) {
console.log(`${name}:`, component.value, `(${component.duration}ms)`);
} else {
console.log(`${name}: Error -`, component.error);
}
});Statistical confidence scoring system that evaluates the reliability of visitor identifiers.
interface Confidence {
/**
* Confidence score between 0 and 1
* Higher values indicate more reliable identification
*/
score: number;
/**
* Human-readable explanation of the confidence assessment
* Includes information about Pro version capabilities
*/
comment?: string;
}Confidence Score Interpretation:
Usage Examples:
const result = await fp.get();
if (result.confidence.score > 0.6) {
console.log('High confidence identification');
} else if (result.confidence.score > 0.4) {
console.log('Moderate confidence identification');
} else {
console.log('Lower confidence identification');
}
// Display confidence details
console.log('Confidence details:', result.confidence.comment);Individual entropy components collected during fingerprint generation.
interface Component<T> {
value: T;
duration: number;
} | {
error: unknown;
duration: number;
}
type UnknownComponents = Record<string, Component<unknown>>;Component Access Patterns:
const result = await fp.get();
// Check for successful component collection
if ('value' in result.components.canvas) {
console.log('Canvas fingerprint:', result.components.canvas.value);
console.log('Collection time:', result.components.canvas.duration, 'ms');
}
// Handle component errors
if ('error' in result.components.webgl) {
console.log('WebGL collection failed:', result.components.webgl.error);
}
// Iterate through all components
Object.entries(result.components).forEach(([name, component]) => {
const status = 'value' in component ? 'Success' : 'Error';
console.log(`${name}: ${status} (${component.duration}ms)`);
});The generated visitor identifier has specific characteristics designed for stability and uniqueness:
Stability Features:
Usage Patterns:
const result = await fp.get();
// Store visitor ID for analytics
localStorage.setItem('analytics_id', result.visitorId);
// Use for fraud detection
if (await isKnownMaliciousId(result.visitorId)) {
console.warn('Potentially fraudulent visitor detected');
}
// Track returning visitors
if (previousVisitorId === result.visitorId) {
console.log('Returning visitor identified');
}Robust error handling for various failure scenarios during fingerprint generation.
try {
const fp = await FingerprintJS.load();
const result = await fp.get();
// Check for partial failures in components
const failedComponents = Object.entries(result.components)
.filter(([_, component]) => 'error' in component)
.map(([name, _]) => name);
if (failedComponents.length > 0) {
console.warn('Some components failed:', failedComponents);
}
return result.visitorId;
} catch (error) {
console.error('Fingerprinting failed:', error);
throw error;
}