@microsoft/applicationinsights-core-js 2.8.1-nightly.2204-21 → 2.8.2-nightly.2204-24
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 +64 -44
- 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 +95 -1
- package/dist/applicationinsights-core-js.api.md +3 -0
- package/dist/applicationinsights-core-js.d.ts +11 -1
- package/dist/applicationinsights-core-js.js +64 -44
- 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 +11 -1
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +5 -5
- package/dist-esm/JavaScriptSDK/BaseCore.js.map +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 +1 -1
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
- package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +3 -3
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/EventHelpers.js +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +66 -44
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InternalConstants.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/TelemetryInitializerPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.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/IDbgExtension.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/ITelemetryInitializers.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/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.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 +2 -2
- package/src/JavaScriptSDK/BaseCore.ts +5 -4
- package/src/JavaScriptSDK/DataCacheHelper.ts +1 -1
- package/src/JavaScriptSDK/DiagnosticLogger.ts +2 -2
- package/src/JavaScriptSDK/InstrumentHooks.ts +75 -48
- package/types/JavaScriptSDK/InstrumentHooks.d.ts +9 -0
- package/types/applicationinsights-core-js.d.ts +1 -1
- package/types/tsdoc-metadata.json +1 -1
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { strShimFunction, strShimPrototype } from "@microsoft/applicationinsights-shims";
|
|
8
8
|
import { hasOwnProperty, _getObjProto } from "./HelperFuncs";
|
|
9
9
|
import { getGlobalInst } from "./EnvUtils";
|
|
10
|
+
import { createElmNodeData } from "./DataCacheHelper";
|
|
10
11
|
|
|
11
12
|
const aiInstrumentHooks = "_aiHooks";
|
|
12
13
|
|
|
@@ -109,15 +110,17 @@ function _createFunctionHook(aiHook:IInstrumentHooks) {
|
|
|
109
110
|
|
|
110
111
|
// Call the original function was called
|
|
111
112
|
let theFunc = aiHook.f;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
if (theFunc) {
|
|
114
|
+
try {
|
|
115
|
+
funcArgs.rslt = theFunc.apply(funcThis, orgArgs);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
// Report the request callback
|
|
118
|
+
funcArgs.err = err;
|
|
119
|
+
_doCallbacks(hooks, funcArgs, cbArgs, hookCtx, CallbackType.FunctionError);
|
|
120
|
+
|
|
121
|
+
// rethrow the original exception so anyone listening for it can catch the exception
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
// Call the post-request hooks
|
|
@@ -129,7 +132,7 @@ function _createFunctionHook(aiHook:IInstrumentHooks) {
|
|
|
129
132
|
|
|
130
133
|
|
|
131
134
|
/** @ignore */
|
|
132
|
-
function _getOwner(target:any, name:string, checkPrototype:boolean): any {
|
|
135
|
+
function _getOwner(target:any, name:string, checkPrototype: boolean): any {
|
|
133
136
|
let owner = null;
|
|
134
137
|
if (target) {
|
|
135
138
|
if (hasOwnProperty(target, name)) {
|
|
@@ -170,6 +173,47 @@ export function InstrumentProtos(target:any, funcNames:string[], callbacks: IIns
|
|
|
170
173
|
return null;
|
|
171
174
|
}
|
|
172
175
|
|
|
176
|
+
function _createInstrumentHook(owner: any, funcName: string, fn: any, callbacks: IInstrumentHooksCallbacks) {
|
|
177
|
+
let aiHook: IInstrumentHooks = fn && fn[aiInstrumentHooks];
|
|
178
|
+
if (!aiHook) {
|
|
179
|
+
// Only hook the function once
|
|
180
|
+
aiHook = {
|
|
181
|
+
i: 0,
|
|
182
|
+
n: funcName,
|
|
183
|
+
f: fn,
|
|
184
|
+
h: []
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// Override (hook) the original function
|
|
188
|
+
let newFunc = _createFunctionHook(aiHook);
|
|
189
|
+
newFunc[aiInstrumentHooks] = aiHook; // Tag and store the function hooks
|
|
190
|
+
owner[funcName] = newFunc;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const theHook: IInstrumentHook = {
|
|
194
|
+
// tslint:disable:object-literal-shorthand
|
|
195
|
+
id: aiHook.i,
|
|
196
|
+
cbks: callbacks,
|
|
197
|
+
rm: function () {
|
|
198
|
+
// DO NOT Use () => { shorthand for the function as the this gets replaced
|
|
199
|
+
// with the outer this and not the this for theHook instance.
|
|
200
|
+
let id = this.id;
|
|
201
|
+
_arrLoop(aiHook.h, (hook, idx) => {
|
|
202
|
+
if (hook.id === id) {
|
|
203
|
+
aiHook.h.splice(idx, 1);
|
|
204
|
+
return 1;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// tslint:enable:object-literal-shorthand
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
aiHook.i++;
|
|
212
|
+
aiHook.h.push(theHook);
|
|
213
|
+
|
|
214
|
+
return theHook;
|
|
215
|
+
}
|
|
216
|
+
|
|
173
217
|
/**
|
|
174
218
|
* Intercept the named prototype functions for the target class / object
|
|
175
219
|
* @param target - The target object
|
|
@@ -183,44 +227,7 @@ export function InstrumentFunc(target:any, funcName:string, callbacks: IInstrume
|
|
|
183
227
|
if (owner) {
|
|
184
228
|
let fn = owner[funcName]
|
|
185
229
|
if (typeof fn === strShimFunction) {
|
|
186
|
-
|
|
187
|
-
if (!aiHook) {
|
|
188
|
-
// Only hook the function once
|
|
189
|
-
aiHook = {
|
|
190
|
-
i: 0,
|
|
191
|
-
n: funcName,
|
|
192
|
-
f: fn,
|
|
193
|
-
h: []
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
// Override (hook) the original function
|
|
197
|
-
let newFunc = _createFunctionHook(aiHook);
|
|
198
|
-
newFunc[aiInstrumentHooks] = aiHook; // Tag and store the function hooks
|
|
199
|
-
owner[funcName] = newFunc;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const theHook: IInstrumentHook = {
|
|
203
|
-
// tslint:disable:object-literal-shorthand
|
|
204
|
-
id: aiHook.i,
|
|
205
|
-
cbks: callbacks,
|
|
206
|
-
rm: function() {
|
|
207
|
-
// DO NOT Use () => { shorthand for the function as the this gets replaced
|
|
208
|
-
// with the outer this and not the this for theHook instance.
|
|
209
|
-
let id = this.id;
|
|
210
|
-
_arrLoop(aiHook.h, (hook, idx) => {
|
|
211
|
-
if (hook.id === id) {
|
|
212
|
-
aiHook.h.splice(idx, 1);
|
|
213
|
-
return 1;
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
// tslint:enable:object-literal-shorthand
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
aiHook.i ++;
|
|
221
|
-
aiHook.h.push(theHook);
|
|
222
|
-
|
|
223
|
-
return theHook;
|
|
230
|
+
return _createInstrumentHook(owner, funcName, fn, callbacks);
|
|
224
231
|
}
|
|
225
232
|
}
|
|
226
233
|
}
|
|
@@ -250,3 +257,23 @@ export function InstrumentFuncs(target:any, funcNames:string[], callbacks: IInst
|
|
|
250
257
|
|
|
251
258
|
return hooks;
|
|
252
259
|
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Add an instrumentation hook to the provided named "event" for the target class / object, this doesn't check whether the
|
|
263
|
+
* named "event" is in fact a function and just assigns the instrumentation hook to the target[evtName]
|
|
264
|
+
* @param target - The target object
|
|
265
|
+
* @param evtName - The name of the event
|
|
266
|
+
* @param callbacks - The callbacks to configure and call whenever the function is called
|
|
267
|
+
* @param checkPrototype - If the function doesn't exist on the target should it attempt to hook the prototype function
|
|
268
|
+
*/
|
|
269
|
+
export function InstrumentEvent(target: any, evtName: string, callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean): IInstrumentHook {
|
|
270
|
+
if (target && evtName && callbacks) {
|
|
271
|
+
let owner = _getOwner(target, evtName, checkPrototype) || target;
|
|
272
|
+
if (owner) {
|
|
273
|
+
return _createInstrumentHook(owner, evtName, owner[evtName], callbacks);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
|
|
@@ -29,3 +29,12 @@ export declare function InstrumentFunc(target: any, funcName: string, callbacks:
|
|
|
29
29
|
* @param checkPrototype - If the function doesn't exist on the target should it attempt to hook the prototype function
|
|
30
30
|
*/
|
|
31
31
|
export declare function InstrumentFuncs(target: any, funcNames: string[], callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean): IInstrumentHook[];
|
|
32
|
+
/**
|
|
33
|
+
* Add an instrumentation hook to the provided named "event" for the target class / object, this doesn't check whether the
|
|
34
|
+
* named "event" is in fact a function and just assigns the instrumentation hook to the target[evtName]
|
|
35
|
+
* @param target - The target object
|
|
36
|
+
* @param evtName - The name of the event
|
|
37
|
+
* @param callbacks - The callbacks to configure and call whenever the function is called
|
|
38
|
+
* @param checkPrototype - If the function doesn't exist on the target should it attempt to hook the prototype function
|
|
39
|
+
*/
|
|
40
|
+
export declare function InstrumentEvent(target: any, evtName: string, callbacks: IInstrumentHooksCallbacks, checkPrototype?: boolean): IInstrumentHook;
|
|
@@ -32,7 +32,7 @@ export { safeGetLogger, DiagnosticLogger, _InternalLogMessage, _throwInternal, _
|
|
|
32
32
|
export { ProcessTelemetryContext, createProcessTelemetryContext } from "./JavaScriptSDK/ProcessTelemetryContext";
|
|
33
33
|
export { initializePlugins, sortPlugins, unloadComponents } from "./JavaScriptSDK/TelemetryHelpers";
|
|
34
34
|
export { _InternalMessageId, _eInternalMessageId, LoggingSeverity, eLoggingSeverity } from "./JavaScriptSDK.Enums/LoggingEnums";
|
|
35
|
-
export { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs } from "./JavaScriptSDK/InstrumentHooks";
|
|
35
|
+
export { InstrumentProto, InstrumentProtos, InstrumentFunc, InstrumentFuncs, InstrumentEvent } from "./JavaScriptSDK/InstrumentHooks";
|
|
36
36
|
export { ICookieMgr, ICookieMgrConfig } from "./JavaScriptSDK.Interfaces/ICookieMgr";
|
|
37
37
|
export { createCookieMgr, safeGetCookieMgr, uaDisallowsSameSiteNone, areCookiesSupported } from "./JavaScriptSDK/CookieMgr";
|
|
38
38
|
export { IDbgExtension } from "./JavaScriptSDK.Interfaces/IDbgExtension";
|