@microsoft/applicationinsights-analytics-js 2.8.0-beta.2203-04 → 2.8.0-beta.2203-07
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/browser/applicationinsights-analytics-js.integrity.json +9 -9
- package/browser/applicationinsights-analytics-js.js +771 -258
- package/browser/applicationinsights-analytics-js.js.map +1 -1
- package/browser/applicationinsights-analytics-js.min.js +2 -2
- package/browser/applicationinsights-analytics-js.min.js.map +1 -1
- package/dist/applicationinsights-analytics-js.api.json +48 -183
- package/dist/applicationinsights-analytics-js.api.md +8 -18
- package/dist/applicationinsights-analytics-js.d.ts +9 -104
- package/dist/applicationinsights-analytics-js.js +771 -258
- package/dist/applicationinsights-analytics-js.js.map +1 -1
- package/dist/applicationinsights-analytics-js.min.js +2 -2
- package/dist/applicationinsights-analytics-js.min.js.map +1 -1
- package/dist/applicationinsights-analytics-js.rollup.d.ts +9 -104
- package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js +674 -0
- package/dist-esm/JavaScriptSDK/AnalyticsPlugin.js.map +1 -0
- package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js +21 -8
- package/dist-esm/JavaScriptSDK/Telemetry/PageViewManager.js.map +1 -1
- package/dist-esm/JavaScriptSDK/Telemetry/PageViewPerformanceManager.js +1 -1
- package/dist-esm/JavaScriptSDK/Telemetry/PageVisitTimeManager.js +1 -1
- package/dist-esm/JavaScriptSDK/Timing.js +39 -0
- package/dist-esm/JavaScriptSDK/Timing.js.map +1 -0
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryConfig.js +1 -1
- package/dist-esm/applicationinsights-analytics-js.js +2 -2
- package/dist-esm/applicationinsights-analytics-js.js.map +1 -1
- package/package.json +5 -5
- package/src/JavaScriptSDK/{ApplicationInsights.ts → AnalyticsPlugin.ts} +403 -324
- package/src/JavaScriptSDK/Telemetry/PageViewManager.ts +28 -9
- package/src/JavaScriptSDK/Timing.ts +46 -0
- package/src/applicationinsights-analytics-js.ts +1 -1
- package/types/JavaScriptSDK/{ApplicationInsights.d.ts → AnalyticsPlugin.d.ts} +7 -11
- package/types/JavaScriptSDK/Telemetry/PageViewManager.d.ts +2 -1
- package/types/JavaScriptSDK/Timing.d.ts +18 -0
- package/types/applicationinsights-analytics-js.d.ts +1 -1
- package/dist-esm/JavaScriptSDK/ApplicationInsights.js +0 -606
- package/dist-esm/JavaScriptSDK/ApplicationInsights.js.map +0 -1
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "@microsoft/applicationinsights-common";
|
|
7
7
|
import {
|
|
8
8
|
IAppInsightsCore, IDiagnosticLogger, LoggingSeverity,
|
|
9
|
-
_InternalMessageId, getDocument, getLocation, arrForEach, isNullOrUndefined, getExceptionName, dumpObj
|
|
9
|
+
_InternalMessageId, getDocument, getLocation, arrForEach, isNullOrUndefined, getExceptionName, dumpObj, IProcessTelemetryUnloadContext, ITelemetryUnloadState
|
|
10
10
|
} from "@microsoft/applicationinsights-core-js";
|
|
11
11
|
import { PageViewPerformanceManager } from "./PageViewPerformanceManager";
|
|
12
12
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
@@ -40,11 +40,9 @@ export class PageViewManager {
|
|
|
40
40
|
_logger = core.logger;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function _flushChannels() {
|
|
43
|
+
function _flushChannels(isAsync: boolean) {
|
|
44
44
|
if (core) {
|
|
45
|
-
|
|
46
|
-
arrForEach(queues, (q) => { q.flush(true); })
|
|
47
|
-
});
|
|
45
|
+
core.flush(isAsync);
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -72,7 +70,7 @@ export class PageViewManager {
|
|
|
72
70
|
|
|
73
71
|
if (doFlush) {
|
|
74
72
|
// We process at least one item so flush the queue
|
|
75
|
-
_flushChannels();
|
|
73
|
+
_flushChannels(true);
|
|
76
74
|
}
|
|
77
75
|
}), 100);
|
|
78
76
|
}
|
|
@@ -99,7 +97,7 @@ export class PageViewManager {
|
|
|
99
97
|
pageView,
|
|
100
98
|
customProperties
|
|
101
99
|
);
|
|
102
|
-
_flushChannels();
|
|
100
|
+
_flushChannels(true);
|
|
103
101
|
|
|
104
102
|
// no navigation timing (IE 8, iOS Safari 8.4, Opera Mini 8 - see http://caniuse.com/#feat=nav-timing)
|
|
105
103
|
_logger.throwInternal(
|
|
@@ -143,7 +141,7 @@ export class PageViewManager {
|
|
|
143
141
|
pageView,
|
|
144
142
|
customProperties
|
|
145
143
|
);
|
|
146
|
-
_flushChannels();
|
|
144
|
+
_flushChannels(true);
|
|
147
145
|
pageViewSent = true;
|
|
148
146
|
}
|
|
149
147
|
|
|
@@ -207,7 +205,24 @@ export class PageViewManager {
|
|
|
207
205
|
|
|
208
206
|
return processed;
|
|
209
207
|
});
|
|
210
|
-
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
_self.teardown = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) => {
|
|
211
|
+
if (intervalHandle) {
|
|
212
|
+
clearInterval(intervalHandle);
|
|
213
|
+
intervalHandle = null;
|
|
214
|
+
|
|
215
|
+
let allItems = itemQueue.slice(0);
|
|
216
|
+
let doFlush = false;
|
|
217
|
+
itemQueue = [];
|
|
218
|
+
arrForEach(allItems, (item) => {
|
|
219
|
+
if (item()) {
|
|
220
|
+
doFlush = true;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
211
226
|
});
|
|
212
227
|
}
|
|
213
228
|
|
|
@@ -224,4 +239,8 @@ export class PageViewManager {
|
|
|
224
239
|
public trackPageView(pageView: IPageViewTelemetry, customProperties?: { [key: string]: any }) {
|
|
225
240
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
226
241
|
}
|
|
242
|
+
|
|
243
|
+
public teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState) {
|
|
244
|
+
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
245
|
+
}
|
|
227
246
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import { dateTimeUtilsDuration } from "@microsoft/applicationinsights-common";
|
|
5
|
+
import { IDiagnosticLogger, LoggingSeverity, _InternalMessageId, _throwInternal } from "@microsoft/applicationinsights-core-js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Used to record timed events and page views.
|
|
9
|
+
*/
|
|
10
|
+
export class Timing {
|
|
11
|
+
|
|
12
|
+
public action: (name?: string, url?: string, duration?: number, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) => void;
|
|
13
|
+
public start: (name: string) => void;
|
|
14
|
+
public stop: (name: string, url: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) => void;
|
|
15
|
+
|
|
16
|
+
constructor(logger: IDiagnosticLogger, name: string) {
|
|
17
|
+
let _self = this;
|
|
18
|
+
let _events: { [key: string]: number; } = {}
|
|
19
|
+
|
|
20
|
+
_self.start = (name: string) => {
|
|
21
|
+
if (typeof _events[name] !== "undefined") {
|
|
22
|
+
_throwInternal(logger,
|
|
23
|
+
LoggingSeverity.WARNING, _InternalMessageId.StartCalledMoreThanOnce, "start was called more than once for this event without calling stop.",
|
|
24
|
+
{ name, key: name }, true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_events[name] = +new Date;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_self.stop = (name: string, url: string, properties?: { [key: string]: string }, measurements?: { [key: string]: number }) => {
|
|
31
|
+
const start = _events[name];
|
|
32
|
+
if (isNaN(start)) {
|
|
33
|
+
_throwInternal(logger,
|
|
34
|
+
LoggingSeverity.WARNING, _InternalMessageId.StopCalledWithoutStart, "stop was called without a corresponding start.",
|
|
35
|
+
{ name, key: name }, true);
|
|
36
|
+
} else {
|
|
37
|
+
const end = +new Date;
|
|
38
|
+
const duration = dateTimeUtilsDuration(start, end);
|
|
39
|
+
_self.action(name, url, duration, properties, measurements);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
delete _events[name];
|
|
43
|
+
_events[name] = undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
export { ApplicationInsights } from "./JavaScriptSDK/
|
|
4
|
+
export { AnalyticsPlugin, AnalyticsPlugin as ApplicationInsights } from "./JavaScriptSDK/AnalyticsPlugin";
|
|
5
5
|
export { IAppInsightsInternal } from "./JavaScriptSDK/Telemetry/PageViewManager";
|
|
@@ -3,22 +3,17 @@
|
|
|
3
3
|
* @copyright Microsoft 2018
|
|
4
4
|
*/
|
|
5
5
|
import { IConfig, IAppInsights, IEventTelemetry, IExceptionTelemetry, ITraceTelemetry, IMetricTelemetry, IAutoExceptionTelemetry, IPageViewTelemetryInternal, IPageViewTelemetry, IPageViewPerformanceTelemetry, IPageViewPerformanceTelemetryInternal } from "@microsoft/applicationinsights-common";
|
|
6
|
-
import { IPlugin, IConfiguration, IAppInsightsCore, BaseTelemetryPlugin, ITelemetryItem, IProcessTelemetryContext, ITelemetryPluginChain, ICustomProperties, ICookieMgr } from "@microsoft/applicationinsights-core-js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare class ApplicationInsights extends BaseTelemetryPlugin implements IAppInsights, IAppInsightsInternal {
|
|
6
|
+
import { IPlugin, IConfiguration, IAppInsightsCore, BaseTelemetryPlugin, ITelemetryItem, IProcessTelemetryContext, ITelemetryPluginChain, ICustomProperties, ICookieMgr, ITelemetryInitializerHandler } from "@microsoft/applicationinsights-core-js";
|
|
7
|
+
import { IAppInsightsInternal } from "./Telemetry/PageViewManager";
|
|
8
|
+
declare function _getDefaultConfig(config?: IConfig): IConfig;
|
|
9
|
+
export declare class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights, IAppInsightsInternal {
|
|
11
10
|
static Version: string;
|
|
12
|
-
static getDefaultConfig
|
|
11
|
+
static getDefaultConfig: typeof _getDefaultConfig;
|
|
13
12
|
identifier: string;
|
|
14
13
|
priority: number;
|
|
15
14
|
config: IConfig;
|
|
16
15
|
queue: Array<() => void>;
|
|
17
16
|
autoRoutePVDelay: number;
|
|
18
|
-
protected _telemetryInitializers: Array<(envelope: ITelemetryItem) => boolean | void>;
|
|
19
|
-
protected _pageViewManager: PageViewManager;
|
|
20
|
-
protected _pageViewPerformanceManager: PageViewPerformanceManager;
|
|
21
|
-
protected _pageVisitTimeManager: PageVisitTimeManager;
|
|
22
17
|
constructor();
|
|
23
18
|
/**
|
|
24
19
|
* Get the current cookie manager for this instance
|
|
@@ -142,6 +137,7 @@ export declare class ApplicationInsights extends BaseTelemetryPlugin implements
|
|
|
142
137
|
* @memberof ApplicationInsights
|
|
143
138
|
*/
|
|
144
139
|
_onerror(exception: IAutoExceptionTelemetry): void;
|
|
145
|
-
addTelemetryInitializer(telemetryInitializer: (item: ITelemetryItem) => boolean | void): void;
|
|
140
|
+
addTelemetryInitializer(telemetryInitializer: (item: ITelemetryItem) => boolean | void): ITelemetryInitializerHandler | void;
|
|
146
141
|
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
147
142
|
}
|
|
143
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IPageViewTelemetry, IPageViewTelemetryInternal, IPageViewPerformanceTelemetryInternal } from "@microsoft/applicationinsights-common";
|
|
2
|
-
import { IAppInsightsCore } from "@microsoft/applicationinsights-core-js";
|
|
2
|
+
import { IAppInsightsCore, IProcessTelemetryUnloadContext, ITelemetryUnloadState } from "@microsoft/applicationinsights-core-js";
|
|
3
3
|
import { PageViewPerformanceManager } from "./PageViewPerformanceManager";
|
|
4
4
|
/**
|
|
5
5
|
* Internal interface to pass appInsights object to subcomponents without coupling
|
|
@@ -26,4 +26,5 @@ export declare class PageViewManager {
|
|
|
26
26
|
trackPageView(pageView: IPageViewTelemetry, customProperties?: {
|
|
27
27
|
[key: string]: any;
|
|
28
28
|
}): void;
|
|
29
|
+
teardown(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState): void;
|
|
29
30
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js";
|
|
2
|
+
/**
|
|
3
|
+
* Used to record timed events and page views.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Timing {
|
|
6
|
+
action: (name?: string, url?: string, duration?: number, properties?: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
}, measurements?: {
|
|
9
|
+
[key: string]: number;
|
|
10
|
+
}) => void;
|
|
11
|
+
start: (name: string) => void;
|
|
12
|
+
stop: (name: string, url: string, properties?: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
}, measurements?: {
|
|
15
|
+
[key: string]: number;
|
|
16
|
+
}) => void;
|
|
17
|
+
constructor(logger: IDiagnosticLogger, name: string);
|
|
18
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ApplicationInsights } from "./JavaScriptSDK/
|
|
1
|
+
export { AnalyticsPlugin, AnalyticsPlugin as ApplicationInsights } from "./JavaScriptSDK/AnalyticsPlugin";
|
|
2
2
|
export { IAppInsightsInternal } from "./JavaScriptSDK/Telemetry/PageViewManager";
|