/* * Microsoft Application Insights JavaScript SDK - Web Analytics, 3.4.3 * Copyright (c) Microsoft and contributors. All rights reserved. * * Microsoft Application Insights Team * https://github.com/microsoft/ApplicationInsights-JS#readme * * --------------------------------------------------------------------------- * This is a single combined (rollup) declaration file for the package, * if you require a namespace wrapped version it is also available. * - Namespaced version: types/applicationinsights-analytics-js.namespaced.d.ts * --------------------------------------------------------------------------- */ import { BaseTelemetryPlugin } from '@microsoft/applicationinsights-core-js'; import { IAppInsights } from '@microsoft/applicationinsights-core-js'; import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js'; import { IAutoExceptionTelemetry } from '@microsoft/applicationinsights-core-js'; import { IConfig } from '@microsoft/applicationinsights-core-js'; import { IConfiguration } from '@microsoft/applicationinsights-core-js'; import { ICookieMgr } from '@microsoft/applicationinsights-core-js'; import { ICustomProperties } from '@microsoft/applicationinsights-core-js'; import { IEventTelemetry } from '@microsoft/applicationinsights-core-js'; import { IExceptionConfig } from '@microsoft/applicationinsights-core-js'; import { IExceptionTelemetry } from '@microsoft/applicationinsights-core-js'; import { IMetricTelemetry } from '@microsoft/applicationinsights-core-js'; import { IPageViewPerformanceTelemetry } from '@microsoft/applicationinsights-core-js'; import { IPageViewPerformanceTelemetryInternal } from '@microsoft/applicationinsights-core-js'; import { IPageViewTelemetry } from '@microsoft/applicationinsights-core-js'; import { IPageViewTelemetryInternal } from '@microsoft/applicationinsights-core-js'; import { IPlugin } from '@microsoft/applicationinsights-core-js'; import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js'; import { ITelemetryInitializerHandler } from '@microsoft/applicationinsights-core-js'; import { ITelemetryItem } from '@microsoft/applicationinsights-core-js'; import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js'; import { ITraceTelemetry } from '@microsoft/applicationinsights-core-js'; declare class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights, IAppInsightsInternal { static Version: string; identifier: string; priority: number; readonly config: IConfig & IConfiguration; queue: Array<() => void>; autoRoutePVDelay: number; constructor(); /** * Get the current cookie manager for this instance */ getCookieMgr(): ICookieMgr; processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void; trackEvent(event: IEventTelemetry, customProperties?: ICustomProperties): void; /** * Start timing an extended event. Call `stopTrackEvent` to log the event when it ends. * @param name - A string that identifies this event uniquely within the document. */ startTrackEvent(name: string): void; /** * Log an extended event that you started timing with `startTrackEvent`. * @param name - The string you used to identify this event in `startTrackEvent`. * @param properties - map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty. * @param measurements - map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty. */ stopTrackEvent(name: string, properties?: { [key: string]: string; }, measurements?: { [key: string]: number; }): void; /** * @description Log a diagnostic message * @param trace - the trace message * @param customProperties - Additional custom properties to include in the event */ trackTrace(trace: ITraceTelemetry, customProperties?: ICustomProperties): void; /** * @description Log a numeric value that is not associated with a specific event. Typically * used to send regular reports of performance indicators. To send single measurement, just * use the name and average fields of {@link IMetricTelemetry}. If you take measurements * frequently, you can reduce the telemetry bandwidth by aggregating multiple measurements * and sending the resulting average at intervals * @param metric - input object argument. Only name and average are mandatory. * @param customProperties - additional data used to filter metrics in the * portal. Defaults to empty. */ trackMetric(metric: IMetricTelemetry, customProperties?: ICustomProperties): void; /** * Logs that a page or other item was viewed. * @param IPageViewTelemetry - The string you used as the name in startTrackPage. Defaults to the document title. * @param customProperties - Additional data used to filter events and metrics. Defaults to empty. * If a user wants to provide duration for pageLoad, it'll have to be in pageView.properties.duration */ trackPageView(pageView?: IPageViewTelemetry, customProperties?: ICustomProperties): void; /** * Create a page view telemetry item and send it to the SDK pipeline through the core.track API * @param pageView - Page view item to be sent * @param properties - Custom properties (Part C) that a user can add to the telemetry item * @param systemProperties - System level properties (Part A) that a user can add to the telemetry item */ sendPageViewInternal(pageView: IPageViewTelemetryInternal, properties?: { [key: string]: any; }, systemProperties?: { [key: string]: any; }): void; /** * @ignore INTERNAL ONLY * @param pageViewPerformance - The page view performance item to be sent * @param properties - Custom properties (Part C) that a user can add to the telemetry item */ sendPageViewPerformanceInternal(pageViewPerformance: IPageViewPerformanceTelemetryInternal, properties?: { [key: string]: any; }, systemProperties?: { [key: string]: any; }): void; /** * Send browser performance metrics. * @param pageViewPerformance - The page view performance item to be sent * @param customProperties - Additional data used to filter pages and metrics in the portal. Defaults to empty. */ trackPageViewPerformance(pageViewPerformance: IPageViewPerformanceTelemetry, customProperties?: ICustomProperties): void; /** * Starts the timer for tracking a page load time. Use this instead of `trackPageView` if you want to control when the page view timer starts and stops, * but don't want to calculate the duration yourself. This method doesn't send any telemetry. Call `stopTrackPage` to log the end of the page view * and send the event. * @param name - A string that idenfities this item, unique within this HTML document. Defaults to the document title. */ startTrackPage(name?: string): void; /** * Stops the timer that was started by calling `startTrackPage` and sends the pageview load time telemetry with the specified properties and measurements. * The duration of the page view will be the time between calling `startTrackPage` and `stopTrackPage`. * @param name - The string you used as the name in startTrackPage. Defaults to the document title. * @param url - String - a relative or absolute URL that identifies the page or other item. Defaults to the window location. * @param properties - map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty. * @param measurements - map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty. */ stopTrackPage(name?: string, url?: string, properties?: { [key: string]: string; }, measurement?: { [key: string]: number; }): void; /** * @ignore INTERNAL ONLY * @param exception - The exception item to be sent * @param properties - Custom properties (Part C) that a user can add to the telemetry item * @param systemProperties - System level properties (Part A) that a user can add to the telemetry item */ sendExceptionInternal(exception: IExceptionTelemetry, customProperties?: { [key: string]: any; }, systemProperties?: { [key: string]: any; }): void; /** * Log an exception you have caught. * * @param exception - Object which contains exception to be sent * @param customProperties - Additional data used to filter pages and metrics in the portal. Defaults to empty. * * Any property of type double will be considered a measurement, and will be treated by Application Insights as a metric. */ trackException(exception: IExceptionTelemetry, customProperties?: ICustomProperties): void; /** * @description Custom error handler for Application Insights Analytics * @param exception - The exception item to be sent */ _onerror(exception: IAutoExceptionTelemetry): void; addTelemetryInitializer(telemetryInitializer: (item: ITelemetryItem) => boolean | void): ITelemetryInitializerHandler; initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void; } export { AnalyticsPlugin } export { AnalyticsPlugin as ApplicationInsights } /** * Enum values for configuring trace context strategy for SPA route changes. * Controls how trace contexts are managed when navigating between pages in a Single Page Application. * @since 3.4.0 */ declare const enum eRouteTraceStrategy { /** * Server strategy: Each page view gets a new, independent trace context. * No parent-child relationships are created between page views. * Each page will use the original server-provided trace context (if available) as its parent, * as defined by the {@link IConfiguration.traceHdrMode} configuration for distributed tracing headers. * This is the traditional behavior where each page view is treated as a separate operation. */ Server = 0, /** * Page strategy: Page views are chained together with parent-child relationships. * Each new page view inherits the trace context from the previous page view, * creating a connected chain of related operations for better correlation. */ Page = 1 } /** * Configuration interface specifically for AnalyticsPlugin * This interface defines only the configuration properties that the Analytics plugin uses. */ export declare interface IAnalyticsConfig { /** * A session is logged if the user is inactive for this amount of time in milliseconds. * @default 1800000 (30 minutes) */ sessionRenewalMs?: number; /** * A session is logged if it has continued for this amount of time in milliseconds. * @default 86400000 (24 hours) */ sessionExpirationMs?: number; /** * If true, exceptions are not autocollected. * @default false */ disableExceptionTracking?: boolean; /** * 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. * @default false */ autoTrackPageVisitTime?: boolean; /** * If true, default behavior of trackPageView is changed to record end of page view duration interval when trackPageView is called. * @default false */ overridePageViewDuration?: boolean; /** * Define whether to track unhandled promise rejections and report as JS errors. * @default false */ enableUnhandledPromiseRejectionTracking?: boolean; /** * Internal flag to track if unhandled promise instrumentation is already set up. * @default false * @internal Internal use only * @ignore INTERNAL ONLY */ autoUnhandledPromiseInstrumented?: boolean; /** * Percentage of events that will be sent. Value must be between 0 and 100. * @default 100 * @example 50 // Only send 50% of events */ samplingPercentage?: number; /** * If true, the SDK will not store or read any data from local and session storage. * @default false */ isStorageUseDisabled?: boolean; /** * If true, the SDK will track all Browser Link requests. * @default false */ isBrowserLinkTrackingEnabled?: boolean; /** * Automatically track route changes in Single Page Applications (SPA). If true, each route change will send a new Pageview to Application Insights. * @default false */ enableAutoRouteTracking?: boolean; /** * An optional value that will be used as name postfix for localStorage and session cookie name. * @default "" * @example "MyApp" // Results in localStorage keys like "ai_session_MyApp" */ namePrefix?: string; /** * If true, debugging data is thrown as an exception by the logger. * @default false */ enableDebug?: boolean; /** * If true, flush method will not be called when onBeforeUnload event triggers. * @default false */ disableFlushOnBeforeUnload?: boolean; /** * If true, flush method will not be called when onPageHide or onVisibilityChange (hidden state) event(s) trigger. * @default false */ disableFlushOnUnload?: boolean; /** * Internal flag to track if exception instrumentation is already set up. * @default false * @internal Internal use only * @ignore INTERNAL ONLY */ autoExceptionInstrumented?: boolean; /** * Exception configuration for additional exception handling options. * @default { inclScripts: false, expLog: undefined, maxLogs: 50 } */ expCfg?: IExceptionConfig; /** * Controls the trace context strategy for SPA route changes. * Determines how trace contexts are managed and correlated across virtual page views * in Single Page Applications, affecting telemetry correlation and operation tracking. * @default eRouteTraceStrategy.Server * @since 3.4.0 */ routeTraceStrategy?: eRouteTraceStrategy; } /** * Internal interface to pass appInsights object to subcomponents without coupling */ export declare interface IAppInsightsInternal { sendPageViewInternal(pageViewItem: IPageViewTelemetryInternal, properties?: Object, systemProperties?: Object): void; sendPageViewPerformanceInternal(pageViewPerformance: IPageViewPerformanceTelemetryInternal, properties?: Object, systemProperties?: Object): void; } export { }