import type { LogLevel } from '../types'; import { InMemoryCollector } from './inMemoryCollector'; import { BatchUploader } from './batchUploader'; export interface Trace { origin_role: string; origin_id: string; trace: { action_id: string; request_info: { user_agent: string; }; start_time_ms: number; total_time_ms: number; service: string; method: string; request: string; response?: string; exception?: string; status_code?: string; tags: { device_type: string; discovery_method?: string; react_native_version?: string; }; version_info: { client_type: string; client_version: string; }; traces: string[]; additional_context: { action_id: string; session_id: string; serial_number: string; }; }; } export interface ProxyEvent { origin_role: string; origin_id: string; event: { domain: string; scope: string; event: string; result: 'OK' | 'ERROR'; }; } /** * A singleton class whose instance exists for the lifetime of the RN SDK. * This class batches traces and sends them to Client-Logger, a Stripe-internal * analytics service. */ export default class Logger { static instance: Logger | null; static posId: string; static logLevel: LogLevel | undefined; private static readerSerialNumber; _collector: InMemoryCollector; _uploader: BatchUploader; static setLogLevel(level: LogLevel | undefined): void; /** Starts trace context for operations performed during a reader session. */ static startReaderSession(serialNumber?: string): void; /** Ends trace context for the current reader session. */ static endReaderSession(): void; private static serialNumberFromReader; private static serialNumberFromConnectArgs; private static updateReaderSessionFromResponse; static getInstance(): Logger; constructor(); private static metricTagsFromArgs; /** Records a terminal_request timer without creating a trace. */ private static recordTerminalRequest; /** * A method that traces that an inner function (`fn`) was called. This should * wrap the entire method body of a public facing Terminal SDK method. * This method logs the function parameters with which the function was called, * and the response that gets sent back to the user. * * @param fn The inner function that should be called and traced. * @param methodName The name of the SDK method that's getting traced. * @returns A function that should be called with `fn`'s args. */ static traceSdkMethod(fn: (...args: any[]) => any | Promise, methodName: string): (this: any, ...args: any[]) => any; private static normalizeResponseError; private static unwrapInternalError; private static unwrapInternalRejection; private static toLoggableInternalError; private static toLoggableCommonError; /** Expects normalized error results; normalizes rejections only for tracing. */ private static tracePromise; private static traceSuccess; private static traceError; private static traceException; }