Optionalcfg(Optional) The IConfiguration configuration object passed to the Application Insights SDK during initialization.
OptionalconnectionThe Application Insights connection string. Either this or instrumentationKey MUST be
provided. This is the recommended approach as it configures both the endpoint and
instrumentation key in a single value.
Optionalcr(Optional) Controls CDN fallback retry behavior. By default (true), if the SDK fails
to load from the configured src URL, the snippet automatically attempts to load from
multiple supported CDN domains in case one or more of them is temporarily unavailable.
Set to false to disable this fallback and only attempt the single configured src URL.
Optionalcross(Optional) The crossOrigin attribute value for the script tag added to download the SDK.
Recommended values: "", "anonymous". When not defined, no crossOrigin attribute is added.
Optionaldle(Optional) Disable Load Error reporting, when set to true, prevents the SDK from reporting load failure telemetry.
OptionalinstrumentationThe Application Insights instrumentation key. Either this or connectionString MUST be
provided — prefer using connectionString instead.
Optionalld(Optional) Defines the load delay (in ms) before attempting to load the SDK.
Default is 0ms. A negative value immediately adds the script tag to the <head>,
to attempt to block the page load event (not all browsers honour this) until the script is loaded or fails.
Optionalname(Optional) The global name for the initialized SDK instance. Defaults to "appInsights".
Optionalpl(Optional) Trusted Type policy support. When set to true, enables Trusted Type policy validation on the snippet.
Optionalpn(Optional) The name of the Trusted Type policy to use. Defaults to "aiPolicy".
Optionalsrc(Optional) The full URL for where to load the SDK from.
Defaults to "https://js.monitor.azure.com/scripts/b/ai.3.gbl.min.js" when not supplied.
Note: When Internet Explorer is detected by the SDK Loader, the URL is automatically
rewritten to load the v2.x SDK (e.g. ai.3.gbl.min.js becomes ai.2.gbl.min.js).
Optionalsri(Optional) Sub-resource Integrity (SRI) checking. When set to true, enables Sub-Resource Integrity (SRI) checking.
The snippet will fetch an integrity file and validate the SDK script hash before execution.
Optionalttp(Optional) A pre-created TrustedTypePolicy instance to apply to the snippet src URL.
Optionaluse(Optional) Use XHR instead of fetch to report SDK load failures. Only needed in environments where fetch would fail to send the failure events.
Configuration options for the
getSdkLoaderScript()helper function, which generates a ready-to-use SDK Loader (snippet) script string for embedding in an HTML page.This is a simplified configuration interface intended for server-side rendering scenarios where you want to programmatically generate the snippet. For the full set of snippet configuration options used by the snippet itself, see ISnippetConfig.
Important: You MUST provide either
connectionStringorinstrumentationKey. Failure to provide at least one of these will result in the SDK not loading, failing to initialize, or reporting an error.Example