import InstrumentationModule from '../../native/InstrumentationModule'; import {version} from '../../../package.json'; import type {AgentConfiguration} from '../objects/AgentConfiguration'; /** * Initialize the agent with a given {@link AgentConfiguration}. * * The agent does not automatically start with your application. Using the app * key shown in your controller UI, you can initialize the agent. This has to be * done near your application's entry point before any other initialization * routines in your application (usually in `App`). * * ```tsx * import React, {useEffect} from 'react'; * import {Text, View} from 'react-native'; * import {Instrumentation, LoggingLevel} from '@appdynamics/react-native-agent'; * * export default function App() { * async function startInstrumentation() { * await Instrumentation.start({ * appKey: '', * loggingLevel: LoggingLevel.VERBOSE, * }); * } * * useEffect(() => { * startInstrumentation; * }, []); * * return ( * * My App * * ); * } * ``` * * @param {AgentConfiguration} config The agent configuration to use. */ async function start(config: AgentConfiguration): Promise { const {crashReportCallback} = config; if (crashReportCallback) { await InstrumentationModule.setCrashReportCallback( crashReportCallback, ); } await InstrumentationModule.start(config, 'React Native', version); } export default start;