///
/**
* Platform enum for targeting specific mobile platforms.
* Use this when you want platform-specific behavior, ensuring commands are only sent to Android or iOS.
*/
declare enum Platform {
/**
* Restricts the command to the Android platform only.
*
* @example
* ```ts
* import { Dynatrace, Platform } from '@dynatrace/react-native-plugin';
*
* // This action will only be tracked on Android devices
* const myAction = Dynatrace.enterAutoAction('MyButton tapped', Platform.Android);
* // Perform the action and whatever else is needed
* myAction.leaveAction();
* ```
*/
Android,
/**
* Restricts the command to the iOS platform only.
*
* @example
* ```ts
* import { Dynatrace, Platform } from '@dynatrace/react-native-plugin';
*
* // This action will only be tracked on iOS devices
* const myAction = Dynatrace.enterAutoAction('MyButton tapped', Platform.Ios);
* // Perform the action and whatever else is needed
* myAction.leaveAction();
* ```
*/
Ios
}
/**
* Enum representing different data collection and privacy levels. Each level determines
* the amount of monitoring data collected and sent by the Dynatrace agent.
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
* @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
*/
declare enum DataCollectionLevel {
/**
* No monitoring data is sent to Dynatrace.
*
* **Characteristics:**
* - No personal data is sent
* - All identifiers are randomized on every app launch
* - A single "Loading " event is sent to track the number of users who opted out
*
* Use this level when users have not consented to any data collection.
*
* @example
* ```ts
* import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
* Dynatrace.applyUserPrivacyOptions(privacyConfig);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
* @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
*/
Off,
/**
* Only performance and automatically captured data is sent to Dynatrace.
*
* **Characteristics:**
* - No personal data is sent
* - All identifiers are randomized on every app launch
* - Performance metrics and crash data are collected
* - User-specific data and custom events are not tracked
*
* Use this level when users consent to performance monitoring but not personal data collection.
*
* @example
* ```ts
* import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Performance, true);
* Dynatrace.applyUserPrivacyOptions(privacyConfig);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
* @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
*/
Performance,
/**
* @deprecated Replaced by `DataCollectionLevel.UserBehavior`
*/
User,
/**
* Both performance data and user behavior data are sent to Dynatrace.
*
* **Characteristics:**
* - Personal data may be sent (depending on configuration)
* - OneAgent recognizes and tracks returning users across sessions
* - User tagging, custom events, and custom values are enabled
* - Full monitoring capabilities are available
*
* **Note:** If you haven't configured user tagging or custom event/value reporting,
* this level functions similarly to the Performance level.
*
* Use this level when users have consented to full monitoring and analytics.
*
* @example
* ```ts
* import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true);
* Dynatrace.applyUserPrivacyOptions(privacyConfig);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
* @see https://docs.dynatrace.com/docs/platform-modules/digital-experience/mobile-applications/additional-configuration/configure-rum-privacy-mobile#data-collection-levels
*/
UserBehavior
}
/**
* Represents user privacy settings for data collection and crash reporting.
* Use this class to configure privacy options and apply them via `Dynatrace.applyUserPrivacyOptions(userPrivacyOptions)`.
*/
declare class UserPrivacyOptions {
private _dataCollectionLevel;
private _crashReportingOptedIn;
private _screenRecordOptedIn;
/**
* Creates a new UserPrivacyOptions instance with the specified privacy settings.
*
* @param {DataCollectionLevel} dataCollectionLevel The level of data collection to allow
* @param {boolean} crashReportingOptedIn Whether crash reporting should be enabled
* @param {boolean} screenRecordOptedIn Whether screen recording (Session Replay) should be enabled
*
* @example
* ```ts
* import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* // Create privacy options with no data collection
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
* Dynatrace.applyUserPrivacyOptions(privacyConfig);
*
* // Create privacy options with full monitoring
* const fullPrivacyConfig = new UserPrivacyOptions(DataCollectionLevel.UserBehavior, true);
* Dynatrace.applyUserPrivacyOptions(fullPrivacyConfig);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
*/
constructor(dataCollectionLevel: DataCollectionLevel, crashReportingOptedIn: boolean, screenRecordOptedIn?: boolean);
/**
* Gets the current data collection level.
*
* @returns {DataCollectionLevel} The configured data collection level
*
* @example
* ```ts
* import { DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Performance, false);
* const level = privacyConfig.dataCollectionLevel;
* console.log(level); // DataCollectionLevel.Performance
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
*/
get dataCollectionLevel(): DataCollectionLevel;
/**
* Returns the opt-in value for crash reporting.
*
* @return {boolean} the opt-in value for crash reporting
*
* Usage:
*
* ```ts
* import { DataCollectionLevel, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
* const crashReporting = privacyConfig.crashReportingOptedIn;
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
*/
get crashReportingOptedIn(): boolean;
/**
* Sets the crash reporting opt-in preference.
*
* @param {boolean} crashReportingOptedIn Set to `true` to enable crash reporting, `false` to disable it
*
* @example
* ```ts
* import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Performance, false);
* privacyConfig.crashReportingOptedIn = true; // Enable crash reporting
* Dynatrace.applyUserPrivacyOptions(privacyConfig);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
*/
set crashReportingOptedIn(crashReportingOptedIn: boolean);
/**
* Sets the data collection level.
*
* @param {DataCollectionLevel} dataCollectionLevel The data collection level to apply
*
* @example
* ```ts
* import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* const privacyConfig = new UserPrivacyOptions(DataCollectionLevel.Off, false);
* privacyConfig.dataCollectionLevel = DataCollectionLevel.Performance; // Change to Performance level
* Dynatrace.applyUserPrivacyOptions(privacyConfig);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
*/
set dataCollectionLevel(dataCollectionLevel: DataCollectionLevel);
get screenRecordOptedIn(): boolean;
set screenRecordOptedIn(screenRecordOptedIn: boolean);
}
/**
* Interface for Action
*/
interface IDynatraceAction {
/**
* Reports an error event with an error code. The key-value pair is marked as an error type.
*
* **Note:** The error will not be reported if the action is already closed or if the errorName
* is null or empty. String values are limited to 250 characters and will be truncated if they
* exceed this limit.
*
* @param {string} errorName Name of the error event (limited to 250 characters)
* @param {number} errorCode The error code to report
* @param {Platform} platform Optional platform filter. Defaults to both Android and iOS.
*
* @example
* ```ts
* import { Dynatrace, Platform } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('User Login');
* action.reportError('Page Not Found', 404);
* action.leaveAction();
*
* // With platform-specific error
* const platformAction = Dynatrace.enterAutoAction('API Call');
* platformAction.reportError('Connection Failed', 500, Platform.Android);
* platformAction.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
*/
reportError(errorName: string, errorCode: number, platform?: Platform): void;
/**
* Reports a timestamped event to track when a user passes through a specific part of your application.
* This method provides a simple way to monitor user behavior and application flow.
*
* **Note:** The event will not be reported if the action is already closed or if the eventName
* is null or empty. String values are limited to 250 characters and will be truncated if they
* exceed this limit.
*
* @param eventName Name of the event to report (limited to 250 characters)
* @param platform Optional platform filter. Defaults to both Android and iOS.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('Checkout Process');
* action.reportEvent('Payment Method Selected');
* action.reportEvent('Order Confirmed');
* action.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
*/
reportEvent(eventName: string, platform?: Platform): void;
/**
* Reports a timestamped string key-value pair for tracking important measurement data.
*
* **Note:** The event will not be reported if the action is already closed, or if either
* valueName or value is null or empty. String values are limited to 250 characters and will
* be truncated if they exceed this limit.
*
* @param valueName Name of the value being reported (limited to 250 characters)
* @param value String value to report (limited to 250 characters)
* @param platform Optional platform filter. Defaults to both Android and iOS.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('User Profile Update');
* action.reportStringValue('User Tier', 'Premium');
* action.reportStringValue('Selected Theme', 'Dark Mode');
* action.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
*/
reportStringValue(valueName: string, value: string, platform?: Platform): void;
/**
* Reports a timestamped integer key-value pair for tracking important measurement data.
*
* **Note:** The event will not be reported if the action is already closed or if
* valueName is null or empty. The valueName is limited to 250 characters and will be
* truncated if it exceeds this limit.
*
* @param valueName Name of the value being reported (limited to 250 characters)
* @param value Integer value to report
* @param platform Optional platform filter. Defaults to both Android and iOS.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('Shopping Cart');
* action.reportIntValue('Items Count', 5);
* action.reportIntValue('Total Quantity', 12);
* action.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
*/
reportIntValue(valueName: string, value: number, platform?: Platform): void;
/**
* Reports a timestamped double (floating-point) key-value pair for tracking important measurement data.
*
* **Note:** The event will not be reported if the action is already closed or if
* valueName is null or empty. The valueName is limited to 250 characters and will be
* truncated if it exceeds this limit.
*
* @param valueName Name of the value being reported (limited to 250 characters)
* @param value Double (floating-point) value to report
* @param platform Optional platform filter. Defaults to both Android and iOS.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('Purchase Transaction');
* action.reportDoubleValue('Transaction Amount', 99.99);
* action.reportDoubleValue('Tax Amount', 8.50);
* action.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
*/
reportDoubleValue(valueName: string, value: number, platform?: Platform): void;
/**
* Completes this action and prepares the collected data for transmission in the next sending interval.
*
* **Note:** When a parent action is exited, all nested child actions are automatically closed.
*
* @param platform Optional platform filter. Defaults to both Android and iOS.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('User Login');
* action.reportEvent('Credentials Validated');
* action.reportIntValue('Login Attempts', 1);
* action.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
*/
leaveAction(platform?: Platform): void;
/**
* Cancels this action and discards all collected data. Similar to `leaveAction()`, but the data
* and all unfinished child actions are discarded instead of being sent to Dynatrace.
*
* Use this when an action was started incorrectly or should not contribute to monitoring data
* (e.g., test actions, debug sessions, pre-production validation).
*
* @param platform Optional platform filter. Defaults to both Android and iOS.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('Data Processing');
* action.reportEvent('Processing Started');
*
* // Cancel if running in development or test mode
* if (__DEV__) {
* action.cancel(); // Don't send test data to production monitoring
* } else {
* action.leaveAction(); // Send the action data
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#cancel-actions
*/
cancel(platform?: Platform): void;
/**
* Generates a unique x-dynatrace header for the web request with a specified url,
* which has to be manually added as http header.
*
* This is the same tag that was provided when constructing the DynatraceWebRequestTiming instance.
* The header key can be obtained with the method getRequestTagHeader.
*
* The string value can be empty in cases when the agent is not able to send data, the agent is turned off completly,
* has not started yet or is not allowed to track web requests because of privacy reasons.
* The tag value is evaluated by the corresponding web server agent.
* The Dynatrace server will link the server-side PurePath data with this mobile user action.
*
* @param {string} url The URL of the request you want to track
* @returns {Promise} The request tag value to be used as the HTTP header value
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('API Request');
* const requestTag = await action.getRequestTag('https://api.example.com/data');
* const headerName = action.getRequestTagHeader();
*
* // Attach to your HTTP request
* fetch('https://api.example.com/data', {
* headers: {
* [headerName]: requestTag,
* 'Content-Type': 'application/json'
* }
* });
*
* action.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
getRequestTag(url: string): Promise;
/**
* Returns the HTTP header name required for manual web request tagging. Use this in combination
* with `getRequestTag()` to link web requests with mobile actions.
*
* @returns {string} The name of the HTTP header to use for request tagging
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterAutoAction('Data Fetch');
* const headerName = action.getRequestTagHeader();
* const headerValue = await action.getRequestTag('https://api.example.com/users');
*
* // Use in your HTTP client
* const response = await fetch('https://api.example.com/users', {
* headers: {
* [headerName]: headerValue
* }
* });
*
* action.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
getRequestTagHeader(): string;
}
type Primitive = string | number | boolean;
type JSONArray = JSONValue[];
type JSONValue = Primitive | JSONArray | JSONObject;
/**
* JSON Object which can be used for sendEvent API
*/
interface JSONObject {
[key: string]: JSONValue;
}
/**
* Log level enum to control the verbosity of plugin logging.
*/
declare enum LogLevel {
/**
* Enables verbose diagnostic logging. Use this level when troubleshooting issues or during development.
*
* **Configuration options:**
* - Via `dynatrace.config.js`: Set `react.debug` to `true`
* - Via code (manual startup): Use the `ConfigurationBuilder`
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace, LogLevel } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withLogLevel(LogLevel.Debug);
* await Dynatrace.start(config.buildConfiguration());
* ```
*/
Debug = 0,
/**
* Enables standard informational logging. This is the default log level and provides essential information
* without excessive detail.
*
* **Note:** Since this is the default, explicit configuration is not required.
*
* **Configuration options:**
* - Via `dynatrace.config.js`: Set `react.debug` to `false`
* - Via code (manual startup): Use the `ConfigurationBuilder`
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace, LogLevel } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withLogLevel(LogLevel.Info);
* await Dynatrace.start(config.buildConfiguration());
* ```
*/
Info = 1
}
/**
* Interface which is containing the additional properties available for instrumentation.
*/
interface IDynatraceProperties {
/**
* This string is changing the name of the action. So it is possible to override the action naming.
*/
dtActionName?: string;
/**
* If true is passed the auto instrumentation will skip the action creation. We allow both string
* and boolean.
*/
dtActionIgnore?: boolean | 'true' | 'false';
}
type ActionNamePreference = 'any' | 'text' | 'icon';
type ActionNameAlgorithm = 'depth-first' | 'breadth-first';
/**
* Configuration interface for Dynatrace agent startup.
* Use this interface when configuring the agent programmatically instead of using auto-startup.
*/
interface IConfiguration {
/**
* The beacon URL used to communicate with the Dynatrace beacon endpoint. This value is mandatory.
*
* **Note:** This value is only used for manual startup. For auto-startup, configure this through
* the native agent configuration.
*/
readonly beaconUrl: string;
/**
* The application ID used to identify and report data for this application. This value is mandatory.
*
* **Note:** This value is only used for manual startup. For auto-startup, configure this through
* the native agent configuration.
*/
readonly applicationId: string;
/**
* Enables crash reporting. Defaults to `true` if not specified.
*
* **Note:** This value is only used for manual startup. For auto-startup, configure this through
* the native agent configuration.
*/
readonly reportCrash: boolean;
/**
* Enables the React Native error/crash handler. Defaults to `true` if not specified.
*
* **Note:** This value is only used for manual startup. For auto-startup, configure this through
* the `react` configuration block in the `dynatrace.config.js` file.
*/
readonly errorHandler: boolean;
/**
* Determines whether fatal errors are reported as crashes or errors.
*
* - When `true` (default): Unhandled fatal errors are reported as crashes and end the current session
* - When `false`: Unhandled fatal errors are reported as errors and the current session continues
*
* **Note:** This value is only used for manual startup. For auto-startup, configure this through
* the `react` configuration block in the `dynatrace.config.js` file.
*/
readonly reportFatalErrorAsCrash: boolean;
/**
* The log level for the Dynatrace plugin during application runtime. Defaults to `LogLevel.Info` if not specified.
*/
readonly logLevel: LogLevel;
/**
* Enables tracking of component update cycles in lifecycle actions. Defaults to `false` if not specified.
*
* **Warning:** Enabling this option generates significantly more monitoring data.
*/
readonly lifecycleUpdate: boolean;
/**
* Activates privacy mode when set to `true`. User consent must be queried and configured separately.
* Privacy settings for data collection and crash reporting can be changed by calling
* `Dynatrace.applyUserPrivacyOptions(userPrivacyOptions)`. Defaults to `false` if not specified.
*
* **Note:** This value is only used for manual startup. For auto-startup, configure this through
* the native agent configuration.
*
* @see Data privacy documentation for more details on privacy settings
*/
readonly userOptIn: boolean;
/**
* Activates privacy mode for Touchables and Buttons. When set to `true`, specific control names
* are hidden and replaced with generic component types (e.g., "Touch on Login" becomes "Touch on Button").
*
* **Note:** This setting is ignored when a `dtActionName` prop is explicitly set on the component.
* Defaults to `false` if not specified.
*/
readonly actionNamePrivacy: boolean;
/**
* Controls which type of child element is preferred when searching the component tree for the
* name of an `onPress` action.
*
* - `'text'`: Prefers text content and falls back to any match.
* - `'icon'`: Prefers `ReactNative.Image` or custom Icons and falls back to any match.
* - `'any'`: Accepts the first match regardless of type (text, image, or icon).
*
* Defaults to `'any'` if not specified.
*/
readonly actionNamePreference: ActionNamePreference;
/**
* Controls the traversal algorithm used when searching the component tree for the name of an `onPress` action.
*
* - `'depth-first'`: Follows the first child branch fully before trying siblings.
* - `'breadth-first'`: Visits all siblings at a level before going deeper, returning the shallowest match first.
*
* Defaults to `'depth-first'` if not specified.
*/
readonly actionNameAlgorithm: ActionNameAlgorithm;
/**
* The bundle name used as a prefix for internal action IDs. Optional.
*/
readonly bundleName?: string;
/**
* The bundle version used for events. This is mandatory for proper crash reporting and source map symbolication.
*
* **Important:** Without a bundle version, source maps cannot be applied to crash reports.
*/
readonly bundleVersion?: string;
/**
* Returns a string representation of the configuration.
*
* @returns A formatted string containing the configuration details
*/
toString(): string;
}
/**
* Interface which declares event modification through modifyEvent
* Implement this interface and register it via Dynatrace.addEventModifier(IEventModifier) to modify events.
*/
interface IEventModifier {
/**
* Event as JSONObject is received and can be modified.
*
* Returning null discards the event and prevents future modifier functions from being executed.
*
* Certain reserved fields and namespaces cannot be modified in any way (added, removed, or overridden),
* while others are open for modification.
*
* Open for modification:
* - url.full
* - exception.stack_trace
*
* Open for modification or can be added:
* - event_properties.*
* - session_properties.*
*
* See the public documentation for a detailed list of reserved/open fields.
* @param event Event as JSONObject
* @returns Either the modified event or null if you want to cancel the event
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* Dynatrace.addEventModifier({ modifyEvent(event) {
* event['event_properties.modified'] = 'modified';
* return event;
* }});
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-custom-events#event-modifiers
*/
modifyEvent(event: JSONObject): JSONObject | null;
}
/**
* Represents the allowed types for event property values.
*/
type EventProperty = string | number | boolean;
type TraceparentHeader = `${string}-${string}-${string}-${string}`;
interface TraceContext {
traceparent: TraceparentHeader;
tracestate: string;
}
/**
* Base interface for all events.
*/
interface IBaseEvent {
/**
* Converts the event into a JSON event object.
*
* @returns The built event as a JSONObject.
*
* @internal
*/
toJSON(): JSONObject | null;
}
interface IHttpRequestEventData extends IBaseEvent {
/**
* Sets the duration of the HTTP request in milliseconds.
*
* @param duration The request duration in milliseconds. Only positive numbers are valid.
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET')
* .withDuration(250);
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
withDuration(duration: number): this;
/**
* Sets the HTTP response status code.
*
* @param statusCode The HTTP status code (e.g., 200, 404, 500). Only positive numbers are valid.
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET')
* .withStatusCode(200);
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
withStatusCode(statusCode: number): this;
/**
* Sets the HTTP response reason phrase.
*
* @param reasonPhrase The reason phrase (e.g., "OK", "Not Found"). Maximum 5000 characters; longer values will be trimmed.
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET')
* .withReasonPhrase('OK');
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
withReasonPhrase(reasonPhrase: string): this;
/**
* Associates an error with the HTTP request event.
*
* @param error A standard JavaScript Error object representing the request failure
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* try {
* // Request code
* } catch (error) {
* let requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET');
*
* if (error instanceof Error) {
* requestEvent.withError(error);
* }
*
* Dynatrace.sendHttpRequestEvent(requestEvent);
* }
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
withError(error: Error): this;
/**
* Sets the number of bytes sent in the request.
*
* @param bytesSent The number of bytes sent in the request payload. Only positive numbers are valid.
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'POST')
* .withBytesSent(1024);
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
withBytesSent(bytesSent: number): this;
/**
* Sets the number of bytes received in the response.
*
* @param bytesReceived The number of bytes received in the response payload. Only positive numbers are valid.
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET')
* .withBytesReceived(2048);
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
withBytesReceived(bytesReceived: number): this;
/**
* Adds a W3C traceparent header for distributed tracing.
*
* @param traceparentHeader A valid traceparent header according to the W3C Trace Context specification.
* Format: `00---` where trace-id is 32 hex digits, parent-id is 16 hex digits.
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET')
* .withTraceparentHeader('00-80e1afed08e019fc1110464cfa66635c-7a085853722dc6d2-01');
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
withTraceparentHeader(traceparentHeader: TraceparentHeader | undefined): this;
/**
* Adds a custom event property to the request event.
* @param key The property key. See property requirements below.
* @param value The property value. Cannot contain functions, undefined, Infinity, or NaN (they will be replaced with null).
*
* **Property Requirements:**
* - Only properties prefixed with `event_properties.*` are allowed
* - Maximum of 50 custom properties per event
* - If the limit is exceeded, properties are sorted alphabetically by key and excess properties are dropped deterministically
* - String properties are limited to 5000 characters (exceeding characters are truncated)
* - Field names must contain only alphabetic characters, numbers, underscores, and dots
* - Each dot must be followed by an alphabetic character
* - Each underscore must be followed by an alphabetic character or number
*
* @returns The event instance for method chaining
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET')
* .addEventProperty('event_properties.user_id', '12345')
* .addEventProperty('event_properties.api_version', 'v2');
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
addEventProperty(key: `event_properties.${string}`, value: EventProperty): this;
}
type AllowedRequestMethods = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH' | 'get' | 'head' | 'post' | 'put' | 'delete' | 'connect' | 'options' | 'trace' | 'patch';
type Url = `http://${string}` | `https://${string}`;
type EventPropertyKey = `event_properties.${string}`;
declare class HttpRequestEventData implements IHttpRequestEventData {
private url;
private requestMethod;
private static readonly allowedRequestMethods;
private duration;
private statusCode?;
private reasonPhrase?;
private bytesReceived?;
private bytesSent?;
private error?;
private traceparentHeader?;
private rawEventProperties;
private hasDroppedProperties;
private triedToOverwriteDuration;
/**
* Creates a new HTTP request event.
*
* @param url The request URL. Must be a valid URL according to the WHATWG URL Standard, starting with
* `http://` or `https://`. Maximum 5000 characters; longer values will be trimmed.
* @param requestMethod The HTTP request method. Allowed values: GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS,
* TRACE, PATCH (case-insensitive).
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'GET');
* Dynatrace.sendHttpRequestEvent(requestEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
constructor(url: Url, requestMethod: AllowedRequestMethods);
withDuration(duration: number): this;
withStatusCode(statusCode: number): this;
withReasonPhrase(reasonPhrase: string): this;
withError(error: Error): this;
withBytesSent(bytesSent: number): this;
withBytesReceived(bytesReceived: number): this;
withTraceparentHeader(traceparentHeader: TraceparentHeader | undefined): this;
addEventProperty(key: EventPropertyKey, value: EventProperty): this;
toJSON(): JSONObject | null;
private getTraceContextHint;
private hasValidMandatoryAttributes;
private isInvalidUrl;
private sanitizeStatusCode;
private sanitizeDuration;
private sanitizeBytesSent;
private sanitizeBytesReceived;
private isStatusCodeError;
}
/**
* Interface for building events with event properties and duration.
*
* Events can include custom properties and duration information.
* Use implementations of this interface with `Dynatrace.sendEvent()`.
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-custom-events#send-custom-events
*/
interface IEventData extends IBaseEvent {
/**
* Sets the duration of the event in milliseconds.
*
* @param duration The event duration in milliseconds. Only positive numbers are valid.
* @returns The event instance for method chaining
*
* @example
* ```typescript
* import { Dynatrace, EventData } from '@dynatrace/react-native-plugin';
*
* const customEvent = new EventData()
* .addEventProperty('event_properties.operation', 'data_sync')
* .withDuration(250);
* Dynatrace.sendEvent(customEvent);
* ```
*/
withDuration(duration: number): this;
/**
* Adds a custom event property to the event.
*
* Event properties allow you to attach custom key-value pairs to events for better
* analysis and filtering in Dynatrace.
*
* @param key - The property key. Must be prefixed with `event_properties.*`
* @param value - The property value (string, number, or boolean). Invalid values will be replaced with null.
* @returns The event instance for method chaining
*
* @remarks
* **Property Requirements:**
* - Only properties prefixed with `event_properties.*` are allowed
* - Maximum of 50 custom properties per event
* - If the limit is exceeded, properties are sorted alphabetically by key and excess properties are dropped deterministically
* - String properties are limited to 5000 characters (exceeding characters are truncated)
* - Field names must contain only alphabetic characters, numbers, underscores, and dots
* - Each dot must be followed by an alphabetic character
* - Each underscore must be followed by an alphabetic character or number
*
* @example
* ```typescript
* import { Dynatrace, EventData } from '@dynatrace/react-native-plugin';
*
* const customEvent = new EventData()
* .addEventProperty('event_properties.user_id', '12345')
* .addEventProperty('event_properties.action_type', 'purchase')
* .addEventProperty('event_properties.amount', 99.99)
* .addEventProperty('event_properties.is_premium_user', true);
* Dynatrace.sendEvent(customEvent);
* ```
*/
addEventProperty(key: `event_properties.${string}`, value: EventProperty): this;
}
declare class EventData implements IEventData {
private rawEventProperties;
private duration?;
addEventProperty(key: `event_properties.${string}`, value: EventProperty): this;
withDuration(duration: number): this;
toJSON(): JSONObject | null;
}
/**
* Interface for building session property events.
*
* Session properties are key-value pairs that persist throughout the entire
* user session and are attached to all subsequent events in that session.
* Use implementations of this interface with `Dynatrace.sendSessionPropertyEvent()`.
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-custom-events#send-session-property-events
*/
interface ISessionPropertyEventData extends IBaseEvent {
/**
* Adds a custom session property to the event.
*
* Session properties allow you to attach custom key-value pairs that persist throughout
* the entire user session. These properties will be automatically attached to all
* subsequent events in the current session.
*
* @param key - The property key. Must be prefixed with `session_properties.*`
* @param value - The property value (string, number, or boolean). Invalid values will be replaced with null.
* @returns The event instance for method chaining
*
* @remarks
* **Property Requirements:**
* - Only properties prefixed with `session_properties.*` are allowed
* - Maximum of 50 custom properties per event
* - If the limit is exceeded, properties are sorted alphabetically by key and excess properties are dropped deterministically
* - String properties are limited to 5000 characters (exceeding characters are truncated)
* - Field names must contain only alphabetic characters, numbers, underscores, and dots
* - Each dot must be followed by an alphabetic character
* - Each underscore must be followed by an alphabetic character or number
*
* @example
* ```typescript
* import { Dynatrace, SessionPropertyEventData } from '@dynatrace/react-native-plugin';
*
* const sessionPropertyEvent = new SessionPropertyEventData()
* .addSessionProperty('session_properties.user_id', 'user_12345')
* .addSessionProperty('session_properties.user_type', 'premium')
* .addSessionProperty('session_properties.feature_flags_enabled', true)
* .addSessionProperty('session_properties.session_score', 95.5);
* Dynatrace.sendSessionPropertyEvent(sessionPropertyEvent);
* ```
*/
addSessionProperty(key: `session_properties.${string}`, value: EventProperty): this;
}
declare class SessionPropertyEventData implements ISessionPropertyEventData {
private rawSessionProperties;
addSessionProperty(key: `session_properties.${string}`, value: EventProperty): this;
toJSON(): JSONObject | null;
}
/**
* Interface for building exception events with event properties.
*
* This interface defines the contract for creating exception events that can be sent
* to Dynatrace. Exception events can include custom properties.
* Use implementations of this interface with `Dynatrace.sendExceptionEvent()`.
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-error-crash-reporting#send-exception-event
*/
interface IExceptionEventData extends IBaseEvent {
/**
* Adds a custom event property to the exception event.
*
* Event properties allow you to attach additional contextual information to the exception.
* Properties must follow the naming convention `event_properties.*` and support string,
* number, and boolean values.
*
* @param key The property key. Must start with "event_properties."
* @param value The property value (string, number, or boolean)
* @returns The event instance for method chaining
*
* @remarks
* **Property Requirements:**
* - Only properties prefixed with `event_properties.*` are allowed
* - Maximum of 50 custom properties per event
* - If the limit is exceeded, properties are sorted alphabetically by key and excess properties are dropped deterministically
* - String properties are limited to 5000 characters (exceeding characters are truncated)
* - Field names must contain only alphabetic characters, numbers, underscores, and dots
* - Each dot must be followed by an alphabetic character
* - Each underscore must be followed by an alphabetic character or number
*
* @example
* ```typescript
* import { Dynatrace, ExceptionEventData } from '@dynatrace/react-native-plugin';
*
* try {
* // Some operation that might throw an error
* throw new Error('Something went wrong');
* } catch (error) {
* if (error instanceof Error) {
* const exceptionEvent = new ExceptionEventData(error)
* .addEventProperty('event_properties.exception_type', 'RuntimeError')
* .addEventProperty('event_properties.stack_depth', 15)
* .addEventProperty('event_properties.handled', true);
*
* Dynatrace.sendExceptionEvent(exceptionEvent);
* }
* }
* ```
*/
addEventProperty(key: string, value: EventProperty): this;
}
declare class ExceptionEventData implements IExceptionEventData {
private rawEventProperties;
private readonly error;
constructor(error: Error);
addEventProperty(key: `event_properties.${string}`, value: EventProperty): this;
toJSON(): JSONObject | null;
}
interface IDynatrace$1 {
/**
* Adds an event modifier that is executed just before the event is transferred.
* This allows you to modify the event to some extent.
*
* Returning null discards the event and prevents future modifier functions from being executed.
*
* Certain reserved fields and namespaces cannot be modified in any way (added, removed, or overridden),
* while others are open for modification.
*
* Open for modification:
* - url.full
* - exception.stack_trace
*
* Open for modification or can be added:
* - event_properties.*
* - session_properties.*
*
* See the public documentation for a detailed list of reserved/open fields.
*
* @param eventModifier The modifier function to modify a given JSONObject
* @returns The registered event modifier instance
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const modifier = Dynatrace.addEventModifier({
* modifyEvent(event) {
* event['event_properties.modified'] = 'modified';
* return event;
* }
* });
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-custom-events#event-modifiers
*/
addEventModifier(eventModifier: IEventModifier): IEventModifier;
/**
* Removes an event modifier so it will no longer modify events.
*
* @param eventModifier The modifier function to be removed
* @returns True if the modifier was successfully removed, false otherwise
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const modifier = Dynatrace.addEventModifier({ modifyEvent: (event) => event });
* const removed = Dynatrace.removeEventModifier(modifier);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-custom-events#remove-event-modifiers
*/
removeEventModifier(eventModifier: IEventModifier): boolean;
/**
* Sends an exception event for error tracking and monitoring.
*
* @param exceptionEventData The exception event data built using ExceptionEventData
*
* @example
* ```ts
* import { Dynatrace, ExceptionEventData } from '@dynatrace/react-native-plugin';
*
* try {
* // Code that may throw an error
* throw new Error('Something went wrong');
* } catch (error) {
* if (error instanceof Error) {
* const exceptionEvent = new ExceptionEventData(error)
* .addEventProperty('event_properties.custom_key', 'custom_value')
* .addEventProperty('event_properties.error_context', 'user_action');
*
* Dynatrace.sendExceptionEvent(exceptionEvent);
* }
* }
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-error-crash-reporting#send-exception-event
*/
sendExceptionEvent(exceptionEventData: ExceptionEventData): void;
/**
* Sends a custom event with event properties and optional duration.
*
* @param eventData The event data built using EventData
*
* @example
* ```ts
* import { Dynatrace, EventData } from '@dynatrace/react-native-plugin';
*
* const customEvent = new EventData()
* .addEventProperty('event_properties.user_action', 'button_click')
* .addEventProperty('event_properties.screen_name', 'checkout')
* .addEventProperty('event_properties.item_count', 3)
* .withDuration(150);
*
* Dynatrace.sendEvent(customEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-custom-events#send-custom-events
*/
sendEvent(eventData: EventData): void;
/**
* Starts a new view context. All events reported after this call will be associated
* with this view until a new view is started.
*
* **Note:** Only one view context can be active at a time. Starting a new view will
* automatically stop any currently active view context.
*
* @param name Name of the view (e.g., screen name, page title)
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* // Start tracking a specific screen
* Dynatrace.startView('HomeScreen');
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-app-performance#view-monitoring
*/
startView(name: string): void;
/**
* Sends a session properties event. Session properties apply to all events in the current session.
*
* **Note:** While you can send multiple session properties at once, if you report the same
* property multiple times, session aggregation will only use one of the values (first or last).
*
* @param sessionPropertyEventData The session property event data built using SessionPropertyEventData builder
*
* @example
* ```ts
* import { Dynatrace, SessionPropertyEventData } from '@dynatrace/react-native-plugin';
*
* // Set session-level properties
* const sessionEvent = new SessionPropertyEventData()
* .addSessionProperty('session_properties.user_tier', 'premium')
* .addSessionProperty('session_properties.app_version', '2.1.0')
* .addSessionProperty('session_properties.device_type', 'mobile');
*
* Dynatrace.sendSessionPropertyEvent(sessionEvent);
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-custom-events#send-session-property-events
*/
sendSessionPropertyEvent(sessionPropertyEventData: SessionPropertyEventData): void;
/**
* Sends an HTTP request event for network activity monitoring.
*
* @param {HttpRequestEventData} httpRequestEvent Event object containing the HTTP request details.
*
* The {@link HttpRequestEventData} class supports the following builder methods:
* - `withDuration(duration)` — Override the request duration in milliseconds.
* - `withStatusCode(statusCode)` — Set the HTTP response status code.
* - `withReasonPhrase(reasonPhrase)` — Set the HTTP response reason phrase.
* - `withError(error)` — Attach an `Error` object for failed requests.
* - `withBytesSent(bytesSent)` — Set the number of bytes sent in the request body.
* - `withBytesReceived(bytesReceived)` — Set the number of bytes received in the response body.
* - `withTraceparentHeader(traceparentHeader)` — Attach a W3C traceparent header for distributed tracing.
* - `addEventProperty(key, value)` — Add a custom event property (key must start with `event_properties.`).
*
* @example
* ```ts
* import { Dynatrace, HttpRequestEventData } from '@dynatrace/react-native-plugin';
*
* const traceContext = Dynatrace.generateTraceContext();
* const body = JSON.stringify({ query: 'search term' });
*
* try {
* const response = await fetch('https://api.example.com/data', {
* method: 'POST',
* headers: { 'Content-Type': 'application/json', ...traceContext },
* body,
* });
*
* const responseBody = await response.text();
*
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'POST')
* .withStatusCode(response.status)
* .withReasonPhrase(response.statusText)
* .withDuration(340)
* .withBytesSent(new Blob([body]).size)
* .withBytesReceived(new Blob([responseBody]).size)
* .withTraceparentHeader(traceContext?.traceparent)
* .addEventProperty('event_properties.endpoint', '/data')
* .addEventProperty('event_properties.payload_type', 'json');
*
* Dynatrace.sendHttpRequestEvent(requestEvent);
* } catch (error) {
* const requestEvent = new HttpRequestEventData('https://api.example.com/data', 'POST')
* .withError(error instanceof Error ? error : new Error(String(error)))
* .withTraceparentHeader(traceContext?.traceparent)
* .addEventProperty('event_properties.endpoint', '/data')
* .addEventProperty('event_properties.payload_type', 'json');
*
* Dynatrace.sendHttpRequestEvent(requestEvent);
* }
* ```
*
* @see https://docs.dynatrace.com/docs/shortlink/react-native-web-request-performance#manual-http-request-reporting
*/
sendHttpRequestEvent(httpRequestEvent: HttpRequestEventData): void;
/**
* Generates a W3C trace context for distributed tracing.
*
* Creates a {@link TraceContext} containing traceparent and tracestate headers
* for distributed tracing. If existing headers are provided, they will be
* reused according to the W3C Trace Context specification.
*
* @param traceparent Optional existing W3C traceparent header value.
* @param tracestate Optional existing W3C tracestate header value.
* @returns A {@link TraceContext} with traceparent and tracestate values, or `undefined` if:
* - The agent is not started
* - The agent configuration is not yet available
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* // Generate new trace context
* const traceContext = Dynatrace.generateTraceContext();
*
* const response = await fetch('https://api.example.com/data', {
* headers: {
* ...traceContext,
* },
* });
*
* // Or reuse existing trace context from an incoming request
* // const existingTraceparent = req.headers['traceparent'];
* // const existingTracestate = req.headers['tracestate'];
* // const traceContext = Dynatrace.generateTraceContext(existingTraceparent, existingTracestate);
* ```
*/
generateTraceContext(traceparent?: TraceparentHeader, tracestate?: string): TraceContext | undefined;
}
/**
* Root action that extends the standard IDynatraceAction with the ability to create
* nested child actions for hierarchical action tracking.
*/
interface IDynatraceRootAction extends IDynatraceAction {
/**
* Creates a child action nested under this root action. Child actions allow you to track
* sub-tasks or operations within a larger workflow, providing hierarchical visibility
* into user interactions and application behavior.
*
* **Note:** When the parent action is closed with `leaveAction()` or `cancel()`, all
* child actions are automatically closed as well.
*
* @param {string} name Name of the child action (limited to 250 characters)
* @param {Platform} platform Optional platform filter. Defaults to both Android and iOS.
* @returns {IDynatraceAction} The created child action instance
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const parentAction = Dynatrace.enterManualAction('User Registration');
*
* const validationAction = parentAction.enterAction('Validate Input');
* validationAction.reportEvent('Email Validated');
* validationAction.leaveAction();
*
* const submitAction = parentAction.enterAction('Submit Form');
* submitAction.reportIntValue('Retry Attempts', 1);
* submitAction.leaveAction();
*
* parentAction.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#create-custom-sub-actions
*/
enterAction(name: string, platform?: Platform): IDynatraceAction;
}
interface IDynatrace extends IDynatrace$1 {
/**
* Starting the React Native plugin and OneAgent for Android or iOS. This method is only necessary
* in case of manual startup and should be ignored in auto startup scenarios. The start method will
* set the error handler for reporting crashes and will apply the provided configuration globally.
*
* @param {IConfiguration} configuration Configuration for a manual startup of the plugin
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const configurationBuilder = new ConfigurationBuilder("beaconUrl", "applicationId");
* // Use several configuration options like withLogLevel(LogLevel.Debug)
* await Dynatrace.start(configurationBuilder.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
start(configuration: IConfiguration): Promise;
/**
* This call allows to monitor the passed in component. Depending on the type of the component
* (Function Component or Class Component), it will be wrapped and data of renderings will be
* automatically reported.
*
* The name of the Component, which can be passed as parameter, is important because the build
* process will remove the name of a Functional Component. Still this parameter is optional as
* other properties can be used at runtime as well (e.g. dtActionName).
*
* @param Component Functional or Class Component
* @param {string} name The name of the Component
* @returns The Component which was wrapped to be monitored
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
* import { FunctionComponent } from 'react';
*
* export const MyFunctionalComponent: FunctionComponent<{}> = () => {
* return null;
* }
*
* Dynatrace.withMonitoring(MyFunctionalComponent, "MyFunctionalComponent");
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#monitor-a-component
*/
withMonitoring(Component: React.FunctionComponent | React.ComponentClass, name?: string): React.FunctionComponent | React.ComponentClass;
/**
* Reroutes to `Dynatrace.enterAutoAction`
*
* @deprecated Please use either {@link enterAutoAction}, which is doing the same or alternatively {@link enterManualAction}.
*/
enterAction(name: string, platform?: Platform): IDynatraceAction;
/**
* Creates an Action which will be automatically handled by the plugin. This means that the
* plugin decides about the hierarchy of this action. If there is no open action, the following
* action will be a root action. All other actions created by this method, while a root action
* is open, will be automatically inserted as a child action. Furthermore the plugin will automatically
* link webrequest (if they are not tagged manually) to the open root action.
*
* @param {string} name Name of the action, which will be created. This name must not be empty. (limited to 250 characters)
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
* @returns {IDynatraceAction} Action that is created. If name was empty a NullAction will be provided,
* which will act as normal action, but has no functionality.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* let myAction = Dynatrace.enterAutoAction("MyButton tapped");
* // Perform the action and whatever else is needed.
* myAction.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#create-custom-actions
*/
enterAutoAction(name: string, platform?: Platform): IDynatraceAction;
/**
* Creates an Action which will NOT be handled by the plugin. This means that you have full control
* about the hierarchy of your actions. This function will create a {@link IDynatraceRootAction} for you,
* which has the ability to create child actions via {@link IDynatraceRootAction.enterAction}. Be aware,
* because of the full manual approach the plugin will not link webrequest automatically. Webrequest
* have to be manually tagged by using the tag provided by the action via {@link IDynatraceAction.getRequestTag}.
*
* @param {string} name Name of the action, which will be created. This name must not be empty. (limited to 250 characters)
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
* @returns {IDynatraceRootAction} Action that is created. If name was empty a NullRootAction will be provided,
* which will act as normal root action, but has no functionality.
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* let myAction = Dynatrace.enterManualAction("MyButton tapped");
* // Perform the action and whatever else is needed.
* myAction.leaveAction();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#create-custom-actions
*/
enterManualAction(name: string, platform?: Platform): IDynatraceRootAction;
/**
* Similar to {@link IDynatraceAction.reportError}. But the error event is reported as root action.
*
* @param {string} errorName Name of the error event (limited to 250 characters)
* @param {number} errorCode The code of the error
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* Dynatrace.reportError("Page not found", 404);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-values
*/
reportError(errorName: string, errorCode: number, platform?: Platform): void;
/**
* Reports a stacktrace
*
* @deprecated Please use {@link reportErrorStacktrace} instead.
*
* @param {String} errorName Name of the Error - SyntaxError (limited to 250 characters)
* @param {String} reason Reason for the Error
* @param {String} stacktrace Whole Stacktrace
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*/
reportErrorWithStacktrace(errorName: string, reason: string, stacktrace: string, platform?: Platform): void;
/**
* Reports an error with its complete stacktrace to Dynatrace for monitoring and analysis.
* Use this method to capture and report errors with their full stack traces, typically within
* try-catch blocks to handle exceptions gracefully while maintaining observability.
*
* @param errorName Name or type of the error (e.g., 'DatabaseError', 'NetworkError'). Limited to 250 characters.
* @param errorValue The error message or value describing what went wrong
* @param reason Additional context explaining why the error occurred
* @param stacktrace The complete stack trace from the error. Use error.stack or provide a custom trace.
* @param platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* try {
* throw new Error('Database connection failed');
* } catch (error) {
* if (error instanceof Error) {
* Dynatrace.reportErrorStacktrace(
* 'DatabaseError',
* error.message,
* 'Failed to connect to remote database',
* error.stack || 'No stack trace available'
* );
* }
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-an-error-stacktrace
*/
reportErrorStacktrace(errorName: string, errorValue: string, reason: string, stacktrace: string, platform?: Platform): void;
/**
* Reports a custom crash event to Dynatrace for critical failures that cause app termination.
* Use this to manually report crashes with detailed stack traces when automatic crash detection
* is insufficient or when you need to report non-fatal errors as crashes for monitoring purposes.
*
* @param crashName Descriptive name for the crash (e.g., 'OutOfMemoryError', 'UnhandledException'). Limited to 250 characters.
* @param reason Brief explanation of why the crash occurred
* @param stacktrace Complete stack trace showing the call sequence leading to the crash
* @param platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* try {
* throw new Error('Fatal memory allocation failure');
* } catch (error) {
* if (error instanceof Error) {
* Dynatrace.reportCrash(
* 'MemoryError',
* error.message,
* error.stack || 'No stack trace available'
* );
* }
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manually-report-a-crash
*/
reportCrash(crashName: string, reason: string, stacktrace: string, platform?: Platform): void;
/**
* Reports a crash using a native JavaScript Error object to Dynatrace.
* This is a convenience method that automatically extracts the error message and stack trace
* from an Error object, making it easier to report crashes from caught exceptions.
*
* @param crashName Descriptive name for the crash (e.g., 'UnhandledPromiseRejection'). Limited to 250 characters.
* @param crash The Error object containing the stack trace and error details
* @param platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* try {
* throw new Error('Critical API endpoint unavailable');
* } catch (error) {
* if (error instanceof Error) {
* Dynatrace.reportCrashWithException('APIFailureCrash', error);
* }
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manually-report-a-crash
*/
reportCrashWithException(crashName: string, crash: Error): void;
/**
* Send a Business Event
*
* With sendBizEvent, you can report a business event. These standalone events are being sent
* detached from user actions or sessions.
*
* Note: The 'dt' key, as well as all 'dt.' prefixed keys are considered reserved by Dynatrace
* and will be stripped from the passed in attributes.
*
* Note: Business events are only supported on Dynatrace SaaS deployments currently.
*
* @param {string} type Mandatory event type
* @param {JSONObject} attributes Must be a valid JSON object and cannot contain functions,
* undefined, Infinity and NaN as values, otherwise they will be removed.
* Attributes need to be serializable using JSON.stringify.
* The resulting event will be populated with attributes parameter,
* and enriched with additional properties, thus also empty objects are valid.
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* Usage:
*
* ```ts
* import { Dynatrace, JSONObject } from '@dynatrace/react-native-plugin';
*
* Dynatrace.sendBizEvent('type', { custom : 123 });
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#business-event-capturing
*/
sendBizEvent(type: string, attributes?: JSONObject, platform?: Platform): void;
/**
* Can be called to end the current visit and start a new visit. All current actions are
* closed and sent to the server.
*
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* Dynatrace.endSession();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#end-the-current-user-session
*/
endSession(platform?: Platform): void;
/**
* The current visit/session will be tagged with the provided user id.
* The value will not be stored and has to be renewed for every new session.
*
* @param {string} user a unique id that allows you to identify the current user.
* If user is null or empty, then the user tag will be removed from the session. (limited to 250 characters)
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* Dynatrace.identifyUser('User');
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#identify-a-user
*/
identifyUser(user: string, platform?: Platform): void;
/**
* Saves the given GPS location for reporting along with the captured data.
*
* @param {Number} latitude latitude data of the position
* @param {Number} longitude longitude data of the position
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* Dynatrace.setGPSLocation(48.31518732698596, 14.305245274594471);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#report-gps-location
*/
setGPSLocation(latitude: number, longitude: number, platform?: Platform): void;
/**
* Tells you if you opted into crash reporting. If this value is false, which means off,
* the native agent will not report a single crash that is happening within the application.
* This method will always return true, when the user opt-in feature is not used.
*
* @deprecated Please use {@link getUserPrivacyOptions} to get the crash reporting opt-in value.
*
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
* @returns {Promise} Promise which resolves true if crash reporting is opted in.
*/
isCrashReportingOptedIn(platform?: Platform): Promise;
/**
* Allows the user to activate/deactivate crash reporting and stores the users decisions for future sessions.
* This method can only be used, when the configuration (dynatrace.config.js) for android or iOS is using the userOptIn mode.
*
* @deprecated Please use {@link applyUserPrivacyOptions} to set crash reporting opt-in.
*
* @param {boolean} crashReporting Pass true, if you want to enable crash reporting
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*/
setCrashReportingOptedIn(crashReporting: boolean, platform?: Platform): void;
/**
* Returns the current {@link DataCollectionLevel} which is used by the plugin. This method will always
* return {@link DataCollectionLevel.UserBehavior}, when the user opt-in feature is not used.
*
* @deprecated Please use {@link getUserPrivacyOptions} to get the current data collection level value.
*
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
* @returns promise which resolve a data collection level string
*/
getDataCollectionLevel(platform?: Platform): Promise;
/**
* Allows the user to set the {@link DataCollectionLevel} and stores the users decisions for future sessions.
* This method can only be used, when the configuration for android or iOS is using the userOptIn mode.
* When the user changes the {@link DataCollectionLevel} a new session will be started.
*
* @deprecated Please use {@link applyUserPrivacyOptions} to apply the current data collection level value.
*
* @param {DataCollectionLevel} dataCollectionLevel New data collection level
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*/
setDataCollectionLevel(dataCollectionLevel: DataCollectionLevel, platform?: Platform): void;
/**
* Get the current user privacy options including data collection level (Off, Performance, UserBehavior)
* and if crash reporting opt-in is enabled
*
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
* @returns {Promise} current user privacy options
*
* @example
* ```ts
* import { Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* let privacyOptions = await Dynatrace.getUserPrivacyOptions();
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
*/
getUserPrivacyOptions(platform?: Platform): Promise;
/**
* Creates a new session with the specified privacy settings and stores the privacy settings for future sessions.
* This method can only be used, when user opt-in feature is enabled. This method call has no effect,
* if the given privacy settings are identical to the previously specified privacy settings.
*
* @param {UserPrivacyOptions} userPrivacyOptions the new privacy settings from the user
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { DataCollectionLevel, Dynatrace, UserPrivacyOptions } from '@dynatrace/react-native-plugin';
*
* Dynatrace.applyUserPrivacyOptions(new UserPrivacyOptions(DataCollectionLevel.Performance, true));
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#user-privacy-options
*/
applyUserPrivacyOptions(userPrivacyOptions: UserPrivacyOptions, platform?: Platform): void;
/**
* Call this function to flush all collected events immediately. To reduce network chatter, the collected events are usually
* sent in packages where the oldest event has an age of up to 2 minutes (the default; the maximum age can be configured).
* Using this function, you can force sending of all collected events regardless of their age.
*
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* Dynatrace.flushEvents();
* ```
*
*/
flushEvents(platform?: Platform): void;
/**
* Puts a set of http headers on every agent http request (eg. the Authorization header). It also triggers the agent to
* reconnect to the beacon endpoint with the new headers. To clear the previous headers,
* call the method with a null or empty value.
*
* @param {Map} headers a set of http headers
* @param {Platform} platform Is optional, which means by default this call will be applied on both platforms (Android & iOS).
*
* @example
* ```ts
* import { Dynatrace } from '@dynatrace/react-native-plugin';
*
* const beaconHeaders = new Map();
* beaconHeaders.set('headerName', 'headerValue');
* Dynatrace.setBeaconHeaders(beaconHeaders);
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#setting-beacon-headers
*/
setBeaconHeaders(headers?: Map | null, platform?: Platform): void;
}
declare const Dynatrace: IDynatrace;
/**
* Manual startup configuration which is used for Dynatrace.start()
* @deprecated Use ConfigurationBuilder and IConfiguration instead
*/
declare class ManualStartupConfiguration implements IConfiguration {
readonly beaconUrl: string;
readonly applicationId: string;
readonly logLevel: LogLevel;
readonly lifecycleUpdate: boolean;
readonly actionNamePrivacy: boolean;
readonly actionNamePreference: ActionNamePreference;
readonly actionNameAlgorithm: ActionNameAlgorithm;
readonly bundleName?: string;
readonly errorHandler: boolean;
readonly reportFatalErrorAsCrash: boolean;
readonly reportCrash: boolean;
readonly userOptIn: boolean;
readonly bundleVersion?: string;
/**
* Creates a Manual Startup configuration instance
*
* @param {string} beaconUrl Identifies your environment within Dynatrace. This property is mandatory for manual startup
* @param {string} applicationId Identifies your mobile app. This property is mandatory for manual startup
* @param {boolean} reportCrash Allows reporting React Native crashes.
* @param {LogLevel} logLevel Allows you to choose between `LogLevel.Info` and `LogLevel.Debug`. Debug returns more logs. This is especially important when something is not functioning correctly.
* @param {boolean} lifecycleUpdate Decide if you want to see update cycles on lifecycle actions as well. This is per default false as it creates a lot more actions.
* @param {boolean} userOptIn Activates the privacy mode when set to `true`. User consent must be queried and set.
* @param {boolean} actionNamePrivacy Activates a privacy mode especially for Touchables and Buttons. Setting this option to true means that a name for the control will no longer be shown, e.g. "Touch on Button". When setting a dtActionName onto the component this setting will be ignored.
* @param {string} bundleName Will define the bundle name which will prefix internal action ids.
* @param {string} bundleVersion Will define the bundle version which will extend bundleName signature.
*
* @deprecated Use ConfigurationBuilder and IConfiguration instead
*/
constructor(beaconUrl: string, applicationId: string, reportCrash?: boolean, logLevel?: LogLevel, lifecycleUpdate?: boolean, userOptIn?: boolean, actionNamePrivacy?: boolean, actionNamePreference?: ActionNamePreference, actionNameAlgorithm?: ActionNameAlgorithm, bundleName?: string, bundleVersion?: string);
toString(): string;
}
/**
* Builder for manual startup configuration used with `Dynatrace.start()`.
*/
declare class ConfigurationBuilder {
private beaconUrl;
private applicationId;
private reportCrash;
private errorHandler;
private reportFatalErrorAsCrash;
private logLevel;
private lifecycleUpdate;
private userOptIn;
private actionNamePrivacy;
private actionNamePreference;
private actionNameAlgorithm;
private bundleName;
private bundleVersion;
private autoStartup;
/**
* Creates a builder for manual startup configuration.
*
* @param {string} beaconUrl The beacon URL that identifies your Dynatrace environment. Mandatory for manual startup.
* @param {string} applicationId The application ID that identifies your mobile app. Mandatory for manual startup.
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const configurationBuilder = new ConfigurationBuilder("beaconUrl", "applicationId");
* Dynatrace.start(configurationBuilder.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
constructor(beaconUrl: string, applicationId: string);
/**
* Configures crash reporting. Defaults to `true`.
*
* @param {boolean} reportCrash Set to `true` to enable React Native crash reporting, `false` to disable it.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withCrashReporting(false); // Disable crash reporting
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withCrashReporting(reportCrash: boolean): this;
/**
* Configures the React Native error handler. Defaults to `true`.
*
* @param {boolean} errorHandler Set to `true` to enable the Dynatrace React Native error handler, `false` to disable it.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withErrorHandler(false); // Disable error handler
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withErrorHandler(errorHandler: boolean): this;
/**
* Configures how fatal errors are reported. Defaults to `true`.
*
* @param {boolean} reportFatalErrorAsCrash Set to `true` to report fatal errors as crashes (ends session),
* `false` to report them as errors (session continues).
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withReportFatalErrorAsCrash(false); // Report as errors, not crashes
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withReportFatalErrorAsCrash(reportFatalErrorAsCrash: boolean): this;
/**
* Configures the log level for the Dynatrace plugin. Defaults to `LogLevel.Info`.
*
* @param {LogLevel} logLevel The log level to use. Choose `LogLevel.Debug` for verbose logging when troubleshooting,
* or `LogLevel.Info` for standard operation.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace, LogLevel } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withLogLevel(LogLevel.Debug); // Enable debug logging
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withLogLevel(logLevel: LogLevel): this;
/**
* Configures tracking of component update cycles in lifecycle actions. Defaults to `false`.
*
* @param {boolean} lifecycleUpdate Set to `true` to track component update cycles.
* **Warning:** This generates significantly more monitoring data.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withLifecycleUpdate(true); // Enable lifecycle updates
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withLifecycleUpdate(lifecycleUpdate: boolean): this;
/**
* Configures privacy mode and user opt-in. Defaults to `false`.
*
* @param {boolean} userOptIn Set to `true` to activate privacy mode. User consent must be queried separately
* and configured using `Dynatrace.applyUserPrivacyOptions(userPrivacyOptions)`.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withUserOptIn(true); // Enable privacy mode
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withUserOptIn(userOptIn: boolean): this;
/**
* Configures action name privacy for Touchables and Buttons. Defaults to `false`.
*
* @param {boolean} actionNamePrivacy Set to `true` to hide specific control names and replace them with
* generic component types (e.g., "Touch on Login" becomes "Touch on Button").
* **Note:** This setting is ignored when a `dtActionName` prop is explicitly set on the component.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withActionNamePrivacy(true); // Enable action name privacy
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withActionNamePrivacy(actionNamePrivacy: boolean): this;
/**
* Configures the preferred child element type for resolving `onPress` action names. Defaults to `'any'`.
*
* @param {ActionNamePreference} actionNamePreference The preferred child element type.
* - `'text'`: Prefers text content and falls back to any match.
* - `'icon'`: Prefers `ReactNative.Image` or custom Icons and falls back to any match.
* - `'any'`: Accepts the first match regardless of type (text, image, or icon).
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withActionNamePreference('text'); // Prioritize text labels for action names
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#how-does-dynatrace-determine-the-user-action-name
*/
withActionNamePreference(actionNamePreference: ActionNamePreference): this;
/**
* Configures the traversal algorithm for searching the component tree for `onPress` action names.
* Defaults to `'depth-first'`.
*
* @param {ActionNameAlgorithm} actionNameAlgorithm The traversal algorithm to use.
* - `'depth-first'`: Follows the first child branch fully before trying siblings.
* - `'breadth-first'`: Visits all siblings at a level before going deeper, returning the shallowest match first.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withActionNameAlgorithm('breadth-first'); // Prioritize shallowest matches in the component tree
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#how-does-dynatrace-determine-the-user-action-name
*/
withActionNameAlgorithm(actionNameAlgorithm: ActionNameAlgorithm): this;
/**
* Configures the bundle name used as a prefix for internal action IDs.
*
* @param {string} bundleName The bundle name to use as a prefix for action IDs.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withBundleName('myapp.bundle');
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withBundleName(bundleName: string): this;
/**
* Configures the bundle version for events. This is mandatory for proper crash reporting.
*
* @param {string} bundleVersion The bundle version to use.
* **Important:** Without a bundle version, source map symbolication will not work for crash reports.
* @returns {ConfigurationBuilder} The builder instance for method chaining
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withBundleVersion('1.0.0');
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
withBundleVersion(bundleVersion: string): this;
/**
* Builds the configuration object for Dynatrace agent startup.
*
* @returns {IConfiguration} The built configuration object
* @throws {Error} If beaconUrl or applicationId is empty during manual startup
*
* @example
* ```ts
* import { ConfigurationBuilder, Dynatrace, LogLevel } from '@dynatrace/react-native-plugin';
*
* const config = new ConfigurationBuilder('beaconUrl', 'applicationId')
* .withLogLevel(LogLevel.Debug)
* .withCrashReporting(true);
* await Dynatrace.start(config.buildConfiguration());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#plugin-startup
*/
buildConfiguration(): IConfiguration;
}
/**
* Interface for manually measuring web request timing and performance metrics.
* Use this to track custom HTTP requests that are not automatically instrumented.
*/
interface IDynatraceWebRequestTiming {
/**
* Starts the measurement of the web request timing. Call this method immediately before
* initiating the HTTP request.
*
* @example
* ```ts
* import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterManualAction('API Data Fetch');
* const url = 'https://api.example.com/data';
* const tag = await action.getRequestTag(url);
* const timing = new DynatraceWebRequestTiming(url, tag);
*
* try {
* timing.startWebRequestTiming();
* const response = await fetch(url, {
* headers: {
* [timing.getRequestTagHeader()]: tag
* }
* });
* const data = await response.text();
* timing.stopWebRequestTiming(response.status, data);
* } catch (error) {
* if (error instanceof Error) {
* timing.stopWebRequestTiming(-1, error.message);
* } else {
* timing.stopWebRequestTiming(-1, (error as any).toString());
* }
* } finally {
* action.leaveAction();
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
startWebRequestTiming(): void;
/**
* Stops the measurement of the web request timing. Call this method after the request
* completes (either successfully or with an error). The response code and message will be
* transferred to Dynatrace and displayed in the web UI.
*
* @param {number} responseCode HTTP status code of the response (e.g., 200, 404, 500)
* @param {string} responseMessage Response message or error description
*
* @example
* ```ts
* import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterManualAction('API Data Fetch');
* const url = 'https://api.example.com/data';
* const tag = await action.getRequestTag(url);
* const timing = new DynatraceWebRequestTiming(url, tag);
*
* try {
* timing.startWebRequestTiming();
* const response = await fetch(url, {
* headers: {
* [timing.getRequestTagHeader()]: tag
* }
* });
* timing.stopWebRequestTiming(response.status, response.statusText);
* } catch (error) {
* if (error instanceof Error) {
* timing.stopWebRequestTiming(-1, error.message);
* } else {
* timing.stopWebRequestTiming(-1, (error as any).toString());
* }
* } finally {
* action.leaveAction();
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
stopWebRequestTiming(responseCode: number, responseMessage: string): void;
/**
* Stops the measurement of the web request timing with additional size information. Call this
* method after the request completes to track both timing and payload sizes. The response code,
* message, and size metrics will be transferred to Dynatrace and displayed in the web UI.
*
* @param {number} responseCode HTTP status code of the response (e.g., 200, 404, 500)
* @param {string} responseMessage Response message or error description
* @param {number} requestSize Size of the request payload in bytes
* @param {number} responseSize Size of the response payload in bytes
*
* @example
* ```ts
* import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterManualAction('API Data Upload');
* const url = 'https://api.example.com/upload';
* const tag = await action.getRequestTag(url);
* const timing = new DynatraceWebRequestTiming(url, tag);
* const requestData = JSON.stringify({ key: 'value' });
*
* try {
* timing.startWebRequestTiming();
* const response = await fetch(url, {
* method: 'POST',
* headers: {
* [timing.getRequestTagHeader()]: tag,
* 'Content-Type': 'application/json'
* },
* body: requestData
* });
* const responseData = await response.text();
* timing.stopWebRequestTimingWithSize(
* response.status,
* response.statusText,
* requestData.length,
* responseData.length
* );
* } catch (error) {
* if (error instanceof Error) {
* timing.stopWebRequestTiming(-1, error.message);
* } else {
* timing.stopWebRequestTiming(-1, (error as any).toString());
* }
* } finally {
* action.leaveAction();
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
stopWebRequestTimingWithSize(responseCode: number, responseMessage: string, requestSize: number, responseSize: number): void;
/**
* Generates a unique x-dynatrace header for the web request with a specified url,
* which has to be manually added as http header.
*
* This is the same tag that was provided when constructing the DynatraceWebRequestTiming instance.
* The header key can be obtained with the method getRequestTagHeader.
*
* The string value can be empty in cases when the agent is not able to send data, the agent is turned off completly,
* has not started yet or is not allowed to track web requests because of privacy reasons.
* The tag value is evaluated by the corresponding web server agent.
* The Dynatrace server will link the server-side PurePath data with this mobile user action.
*
* @returns {string} The request tag value to be used as the HTTP header value
*
* @example
* ```ts
* import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterManualAction('Manual Web Request');
* const url = 'https://api.example.com/data';
* const tag = await action.getRequestTag(url);
* const timing = new DynatraceWebRequestTiming(url, tag);
*
* // Retrieve the tag value (same as the one used during construction)
* console.log(timing.getRequestTag());
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
getRequestTag(): string;
/**
* Returns the HTTP header name required for request tagging. Use this header name in
* combination with `getRequestTag()` to properly tag HTTP requests for tracking.
*
* @returns {string} The name of the HTTP header to use for request tagging
*
* @example
* ```ts
* import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin';
*
* const action = Dynatrace.enterManualAction('Manual Web Request');
* const url = 'https://api.example.com/data';
* const tag = await action.getRequestTag(url);
* const timing = new DynatraceWebRequestTiming(url, tag);
*
* // Get the header name to use in HTTP requests
* const headerName = timing.getRequestTagHeader();
* console.log(headerName); // typically outputs: 'x-dynatrace'
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
getRequestTagHeader(): string;
}
/**
* Class which gives you the option to measure a web request
*/
declare class DynatraceWebRequestTiming implements IDynatraceWebRequestTiming {
/**
* The request which should be used for tagging
*/
private readonly requestTag;
/**
* The URL of the request that is timed
*/
private readonly url;
/**
* Constructor for creating a DynatraceWebRequestTiming
*
* @param {string} requestTag Request Tag for the action to be linked to
* @param {string} url URL that should be linked
*
* Usage (with Axios example):
*
* ```ts
* import { Dynatrace, DynatraceWebRequestTiming } from '@dynatrace/react-native-plugin'
*
* const action = Dynatrace.enterManualAction("Manual Web Request");
* const tag = await action.getRequestTag(url);
* const timing = new DynatraceWebRequestTiming(url, tag);
*
* try {
* timing.startWebRequestTiming();
* const axiosResponse = await axios.get(url, {
* headers: {
* timing.getRequestTagHeader(): tag
* }
* });
* timing.stopWebRequestTiming(axiosResponse.status, axiosResponse.data);
* } catch (error) {
* timing.stopWebRequestTiming(-1, error);
* } finally {
* action.leaveAction();
* }
* ```
*
* @see https://www.npmjs.com/package/@dynatrace/react-native-plugin#manual-web-request-tagging
*/
constructor(requestTag: string, url: string);
startWebRequestTiming(): void;
stopWebRequestTiming(responseCode: number, responseMessage: string): void;
stopWebRequestTimingWithSize(responseCode: number, responseMessage: string, requestSize: number, responseSize: number): void;
getRequestTag(): string;
getRequestTagHeader(): string;
}
declare module 'react' {
namespace JSX {
interface IntrinsicAttributes extends IDynatraceProperties {
}
}
}
export { ConfigurationBuilder, DataCollectionLevel, Dynatrace, DynatraceWebRequestTiming, EventData, ExceptionEventData, HttpRequestEventData, LogLevel, ManualStartupConfiguration, Platform, SessionPropertyEventData, UserPrivacyOptions };
export type { IConfiguration, IDynatraceAction, IDynatraceRootAction, IDynatraceWebRequestTiming, IEventModifier, JSONObject };