React Native plugin for Application Insights JavaScript SDK
The React Native plugin for Application Insights JavaScript SDK collects device information, by default this plugin automatically collects:
- Unique Device ID (Also known as Installation ID.)
- Device Model Name (Such as iPhone X, Samsung Galaxy Fold, Huawei P30 Pro etc.)
- Device Type (For example, handset, tablet, etc.)
Requirements
You must be using a version >= 2.0.0 of @microsoft/applicationinsights-web
. This plugin will only work in react-native apps. It will not work with apps using the Expo framework, therefore it will not work with Create React Native App.
Getting started
Install and link the react-native-device-info package. Keep the react-native-device-info
package up to date to collect the latest device names using your app.
npm install --save @microsoft/applicationinsights-react-native @microsoft/applicationinsights-web
npm install --save react-native-device-info
react-native link react-native-device-info
Initializing the plugin
To use this plugin, you need to construct the plugin and add it as an extension
to your existing Application Insights instance.
Note
On March 31, 2025, support for instrumentation key ingestion will end. Instrumentation key ingestion will continue to work, but we'll no longer provide updates or support for the feature. Transition to connection strings to take advantage of new capabilities.
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
import { ReactNativePlugin } from '@microsoft/applicationinsights-react-native';
var RNPlugin = new ReactNativePlugin();
var appInsights = new ApplicationInsights({
config: {
connectionString: 'YOUR_CONNECTION_STRING_GOES_HERE',
extensions: [RNPlugin]
}
});
appInsights.loadAppInsights();
Enable Correlation
Correlation generates and sends data that enables distributed tracing and powers the application map, end-to-end transaction view, and other diagnostic tools.
In JavaScript correlation is turned off by default in order to minimize the telemetry we send by default. To enable correlation please reference JavaScript client-side correlation documentation.
PageView
If a custom PageView
duration is not provided, PageView
duration defaults to a value of 0.
Next steps
- To learn more about the JavaScript SDK, see the Application Insights JavaScript SDK documentation.
- To learn about the Kusto query language and querying data in Log Analytics, see the Log query overview.
Feedback
Submit and view feedback for