UNPKG

fingerprint-oss

Version:

A comprehensive JavaScript library for device fingerprinting and system information collection. Provides robust, deterministic fingerprinting for web applications with privacy-conscious design.

76 lines (75 loc) 2.29 kB
/*! * Copyright (c) 2025 Akshat Kotpalliwar (alias IntegerAlex on GitHub) * This software is licensed under the GNU Lesser General Public License (LGPL) v3 or later. * * Telemetry module for fingerprint-oss * Provides minimal OpenTelemetry integration for error tracking and usage analytics */ import { Span } from '@opentelemetry/api'; /** * Telemetry configuration interface */ export interface TelemetryConfig { /** Enable/disable telemetry collection */ enabled?: boolean; /** Custom service name for telemetry */ serviceName?: string; /** Custom service version */ serviceVersion?: string; /** Endpoint for telemetry data export */ endpoint?: string; /** Sample rate (0.0 to 1.0) for telemetry collection */ sampleRate?: number; /** Enable debug logging */ debug?: boolean; } /** * Public API for telemetry */ export declare const Telemetry: { /** * Initialize telemetry */ initialize: (config?: TelemetryConfig) => void; /** * Start a span */ startSpan: (name: string, attributes?: Record<string, any>) => Span | null; /** * End a span */ endSpan: (span: Span | null, attributes?: Record<string, any>) => void; /** * End a span with error */ endSpanWithError: (span: Span | null, error: Error, attributes?: Record<string, any>) => void; /** * Record an error */ recordError: (error: Error, context?: Record<string, any>) => void; /** * Record function execution */ recordFunctionCall: (functionName: string, executionTime: number, success: boolean, context?: Record<string, any>) => void; /** * Increment a counter */ incrementCounter: (name: string, value?: number, attributes?: Record<string, any>) => void; /** * Record histogram value */ recordHistogram: (name: string, value: number, attributes?: Record<string, any>) => void; /** * Check if enabled */ isEnabled: () => boolean; /** * Get configuration */ getConfig: () => TelemetryConfig; }; /** * Decorator for automatic function telemetry */ export declare function withTelemetry<T extends (...args: any[]) => any>(functionName: string, originalFunction: T): T; export default Telemetry;