You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #245696 from v-jbasden/v-jbasden-javascript-sdk-updates-9
framework extensions: Move track router history to own section, add React Native Manual Device Plugin, clarify exception tracking and device info collection
By default, this plugin relies on the [`react-native-device-info` package](https://www.npmjs.com/package/react-native-device-info). You must install and link to this package. Keep the `react-native-device-info` package up to date to collect the latest device names using your app.
98
+
-**React Native Plugin**
99
99
100
-
Since v3, support for accessing the DeviceInfo has been abstracted into an interface `IDeviceInfoModule` to enable you to use / set your own device info module. This interface uses the same function names and result `react-native-device-info`.
100
+
By default, the React Native Plugin relies on the [`react-native-device-info` package](https://www.npmjs.com/package/react-native-device-info). You must install and link to this package. Keep the `react-native-device-info` package up to date to collect the latest device names using your app.
101
101
102
-
```zsh
102
+
Since v3, support for accessing the DeviceInfo has been abstracted into an interface `IDeviceInfoModule` to enable you to use / set your own device info module. This interface uses the same function names and result `react-native-device-info`.
If you're using React Native Expo, add the React Native Manual Device Plugin instead of the React Native Plugin. The React Native Plugin uses the `react-native-device-info package` package, which React Native Expo doesn't support.
To use this plugin, you need to construct the plugin and add it as an `extension` to your existing Application Insights instance.
177
+
-**React Native Plug-in**
164
178
165
-
> [!TIP]
166
-
> If you want to add the [Click Analytics plug-in](./javascript-feature-extensions.md), uncomment the lines for Click Analytics and delete `extensions: [RNPlugin]`.
179
+
To use this plugin, you need to construct the plugin and add it as an `extension` to your existing Application Insights instance.
// import { ClickAnalyticsPlugin } from '@microsoft/applicationinsights-clickanalytics-js';
173
-
var RNPlugin =newReactNativePlugin();
174
-
// Add the Click Analytics plug-in.
175
-
/* var clickPluginInstance = new ClickAnalyticsPlugin();
176
-
var clickPluginConfig = {
181
+
> [!TIP]
182
+
> If you want to add the [Click Analytics plug-in](./javascript-feature-extensions.md), uncomment the lines for Click Analytics and delete `extensions: [RNPlugin]`.
> If you're adding the Click Analytics plug-in, see [Use the Click Analytics plug-in](./javascript-feature-extensions.md#use-the-plug-in) to continue with the setup process.
211
+
> [!TIP]
212
+
> If you're adding the Click Analytics plug-in, see [Use the Click Analytics plug-in](./javascript-feature-extensions.md#use-the-plug-in) to continue with the setup process.
213
+
214
+
215
+
-**React Native Manual Device Plugin**
216
+
217
+
To use this plugin, you must either disable automatic device info collection or use your own device info collection class after you add the extension to your code.
218
+
219
+
1. Construct the plugin and add it as an `extension` to your existing Application Insights instance.
|history|object|Optional|null|Trackrouterhistory. Formoreinformation, seethe [Reactrouterpackagedocumentation](https://reactrouter.com/en/main).<br><br>To track router history, most users can use the `enableAutoRouteTracking` field in the [JavaScript SDK configuration](./javascript-sdk-configuration.md#sdk-configuration). This field collects the same data for page views as the `history` object.<br><br>Use the `history` object when you're using a router implementation that doesn't update the browser URL, which is what the configuration listens to. You shouldn't enable both the `enableAutoRouteTracking` field and `history` object, because you'll get multiple page view events. |
[React error boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) provide a way to gracefully handle an exception when it occurs within a React application. When such an exception occurs, it's likely that the exception needs to be logged. The React plug-in for Application Insights provides an error boundary component that automatically logs the exception when it occurs.
410
+
[Reacterrorboundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) provide a way to gracefully handle an uncaught exception when it occurs within a React application. When such an exception occurs, it's likely that the exception needs to be logged. The React plug-in for Application Insights provides an error boundary component that automatically logs the exception when it occurs.
264
411
265
412
```javascript
266
413
import React from "react";
@@ -280,7 +427,7 @@ The `AppInsightsErrorBoundary` requires two props to be passed to it. They're th
280
427
281
428
#### [ReactNative](#tab/reactnative)
282
429
283
-
Exception tracking is enabled by default. If you want to disable it, set `disableExceptionCollection` to `true`.
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
@@ -361,7 +508,10 @@ N/A
361
508
362
509
#### [ReactNative](#tab/reactnative)
363
510
364
-
In addition to user agent info from the browser, which is collected by Application Insights web package, React Native also collects device information. Device information is automatically collected when you add the plug-in.
| history | object | Optional | null | Track router history. For more information, see the [React router package documentation](https://reactrouter.com/en/main).<br><br>To track router history, most users can use the `enableAutoRouteTracking` field in the [JavaScript SDK configuration](./javascript-sdk-configuration.md#sdk-configuration). This field collects the same data for page views as the `history` object.<br><br>Use the `history` object when you're using a router implementation that doesn't update the browser URL, which is what the configuration listens to. You shouldn't enable both the `enableAutoRouteTracking` field and `history` object, because you'll get multiple page view events. |
384
-
385
-
The following code example shows how to enable the `enableAutoRouteTracking` field.
0 commit comments