import InstrumentationModule from '../../native/InstrumentationModule';
interface UIEventInfo {
/** Name of the current screen */
screenName: string;
/** Name of the action, e.g. "Button Pressed", "Text View Unfocused" */
eventName: string;
/** Class of the UI element, e.g. TouchableOpacity */
className: string;
/** Tag value for the component. */
tag?: number;
/** The title of a component. */
label?: string;
/** The accessibility label of the component. */
accessibilityLabel?: string;
/** Index in a FlatList. */
index?: string;
/** Name of the method called onPress. */
uiResponder?: string;
}
/**
* Manually tracks UI events (button taps, TextView focused etc.).
*
* ```ts
* import { Instrumentation } from "@appdynamics/react-native-agent";
* import React, { View, Text, TouchableOpacity } from "react";
*
* function LoginScreen() {
* async function login() {
* try {
* await Instrumentation.trackUIEvent({
* screenName: "LoginScreen",
* eventName: "Login button press",
* className: "TouchableOpacity",
* label: "Proceed with login",
* accessibilityLabel: "loginButton",
* uiResponder: "loginCustomer",
* });
*
* // customer login logic
* } catch (error) {
* // handle exception
* }
* }
*
* return (
*
*
* Proceed with login
*
*
* );
* }
* ```
*
* @param {UIEventInfo} eventInfo Info regarding the event to be tracked.
*/
async function trackUIEvent(eventInfo: UIEventInfo): Promise {
await InstrumentationModule.trackUIEvent(eventInfo);
}
export {trackUIEvent, type UIEventInfo};