newrelic-react-native-agent
Version:
A New Relic Mobile Agent for React Native
321 lines • 14 kB
TypeScript
export default newRelic;
declare const newRelic: NewRelic;
/**
* New Relic
*/
declare class NewRelic {
JSAppVersion: string;
state: {
didAddErrorHandler: boolean;
didAddPromiseRejection: boolean;
didOverrideConsole: boolean;
isFirstScreen: boolean;
};
lastScreen: string;
LOG: import("./new-relic/nr-logger").default;
NRMAModularAgentWrapper: NRMAModularAgentWrapper;
agentVersion: any;
agentConfiguration: {
analyticsEventEnabled: boolean;
nativeCrashReportingEnabled: boolean;
crashReportingEnabled: boolean;
interactionTracingEnabled: boolean;
networkRequestEnabled: boolean;
networkErrorRequestEnabled: boolean;
httpResponseBodyCaptureEnabled: boolean;
loggingEnabled: boolean;
logLevel: string;
webViewInstrumentation: boolean;
collectorAddress: string;
crashCollectorAddress: string;
fedRampEnabled: boolean;
offlineStorageEnabled: boolean;
backgroundReportingEnabled: boolean;
newEventSystemEnabled: boolean;
distributedTracingEnabled: boolean;
};
LogLevel: {
ERROR: string;
WARN: string;
INFO: string;
VERBOSE: string;
AUDIT: string;
DEBUG: string;
};
NetworkFailure: {
Unknown: string;
BadURL: string;
TimedOut: string;
CannotConnectToHost: string;
DNSLookupFailed: string;
BadServerResponse: string;
SecureConnectionFailed: string;
};
MetricUnit: {
PERCENT: string;
BYTES: string;
SECONDS: string;
BYTES_PER_SECOND: string;
OPERATIONS: string;
};
/**
* True if native agent is started. False if native agent is not started.
* @returns {boolean}
*/
isAgentStarted: () => boolean;
/**
* Navigation Route Listener
*/
/**
* Subcribe onNavigationStateChange Listenr from React Navigation Version 4.x and lower
=
* Creates and records a MobileBreadcrumb for Current Screen
*/
onNavigationStateChange: (prevState: any, newState: any, action: any) => void;
getCurrentRouteName: (currentState: any) => any;
/**
* Subcribe componentDidAppearListener Listenr from React Native Navigation Package
* Creates and records a MobileBreadcrumb for Current Screen
*/
componentDidAppearListener: (event: any) => void;
/**
* Subcribe OnStateChange Listenr from React Navigation Version 5.x and higer
* Creates and records a MobileBreadcrumb for Current Screen
*/
onStateChange: (state: any) => void;
getCurrentScreen(state: any): any;
/**
* Start the agent
*/
startAgent(appkey: any, customerConfiguration: any): void;
config: any;
getReactNativeVersion(): string;
/**
* FOR ANDROID ONLY.
* Enable or disable collection of event data.
* @param enabled {boolean} Boolean value for enabling analytics events.
*/
analyticsEventEnabled(enabled: boolean): void;
/**
* Enable or disable reporting successful HTTP requests to the MobileRequest event type.
* @param enabled {boolean} Boolean value for enabling successful HTTP requests.
*/
networkRequestEnabled(enabled: boolean): void;
/**
* Enable or disable reporting network and HTTP request errors to the MobileRequestError event type.
* @param enabled {boolean} Boolean value for enabling network request errors.
*/
networkErrorRequestEnabled(enabled: boolean): void;
/**
* Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events.
* @param enabled {boolean} Boolean value for enabling HTTP response bodies.
*/
httpResponseBodyCaptureEnabled(enabled: boolean): void;
/**
* Creates and records a MobileBreadcrumb event
* @param eventName {string} the name you want to give to the breadcrumb event.
* @param attributes {Map<string, any>} a map that includes a list of attributes.
*/
recordBreadcrumb(eventName: string, attributes: Map<string, any>): void;
/**
* Creates and records a custom event, for use in New Relic Insights.
* The event includes a list of attributes, specified as a map.
* @param eventType {string} The type of event.
* @param eventName {string} Use this parameter to name the event.
* @param attributes {Map<string, any>} A map that includes a list of attributes.
*/
recordCustomEvent(eventType: string, eventName: string, attributes: Map<string, any>): void;
/**
* Throws a demo run-time exception to test New Relic crash reporting.
* @param message {string} Optional argument attached to the exception.
*/
crashNow(message?: string): void;
/**
* Returns the current session ID.
* This method is useful for consolidating monitoring of app data (not just New Relic data) based on a single session definition and identifier.
* @return currentSessionId {Promise} A promise that returns the current session id.
*/
currentSessionId(): Promise<any>;
/**
* Tracks network requests manually.
* You can use this method to record HTTP transactions, with an option to also send a response body.
* @param url {string} The URL of the request.
* @param httpMethod {string} The HTTP method used, such as GET or POST
* @param statusCode {number} The statusCode of the HTTP response, such as 200 for OK.
* @param startTime {number} The start time of the request in milliseconds since the epoch.
* @param endTime {number} The end time of the request in milliseconds since the epoch.
* @param bytesSent {number} The number of bytes sent in the request.
* @param bytesReceived {number} The number of bytes received in the response
* @param responseBody {string} The response body of the HTTP response. The response body will be truncated and included in an HTTP Error metric if the HTTP transaction is an error.
*/
noticeHttpTransaction(url: string, httpMethod: string, statusCode: number, startTime: number, endTime: number, bytesSent: number, bytesReceived: number, responseBody: string): void;
/**
* Add Headers as Attributes in Http Requests, for use in New Relic Insights.
* The method includes a list of headers, specified as a map.
* @param headers {Map<string, any>} A map that includes a list of headers.
*/
addHTTPHeadersTrackingFor(headers: Map<string, any>): void;
/**
* Records network failures.
* If a network request fails, use this method to record details about the failure.
* In most cases, place this call inside exception handlers.
* @param url {string} The URL of the request.
* @param httpMethod {string} The HTTP method used, such as GET or POST.
* @param startTime {number} The start time of the request in milliseconds since the epoch.
* @param endTime {number} The end time of the request in milliseconds since the epoch.
* @param failure {string} Name of the network failure. Possible values are in NewRelic.NetworkFailure.
*/
noticeNetworkFailure(url: string, httpMethod: string, startTime: number, endTime: number, failure: string): void;
/**
* Records custom metrics (arbitrary numerical data).
* @param name {string} The name for the custom metric.
* @param category {string} The metric category name.
* @param value {number} Optional. The value of the metric. Value should be a non-zero positive number.
* @param countUnit {string} Optional (but requires value and valueUnit to be set). Unit of measurement for the metric count. Supported values are in NewRelic.MetricUnit.
* @param valueUnit {string} Optional (but requires value and countUnit to be set). Unit of measurement for the metric value. Supported values are in NewRelic.MetricUnit.
*/
recordMetric(name: string, category: string, value?: number, countUnit?: string, valueUnit?: string): void;
/**
* Removes all attributes from the session.
*/
removeAllAttributes(): void;
/**
* Records javascript errors for react-native.
* @param e {Error} A JavaScript error.
*/
recordError(e: Error): Promise<void>;
/***
* Sets the event harvest cycle length.
* Default is 600 seconds (10 minutes).
* Minimum value cannot be less than 60 seconds.
* Maximum value should not be greater than 600 seconds.
* @param maxBufferTimeInSeconds {number} The maximum time (in seconds) that the agent should store events in memory.
*/
setMaxEventBufferTime(maxBufferTimeInSeconds: number): void;
/**
* Sets the maximum size of the event pool stored in memory until the next harvest cycle.
* When the pool size limit is reached, the agent will start sampling events, discarding some new and old, until the pool of events is sent in the next harvest cycle.
* Default is a maximum of 1000 events per event harvest cycle.
* @param maxSize {number} The maximum number of events per harvest cycle.
*/
setMaxEventPoolSize(maxSize: number): void;
/**
* Sets the maximum size of total data that can be stored for offline storage.By default, mobile monitoring can collect a maximum of 100 megaBytes of offline storage.
* When a data payload fails to send because the device doesn't have an internet connection, it can be stored in the file system until an internet connection has been made.
* After a typical harvest payload has been successfully sent, all offline data is sent to New Relic and cleared from storage.
* @param megaBytes {number} Maximum size in megaBytes that can be stored in the file system..
*/
setMaxOfflineStorageSize(megaBytes: number): void;
/**
* Track a method as an interaction
*/
startInteraction(actionName: any): Promise<any>;
/**
* End an interaction
* Required. The string ID for the interaction you want to end.
* This string is returned when you use startInteraction().
*/
endInteraction(interActionId: any): void;
/**
* ANDROID ONLY
* Name or rename an interaction
*/
setInteractionName(name: any): void;
/**
* Creates a custom attribute with a specified name and value.
* When called, it overwrites its previous value and type.
* The created attribute is shared by multiple Mobile event types.
* @param attributeName {string} Name of the attribute.
* @param value {string|number|boolean}
*/
setAttribute(attributeName: string, value: string | number | boolean): void;
/**
* Remove a custom attribute with a specified name and value.
* When called, it removes the attribute specified by the name string.
* The removed attribute is shared by multiple Mobile event types.
* @param attributeName {string} Name of the attribute.
*/
removeAttribute(attributeName: string): void;
/**
* This function is used to log a message with a specific log level.
*
* @param {Object} logLevel - The level of the log (e.g., ERROR, WARNING, INFO, VERBOSE, AUDIT).
* @param {string} message - The message to be logged.
*/
log(logLevel: any, message: string): void;
/**
* This function is used to log an error message.
*
* @param {string} message - The error message to be logged.
*/
logError(message: string): void;
/**
* This function is used to log a debug message.
*
* @param {string} message - The debug message to be logged.
*/
logDebug(message: string): void;
/**
* This function is used to log an informational message.
*
* @param {string} message - The informational message to be logged.
*/
logInfo(message: string): void;
/**
* This function is used to log a verbose message.
*
* @param {string} message - The verbose message to be logged.
*/
logVerbose(message: string): void;
/**
* This function is used to log a warning message.
*
* @param {string} message - The warning message to be logged.
*/
logWarn(message: string): void;
/**
* This function is used to log all attributes.
*
* @param {Error} error - The error object from which the message is extracted.
* @param {Map} attributes - A map of attributes to be logged.
*/
logAll(error: Error, attributes: Map<any, any>): void;
/**
* This function is used to log attributes.
*
* @param {Object} attributes - The attributes to be logged.
*/
logAttributes(attributes: any): void;
/**
* Increments the count of an attribute with a specified name.
* When called, it overwrites its previous value and type each time.
* If attribute does not exist, it creates an attribute with a value of 1.
* The incremented attribute is shared by multiple Mobile event types.
* @param attributeName {string} Name of the Attribute.
* @param value {number} Optional argument that increments the attribute by this value.
*/
incrementAttribute(attributeName: string, value?: number): void;
/**
* Sets the js release version
* @param version {string}
*/
setJSAppVersion(version: string): void;
/**
* Sets a custom user identifier value to associate mobile user
* @param userId {string}
*/
setUserId(userId: string): void;
/**
* Shut down the agent within the current application lifecycle during runtime.
*/
shutdown(): void;
/**
* @private
*/
private addNewRelicErrorHandler;
addNewRelicPromiseRejectionHandler(): void;
_overrideConsole(): void;
sendConsole(type: any, args: any): void;
}
import NRMAModularAgentWrapper from "./new-relic/nrma-modular-agent-wrapper";
//# sourceMappingURL=index.d.ts.map