Instrument Your Application Code

In the index.js file of your React application:

  1. At the top of the file near the other import statements, add the following line of code to import the agent:
     import {Instrumentation} from '@appdynamics/react-native-agent';
    1. In the same file and in the global scope, initialize the instrumentation with the following, making sure to replace <EUM_APP_KEY> with a string containing your EUM App Key.
      Instrumentation.start({
          appKey: <EUM_APP_KEY>,
      }); 
      Note: Whenever possible, we recommend you call Instrumentation.startin a context that permits awaiting for this async call and even enabling verbose logging for better debugging:
      async function startInstrumentation() {
        await Instrumentation.start({
          appKey: <EUM_APP_KEY>,
          loggingLevel: LoggingLevel.VERBOSE
        });
      }
  2. Verify that your index.js file looks similar to the following:
    import App from './src/App';
    import {AppRegistry} from 'react-native';
    import {name as appName} from './app.json';
    
    import {Instrumentation} from '@appdynamics/react-native-agent';  
    
    Instrumentation.start({
        appKey: 'YOUR-APP-KEY',
    });
    
    AppRegistry.registerComponent(appName, () => App);
  3. (For older React Native setup builds) If you have use_frameworks! defined in your ios/Podfile, we recommend adding the following:
    $ toggleADEUMRNStaticFramework = true