/** * New Relic Instrumentation Service * * A TypeScript service that provides a wrapper around New Relic browser APIs. * This service uses lazy initialization to access New Relic only when needed, * ensuring that it works even if the host application initializes New Relic * after this service is instantiated - or not at all. */ export declare class NewRelicInstrumentationService { private document; /** * Creates an instance of NewRelicInstrumentationService. * @param document - The Document object, used to access the window */ constructor(document: Document); /** * Gets the New Relic instance from the window object * This is called lazily when needed, not at initialization time * @returns The New Relic instance or undefined if not available */ private getNewRelic; /** * Check if New Relic is currently available * @returns boolean indicating whether New Relic is available */ isAvailable(): boolean; /** * Add a page action (custom event) to New Relic * @param eventName - Name of the event * @param attributes - Attributes associated with the event */ addPageAction(eventName: string, attributes: Record): void; /** * Add information to an in-progress session trace * @param attribute - The attribute to add to the trace */ addToTrace(attribute: Record): void; /** * Record a time point when the page is finished according to custom criteria */ finished(): void; /** * Add a custom attribute to subsequent events on the page * @param key - The attribute name * @param value - The attribute value */ setCustomAttribute(key: string, value: any): void; /** * Add application version information to subsequent events * @param version - The application version */ setApplicationVersion(version: string): void; /** * Group page views by setting a page name * @param name - The page name */ setPageViewName(name: string): void; /** * Add user ID information to subsequent events on the page * @param userId - The user ID */ setUserId(userId: string): void; /** * Capture a single browser log event * @param message - The log message * @param level - Log level (optional) * @param context - Additional context (optional) */ log(message: string, level?: string, context?: Record): void; /** * Wrap an existing logger to capture messages as log events * @param logger - The logger to wrap */ wrapLogger(logger: any): void; /** * Tag errors with your app's version information * @param releaseName - The release name/version */ addRelease(releaseName: string): void; /** * Capture a caught or handled error without disrupting the app's operation * @param error - The error object * @param customAttributes - Optional custom attributes */ noticeError(error: any, customAttributes?: Record): void; /** * Set a custom error handler to ignore specific errors * @param errorHandler - Function that returns true if the error should be ignored */ setErrorHandler(errorHandler: (error: any) => boolean): void; /** * Return a new API object bound to the current interaction * If New Relic is not available, returns a no-op implementation */ interaction(): any; /** * Set the actionText of a SPA interaction * @param text - The text of the HTML element clicked */ setInteractionActionText(text: string): void; /** * End a SPA interaction */ endInteraction(): void; /** * Add a custom attribute to the current interaction * @param key - The attribute name * @param value - The attribute value */ setInteractionAttribute(key: string, value: any): void; /** * Give SPA routes more accurate names than default names * @param routeName - The route name */ setCurrentRouteName(routeName: string): void; /** * Ignore the current interaction */ ignoreInteraction(): void; /** * Save the current interaction */ saveInteraction(): void; /** * Start harvesting one or more features * @param features - Array of features to start */ start(features: string[]): void; /** * Manually start session replay collection */ recordReplay(): void; /** * Manually pause session replay collection */ pauseReplay(): void; } /** * Base class for clients that need New Relic instrumentation * * This abstract class provides common New Relic initialization and tracking * functionality that can be reused across different client implementations. */ export declare abstract class NewRelicEnabledClient { protected newRelic: NewRelicInstrumentationService | null; /** * Constructor initializes New Relic automatically */ constructor(); /** * Track API activity or errors in New Relic */ protected track(type: "activity" | "error", name: string, attributes: Record, error?: Error): void; /** * Get network information for diagnostics */ protected getNetworkInfo(): Record; /** * Override this method to provide class-specific attributes for tracking */ protected abstract getTrackingBaseAttributes(): Record; }