Skip to content

Commit 7b893d0

Browse files
committed
edit pass: tracing-web-app-availability-javascript
1 parent 4cadbe6 commit 7b893d0

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

articles/azure-monitor/app/javascript.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Azure Application Insights for JavaScript web apps
3-
description: Get page view and session counts, web client data, Single Page Applications (SPA), and track usage patterns. Detect exceptions and performance issues in JavaScript web pages.
3+
description: Get page view and session counts, web client data, and single-page applications (SPAs) and track usage patterns. Detect exceptions and performance issues in JavaScript web pages.
44
ms.topic: conceptual
55
ms.date: 08/06/2020
66
ms.devlang: javascript
@@ -22,20 +22,20 @@ Application Insights can be used with any web pages by adding a short piece of J
2222
1. First you need an Application Insights resource. If you don't already have a resource and connection string, follow the instructions to [create a new resource](create-new-resource.md).
2323
1. Copy the [connection string](#connection-string-setup) for the resource where you want your JavaScript telemetry to be sent (from step 1). You'll add it to the `connectionString` setting of the Application Insights JavaScript SDK.
2424
1. Add the Application Insights JavaScript SDK to your web page or app via one of the following two options:
25-
* [npm Setup](#npm-based-setup)
26-
* [JavaScript Snippet](#snippet-based-setup)
25+
* [Node Package Manager (npm) setup](#npm-based-setup)
26+
* [JavaScript snippet](#snippet-based-setup)
2727

2828
> [!WARNING]
2929
> `@microsoft/applicationinsights-web-basic - AISKULight` doesn't support the use of connection strings.
3030
31-
Only use one method to add the JavaScript SDK to your application. If you use the npm Setup, don't use the Snippet and vice versa.
31+
Only use one method to add the JavaScript SDK to your application. If you use the npm setup, don't use the snippet and vice versa.
3232

3333
> [!NOTE]
34-
> npm Setup installs the JavaScript SDK as a dependency to your project, enabling IntelliSense, whereas the Snippet fetches the SDK at runtime. Both support the same features. Developers who want more custom events and configuration generally opt for npm Setup. Users looking for quick enablement of out-of-the-box web analytics opt for the Snippet.
34+
> The npm setup installs the JavaScript SDK as a dependency to your project and enables IntelliSense. The snippet fetches the SDK at runtime. Both support the same features. Developers who want more custom events and configuration generally opt for the npm setup. Users who are looking for quick enablement of out-of-the-box web analytics opt for the snippet.
3535
3636
### npm-based setup
3737

38-
Install via Node Package Manager (npm).
38+
Install via npm.
3939

4040
```sh
4141
npm i --save @microsoft/applicationinsights-web
@@ -57,11 +57,11 @@ appInsights.trackPageView(); // Manually call trackPageView to establish the cur
5757

5858
### Snippet-based setup
5959

60-
If your app doesn't use npm, you can directly instrument your webpages with Application Insights by pasting this snippet at the top of each of your pages. Preferably, it should be the first script in your `<head>` section so that it can monitor any potential issues with all of your dependencies and optionally any JavaScript errors. If you're using Blazor Server App, add the snippet at the top of the file `_Host.cshtml` in the `<head>` section.
60+
If your app doesn't use npm, you can directly instrument your webpages with Application Insights by pasting this snippet at the top of each of your pages. Preferably, it should be the first script in your `<head>` section. That way it can monitor any potential issues with all your dependencies and optionally any JavaScript errors. If you're using Blazor Server App, add the snippet at the top of the file `_Host.cshtml` in the `<head>` section.
6161

62-
Starting from version 2.5.5, the page view event will include the new tag "ai.internal.snippet" that contains the identified Snippet version. This feature assists with tracking which version of the Snippet your application is using.
62+
Starting from version 2.5.5, the page view event will include the new tag "ai.internal.snippet" that contains the identified snippet version. This feature assists with tracking which version of the snippet your application is using.
6363

64-
The current Snippet that follows is version "5." The version is encoded in the snippet as sv:"#." The [current version is also available on GitHub](https://go.microsoft.com/fwlink/?linkid=2156318).
64+
The current snippet that follows is version "5." The version is encoded in the snippet as sv:"#." The [current version is also available on GitHub](https://go.microsoft.com/fwlink/?linkid=2156318).
6565

6666
```html
6767
<script type="text/javascript">
@@ -82,19 +82,19 @@ cfg: { // Application Insights Configuration
8282
> [!NOTE]
8383
> For readability and to reduce possible JavaScript errors, all of the possible configuration options are listed on a new line in the preceding snippet code. If you don't want to change the value of a commented line, it can be removed.
8484
85-
#### Reporting Script load failures
85+
#### Report script load failures
8686

87-
This version of the snippet detects and reports failures when loading the SDK from the CDN as an exception to the Azure Monitor portal (under the failures &gt; exceptions &gt; browser). The exception provides visibility into failures of this type so that you're aware your application isn't reporting telemetry (or other exceptions) as expected. This signal is an important measurement in understanding that you have lost telemetry because the SDK didn't load or initialize, which can lead to:
87+
This version of the snippet detects and reports failures when the SDK is loaded from the CDN as an exception to the Azure Monitor portal (under the failures &gt; exceptions &gt; browser). The exception provides visibility into failures of this type so that you're aware your application isn't reporting telemetry (or other exceptions) as expected. This signal is an important measurement in understanding that you've lost telemetry because the SDK didn't load or initialize, which can lead to:
8888

89-
- Under-reporting of how users are using or trying to use your site.
89+
- Underreporting of how users are using or trying to use your site.
9090
- Missing telemetry on how your users are using your site.
9191
- Missing JavaScript errors that could potentially be blocking your users from successfully using your site.
9292

9393
For information on this exception, see the [SDK load failure](javascript-sdk-load-failure.md) troubleshooting page.
9494

9595
Reporting of this failure as an exception to the portal doesn't use the configuration option ```disableExceptionTracking``` from the Application Insights configuration. For this reason, if this failure occurs, it will always be reported by the snippet, even when the window.onerror support is disabled.
9696

97-
Reporting of SDK load failures isn't supported on Internet Explorer 8 or earlier. This behavior reduces the minified size of the snippet by assuming that most environments aren't exclusively IE 8 or less. If you have this requirement and you want to receive these exceptions, you'll need to either include a fetch poly fill or create your own snippet version that uses ```XDomainRequest``` instead of ```XMLHttpRequest```. We recommend that you use the [provided snippet source code](https://github.com/microsoft/ApplicationInsights-JS/blob/master/AISKU/snippet/snippet.js) as a starting point.
97+
Reporting of SDK load failures isn't supported on Internet Explorer 8 or earlier. This behavior reduces the minified size of the snippet by assuming that most environments aren't exclusively Internet Explorer 8 or less. If you have this requirement and you want to receive these exceptions, you'll need to either include a fetch poly fill or create your own snippet version that uses ```XDomainRequest``` instead of ```XMLHttpRequest```. We recommend that you use the [provided snippet source code](https://github.com/microsoft/ApplicationInsights-JS/blob/master/AISKU/snippet/snippet.js) as a starting point.
9898

9999
> [!NOTE]
100100
> If you're using a previous version of the snippet, we recommend that you update to the latest version so that you'll receive these previously unreported issues.
@@ -109,7 +109,7 @@ The available configuration options are listed in this table.
109109

110110
| Name | Type | Description
111111
|------|------|----------------
112-
| src | string **[required]** | The full URL for where to load the SDK from. This value is used for the "src" attribute of a dynamically added &lt;script /&gt; tag. You can use the public CDN location or your own privately hosted one.
112+
| src | string *[required]* | The full URL for where to load the SDK from. This value is used for the "src" attribute of a dynamically added &lt;script /&gt; tag. You can use the public CDN location or your own privately hosted one.
113113
| name | string *[optional]* | The global name for the initialized SDK, defaults to `appInsights`. So ```window.appInsights``` will be a reference to the initialized instance. If you provide a name value or a previous instance appears to be assigned (via the global name appInsightsSDK), this name value will also be defined in the global namespace as ```window.appInsightsSDK=<name value>```. The SDK initialization code uses this reference to ensure it's initializing and updating the correct snippet skeleton and proxy methods.
114114
| ld | number in ms *[optional]* | Defines the load delay to wait before attempting to load the SDK. Default value is 0ms. Any negative value will immediately add a script tag to the &lt;head&gt; region of the page, which will then block the page load event until the script is loaded or fails.
115115
| useXhr | boolean *[optional]* | This setting is used only for reporting SDK load failures. Reporting will first attempt to use fetch() if available and then fall back to XHR. Setting this value to true just bypasses the fetch check. Use of this value is only required if your application is being used in an environment where fetch would fail to send the failure events.
@@ -137,18 +137,18 @@ By default, the Application Insights JavaScript SDK autocollects many telemetry
137137

138138
This telemetry includes:
139139

140-
- **Uncaught exceptions** in your app, including information on:
141-
- Stack trace
142-
- Exception details and message accompanying the error
143-
- Line and column number of error
144-
- URL where error was raised
145-
- **Network Dependency Requests** made by your app **XHR** and **Fetch** (fetch collection is disabled by default) requests, include information on:
146-
- Url of dependency source
147-
- Command and method used to request the dependency
148-
- Duration of the request
149-
- Result code and success status of the request
150-
- ID (if any) of user making the request
151-
- Correlation context (if any) where request is made
140+
- **Uncaught exceptions** in your app, including information on the:
141+
- Stack trace.
142+
- Exception details and message accompanying the error.
143+
- Line and column number of the error.
144+
- URL where the error was raised.
145+
- **Network Dependency Requests** made by your app **XHR** and **Fetch** (fetch collection is disabled by default) requests, include information on the:
146+
- URL of dependency source.
147+
- Command and method used to request the dependency.
148+
- Duration of the request.
149+
- Result code and success status of the request.
150+
- ID (if any) of the user making the request.
151+
- Correlation context (if any) where the request is made.
152152
- **User information** (for example, location, network, IP)
153153
- **Device information** (for example, browser, OS, version, language, model)
154154
- **Session information**
@@ -157,7 +157,7 @@ This telemetry includes:
157157

158158
Telemetry initializers are used to modify the contents of collected telemetry before being sent from the user's browser. They can also be used to prevent certain telemetry from being sent by returning `false`. Multiple telemetry initializers can be added to your Application Insights instance. They're executed in the order of adding them.
159159

160-
The input argument to `addTelemetryInitializer` is a callback that takes a [`ITelemetryItem`](https://github.com/microsoft/ApplicationInsights-JS/blob/master/API-reference.md#addTelemetryInitializer) as an argument and returns `boolean` or `void`. If returning `false`, the telemetry item isn't sent, else it proceeds to the next telemetry initializer, if any, or is sent to the telemetry collection endpoint.
160+
The input argument to `addTelemetryInitializer` is a callback that takes a [`ITelemetryItem`](https://github.com/microsoft/ApplicationInsights-JS/blob/master/API-reference.md#addTelemetryInitializer) as an argument and returns `boolean` or `void`. If `false` is returned, the telemetry item isn't sent, or else it proceeds to the next telemetry initializer, if any, or is sent to the telemetry collection endpoint.
161161

162162
An example of using telemetry initializers:
163163

@@ -174,12 +174,12 @@ appInsights.trackTrace({message: 'this message will not be sent'}); // Not sent
174174

175175
## Configuration
176176

177-
Most configuration fields are named such that they can be defaulted to false. All fields are optional except for `connectionString`.
177+
Most configuration fields are named so that they can be defaulted to false. All fields are optional except for `connectionString`.
178178

179179
| Name | Description | Default |
180180
|------|-------------|---------|
181-
| connectionString | **Required**<br>Connection string that you obtained from the Azure portal. | string<br/>null |
182-
| accountId | An optional account ID, if your app groups users into accounts. No spaces, commas, semicolons, equals, or vertical bars. | string<br/>null |
181+
| connectionString | *Required*<br>Connection string that you obtained from the Azure portal. | string<br/>null |
182+
| accountId | An optional account ID, if your app groups users into accounts. No spaces, commas, semicolons, equal signs, or vertical bars. | string<br/>null |
183183
| sessionRenewalMs | A session is logged if the user is inactive for this amount of time in milliseconds. | numeric<br/>1800000<br/>(30 mins) |
184184
| sessionExpirationMs | A session is logged if it has continued for this amount of time in milliseconds. | numeric<br/>86400000<br/>(24 hours) |
185185
| maxBatchSizeInBytes | Maximum size of telemetry batch. If a batch exceeds this limit, it's immediately sent and a new batch is started. | numeric<br/>10000 |
@@ -191,20 +191,20 @@ Most configuration fields are named such that they can be defaulted to false. Al
191191
| loggingLevelTelemetry | Sends *internal* Application Insights errors as telemetry. <br>0: off, <br>1: Critical errors only, <br>2: Everything (errors & warnings) | numeric<br/> 1 |
192192
| diagnosticLogInterval | (internal) Polling interval (in ms) for internal logging queue. | numeric<br/> 10000 |
193193
| samplingPercentage | Percentage of events that will be sent. Default is 100, meaning all events are sent. Set this option if you want to preserve your data cap for large-scale applications. | numeric<br/>100 |
194-
| autoTrackPageVisitTime | If true, on a pageview, the _previous_ instrumented page's view time is tracked and sent as telemetry and a new timer is started for the current pageview. It's sent as a custom metric named `PageVisitTime` in `milliseconds` and is calculated via the Date [now()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) function (if available) and falls back to (new Date()).[getTime()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) if now() is unavailable (IE8 or less). Default is false. | boolean<br/>false |
194+
| autoTrackPageVisitTime | If true, on a pageview, the _previous_ instrumented page's view time is tracked and sent as telemetry and a new timer is started for the current pageview. It's sent as a custom metric named `PageVisitTime` in `milliseconds` and is calculated via the Date [now()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) function (if available) and falls back to (new Date()).[getTime()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) if now() is unavailable (Internet Explorer 8 or less). Default is false. | boolean<br/>false |
195195
| disableAjaxTracking | If true, Ajax calls aren't autocollected. | boolean<br/> false |
196196
| disableFetchTracking | If true, Fetch requests aren't autocollected.|boolean<br/>true |
197-
| overridePageViewDuration | If true, default behavior of trackPageView is changed to record end of page view duration interval when trackPageView is called. If false and no custom duration is provided to trackPageView, the page view performance is calculated using the navigation timing API. |boolean<br/>
197+
| overridePageViewDuration | If true, default behavior of trackPageView is changed to record end of page view duration interval when trackPageView is called. If false and no custom duration is provided to trackPageView, the page view performance is calculated by using the navigation timing API. |boolean<br/>
198198
| maxAjaxCallsPerView | Default 500 - controls how many Ajax calls will be monitored per page view. Set to -1 to monitor all (unlimited) Ajax calls on the page. | numeric<br/> 500 |
199199
| disableDataLossAnalysis | If false, internal telemetry sender buffers will be checked at startup for items not yet sent. | boolean<br/> true |
200200
| disable&#8203;CorrelationHeaders | If false, the SDK will add two headers ('Request-Id' and 'Request-Context') to all dependency requests to correlate them with corresponding requests on the server side. | boolean<br/> false |
201201
| correlationHeader&#8203;ExcludedDomains | Disable correlation headers for specific domains. | string[]<br/>undefined |
202-
| correlationHeader&#8203;ExcludePatterns | Disable correlation headers using regular expressions. | regex[]<br/>undefined |
202+
| correlationHeader&#8203;ExcludePatterns | Disable correlation headers by using regular expressions. | regex[]<br/>undefined |
203203
| correlationHeader&#8203;Domains | Enable correlation headers for specific domains. | string[]<br/>undefined |
204204
| disableFlush&#8203;OnBeforeUnload | If true, flush method won't be called when onBeforeUnload event triggers. | boolean<br/> false |
205205
| enableSessionStorageBuffer | If true, the buffer with all unsent telemetry is stored in session storage. The buffer is restored on page load. | boolean<br />true |
206206
| cookieCfg | Defaults to cookie usage enabled. See [ICookieCfgConfig](#icookiemgrconfig) settings for full defaults. | [ICookieCfgConfig](#icookiemgrconfig)<br>(Since 2.6.0)<br/>undefined |
207-
| ~~isCookieUseDisabled~~<br>disableCookiesUsage | If true, the SDK won't store or read any data from cookies. Disables the User and Session cookies and renders the usage blades and experiences useless. isCookieUseDisable is deprecated in favor of disableCookiesUsage. When both are provided disableCookiesUsage takes precedence.<br>(Since v2.6.0) And if `cookieCfg.enabled` is also defined, it will take precedence over these values, Cookie usage can be re-enabled after initialization via the core.getCookieMgr().setEnabled(true). | alias for [`cookieCfg.enabled`](#icookiemgrconfig)<br>false |
207+
| ~~isCookieUseDisabled~~<br>disableCookiesUsage | If true, the SDK won't store or read any data from cookies. Disables the User and Session cookies and renders the usage blades and experiences useless. isCookieUseDisable is deprecated in favor of disableCookiesUsage. When both are provided, disableCookiesUsage takes precedence.<br>(Since v2.6.0) And if `cookieCfg.enabled` is also defined, it will take precedence over these values. Cookie usage can be re-enabled after initialization via the core.getCookieMgr().setEnabled(true). | alias for [`cookieCfg.enabled`](#icookiemgrconfig)<br>false |
208208
| cookieDomain | Custom cookie domain. This option is helpful if you want to share Application Insights cookies across subdomains.<br>(Since v2.6.0) If `cookieCfg.domain` is defined, it will take precedence over this value. | alias for [`cookieCfg.domain`](#icookiemgrconfig)<br>null |
209209
| cookiePath | Custom cookie path. This option is helpful if you want to share Application Insights cookies behind an application gateway.<br>If `cookieCfg.path` is defined, it will take precedence over this value. | alias for [`cookieCfg.path`](#icookiemgrconfig)<br>(Since 2.6.0)<br/>null |
210210
| isRetryDisabled | If false, retry on 206 (partial success), 408 (timeout), 429 (too many requests), 500 (internal server error), 503 (service unavailable), and 0 (offline, only if detected). | boolean<br/>false |

0 commit comments

Comments
 (0)