@microsoft/applicationinsights-react-js 19.4.2-nightly.2609-01 → 19.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -3
- package/browser/applicationinsights-react-js.js +39 -2519
- package/browser/applicationinsights-react-js.js.map +1 -1
- package/browser/applicationinsights-react-js.min.js +2 -2
- package/browser/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.api.json +1 -1
- package/dist/applicationinsights-react-js.d.ts +1 -1
- package/dist/applicationinsights-react-js.js +39 -2519
- package/dist/applicationinsights-react-js.js.map +1 -1
- package/dist/applicationinsights-react-js.min.js +2 -2
- package/dist/applicationinsights-react-js.min.js.map +1 -1
- package/dist/applicationinsights-react-js.rollup.d.ts +1 -1
- package/dist-esm/AppInsightsContext.js +1 -1
- package/dist-esm/AppInsightsErrorBoundary.js +1 -1
- package/dist-esm/Interfaces/IReactExtensionConfig.js +1 -1
- package/dist-esm/ReactPlugin.js +1 -1
- package/dist-esm/applicationinsights-react-js.js +1 -1
- package/dist-esm/useTrackEvent.js +1 -1
- package/dist-esm/useTrackMetric.js +1 -1
- package/dist-esm/withAITracking.js +1 -1
- package/package.json +81 -83
- package/types/tsdoc-metadata.json +1 -1
package/README.md
CHANGED
|
@@ -11,10 +11,19 @@ Full documentation for the React Plugin for the Application Insights JavaScript
|
|
|
11
11
|
|
|
12
12
|
## Getting Started
|
|
13
13
|
|
|
14
|
-
Install
|
|
14
|
+
Install the React plugin and the Application Insights web SDK together:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install @microsoft/applicationinsights-react-js
|
|
17
|
+
npm install @microsoft/applicationinsights-react-js @microsoft/applicationinsights-web
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Use compatible versions of the two packages from the
|
|
21
|
+
[compatibility matrix](https://github.com/microsoft/applicationinsights-react-js#compatibility-matrix),
|
|
22
|
+
and update them together. Mismatched Application Insights dependencies can cause TypeScript errors
|
|
23
|
+
such as:
|
|
24
|
+
|
|
25
|
+
```plaintext
|
|
26
|
+
Type 'ReactPlugin' is not assignable to type 'ITelemetryPlugin'.
|
|
18
27
|
```
|
|
19
28
|
|
|
20
29
|
## Basic Usage
|
|
@@ -62,6 +71,36 @@ var appInsights = new ApplicationInsights({
|
|
|
62
71
|
appInsights.loadAppInsights();
|
|
63
72
|
```
|
|
64
73
|
|
|
74
|
+
## Choosing a tracking approach
|
|
75
|
+
|
|
76
|
+
The tracking options collect different telemetry and can be used together:
|
|
77
|
+
|
|
78
|
+
| Option | Telemetry | When to use it |
|
|
79
|
+
|--------|-----------|----------------|
|
|
80
|
+
| `enableAutoRouteTracking` | Page views | Track URL changes made through the browser History API, including routes in a single-page application. Virtual page-view duration is reported as zero because a URL change does not identify when rendering finishes. |
|
|
81
|
+
| `autoTrackPageVisitTime` | `PageVisitTime` metrics | Measure how long a user stays on a page. The metric for the previous page is sent when the next page view is tracked. This is visit time, not page-load time. |
|
|
82
|
+
| `withAITracking` | `React Component Engaged Time (seconds)` metrics | Measure how long a wrapped React component is mounted, excluding idle time. The metric is sent when the component unmounts. |
|
|
83
|
+
|
|
84
|
+
For example, enable `enableAutoRouteTracking` for navigation telemetry and wrap only the
|
|
85
|
+
components whose engagement time you want to measure with `withAITracking`. Enabling automatic
|
|
86
|
+
route tracking does not make component tracking redundant because the options send different
|
|
87
|
+
telemetry.
|
|
88
|
+
|
|
89
|
+
Use the SDK's explicit tracking methods for application-specific telemetry:
|
|
90
|
+
|
|
91
|
+
| Method | Common use case |
|
|
92
|
+
|--------|-----------------|
|
|
93
|
+
| `trackEvent` | Record a user action or business event. Use `startTrackEvent` and `stopTrackEvent` when the event duration matters. |
|
|
94
|
+
| `trackPageView` | Record navigation when automatic route tracking is disabled, or attach custom page-view properties. Avoid calling it for the same navigation already captured by `enableAutoRouteTracking`. Use `startTrackPage` and `stopTrackPage` when you can determine when a virtual page finishes loading. |
|
|
95
|
+
| `trackPageViewPerformance` | Record browser page-load performance measurements. |
|
|
96
|
+
| `trackException` | Record a handled error that automatic exception collection does not capture. |
|
|
97
|
+
| `trackTrace` | Record diagnostic or workflow information. |
|
|
98
|
+
| `trackMetric` | Record an application-specific measurement or preaggregated metric. |
|
|
99
|
+
| `trackDependencyData` | Record a dependency call that automatic `fetch` or `XMLHttpRequest` collection does not capture. |
|
|
100
|
+
|
|
101
|
+
See the [Application Insights JavaScript SDK API documentation](https://microsoft.github.io/ApplicationInsights-JS/webSdk/applicationinsights-web/classes/ApplicationInsights.html)
|
|
102
|
+
for method parameters and additional configuration.
|
|
103
|
+
|
|
65
104
|
|
|
66
105
|
|
|
67
106
|
## Configuration
|
|
@@ -93,7 +132,7 @@ Please note that it can take up to 10 minutes for new custom metric to appear in
|
|
|
93
132
|
|
|
94
133
|
## Sample App
|
|
95
134
|
|
|
96
|
-
[
|
|
135
|
+
[Application Insights React sample](https://github.com/microsoft/applicationinsights-react-js/tree/main/sample/applicationinsights-react-sample).
|
|
97
136
|
|
|
98
137
|
## React Router
|
|
99
138
|
|