import { NewRelicEnabledClient } from "./new-relic"; /** * Configuration options for API request retry behavior */ export type RetryConfig = { /** * Maximum number of retry attempts for failed requests. * Does not include the initial request attempt. * Default: 2 */ maxRetryAttempts?: number; /** * Maximum time in milliseconds to wait for a response before aborting the request. * Used to prevent requests from hanging indefinitely in poor network conditions. * Default: 10000 (10 seconds) */ requestTimeoutMs?: number; /** * Initial delay in milliseconds before the first retry attempt. * This value is used as the base for exponential backoff calculation. * Default: 500 (0.5 seconds) */ initialRetryDelayMs?: number; /** * Maximum delay in milliseconds between retry attempts. * Caps the exponential backoff to prevent excessively long waits. * Default: 2000 (2 seconds) */ maxRetryDelayMs?: number; /** * Enable tracking page actions/events with New Relic. * When enabled, all network requests will be instrumented. * Note: Setting this to true increases data sent to New Relic, which may affect costs. * Default: false */ trackPageActions?: boolean; }; /** * Shared fetch utility class that provides retry capability * Can be used standalone or extended by other clients */ export declare class FetchUtils extends NewRelicEnabledClient { private readonly trackingInfo; private readonly retryConfig; constructor(trackingInfo?: Record, config?: RetryConfig); /** * Implementation of the abstract method from NewRelicEnabledClient */ protected getTrackingBaseAttributes(): Record; /** * Create a sanitized sample of request data that's safe to log */ private createSanitizedDataSample; /** * Check if an error is a network error */ private isNetworkError; /** * Track API call start if trackPageActions is enabled */ private trackOperationStart; /** * Track API call complete if trackPageActions is enabled */ private trackOperationComplete; /** * Track API call completion */ private trackRequestComplete; /** * Track retry attempt */ private trackRetryAttempt; /** * Track error */ private trackError; /** * Calculate exponential backoff wait time for retries */ private calculateBackoffTime; /** * Wait for network connectivity if offline */ private waitForConnectivity; /** * Core retry logic for any fetch operation */ private executeWithRetry; /** * Make an API call with configurable retry logic * * @param url - Full URL to fetch * @param options - Request options (method, headers, body, etc.) * @param endpointName - Name of endpoint for tracking purposes * @returns A promise that resolves to the parsed response data */ fetchWithRetry(url: string, options: RequestInit, endpointName: string): Promise; /** * Convenience method for API calls with standard JSON headers and authorization */ callApi(url: string, method: string, token: string, data?: any, customHeaders?: Record): Promise; /** * Convenience method for GraphQL requests */ executeGraphQL(endpoint: string, token: string, query: string, variables?: any): Promise; /** * Convenience method for file uploads with direct signed URLs */ uploadFile(signedURL: string, file: File, endpointName?: string): Promise; /** * Convenience method for DELETE operations with signed URLs */ deleteWithSignedUrl(signedURL: string, endpointName?: string): Promise; }