@microsoft/applicationinsights-perfmarkmeasure-js 3.1.0-nightly3.2402-09 → 3.1.1-nightly3.2402-13
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/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.cjs.js → ai.prfmm-mgr.3.1.1-nightly3.2402-13.cjs.js} +2 -2
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.cjs.js.map → ai.prfmm-mgr.3.1.1-nightly3.2402-13.cjs.js.map} +1 -1
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.cjs.min.js → ai.prfmm-mgr.3.1.1-nightly3.2402-13.cjs.min.js} +2 -2
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.cjs.min.js.map → ai.prfmm-mgr.3.1.1-nightly3.2402-13.cjs.min.js.map} +1 -1
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.gbl.js → ai.prfmm-mgr.3.1.1-nightly3.2402-13.gbl.js} +4 -4
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.gbl.js.map → ai.prfmm-mgr.3.1.1-nightly3.2402-13.gbl.js.map} +1 -1
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.gbl.min.js → ai.prfmm-mgr.3.1.1-nightly3.2402-13.gbl.min.js} +3 -3
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.gbl.min.js.map → ai.prfmm-mgr.3.1.1-nightly3.2402-13.gbl.min.js.map} +1 -1
- package/browser/es5/ai.prfmm-mgr.3.1.1-nightly3.2402-13.integrity.json +66 -0
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.js → ai.prfmm-mgr.3.1.1-nightly3.2402-13.js} +4 -4
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.js.map → ai.prfmm-mgr.3.1.1-nightly3.2402-13.js.map} +1 -1
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.min.js → ai.prfmm-mgr.3.1.1-nightly3.2402-13.min.js} +3 -3
- package/browser/es5/{ai.prfmm-mgr.3.1.0-nightly3.2402-09.min.js.map → ai.prfmm-mgr.3.1.1-nightly3.2402-13.min.js.map} +1 -1
- package/browser/es5/ai.prfmm-mgr.3.cjs.js +1 -1
- package/browser/es5/ai.prfmm-mgr.3.cjs.js.map +1 -1
- package/browser/es5/ai.prfmm-mgr.3.cjs.min.js +1 -1
- package/browser/es5/ai.prfmm-mgr.3.cjs.min.js.map +1 -1
- package/browser/es5/ai.prfmm-mgr.3.gbl.js +3 -3
- package/browser/es5/ai.prfmm-mgr.3.gbl.js.map +1 -1
- package/browser/es5/ai.prfmm-mgr.3.gbl.min.js +2 -2
- package/browser/es5/ai.prfmm-mgr.3.gbl.min.js.map +1 -1
- package/browser/es5/ai.prfmm-mgr.3.integrity.json +25 -25
- package/browser/es5/ai.prfmm-mgr.3.js +3 -3
- package/browser/es5/ai.prfmm-mgr.3.js.map +1 -1
- package/browser/es5/ai.prfmm-mgr.3.min.js +2 -2
- package/browser/es5/ai.prfmm-mgr.3.min.js.map +1 -1
- package/dist/es5/applicationinsights-perfmarkmeasure-js.js +1 -1
- package/dist/es5/applicationinsights-perfmarkmeasure-js.js.map +1 -1
- package/dist/es5/applicationinsights-perfmarkmeasure-js.min.js +1 -1
- package/dist/es5/applicationinsights-perfmarkmeasure-js.min.js.map +1 -1
- package/dist-es5/PerfMarkMeasureManager.js +1 -1
- package/dist-es5/__DynamicConstants.js +1 -1
- package/dist-es5/applicationinsights-perfmarkmeasure-js.js +1 -1
- package/dist-es5/interfaces/IPerfMarkMeasureConfiguration.js +1 -1
- package/package.json +4 -4
- package/types/applicationinsights-perfmarkmeasure-js.d.ts +7 -2
- package/types/applicationinsights-perfmarkmeasure-js.namespaced.d.ts +518 -14
- package/browser/es5/ai.prfmm-mgr.3.1.0-nightly3.2402-09.integrity.json +0 -66
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.
|
|
2
|
+
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.1-nightly3.2402-13
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.
|
|
2
|
+
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.1-nightly3.2402-13
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.
|
|
2
|
+
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.1-nightly3.2402-13
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.
|
|
2
|
+
* Application Insights JavaScript SDK - Performance Mark and Measure Manager plugin, 3.1.1-nightly3.2402-13
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-perfmarkmeasure-js",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1-nightly3.2402-13",
|
|
4
4
|
"description": "Microsoft Application Insights Performance Mark and Measure Manager plugin",
|
|
5
5
|
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
6
|
"author": "Microsoft Application Insights Team",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@microsoft/ai-test-framework": "0.0.1",
|
|
33
33
|
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
|
|
34
34
|
"@microsoft/applicationinsights-rollup-es5": "1.0.2",
|
|
35
|
-
"@microsoft/api-extractor": "^7.
|
|
35
|
+
"@microsoft/api-extractor": "^7.40.0",
|
|
36
36
|
"typescript": "^4.9.3",
|
|
37
37
|
"tslib": "^2.0.0",
|
|
38
38
|
"grunt": "^1.5.3",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@microsoft/dynamicproto-js": "^2.0.3",
|
|
57
57
|
"@microsoft/applicationinsights-shims": "3.0.1",
|
|
58
|
-
"@microsoft/applicationinsights-core-js": "3.1.
|
|
59
|
-
"@nevware21/ts-utils": ">= 0.10.
|
|
58
|
+
"@microsoft/applicationinsights-core-js": "3.1.1-nightly3.2402-13",
|
|
59
|
+
"@nevware21/ts-utils": ">= 0.10.5 < 2.x"
|
|
60
60
|
},
|
|
61
61
|
"license": "MIT",
|
|
62
62
|
"publishConfig": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights Performance Mark and Measure Manager plugin, 3.1.
|
|
2
|
+
* Microsoft Application Insights Performance Mark and Measure Manager plugin, 3.1.1-nightly3.2402-13
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -20,10 +20,15 @@ import { IPerfManagerProvider } from '@microsoft/applicationinsights-core-js';
|
|
|
20
20
|
import { PerfManager } from '@microsoft/applicationinsights-core-js';
|
|
21
21
|
|
|
22
22
|
export { doPerf }
|
|
23
|
+
|
|
23
24
|
export { INotificationManager }
|
|
25
|
+
|
|
24
26
|
export { IPerfEvent }
|
|
27
|
+
|
|
25
28
|
export { IPerfManager }
|
|
29
|
+
|
|
26
30
|
export { IPerfManagerProvider }
|
|
31
|
+
|
|
27
32
|
/**
|
|
28
33
|
* @copyright Microsoft 2021
|
|
29
34
|
*/
|
|
@@ -95,4 +100,4 @@ export declare class PerfMarkMeasureManager extends PerfManager {
|
|
|
95
100
|
fire(perfEvent: IPerfEvent): void;
|
|
96
101
|
}
|
|
97
102
|
|
|
98
|
-
export { }
|
|
103
|
+
export { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights Performance Mark and Measure Manager plugin, 3.1.
|
|
2
|
+
* Microsoft Application Insights Performance Mark and Measure Manager plugin, 3.1.1-nightly3.2402-13
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -7,18 +7,218 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
declare namespace ApplicationInsights {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Helper function to wrap a function with a perf event
|
|
12
|
+
* @param mgrSource - The Performance Manager or a Performance provider source (may be null)
|
|
13
|
+
* @param getSource - The callback to create the source name for the event (if perf monitoring is enabled)
|
|
14
|
+
* @param func - The function to call and measure
|
|
15
|
+
* @param details - A function to return the payload details
|
|
16
|
+
* @param isAsync - Is the event / function being call asynchronously or synchronously
|
|
17
|
+
*/
|
|
18
|
+
function doPerf<T>(mgrSource: IPerfManagerProvider | IPerfManager, getSource: () => string, func: (perfEvt?: IPerfEvent) => T, details?: () => any, isAsync?: boolean): T;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This defines the handler function that is called via the finally when the promise is resolved or rejected
|
|
22
|
+
*/
|
|
23
|
+
type FinallyPromiseHandler = (() => void) | undefined | null;
|
|
24
|
+
|
|
25
|
+
interface ICustomProperties {
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An interface used for the notification listener.
|
|
31
|
+
* @interface
|
|
32
|
+
*/
|
|
33
|
+
interface INotificationListener {
|
|
34
|
+
/**
|
|
35
|
+
* [Optional] A function called when events are sent.
|
|
36
|
+
* @param events - The array of events that have been sent.
|
|
37
|
+
*/
|
|
38
|
+
eventsSent?: (events: ITelemetryItem[]) => void;
|
|
39
|
+
/**
|
|
40
|
+
* [Optional] A function called when events are discarded.
|
|
41
|
+
* @param events - The array of events that have been discarded.
|
|
42
|
+
* @param reason - The reason for discarding the events. The EventsDiscardedReason
|
|
43
|
+
* constant should be used to check the different values.
|
|
44
|
+
*/
|
|
45
|
+
eventsDiscarded?: (events: ITelemetryItem[], reason: number) => void;
|
|
46
|
+
/**
|
|
47
|
+
* [Optional] A function called when the events have been requested to be sent to the sever.
|
|
48
|
+
* @param sendReason - The reason why the event batch is being sent.
|
|
49
|
+
* @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
|
|
50
|
+
*/
|
|
51
|
+
eventsSendRequest?: (sendReason: number, isAsync?: boolean) => void;
|
|
52
|
+
/**
|
|
53
|
+
* [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
|
|
54
|
+
* the event can be displayed via the debug plugin extension.
|
|
55
|
+
* @param perfEvent
|
|
56
|
+
*/
|
|
57
|
+
perfEvent?: (perfEvent: IPerfEvent) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Unload and remove any state that this INotificationListener may be holding, this is generally called when the
|
|
60
|
+
* owning Manager is being unloaded.
|
|
61
|
+
* @param isAsync - Can the unload be performed asynchronously (default)
|
|
62
|
+
* @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
|
|
63
|
+
* the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
|
|
64
|
+
* / Promise to allow any listeners to wait for the operation to complete.
|
|
65
|
+
*/
|
|
66
|
+
unload?(isAsync?: boolean): void | IPromise<void>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Class to manage sending notifications to all the listeners.
|
|
71
|
+
*/
|
|
72
|
+
interface INotificationManager {
|
|
73
|
+
listeners: INotificationListener[];
|
|
74
|
+
/**
|
|
75
|
+
* Adds a notification listener.
|
|
76
|
+
* @param listener - The notification listener to be added.
|
|
77
|
+
*/
|
|
78
|
+
addNotificationListener(listener: INotificationListener): void;
|
|
79
|
+
/**
|
|
80
|
+
* Removes all instances of the listener.
|
|
81
|
+
* @param listener - AWTNotificationListener to remove.
|
|
82
|
+
*/
|
|
83
|
+
removeNotificationListener(listener: INotificationListener): void;
|
|
84
|
+
/**
|
|
85
|
+
* Notification for events sent.
|
|
86
|
+
* @param events - The array of events that have been sent.
|
|
87
|
+
*/
|
|
88
|
+
eventsSent(events: ITelemetryItem[]): void;
|
|
89
|
+
/**
|
|
90
|
+
* Notification for events being discarded.
|
|
91
|
+
* @param events - The array of events that have been discarded by the SDK.
|
|
92
|
+
* @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
|
|
93
|
+
* constant should be used to check the different values.
|
|
94
|
+
*/
|
|
95
|
+
eventsDiscarded(events: ITelemetryItem[], reason: number): void;
|
|
96
|
+
/**
|
|
97
|
+
* [Optional] A function called when the events have been requested to be sent to the sever.
|
|
98
|
+
* @param sendReason - The reason why the event batch is being sent.
|
|
99
|
+
* @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
|
|
100
|
+
*/
|
|
101
|
+
eventsSendRequest?(sendReason: number, isAsync: boolean): void;
|
|
102
|
+
/**
|
|
103
|
+
* [Optional] This event is sent if you have enabled perf events, they are primarily used to track internal performance testing and debugging
|
|
104
|
+
* the event can be displayed via the debug plugin extension.
|
|
105
|
+
* @param perfEvent - The perf event details
|
|
106
|
+
*/
|
|
107
|
+
perfEvent?(perfEvent: IPerfEvent): void;
|
|
108
|
+
/**
|
|
109
|
+
* Unload and remove any state that this INotificationManager may be holding, this is generally called when the
|
|
110
|
+
* owning SDK is being unloaded.
|
|
111
|
+
* @param isAsync - Can the unload be performed asynchronously (default)
|
|
112
|
+
* @return If the unload occurs synchronously then nothing should be returned, if happening asynchronously then
|
|
113
|
+
* the function should return an [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
|
|
114
|
+
* / Promise to allow any listeners to wait for the operation to complete.
|
|
115
|
+
*/
|
|
116
|
+
unload?(isAsync?: boolean): void | IPromise<void>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* This interface identifies the details of an internal performance event - it does not represent an outgoing reported event
|
|
121
|
+
*/
|
|
122
|
+
interface IPerfEvent {
|
|
123
|
+
/**
|
|
124
|
+
* The name of the performance event
|
|
125
|
+
*/
|
|
126
|
+
name: string;
|
|
127
|
+
/**
|
|
128
|
+
* The start time of the performance event
|
|
129
|
+
*/
|
|
130
|
+
start: number;
|
|
131
|
+
/**
|
|
132
|
+
* The payload (contents) of the perfEvent, may be null or only set after the event has completed depending on
|
|
133
|
+
* the runtime environment.
|
|
134
|
+
*/
|
|
135
|
+
payload: any;
|
|
136
|
+
/**
|
|
137
|
+
* Is this occurring from an asynchronous event
|
|
138
|
+
*/
|
|
139
|
+
isAsync: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Identifies the total inclusive time spent for this event, including the time spent for child events,
|
|
142
|
+
* this will be undefined until the event is completed
|
|
143
|
+
*/
|
|
144
|
+
time?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Identifies the exclusive time spent in for this event (not including child events),
|
|
147
|
+
* this will be undefined until the event is completed.
|
|
148
|
+
*/
|
|
149
|
+
exTime?: number;
|
|
150
|
+
/**
|
|
151
|
+
* The Parent event that was started before this event was created
|
|
152
|
+
*/
|
|
153
|
+
parent?: IPerfEvent;
|
|
154
|
+
/**
|
|
155
|
+
* The child perf events that are contained within the total time of this event.
|
|
156
|
+
*/
|
|
157
|
+
childEvts?: IPerfEvent[];
|
|
158
|
+
/**
|
|
159
|
+
* Identifies whether this event is a child event of a parent
|
|
160
|
+
*/
|
|
161
|
+
isChildEvt: () => boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Get the names additional context associated with this perf event
|
|
164
|
+
*/
|
|
165
|
+
getCtx?: (key: string) => any;
|
|
166
|
+
/**
|
|
167
|
+
* Set the named additional context to be associated with this perf event, this will replace any existing value
|
|
168
|
+
*/
|
|
169
|
+
setCtx?: (key: string, value: any) => void;
|
|
170
|
+
/**
|
|
171
|
+
* Mark this event as completed, calculating the total execution time.
|
|
172
|
+
*/
|
|
173
|
+
complete: () => void;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* This defines an internal performance manager for tracking and reporting the internal performance of the SDK -- It does
|
|
178
|
+
* not represent or report any event to the server.
|
|
179
|
+
*/
|
|
180
|
+
interface IPerfManager {
|
|
181
|
+
/**
|
|
182
|
+
* Create a new event and start timing, the manager may return null/undefined to indicate that it does not
|
|
183
|
+
* want to monitor this source event.
|
|
184
|
+
* @param src - The source name of the event
|
|
185
|
+
* @param payloadDetails - An optional callback function to fetch the payload details for the event.
|
|
186
|
+
* @param isAsync - Is the event occurring from a async event
|
|
187
|
+
*/
|
|
188
|
+
create(src: string, payloadDetails?: () => any, isAsync?: boolean): IPerfEvent | null | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Complete the perfEvent and fire any notifications.
|
|
191
|
+
* @param perfEvent - Fire the event which will also complete the passed event
|
|
192
|
+
*/
|
|
193
|
+
fire(perfEvent: IPerfEvent): void;
|
|
194
|
+
/**
|
|
195
|
+
* Set an execution context value
|
|
196
|
+
* @param key - The context key name
|
|
197
|
+
* @param value - The value
|
|
198
|
+
*/
|
|
199
|
+
setCtx(key: string, value: any): void;
|
|
200
|
+
/**
|
|
201
|
+
* Get the execution context value
|
|
202
|
+
* @param key - The context key
|
|
203
|
+
*/
|
|
204
|
+
getCtx(key: string): any;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Identifies an interface to a host that can provide an IPerfManager implementation
|
|
209
|
+
*/
|
|
210
|
+
interface IPerfManagerProvider {
|
|
211
|
+
/**
|
|
212
|
+
* Get the current performance manager
|
|
213
|
+
*/
|
|
214
|
+
getPerfMgr(): IPerfManager;
|
|
215
|
+
/**
|
|
216
|
+
* Set the current performance manager
|
|
217
|
+
* @param perfMgr - The performance manager
|
|
218
|
+
*/
|
|
219
|
+
setPerfMgr(perfMgr: IPerfManager): void;
|
|
220
|
+
}
|
|
221
|
+
|
|
22
222
|
/**
|
|
23
223
|
* @copyright Microsoft 2021
|
|
24
224
|
*/
|
|
@@ -73,6 +273,293 @@ declare namespace ApplicationInsights {
|
|
|
73
273
|
};
|
|
74
274
|
}
|
|
75
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Create a Promise object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
|
|
278
|
+
* This interface definition, closely mirrors the typescript / javascript PromiseLike<T> and Promise<T> definitions as well as providing
|
|
279
|
+
* simular functions as that provided by jQuery deferred objects.
|
|
280
|
+
*
|
|
281
|
+
* The returned Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers
|
|
282
|
+
* with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous
|
|
283
|
+
* methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point
|
|
284
|
+
* in the future.
|
|
285
|
+
*
|
|
286
|
+
* A Promise is in one of these states:
|
|
287
|
+
* <ul>
|
|
288
|
+
* <li> pending: initial state, neither fulfilled nor rejected.
|
|
289
|
+
* <li> fulfilled: meaning that the operation was completed successfully.
|
|
290
|
+
* <li> rejected: meaning that the operation failed.
|
|
291
|
+
* </ul>
|
|
292
|
+
*
|
|
293
|
+
* A pending promise can either be fulfilled with a value or rejected with a reason (error). When either of these options happens, the
|
|
294
|
+
* associated handlers queued up by a promise's then method are called synchronously. If the promise has already been fulfilled or rejected
|
|
295
|
+
* when a corresponding handler is attached, the handler will be called synchronously, so there is no race condition between an asynchronous
|
|
296
|
+
* operation completing and its handlers being attached.
|
|
297
|
+
*
|
|
298
|
+
* As the `then()` and `catch()` methods return promises, they can be chained.
|
|
299
|
+
* @typeParam T - Identifies the expected return type from the promise
|
|
300
|
+
*/
|
|
301
|
+
interface IPromise<T> extends PromiseLike<T>, Promise<T> {
|
|
302
|
+
/**
|
|
303
|
+
* Returns a string representation of the current state of the promise. The promise can be in one of four states.
|
|
304
|
+
* <ul>
|
|
305
|
+
* <li> <b>"pending"</b>: The promise is not yet in a completed state (neither "rejected"; or "resolved").</li>
|
|
306
|
+
* <li> <b>"resolved"</b>: The promise is in the resolved state.</li>
|
|
307
|
+
* <li> <b>"rejected"</b>: The promise is in the rejected state.</li>
|
|
308
|
+
* </ul>
|
|
309
|
+
* @example
|
|
310
|
+
* ```ts
|
|
311
|
+
* let doResolve;
|
|
312
|
+
* let promise: IPromise<any> = createSyncPromise((resolve) => {
|
|
313
|
+
* doResolve = resolve;
|
|
314
|
+
* });
|
|
315
|
+
*
|
|
316
|
+
* let state: string = promise.state();
|
|
317
|
+
* console.log("State: " + state); // State: pending
|
|
318
|
+
* doResolve(true); // Promise will resolve synchronously as it's a synchronous promise
|
|
319
|
+
* console.log("State: " + state); // State: resolved
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
state?: string;
|
|
323
|
+
/**
|
|
324
|
+
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
325
|
+
* @param onResolved The callback to execute when the Promise is resolved.
|
|
326
|
+
* @param onRejected The callback to execute when the Promise is rejected.
|
|
327
|
+
* @returns A Promise for the completion of which ever callback is executed.
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* const promise1 = createPromise((resolve, reject) => {
|
|
331
|
+
* resolve('Success!');
|
|
332
|
+
* });
|
|
333
|
+
*
|
|
334
|
+
* promise1.then((value) => {
|
|
335
|
+
* console.log(value);
|
|
336
|
+
* // expected output: "Success!"
|
|
337
|
+
* });
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): IPromise<TResult1 | TResult2>;
|
|
341
|
+
/**
|
|
342
|
+
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
343
|
+
* @param onResolved The callback to execute when the Promise is resolved.
|
|
344
|
+
* @param onRejected The callback to execute when the Promise is rejected.
|
|
345
|
+
* @returns A Promise for the completion of which ever callback is executed.
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* const promise1 = createPromise((resolve, reject) => {
|
|
349
|
+
* resolve('Success!');
|
|
350
|
+
* });
|
|
351
|
+
*
|
|
352
|
+
* promise1.then((value) => {
|
|
353
|
+
* console.log(value);
|
|
354
|
+
* // expected output: "Success!"
|
|
355
|
+
* });
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): PromiseLike<TResult1 | TResult2>;
|
|
359
|
+
/**
|
|
360
|
+
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
|
361
|
+
* @param onResolved The callback to execute when the Promise is resolved.
|
|
362
|
+
* @param onRejected The callback to execute when the Promise is rejected.
|
|
363
|
+
* @returns A Promise for the completion of which ever callback is executed.
|
|
364
|
+
* @example
|
|
365
|
+
* ```ts
|
|
366
|
+
* const promise1 = createPromise((resolve, reject) => {
|
|
367
|
+
* resolve('Success!');
|
|
368
|
+
* });
|
|
369
|
+
*
|
|
370
|
+
* promise1.then((value) => {
|
|
371
|
+
* console.log(value);
|
|
372
|
+
* // expected output: "Success!"
|
|
373
|
+
* });
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
then<TResult1 = T, TResult2 = never>(onResolved?: ResolvedPromiseHandler<T, TResult1>, onRejected?: RejectedPromiseHandler<TResult2>): Promise<TResult1 | TResult2>;
|
|
377
|
+
/**
|
|
378
|
+
* Attaches a callback for only the rejection of the Promise.
|
|
379
|
+
* @param onRejected The callback to execute when the Promise is rejected.
|
|
380
|
+
* @returns A Promise for the completion of the callback.
|
|
381
|
+
* @example
|
|
382
|
+
* ```ts
|
|
383
|
+
* const promise1 = createPromise((resolve, reject) => {
|
|
384
|
+
* throw 'Uh-oh!';
|
|
385
|
+
* });
|
|
386
|
+
*
|
|
387
|
+
* promise1.catch((error) => {
|
|
388
|
+
* console.error(error);
|
|
389
|
+
* });
|
|
390
|
+
* // expected output: Uh-oh!
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): IPromise<T | TResult>;
|
|
394
|
+
/**
|
|
395
|
+
* Attaches a callback for only the rejection of the Promise.
|
|
396
|
+
* @param onRejected The callback to execute when the Promise is rejected.
|
|
397
|
+
* @returns A Promise for the completion of the callback.
|
|
398
|
+
* @example
|
|
399
|
+
* ```ts
|
|
400
|
+
* const promise1 = createPromise((resolve, reject) => {
|
|
401
|
+
* throw 'Uh-oh!';
|
|
402
|
+
* });
|
|
403
|
+
*
|
|
404
|
+
* promise1.catch((error) => {
|
|
405
|
+
* console.error(error);
|
|
406
|
+
* });
|
|
407
|
+
* // expected output: Uh-oh!
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): PromiseLike<T | TResult>;
|
|
411
|
+
/**
|
|
412
|
+
* Attaches a callback for only the rejection of the Promise.
|
|
413
|
+
* @param onRejected The callback to execute when the Promise is rejected.
|
|
414
|
+
* @returns A Promise for the completion of the callback.
|
|
415
|
+
* @example
|
|
416
|
+
* ```ts
|
|
417
|
+
* const promise1 = createPromise((resolve, reject) => {
|
|
418
|
+
* throw 'Uh-oh!';
|
|
419
|
+
* });
|
|
420
|
+
*
|
|
421
|
+
* promise1.catch((error) => {
|
|
422
|
+
* console.error(error);
|
|
423
|
+
* });
|
|
424
|
+
* // expected output: Uh-oh!
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | IPromise<TResult>) | undefined | null): Promise<T | TResult>;
|
|
428
|
+
/**
|
|
429
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
430
|
+
* resolved value cannot be modified from the callback.
|
|
431
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
432
|
+
* @returns A Promise for the completion of the callback.
|
|
433
|
+
* @example
|
|
434
|
+
* ```ts
|
|
435
|
+
* function doFunction() {
|
|
436
|
+
* return createPromise((resolve, reject) => {
|
|
437
|
+
* if (Math.random() > 0.5) {
|
|
438
|
+
* resolve('Function has completed');
|
|
439
|
+
* } else {
|
|
440
|
+
* reject(new Error('Function failed to process'));
|
|
441
|
+
* }
|
|
442
|
+
* });
|
|
443
|
+
* }
|
|
444
|
+
*
|
|
445
|
+
* doFunction().then((data) => {
|
|
446
|
+
* console.log(data);
|
|
447
|
+
* }).catch((err) => {
|
|
448
|
+
* console.error(err);
|
|
449
|
+
* }).finally(() => {
|
|
450
|
+
* console.log('Function processing completed');
|
|
451
|
+
* });
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
finally(onfinally?: FinallyPromiseHandler): IPromise<T>;
|
|
455
|
+
/**
|
|
456
|
+
* Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The
|
|
457
|
+
* resolved value cannot be modified from the callback.
|
|
458
|
+
* @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected).
|
|
459
|
+
* @returns A Promise for the completion of the callback.
|
|
460
|
+
* @example
|
|
461
|
+
* ```ts
|
|
462
|
+
* function doFunction() {
|
|
463
|
+
* return createPromise((resolve, reject) => {
|
|
464
|
+
* if (Math.random() > 0.5) {
|
|
465
|
+
* resolve('Function has completed');
|
|
466
|
+
* } else {
|
|
467
|
+
* reject(new Error('Function failed to process'));
|
|
468
|
+
* }
|
|
469
|
+
* });
|
|
470
|
+
* }
|
|
471
|
+
*
|
|
472
|
+
* doFunction().then((data) => {
|
|
473
|
+
* console.log(data);
|
|
474
|
+
* }).catch((err) => {
|
|
475
|
+
* console.error(err);
|
|
476
|
+
* }).finally(() => {
|
|
477
|
+
* console.log('Function processing completed');
|
|
478
|
+
* });
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
finally(onFinally?: FinallyPromiseHandler): Promise<T>;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Telemety item supported in Core
|
|
486
|
+
*/
|
|
487
|
+
interface ITelemetryItem {
|
|
488
|
+
/**
|
|
489
|
+
* CommonSchema Version of this SDK
|
|
490
|
+
*/
|
|
491
|
+
ver?: string;
|
|
492
|
+
/**
|
|
493
|
+
* Unique name of the telemetry item
|
|
494
|
+
*/
|
|
495
|
+
name: string;
|
|
496
|
+
/**
|
|
497
|
+
* Timestamp when item was sent
|
|
498
|
+
*/
|
|
499
|
+
time?: string;
|
|
500
|
+
/**
|
|
501
|
+
* Identifier of the resource that uniquely identifies which resource data is sent to
|
|
502
|
+
*/
|
|
503
|
+
iKey?: string;
|
|
504
|
+
/**
|
|
505
|
+
* System context properties of the telemetry item, example: ip address, city etc
|
|
506
|
+
*/
|
|
507
|
+
ext?: {
|
|
508
|
+
[key: string]: any;
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* System context property extensions that are not global (not in ctx)
|
|
512
|
+
*/
|
|
513
|
+
tags?: Tags;
|
|
514
|
+
/**
|
|
515
|
+
* Custom data
|
|
516
|
+
*/
|
|
517
|
+
data?: ICustomProperties;
|
|
518
|
+
/**
|
|
519
|
+
* Telemetry type used for part B
|
|
520
|
+
*/
|
|
521
|
+
baseType?: string;
|
|
522
|
+
/**
|
|
523
|
+
* Based on schema for part B
|
|
524
|
+
*/
|
|
525
|
+
baseData?: {
|
|
526
|
+
[key: string]: any;
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
class PerfManager implements IPerfManager {
|
|
531
|
+
/**
|
|
532
|
+
* General bucket used for execution context set and retrieved via setCtx() and getCtx.
|
|
533
|
+
* Defined as private so it can be visualized via the DebugPlugin
|
|
534
|
+
*/
|
|
535
|
+
// private ctx;
|
|
536
|
+
constructor(manager?: INotificationManager);
|
|
537
|
+
/**
|
|
538
|
+
* Create a new event and start timing, the manager may return null/undefined to indicate that it does not
|
|
539
|
+
* want to monitor this source event.
|
|
540
|
+
* @param src - The source name of the event
|
|
541
|
+
* @param payloadDetails - An optional callback function to fetch the payload details for the event.
|
|
542
|
+
* @param isAsync - Is the event occurring from a async event
|
|
543
|
+
*/
|
|
544
|
+
create(src: string, payload?: any, isAsync?: boolean): IPerfEvent | null | undefined;
|
|
545
|
+
/**
|
|
546
|
+
* Complete the perfEvent and fire any notifications.
|
|
547
|
+
* @param perfEvent - Fire the event which will also complete the passed event
|
|
548
|
+
*/
|
|
549
|
+
fire(perfEvent: IPerfEvent): void;
|
|
550
|
+
/**
|
|
551
|
+
* Set an execution context value
|
|
552
|
+
* @param key - The context key name
|
|
553
|
+
* @param value - The value
|
|
554
|
+
*/
|
|
555
|
+
setCtx(key: string, value: any): void;
|
|
556
|
+
/**
|
|
557
|
+
* Get the execution context value
|
|
558
|
+
* @param key - The context key
|
|
559
|
+
*/
|
|
560
|
+
getCtx(key: string): any;
|
|
561
|
+
}
|
|
562
|
+
|
|
76
563
|
class PerfMarkMeasureManager extends PerfManager {
|
|
77
564
|
constructor(config?: IPerfMarkMeasureConfiguration, manager?: INotificationManager);
|
|
78
565
|
/**
|
|
@@ -90,5 +577,22 @@ declare namespace ApplicationInsights {
|
|
|
90
577
|
fire(perfEvent: IPerfEvent): void;
|
|
91
578
|
}
|
|
92
579
|
|
|
93
|
-
|
|
580
|
+
/**
|
|
581
|
+
* This defines the handler function for when a promise is rejected.
|
|
582
|
+
* @param value This is the value passed as part of resolving the Promise
|
|
583
|
+
* @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
|
|
584
|
+
*/
|
|
585
|
+
type RejectedPromiseHandler<T = never> = (((reason: any) => T | IPromise<T> | PromiseLike<T>) | undefined | null);
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* This defines the handler function for when a promise is resolved.
|
|
589
|
+
* @param value This is the value passed as part of resolving the Promise
|
|
590
|
+
* @return This may return a value, another Promise or void. @see {@link IPromise.then} for how the value is handled.
|
|
591
|
+
*/
|
|
592
|
+
type ResolvedPromiseHandler<T, TResult1 = T> = (((value: T) => TResult1 | IPromise<TResult1> | PromiseLike<TResult1>) | undefined | null);
|
|
593
|
+
|
|
594
|
+
interface Tags {
|
|
595
|
+
[key: string]: any;
|
|
596
|
+
}
|
|
597
|
+
|
|
94
598
|
}
|