Integration and Configuration
    • 1 Minute to read
    • Dark
      Light

    Integration and Configuration

    • Dark
      Light

    Article summary

    This section describes the installation and initialization of the React Native Software Development Kit and covers global and advanced configurations.

    A) Installation

    To install the Mapp Intelligence plugin for the React Native application, run the following command in the terminal from the application root directory:

    Using npm:

    npm install mapp-intelligence-reactnative-plugin --save

    Using Yarn:

    yarn add mapp-intelligence-reactnative-plugin

    For iOS, you also need to install CocoaPods:

    pod install

    B) Initialization and Usage

    After installing the plugin, configure and initialize it at the application start:

    import MappIntelligence, { LogLevel, ExceptionType } from 'react-native-mappinteligence-plugin';
    
    // Required: Disable anonymous tracking
    await MappIntelligencePlugin.setAnonymousTracking(false);
    
    // Required: Initialize with configuration
    await MappIntelligencePlugin.initWithConfiguration(
       [TRACK_IDS],
       TRACK_DOMAIN
    );
    
    // Optional: Set various configuration options
    await MappIntelligencePlugin.setLogLevel(LogLevel.all);
    await MappIntelligencePlugin.setBatchSupportEnabled(false);
    await MappIntelligencePlugin.setBatchSupportSize(150);
    await MappIntelligencePlugin.setRequestInterval(1);
    await MappIntelligencePlugin.setRequestPerQueue(300);
    await MappIntelligencePlugin.setSendAppVersionInEveryRequest(true);
    await MappIntelligencePlugin.setEnableBackgroundSendout(true);
    await MappIntelligencePlugin.setExceptionLogLevel(ExceptionType.all);
    await MappIntelligencePlugin.setEnableUserMatching(false);
    
    // Required: Build the configuration
    await MappIntelligencePlugin.build();

    C) Track Uncaught Exceptions

    To set up a global error handler in a React Native application using the Mapp Intelligence plugin, follow these steps:

    1. Import Required Functions: Import the necessary functions from the MappIntelligence plugin.

      import { setGlobalErrorHandler } from 'mapp-intelligence-reactnative-plugin';

    2. Define Error Handling Function (optional): Define a function to handle errors. This function will display an alert with information about the error.

      const showError = (error: Error, isFatal: boolean) => {
        Alert.alert(
          'Unexpected error occurred',
          `Error: ${isFatal ? 'Fatal:' : ''} ${error.name} ${error.message}
      
          We have reported this to our team! Please close the app and start again!`,
          [
            {
              text: 'Close',
              onPress: () => {
                // Optionally, you can close or restart the app
              },
            },
          ]
        );
      };

    3. Set Global Error Handler: Use the setGlobalErrorHandler function to set the global error handler. Pass the error handling function defined in the previous step.

      setGlobalErrorHandler((error: Error, isFatal: boolean) => {
        showError(error, isFatal);
      });

    4. Register Component: Finally, register your main application component with AppRegistry.

      AppRegistry.registerComponent(appName, () => App);

    Supported Characters and Coding Formats

    Mapp Intelligence supports the UTF-8 standard.

    • A request may not be larger than 7KB.

    • Input is case-sensitive.

    Parameters can have the data type text or figure.

    • Text parameters support a maximum of 255 characters. If a parameter is configured to capture multiple values simultaneously, then each single value of the parameter can consist of up to 255 characters. Each of these scalar values is stored in the database as one parameter.

    • Figure parameters support a range of decimal(12,2). That means ten digits with two decimal places (range: -9999999999.99 to 9999999999.99).


    Was this article helpful?

    What's Next