@microsoft/applicationinsights-core-js 2.7.1-nightly.202110-03 → 2.7.1-nightly.202110-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-core-js.integrity.json +9 -9
- package/browser/applicationinsights-core-js.js +71 -2
- package/browser/applicationinsights-core-js.js.map +1 -1
- package/browser/applicationinsights-core-js.min.js +2 -2
- package/browser/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.api.json +300 -1
- package/dist/applicationinsights-core-js.api.md +15 -0
- package/dist/applicationinsights-core-js.d.ts +52 -1
- package/dist/applicationinsights-core-js.js +71 -2
- package/dist/applicationinsights-core-js.js.map +1 -1
- package/dist/applicationinsights-core-js.min.js +2 -2
- package/dist/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.rollup.d.ts +52 -1
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +100 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +3 -2
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
- package/dist-esm/applicationinsights-core-js.js +2 -2
- package/dist-esm/applicationinsights-core-js.js.map +1 -1
- package/package.json +1 -1
- package/src/JavaScriptSDK/CoreUtils.ts +116 -0
- package/src/JavaScriptSDK.Enums/LoggingEnums.ts +2 -1
- package/src/JavaScriptSDK.Interfaces/IConfiguration.ts +14 -0
- package/types/JavaScriptSDK/CoreUtils.d.ts +34 -0
- package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +1 -0
- package/types/JavaScriptSDK.Interfaces/IConfiguration.d.ts +12 -0
- package/types/applicationinsights-core-js.d.ts +1 -1
|
@@ -14,6 +14,10 @@ import {
|
|
|
14
14
|
} from "./HelperFuncs";
|
|
15
15
|
import { randomValue, random32, mwcRandomSeed, mwcRandom32 } from "./RandomHelper";
|
|
16
16
|
|
|
17
|
+
const strVisibilityChangeEvt: string = "visibilitychange";
|
|
18
|
+
const strPageHide: string = "pagehide";
|
|
19
|
+
const strPageShow: string = "pageshow";
|
|
20
|
+
|
|
17
21
|
let _cookieMgrs: ICookieMgr[] = null;
|
|
18
22
|
let _canUseCookies: boolean; // legacy supported config
|
|
19
23
|
|
|
@@ -42,6 +46,118 @@ export function addEventHandler(eventName: string, callback: any): boolean {
|
|
|
42
46
|
return result;
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Bind the listener to the array of events
|
|
51
|
+
* @param events An string array of event names to bind the listener to
|
|
52
|
+
* @param listener The event callback to call when the event is triggered
|
|
53
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
54
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
55
|
+
*/
|
|
56
|
+
export function addEventListeners(events: string[], listener: any, excludeEvents?: string[]): boolean {
|
|
57
|
+
let added = false;
|
|
58
|
+
|
|
59
|
+
if (listener && events && isArray(events)) {
|
|
60
|
+
let excluded: string[] = [];
|
|
61
|
+
arrForEach(events, (name) => {
|
|
62
|
+
if (isString(name)) {
|
|
63
|
+
if (!excludeEvents || arrIndexOf(excludeEvents, name) === -1) {
|
|
64
|
+
added = addEventHandler(name, listener) || added;
|
|
65
|
+
} else {
|
|
66
|
+
excluded.push(name);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (!added && excluded.length > 0) {
|
|
72
|
+
// Failed to add any listeners and we excluded some, so just attempt to add the excluded events
|
|
73
|
+
added = addEventListeners(excluded, listener);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return added;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Listen to the 'beforeunload', 'unload' and 'pagehide' events which indicates a page unload is occurring,
|
|
82
|
+
* this does NOT listen to the 'visibilitychange' event as while it does indicate that the page is being hidden
|
|
83
|
+
* it does not *necessarily* mean that the page is being completely unloaded, it can mean that the user is
|
|
84
|
+
* just navigating to a different Tab and may come back (without unloading the page). As such you may also
|
|
85
|
+
* need to listen to the 'addPageHideEventListener' and 'addPageShowEventListener' events.
|
|
86
|
+
* @param listener - The event callback to call when a page unload event is triggered
|
|
87
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked, unless no other events can be.
|
|
88
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
89
|
+
*/
|
|
90
|
+
export function addPageUnloadEventListener(listener: any, excludeEvents?: string[]): boolean {
|
|
91
|
+
// Hook the unload event for the document, window and body to ensure that the client events are flushed to the server
|
|
92
|
+
// As just hooking the window does not always fire (on chrome) for page navigation's.
|
|
93
|
+
return addEventListeners(["beforeunload", "unload", "pagehide"], listener, excludeEvents);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Listen to the pagehide and visibility changing to 'hidden' events
|
|
98
|
+
* @param listener - The event callback to call when a page hide event is triggered
|
|
99
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
100
|
+
* Suggestion: pass as true if you are also calling addPageUnloadEventListener as that also hooks pagehide
|
|
101
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
102
|
+
*/
|
|
103
|
+
export function addPageHideEventListener(listener: any, excludeEvents?: string[]): boolean {
|
|
104
|
+
|
|
105
|
+
function _handlePageVisibility(evt: any) {
|
|
106
|
+
let doc = getDocument();
|
|
107
|
+
if (listener && doc && doc.visibilityState === 'hidden') {
|
|
108
|
+
listener(evt);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let pageUnloadAdded = false;
|
|
113
|
+
if (!excludeEvents || arrIndexOf(excludeEvents, strPageHide) === -1) {
|
|
114
|
+
pageUnloadAdded = addEventHandler(strPageHide, listener);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
|
|
118
|
+
pageUnloadAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageUnloadAdded;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!pageUnloadAdded && excludeEvents) {
|
|
122
|
+
// Failed to add any listeners and we where requested to exclude some, so just call again without excluding anything
|
|
123
|
+
pageUnloadAdded = addPageHideEventListener(listener);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return pageUnloadAdded;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Listen to the pageshow and visibility changing to 'visible' events
|
|
131
|
+
* @param listener - The event callback to call when a page is show event is triggered
|
|
132
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
133
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
134
|
+
*/
|
|
135
|
+
export function addPageShowEventListener(listener: any, excludeEvents?: string[]): boolean {
|
|
136
|
+
|
|
137
|
+
function _handlePageVisibility(evt: any) {
|
|
138
|
+
let doc = getDocument();
|
|
139
|
+
if (listener && doc && doc.visibilityState === 'visible') {
|
|
140
|
+
listener(evt);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let pageShowAdded = false;
|
|
145
|
+
if (!excludeEvents || arrIndexOf(excludeEvents, strPageShow) === -1) {
|
|
146
|
+
pageShowAdded = addEventHandler(strPageShow, listener);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!excludeEvents || arrIndexOf(excludeEvents, strVisibilityChangeEvt) === -1) {
|
|
150
|
+
pageShowAdded = addEventHandler(strVisibilityChangeEvt, _handlePageVisibility) || pageShowAdded;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!pageShowAdded && excludeEvents) {
|
|
154
|
+
// Failed to add any listeners and we where requested to exclude some, so just call again without excluding anything
|
|
155
|
+
pageShowAdded = addPageShowEventListener(listener);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return pageShowAdded;
|
|
159
|
+
}
|
|
160
|
+
|
|
45
161
|
export function newGuid(): string {
|
|
46
162
|
function randomHexDigit() {
|
|
47
163
|
return randomValue(15); // Get a random value from 0..15
|
|
@@ -99,6 +99,7 @@ export const _InternalMessageId = {
|
|
|
99
99
|
CannotParseAiBlobValue: 101,
|
|
100
100
|
InvalidContentBlob: 102,
|
|
101
101
|
TrackPageActionEventFailed: 103,
|
|
102
|
-
FailedAddingCustomDefinedRequestContext: 104
|
|
102
|
+
FailedAddingCustomDefinedRequestContext: 104,
|
|
103
|
+
InMemoryStorageBufferFull: 105
|
|
103
104
|
};
|
|
104
105
|
export type _InternalMessageId = number | typeof _InternalMessageId;
|
|
@@ -149,4 +149,18 @@ export interface IConfiguration {
|
|
|
149
149
|
* cookieDomain and disableCookiesUsage values.
|
|
150
150
|
*/
|
|
151
151
|
cookieCfg?: ICookieMgrConfig;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* [Optional] An array of the page unload events that you would like to be ignored, special note there must be at least one valid unload
|
|
155
|
+
* event hooked, if you list all or the runtime environment only supports a listed "disabled" event it will still be hooked, if required by the SDK.
|
|
156
|
+
* Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
|
|
157
|
+
*/
|
|
158
|
+
disablePageUnloadEvents?: string[];
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* [Optional] An array of page show events that you would like to be ignored, special note there must be at lease one valid show event
|
|
162
|
+
* hooked, if you list all or the runtime environment only supports a listed (disabled) event it will STILL be hooked, if required by the SDK.
|
|
163
|
+
* Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
|
|
164
|
+
*/
|
|
165
|
+
disablePageShowEvents?: string[];
|
|
152
166
|
}
|
|
@@ -9,6 +9,40 @@ export declare const Undefined = "undefined";
|
|
|
9
9
|
* @return {boolean} - true if the handler was successfully added
|
|
10
10
|
*/
|
|
11
11
|
export declare function addEventHandler(eventName: string, callback: any): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Bind the listener to the array of events
|
|
14
|
+
* @param events An string array of event names to bind the listener to
|
|
15
|
+
* @param listener The event callback to call when the event is triggered
|
|
16
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
17
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
18
|
+
*/
|
|
19
|
+
export declare function addEventListeners(events: string[], listener: any, excludeEvents?: string[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Listen to the 'beforeunload', 'unload' and 'pagehide' events which indicates a page unload is occurring,
|
|
22
|
+
* this does NOT listen to the 'visibilitychange' event as while it does indicate that the page is being hidden
|
|
23
|
+
* it does not *necessarily* mean that the page is being completely unloaded, it can mean that the user is
|
|
24
|
+
* just navigating to a different Tab and may come back (without unloading the page). As such you may also
|
|
25
|
+
* need to listen to the 'addPageHideEventListener' and 'addPageShowEventListener' events.
|
|
26
|
+
* @param listener - The event callback to call when a page unload event is triggered
|
|
27
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked, unless no other events can be.
|
|
28
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
29
|
+
*/
|
|
30
|
+
export declare function addPageUnloadEventListener(listener: any, excludeEvents?: string[]): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Listen to the pagehide and visibility changing to 'hidden' events
|
|
33
|
+
* @param listener - The event callback to call when a page hide event is triggered
|
|
34
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
35
|
+
* Suggestion: pass as true if you are also calling addPageUnloadEventListener as that also hooks pagehide
|
|
36
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
37
|
+
*/
|
|
38
|
+
export declare function addPageHideEventListener(listener: any, excludeEvents?: string[]): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Listen to the pageshow and visibility changing to 'visible' events
|
|
41
|
+
* @param listener - The event callback to call when a page is show event is triggered
|
|
42
|
+
* @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
|
|
43
|
+
* @returns true - when at least one of the events was registered otherwise false
|
|
44
|
+
*/
|
|
45
|
+
export declare function addPageShowEventListener(listener: any, excludeEvents?: string[]): boolean;
|
|
12
46
|
export declare function newGuid(): string;
|
|
13
47
|
/**
|
|
14
48
|
* Return the current value of the Performance Api now() function (if available) and fallback to dateNow() if it is unavailable (IE9 or less)
|
|
@@ -93,5 +93,6 @@ export declare const _InternalMessageId: {
|
|
|
93
93
|
InvalidContentBlob: number;
|
|
94
94
|
TrackPageActionEventFailed: number;
|
|
95
95
|
FailedAddingCustomDefinedRequestContext: number;
|
|
96
|
+
InMemoryStorageBufferFull: number;
|
|
96
97
|
};
|
|
97
98
|
export declare type _InternalMessageId = number | typeof _InternalMessageId;
|
|
@@ -128,4 +128,16 @@ export interface IConfiguration {
|
|
|
128
128
|
* cookieDomain and disableCookiesUsage values.
|
|
129
129
|
*/
|
|
130
130
|
cookieCfg?: ICookieMgrConfig;
|
|
131
|
+
/**
|
|
132
|
+
* [Optional] An array of the page unload events that you would like to be ignored, special note there must be at least one valid unload
|
|
133
|
+
* event hooked, if you list all or the runtime environment only supports a listed "disabled" event it will still be hooked, if required by the SDK.
|
|
134
|
+
* Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
|
|
135
|
+
*/
|
|
136
|
+
disablePageUnloadEvents?: string[];
|
|
137
|
+
/**
|
|
138
|
+
* [Optional] An array of page show events that you would like to be ignored, special note there must be at lease one valid show event
|
|
139
|
+
* hooked, if you list all or the runtime environment only supports a listed (disabled) event it will STILL be hooked, if required by the SDK.
|
|
140
|
+
* Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
|
|
141
|
+
*/
|
|
142
|
+
disablePageShowEvents?: string[];
|
|
131
143
|
}
|
|
@@ -14,7 +14,7 @@ export { AppInsightsCore } from "./JavaScriptSDK/AppInsightsCore";
|
|
|
14
14
|
export { BaseCore } from './JavaScriptSDK/BaseCore';
|
|
15
15
|
export { BaseTelemetryPlugin } from './JavaScriptSDK/BaseTelemetryPlugin';
|
|
16
16
|
export { randomValue, random32, mwcRandomSeed, mwcRandom32 } from './JavaScriptSDK/RandomHelper';
|
|
17
|
-
export { CoreUtils, ICoreUtils, EventHelper, IEventHelper, Undefined, addEventHandler, newGuid, perfNow, newId, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr } from "./JavaScriptSDK/CoreUtils";
|
|
17
|
+
export { CoreUtils, ICoreUtils, EventHelper, IEventHelper, Undefined, addEventHandler, newGuid, perfNow, newId, generateW3CId, disableCookies, canUseCookies, getCookie, setCookie, deleteCookie, _legacyCookieMgr, addEventListeners, addPageUnloadEventListener, addPageHideEventListener, addPageShowEventListener } from "./JavaScriptSDK/CoreUtils";
|
|
18
18
|
export { isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, attachEvent, detachEvent, normalizeJsName, objForEachKey, strEndsWith, strStartsWith, isDate, isArray, isError, isString, isNumber, isBoolean, toISOString, arrForEach, arrIndexOf, arrMap, arrReduce, strTrim, objKeys, objDefineAccessors, dateNow, getExceptionName, throwError, strContains, isSymbol, setValue, getSetValue, isNotTruthy, isTruthy, proxyAssign, createClassFromInterface, optimizeObject, isNotUndefined, isNotNullOrUndefined, objFreeze, objSeal } from './JavaScriptSDK/HelperFuncs';
|
|
19
19
|
export { getGlobalInst, hasWindow, getWindow, hasDocument, getDocument, getCrypto, getMsCrypto, hasNavigator, getNavigator, hasHistory, getHistory, getLocation, getPerformance, hasJSON, getJSON, isReactNative, getConsole, dumpObj, isIE, getIEVersion, isSafari, setEnableEnvMocks, isBeaconsSupported, isFetchSupported, useXDomainRequest, isXhrSupported } from "./JavaScriptSDK/EnvUtils";
|
|
20
20
|
export { getGlobal, objCreateFn as objCreate, strShimPrototype as strPrototype, strShimFunction as strFunction, strShimUndefined as strUndefined, strShimObject as strObject } from '@microsoft/applicationinsights-shims';
|