Functions

Prev Next

Initialization

initWithConfiguration

Description: Initializes the plugin with a provided array of Track ID and a Track Domain.

Parameters:

  • trackIDs (number[]): An array of track IDs.

  • domain (string): The tracking domain URL.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

const trackIDs = [12345, 67890];
const domain = 'https://example.com';

initWithConfiguration(trackIDs, domain)
  .then(result => {
    console.log('Initialization result:', result);
  })
  .catch(error => {
    console.error('Initialization error:', error);
  });

Configuration

Log Level

setLogLevel

Description: Sets the log level to define what will be logged to the console.

Parameters:

Returns: A Promise<number> that resolves with a result indicating whether the method was executed successfully.

Usage Example:

import { setLogLevel, LogLevel } from 'mapp-intelligence-reactnative-plugin';

setLogLevel(LogLevel.debug)
  .then(result => {
    console.log('Log level set:', result);
  })
  .catch(error => {
    console.error('Error setting log level:', error);
  });

Request Interval

setRequestInterval

Description: Sets the interval in minutes for the periodic job to execute and send tracked requests to the server.

Parameters:

  • interval (number): The interval in minutes. The minimum is 15, limited by Android specification for a worker.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setRequestInterval(30)
  .then(result => {
    console.log('Request interval set:', result);
  })
  .catch(error => {
    console.error('Error setting request interval:', error);
  });

Batch Support

Enable Batch Support

setBatchSupportEnabled

Description: Enables or disables batch support for sending requests.

Parameters:

  • enabled (boolean): Specify if the batch is enabled or disabled.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setBatchSupportEnabled(true)
  .then(result => {
    console.log('Batch support enabled:', result);
  })
  .catch(error => {
    console.error('Error enabling batch support:', error);
  });

Set Batch Size

setBatchSupportSize

Description: Sets the number of track records to send in a single batch request.

Parameters:

  • size (number): The number of track records.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setBatchSupportSize(50)
  .then(result => {
    console.log('Batch support size set:', result);
  })
  .catch(error => {
    console.error('Error setting batch support size:', error);
  });

Track Exception

setExceptionLogLevel

Description: Sets the exception log level.

Parameters:

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

import { setExceptionLogLevel, ExceptionType } from 'mapp-intelligence-reactnative-plugin';

setExceptionLogLevel(ExceptionType.uncaught)
  .then(result => {
    console.log('Exception log level set:', result);
  })
  .catch(error => {
    console.error('Error setting exception log level:', error);
  });

Request Queue

setRequestPerQueue

Description: Requests are buffered in a queue before sending. This option sets the size of the queue.

Parameters:

  • numberOfRequests (number): The size of the queue for buffering requests.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setRequestPerQueue(100)
  .then(result => {
    console.log('Request per queue set:', result);
  })
  .catch(error => {
    console.error('Error setting request per queue:', error);
  });

Send App Version in Every Request

setSendAppVersionInEveryRequest

Description: Send the application version as a parameter in every request.

Parameters:

  • flag (boolean): True to set sending the application version in every request; otherwise false.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setSendAppVersionInEveryRequest(true)
  .then(result => {
    console.log('App version will be sent in every request:', result);
  })
  .catch(error => {
    console.error('Error setting app version in every request:', error);
  });

User Matching

setEnableUserMatching

Description: Enables or disables user matching between Engage and Intelligence systems.

Parameters:

  • enabled (boolean): True to enable user matching; false to disable it.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setEnableUserMatching(true)
  .then(result => {
    console.log('User matching enabled:', result);
  })
  .catch(error => {
    console.error('Error enabling user matching:', error);
  });

Set Ever ID

setEverId

Description: Sets a unique everId as an identifier for a single device/user.

Parameters:

  • everId (string | null): Unique identifier in the tracking system.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setEverId('unique-ever-id')
  .then(result => {
    console.log('EverId set:', result);
  })
  .catch(error => {
    console.error('Error setting EverId:', error);
  });

Enable Background Sendout

This method is only available in iOS.

setEnableBackgroundSendout

Description: Enables sending data while the application is in a background state.

Parameters:

  • enabled (boolean): Specify if background sendout is enabled or disabled.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setEnableBackgroundSendout(true)
  .then(result => {
    console.log('Background sendout enabled:', result);
  })
  .catch(error => {
    console.error('Error enabling background sendout:', error);
  });

Build Plugin

build

Description: Builds the plugin with a provided configuration. After this method finishes, the plugin is ready for use.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

build()
  .then(result => {
    console.log('Build result:', result);
  })
  .catch(error => {
    console.error('Build error:', error);
  });

setAnonymousTracking

Description: Based on the result of the user's consent to allow personalized tracking or not, enable anonymous tracking when no consent is given. If enabled, everId will be deleted (and not generated until anonymous tracking is disabled).

Please note that this will decrease data quality significantly and we do not recommend this unless required by your data compliance manager. Find more information here: What is Anonymized (aka Cookieless) Tracking?


Parameters:

  • anonymous (boolean): True to enable anonymous tracking; false to disable it.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setAnonymousTracking(true)
  .then(result => {
    console.log('Anonymous tracking enabled:', result);
  })
  .catch(error => {
    console.error('Error enabling anonymous tracking:', error);
  });

setTemporarySessionId

Description: Temporary sessionId is used when anonymous tracking is enabled to provide anonymous tracking of a single session.

Parameters:

  • sessionId (string | null): Unique session identifier.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

setTemporarySessionId('temp-session-id')
  .then(result => {
    console.log('Temporary sessionId set:', result);
  })
  .catch(error => {
    console.error('Error setting temporary sessionId:', error);
  });

Tracking Functions

Track Page

Standard Page Tracking

trackPage

Description: Tracks a single page by its page name.

Parameters:

  • pageTitle (string): The page name for tracking.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

trackPage('HomePage')
  .then(result => {
    console.log('Page tracked:', result);
  })
  .catch(error => {
    console.error('Error tracking page:', error);
  });

Custom Page Tracking

trackCustomPage

Description: Detailed page tracking with additional parameters that can be set to track.

Parameters:

  • pageTitle (string): Name of the page.

  • pageParameters (PageParameters | null): Parameters for the page.

  • sessionParameters (SessionParameters | null): Parameters for the current session.

  • userCategories (UserCategories | null): Predefined user categories.

  • ecommerceParameters (EcommerceParameters | null): Predefined eCommerce parameters.

  • campaignParameters (CampaignParameters | null): Predefined campaign parameters.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

import { trackCustomPage, PageParameters, SessionParameters, UserCategories, EcommerceParameters, CampaignParameters } from 'mapp-intelligence-reactnative-plugin';

const pageParameters: PageParameters = { /* page parameters */ };
const sessionParameters: SessionParameters = { /* session parameters */ };
const userCategories: UserCategories = { /* user categories */ };
const ecommerceParameters: EcommerceParameters = { /* eCommerce parameters */ };
const campaignParameters: CampaignParameters = { /* campaign parameters */ };
const pageName = /* PAGE NAME */;

trackCustomPage(pageName, pageParameters, sessionParameters, userCategories, ecommerceParameters, campaignParameters)
  .then(result => {
    console.log('Custom page tracked:', result);
  })
  .catch(error => {
    console.error('Error tracking custom page:', error);
  });

Track Page with Custom Data

trackPageWithCustomData

Description: Custom page tracking with the option to track some custom parameters.

Parameters:

  • pageTitle (string): Name of the page.

  • pageParameters (Map<string, string> | null): Custom parameters that can be tracked.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

const pageParameters = new Map<string, string>([
  ['param1', 'value1'],
  ['param2', 'value2']
]);

trackPageWithCustomData('CustomPage', pageParameters)
  .then(result => {
    console.log('Page with custom data tracked:', result);
  })
  .catch(error => {
    console.error('Error tracking page with custom data:', error);
  });

Event Tracking

trackAction

Description: Tracks user action.

Parameters:

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

import { trackAction, EventParameters, SessionParameters, UserCategories, EcommerceParameters, CampaignParameters } from 'mapp-intelligence-reactnative-plugin';

const eventParameters: EventParameters = { /* event parameters */ };
const sessionParameters: SessionParameters = { /* session parameters */ };
const userCategories: UserCategories = { /* user categories */ };
const ecommerceParameters: EcommerceParameters = { /* eCommerce parameters */ };
const campaignParameters: CampaignParameters = { /* campaign parameters */ };

trackAction('ButtonClick', eventParameters, sessionParameters, userCategories, ecommerceParameters, campaignParameters)
  .then(result => {
    console.log('Action tracked:', result);
  })
  .catch(error => {
    console.error('Error tracking action:', error);
  });

Deep Link Tracking

trackUrl

Description: Tracks URLs with included deep links and media parameters.

Parameters:

  • url (string): Single URL that can contain some query parameters for tracking.

  • mediaCode (string | null): Media code to track.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

trackUrl('https://example.com', 'media123')
  .then(result => {
    console.log('URL tracked:', result);
  })
  .catch(error => {
    console.error('Error tracking URL:', error);
  });

Media Tracking

trackMedia

Description: Tracks video or audio events such as starting, playing, pausing/stopping, and ending of playback.

Parameters:

  • mediaEvent (MediaEvent): Predefined events to track.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

import { trackMedia, MediaEvent } from 'mapp-intelligence-reactnative-plugin';

const mediaEvent: MediaEvent = { /* media event details */ };

trackMedia(mediaEvent)
  .then(result => {
    console.log('Media event tracked:', result);
  })
  .catch(error => {
    console.error('Error tracking media event:', error);
  });

Exception Tracking

Handled Exceptions without Specific Name

trackException

Description: Records data about handled exceptions.

Parameters:

  • e (Error): Caught exception.

  • stackTrace (string | null): Stack trace of the caught exception.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

try {
  // Some code that may throw an exception
} catch (error) {
  trackException(error)
    .then(result => {
      console.log('Exception tracked:', result);
    })
    .catch(trackError => {
      console.error('Error tracking exception:', trackError);
    });
}

Handled Exception with Specified Name

trackExceptionWithName

Description: Records data about handled exceptions with a specified name.

Parameters:

  • name (string): Name or type of the exception if it can be obtained.

  • message (string): Message of the current caught exception.

  • stackTrace (string | null): Stack trace of the caught exception.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

trackExceptionWithName('TypeError', 'An unexpected type error occurred.')
  .then(result => {
    console.log('Exception with name tracked:', result);
  })
  .catch(error => {
    console.error('Error tracking exception with name:', error);
  });

Enable/Disable Tracking

OptOut

optOut

Description: In some cases, it is necessary to exclude users completely from tracking. For this purpose, the SDK provides an opt-out option. Internally, calling this method will delete all current tracking data cached in the database (if sendCurrentData is set to false), cancel the sending of requests, terminate the WorkManager, and disable all incoming tracking requests.

Parameters:

  • sendData (boolean): true to send recorded data before opting out.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

optOut(true)
  .then(result => {
    console.log('Opted out of tracking:', result);
  })
  .catch(error => {
    console.error('Error opting out of tracking:', error);
  });

OptIn

optIn

Description: Disables opt-out and resets tracking to enabled.

Parameters:

  • sendData (boolean): true to send recorded data before opting in.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

optIn(true)
  .then(result => {
    console.log('Opted in to tracking:', result);
  })
  .catch(error => {
    console.error('Error opting in to tracking:', error);
  });

Helper Function / Utils

Send Request

sendRequestsAndClean

Description: When called, data will be immediately sent. The request will then be deleted from the database, cleaning it. Please note that the application must be initialized for this method to work.

Parameters: None.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

sendRequestsAndClean()
  .then(result => {
    console.log('Requests sent and cleaned:', result);
  })
  .catch(error => {
    console.error('Error sending requests and cleaning:', error);
  });

Print Currently Used Configuration

printCurrentConfig

Description: Retrieves the current configuration of the MappIntelligence plugin and returns it as a string representation.

Parameters: None.

Returns: A Promise<string> that resolves with the string representation of the current configuration.

Usage Example:

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

printCurrentConfig()
  .then(configString => {
    console.log('Current Configuration:', configString);
  })
  .catch(error => {
    console.error('Error retrieving current configuration:', error);
  });

Initialisation Check

isInitialized

Description: Checks if the plugin is initialized and ready to use.

Parameters: None.

Returns: A Promise<boolean> that resolves with true if the plugin is ready to use; false otherwise.

Usage Example:

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

isInitialized()
  .then(initialized => {
    console.log('Plugin initialized:', initialized);
  })
  .catch(error => {
    console.error('Error checking initialization:', error);
  });

Reset

reset

Description: Resets all Mapp configurations. After this, a new initialization with settings must be called before using the plugin.

Parameters: None.

Returns: A Promise<number> that resolves with a result indicating if the method was executed successfully or not.

Usage Example:

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

reset()
  .then(result => {
    console.log('Configuration reset:', result);
  })
  .catch(error => {
    console.error('Error resetting configuration:', error);
  });

Get EverID

getEverId

Description: Returns the current EverID of a device.

Parameters: None.

Returns: A Promise<string> that resolves with the current EverId.

Usage Example:

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

getEverId()
  .then(everId => {
    console.log('Current EverId:', everId);
  })
  .catch(error => {
    console.error('Error getting EverId:', error);
  });