@microsoft/1ds-post-js 3.2.10 → 4.0.0

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.
Files changed (105) hide show
  1. package/README.md +1 -1
  2. package/bundle/es5/ms.post-4.0.0.gbl.js +5816 -0
  3. package/bundle/es5/ms.post-4.0.0.gbl.js.map +1 -0
  4. package/bundle/es5/ms.post-4.0.0.gbl.min.js +7 -0
  5. package/bundle/es5/ms.post-4.0.0.gbl.min.js.map +1 -0
  6. package/bundle/es5/ms.post-4.0.0.integrity.json +46 -0
  7. package/bundle/es5/ms.post-4.0.0.js +5820 -0
  8. package/bundle/es5/ms.post-4.0.0.js.map +1 -0
  9. package/bundle/es5/ms.post-4.0.0.min.js +7 -0
  10. package/bundle/es5/ms.post-4.0.0.min.js.map +1 -0
  11. package/bundle/es5/ms.post.gbl.js +5816 -0
  12. package/bundle/es5/ms.post.gbl.js.map +1 -0
  13. package/bundle/es5/ms.post.gbl.min.js +7 -0
  14. package/bundle/es5/ms.post.gbl.min.js.map +1 -0
  15. package/bundle/es5/ms.post.integrity.json +46 -0
  16. package/bundle/es5/ms.post.js +5820 -0
  17. package/bundle/es5/ms.post.js.map +1 -0
  18. package/bundle/es5/ms.post.min.js +7 -0
  19. package/bundle/es5/ms.post.min.js.map +1 -0
  20. package/{bundle → dist/es5}/ms.post.js +2942 -1670
  21. package/dist/es5/ms.post.js.map +1 -0
  22. package/dist/es5/ms.post.min.js +7 -0
  23. package/dist/es5/ms.post.min.js.map +1 -0
  24. package/{dist-esm/src → dist-es5}/BatchNotificationActions.js +1 -1
  25. package/{dist-esm/src → dist-es5}/ClockSkewManager.js +2 -2
  26. package/{dist-esm/src → dist-es5}/ClockSkewManager.js.map +1 -1
  27. package/{dist-esm/src → dist-es5}/DataModels.js +1 -1
  28. package/{dist-esm/src → dist-es5}/EventBatch.js +1 -1
  29. package/{dist-esm/src → dist-es5}/HttpManager.js +175 -94
  30. package/dist-es5/HttpManager.js.map +1 -0
  31. package/{dist-esm/src → dist-es5}/Index.js +2 -2
  32. package/dist-es5/Index.js.map +1 -0
  33. package/{dist-esm/src → dist-es5}/InternalConstants.js +1 -1
  34. package/{dist-esm/src → dist-es5}/KillSwitch.js +2 -2
  35. package/{dist-esm/src → dist-es5}/KillSwitch.js.map +1 -1
  36. package/{dist-esm/src → dist-es5}/PostChannel.js +166 -144
  37. package/dist-es5/PostChannel.js.map +1 -0
  38. package/{dist-esm/src → dist-es5}/RetryPolicy.js +1 -1
  39. package/{dist-esm/src → dist-es5}/Serializer.js +3 -2
  40. package/dist-es5/Serializer.js.map +1 -0
  41. package/dist-es5/TimeoutOverrideWrapper.js +24 -0
  42. package/dist-es5/TimeoutOverrideWrapper.js.map +1 -0
  43. package/{dist-esm/src → dist-es5}/typings/XDomainRequest.js +1 -1
  44. package/package.json +17 -11
  45. package/tsconfig.json +5 -2
  46. package/{src/DataModels.ts → types/1ds-post-js.d.ts} +408 -467
  47. package/types/1ds-post-js.namespaced.d.ts +404 -0
  48. package/bundle/ms.post-3.2.10.gbl.js +0 -4524
  49. package/bundle/ms.post-3.2.10.gbl.js.map +0 -1
  50. package/bundle/ms.post-3.2.10.gbl.min.js +0 -7
  51. package/bundle/ms.post-3.2.10.gbl.min.js.map +0 -1
  52. package/bundle/ms.post-3.2.10.integrity.json +0 -46
  53. package/bundle/ms.post-3.2.10.js +0 -4527
  54. package/bundle/ms.post-3.2.10.js.map +0 -1
  55. package/bundle/ms.post-3.2.10.min.js +0 -7
  56. package/bundle/ms.post-3.2.10.min.js.map +0 -1
  57. package/bundle/ms.post.gbl.js +0 -4524
  58. package/bundle/ms.post.gbl.js.map +0 -1
  59. package/bundle/ms.post.gbl.min.js +0 -7
  60. package/bundle/ms.post.gbl.min.js.map +0 -1
  61. package/bundle/ms.post.integrity.json +0 -46
  62. package/bundle/ms.post.js.map +0 -1
  63. package/bundle/ms.post.min.js +0 -7
  64. package/bundle/ms.post.min.js.map +0 -1
  65. package/dist/ms.post.js +0 -2144
  66. package/dist/ms.post.js.map +0 -1
  67. package/dist/ms.post.min.js +0 -7
  68. package/dist/ms.post.min.js.map +0 -1
  69. package/dist-esm/src/BatchNotificationActions.d.ts +0 -36
  70. package/dist-esm/src/ClockSkewManager.d.ts +0 -38
  71. package/dist-esm/src/DataModels.d.ts +0 -405
  72. package/dist-esm/src/EventBatch.d.ts +0 -47
  73. package/dist-esm/src/HttpManager.d.ts +0 -88
  74. package/dist-esm/src/HttpManager.js.map +0 -1
  75. package/dist-esm/src/Index.d.ts +0 -9
  76. package/dist-esm/src/Index.js.map +0 -1
  77. package/dist-esm/src/InternalConstants.d.ts +0 -28
  78. package/dist-esm/src/KillSwitch.d.ts +0 -26
  79. package/dist-esm/src/PostChannel.d.ts +0 -101
  80. package/dist-esm/src/PostChannel.js.map +0 -1
  81. package/dist-esm/src/RetryPolicy.d.ts +0 -21
  82. package/dist-esm/src/Serializer.d.ts +0 -108
  83. package/dist-esm/src/Serializer.js.map +0 -1
  84. package/dist-esm/src/TimeoutOverrideWrapper.d.ts +0 -18
  85. package/dist-esm/src/TimeoutOverrideWrapper.js +0 -28
  86. package/dist-esm/src/TimeoutOverrideWrapper.js.map +0 -1
  87. package/dist-esm/src/typings/XDomainRequest.d.ts +0 -17
  88. package/src/BatchNotificationActions.ts +0 -44
  89. package/src/ClockSkewManager.ts +0 -127
  90. package/src/EventBatch.ts +0 -137
  91. package/src/HttpManager.ts +0 -1379
  92. package/src/Index.ts +0 -18
  93. package/src/InternalConstants.ts +0 -42
  94. package/src/KillSwitch.ts +0 -84
  95. package/src/PostChannel.ts +0 -1163
  96. package/src/RetryPolicy.ts +0 -46
  97. package/src/Serializer.ts +0 -487
  98. package/src/TimeoutOverrideWrapper.ts +0 -29
  99. package/src/typings/XDomainRequest.ts +0 -23
  100. /package/{dist-esm/src → dist-es5}/BatchNotificationActions.js.map +0 -0
  101. /package/{dist-esm/src → dist-es5}/DataModels.js.map +0 -0
  102. /package/{dist-esm/src → dist-es5}/EventBatch.js.map +0 -0
  103. /package/{dist-esm/src → dist-es5}/InternalConstants.js.map +0 -0
  104. /package/{dist-esm/src → dist-es5}/RetryPolicy.js.map +0 -0
  105. /package/{dist-esm/src → dist-es5}/typings/XDomainRequest.js.map +0 -0
@@ -1,36 +0,0 @@
1
- /**
2
- * BatchNotificationActions.ts
3
- * @author Nev Wylie (newylie)
4
- * @copyright Microsoft 2020
5
- */
6
- import { EventBatch } from "./EventBatch";
7
- import { EventBatchNotificationReason } from "./DataModels";
8
- import { EventSendType } from "@microsoft/1ds-core-js";
9
- export type BatchNotificationAction = (batches: EventBatch[], reason?: EventBatchNotificationReason, isSyncRequest?: boolean, sendType?: EventSendType) => void;
10
- export interface BatchNotificationActions {
11
- /**
12
- * Attempts have been made to send the events but all failed.
13
- * Requeue the events (if possible) for resending.
14
- */
15
- requeue?: BatchNotificationAction;
16
- /**
17
- * The batch is about to be sent
18
- */
19
- send?: BatchNotificationAction;
20
- /**
21
- * The batch has been sent acknowledged by the server
22
- */
23
- sent?: BatchNotificationAction;
24
- /**
25
- * The events of the batch have been dropped
26
- */
27
- drop?: BatchNotificationAction;
28
- /**
29
- * The events of the batch have been dropped after being sent but not acknowledged
30
- */
31
- rspFail?: BatchNotificationAction;
32
- /**
33
- * Default callback action to call when no specific action could be identified for the reason
34
- */
35
- oth?: BatchNotificationAction;
36
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * ClockSkewManager.ts
3
- * @author Abhilash Panwar (abpanwar)
4
- * @copyright Microsoft 2018
5
- */
6
- /**
7
- * Class to manage clock skew correction.
8
- */
9
- export default class ClockSkewManager {
10
- constructor();
11
- /**
12
- * Determine if the request can be sent.
13
- * @returns True if requests can be sent, false otherwise.
14
- */
15
- allowRequestSending(): boolean;
16
- /**
17
- * Tells the ClockSkewManager that it should assume that the first request has now been sent,
18
- * If this method had not yet been called AND the clock Skew had not been set this will set
19
- * allowRequestSending to false until setClockSet() is called.
20
- */
21
- firstRequestSent(): void;
22
- /**
23
- * Determine if clock skew headers should be added to the request.
24
- * @returns True if clock skew headers should be added, false otherwise.
25
- */
26
- shouldAddClockSkewHeaders(): boolean;
27
- /**
28
- * Gets the clock skew header value.
29
- * @returns The clock skew header value.
30
- */
31
- getClockSkewHeaderValue(): string;
32
- /**
33
- * Sets the clock skew header value. Once clock skew is set this method
34
- * is no-op.
35
- * @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.
36
- */
37
- setClockSkew(timeDeltaInMillis?: string): void;
38
- }
@@ -1,405 +0,0 @@
1
- /**
2
- * DataModels.ts
3
- * @author Abhilash Panwar (abpanwar) and Hector Hernandez (hectorh)
4
- * @copyright Microsoft 2018
5
- * File containing the interfaces for Post channel module.
6
- */
7
- import { IExtendedTelemetryItem, NotificationManager, IDiagnosticLogger, ITelemetryPlugin, IProcessTelemetryContext, IValueSanitizer } from "@microsoft/1ds-core-js";
8
- /** IPayloadData describes interface of payload sent via POST channel */
9
- export interface IPayloadData {
10
- urlString: string;
11
- data: Uint8Array | string;
12
- headers?: {
13
- [name: string]: string;
14
- };
15
- timeout?: number;
16
- disableXhrSync?: boolean;
17
- disableFetchKeepAlive?: boolean;
18
- }
19
- /**
20
- * Defines the function signature for the Payload Preprocessor.
21
- * @param payload - The Initial constructed payload that if not modified should be passed onto the callback function.
22
- * @param callback - The preprocessor MUST call the callback function to ensure that the events are sent to the server, failing to call WILL result in dropped events.
23
- * The modifiedBuffer argument can be either the original payload or may be modified by performing GZipping of the payload and adding the content header.
24
- * @param isSync - A boolean flag indicating whether this request was initiated as part of a sync response (unload / flush request), this is for informative only.
25
- * e.g the preprocessor may wish to not perform any GZip operations if the request was a sync request which is normally called as part of an unload request.
26
- */
27
- export type PayloadPreprocessorFunction = (payload: IPayloadData, callback: (modifiedBuffer: IPayloadData) => void, isSync?: boolean) => void;
28
- /**
29
- * Defines the function signature of a payload listener, which is called after the payload has been sent to the server. The listener is passed
30
- * both the initial payload object and any altered (modified) payload from a preprocessor so it can determine what payload it may want to log or send.
31
- * Used by the Remove DDV extension to listen to server send events.
32
- * @param orgPayload - The initially constructed payload object
33
- * @param sendPayload - The alternative (possibly modified by a preprocessor) payload
34
- * @param isSync - A boolean flag indicating whether this request was initiated as part of a sync response (unload / flush request), this is for informative only.
35
- * @param isBeaconSend - A boolean flag indicating whether the payload was sent using the navigator.sendBeacon() API.
36
- */
37
- export type PayloadListenerFunction = (orgPayload: IPayloadData, sendPayload?: IPayloadData, isSync?: boolean, isBeaconSend?: boolean) => void;
38
- /**
39
- * The IChannelConfiguration interface holds the configuration details passed to Post module.
40
- */
41
- export interface IChannelConfiguration {
42
- /**
43
- * [Optional] The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
44
- */
45
- eventsLimitInMem?: number;
46
- /**
47
- * [Optional] Sets the maximum number of immediate latency events that will be cached in memory before the SDK starts to drop other
48
- * immediate events only, does not drop normal and real time latency events as immediate events have their own internal queue. Under
49
- * normal situations immediate events are scheduled to be sent in the next Javascript execution cycle, so the typically number of
50
- * immediate events is small (~1), the only time more than one event may be present is when the channel is paused or immediate send
51
- * is disabled (via manual transmit profile). By default max number of events is 500 and the default transmit time is 0ms.
52
- */
53
- immediateEventLimit?: number;
54
- /**
55
- * [Optional] If defined, when the number of queued events reaches or exceeded this limit this will cause the queue to be immediately
56
- * flushed rather than waiting for the normal timers. Defaults to undefined.
57
- */
58
- autoFlushEventsLimit?: number;
59
- /**
60
- * [Optional] If defined allows you to disable the auto batch (iKey set of requests) flushing logic. This is in addition to the
61
- * default transmission profile timers, autoFlushEventsLimit and eventsLimitInMem config values.
62
- */
63
- disableAutoBatchFlushLimit?: boolean;
64
- /**
65
- * [Optional] The HTTP override that should be used to send requests, as an IXHROverride object.
66
- * By default during the unload of a page or if the event specifies that it wants to use sendBeacon() or sync fetch (with keep-alive),
67
- * this override will NOT be called. You can now change this behavior by enabling the 'alwaysUseXhrOverride' configuration value.
68
- * The payload data (first argument) now also includes any configured 'timeout' (defaults to undefined) and whether you should avoid
69
- * creating any synchronous XHR requests 'disableXhrSync' (defaults to false/undefined)
70
- */
71
- httpXHROverride?: IXHROverride;
72
- /**
73
- * Override for Instrumentation key
74
- */
75
- overrideInstrumentationKey?: string;
76
- /**
77
- * Override for Endpoint where telemetry data is sent
78
- */
79
- overrideEndpointUrl?: string;
80
- /**
81
- * The master off switch. Do not send any data if set to TRUE
82
- */
83
- disableTelemetry?: boolean;
84
- /**
85
- * MC1 and MS0 cookies will not be returned from Collector endpoint.
86
- */
87
- ignoreMc1Ms0CookieProcessing?: boolean;
88
- /**
89
- * Override for setTimeout
90
- */
91
- setTimeoutOverride?: typeof setTimeout;
92
- /**
93
- * Override for clearTimeout
94
- */
95
- clearTimeoutOverride?: typeof clearTimeout;
96
- /**
97
- * [Optional] POST channel preprocessing function. Can be used to gzip the payload before transmission and to set the appropriate
98
- * Content-Encoding header. The preprocessor is explicitly not called during teardown when using the sendBeacon() API.
99
- */
100
- payloadPreprocessor?: PayloadPreprocessorFunction;
101
- /**
102
- * [Optional] POST channel listener function, used for enabling logging or reporting (RemoteDDVChannel) of the payload that is being sent.
103
- */
104
- payloadListener?: PayloadListenerFunction;
105
- /**
106
- * [Optional] By default additional timing metrics details are added to each event after they are sent to allow you to review how long it took
107
- * to create serialized request. As not all implementations require this level of detail and it's now possible to get the same metrics via
108
- * the IPerfManager and IPerfEvent we are enabling these details to be disabled. Default value is false to retain the previous behavior,
109
- * if you are not using these metrics and performance is a concern then it is recommended to set this value to true.
110
- */
111
- disableEventTimings?: boolean;
112
- /**
113
- * [Optional] The value sanitizer to use while constructing the envelope.
114
- */
115
- valueSanitizer?: IValueSanitizer;
116
- /**
117
- * [Optional] During serialization, when an object is identified, should the object be serialized by JSON.stringify(theObject); (when true) otherwise by theObject.toString().
118
- * Defaults to false
119
- */
120
- stringifyObjects?: boolean;
121
- /**
122
- * [Optional] Enables support for objects with compound keys which indirectly represent an object where the "key" of the object contains a "." as part of it's name.
123
- * @example
124
- * ```typescript
125
- * event: { "somedata.embeddedvalue": 123 }
126
- * ```
127
- */
128
- enableCompoundKey?: boolean;
129
- /**
130
- * [Optional] Switch to disable the v8 optimizeObject() calls used to provide better serialization performance. Defaults to false.
131
- */
132
- disableOptimizeObj?: boolean;
133
- /**
134
- * [Optional] By default a "Cache-Control" header will be added to the outbound payloads with the value "no-cache, no-store", this is to
135
- * avoid instances where Chrome can "Stall" requests which use the same outbound URL.
136
- */
137
- /**
138
- * [Optional] Either an array or single value identifying the requested TransportType type that should be used.
139
- * This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided.
140
- */
141
- transports?: number | number[];
142
- /**
143
- * [Optional] Either an array or single value identifying the requested TransportType type(s) that should be used during unload or events
144
- * marked as sendBeacon. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride
145
- * is provided and alwaysUseXhrOverride is true.
146
- */
147
- unloadTransports?: number | number[];
148
- /**
149
- * [Optional] A flag to enable or disable the usage of the sendBeacon() API (if available). If running on ReactNative this defaults
150
- * to `false` for all other cases it defaults to `true`.
151
- */
152
- useSendBeacon?: boolean;
153
- /**
154
- * [Optional] A flag to disable the usage of the [fetch with keep-alive](https://javascript.info/fetch-api#keepalive) support.
155
- */
156
- disableFetchKeepAlive?: boolean;
157
- /**
158
- * [Optional] Avoid adding request headers to the outgoing request that would cause a pre-flight (OPTIONS) request to be sent for each request.
159
- * This currently defaults to true but will be changed once the collector handles additional settings to allow the browser to better cache any
160
- * previous OPTIONS response, at which point some of the current dynamic values sent on the query string will be moved to a header.
161
- */
162
- avoidOptions?: boolean;
163
- /**
164
- * [Optional] Specify a timeout (in ms) to apply to requests when sending requests using XHR, XDR or fetch requests. Defaults to undefined
165
- * and therefore the runtime defaults (normally zero for browser environments)
166
- */
167
- xhrTimeout?: number;
168
- /**
169
- * [Optional] When using Xhr for sending requests disable sending as synchronous during unload or synchronous flush.
170
- * You should enable this feature for IE (when there is no sendBeacon() or fetch (with keep-alive)) and you have clients
171
- * that end up blocking the UI during page unloading. This will cause ALL XHR requests to be sent asynchronously which
172
- * during page unload may result in the lose of telemetry.
173
- */
174
- disableXhrSync?: boolean;
175
- /**
176
- * [Optional] By default during unload (or when you specify to use sendBeacon() or sync fetch (with keep-alive) for an event) the SDK
177
- * ignores any provided httpXhrOverride and attempts to use sendBeacon() or fetch(with keep-alive) when they are available.
178
- * When this configuration option is true any provided httpXhrOverride will always be used, so any provided httpXhrOverride will
179
- * also need to "handle" the synchronous unload scenario.
180
- */
181
- alwaysUseXhrOverride?: boolean;
182
- /**
183
- * [Optional] Identifies the number of times any single event will be retried if it receives a failed (retirable) response, this
184
- * causes the event to be internally "requeued" and resent in the next batch. As each normal batched send request is retried at
185
- * least once before starting to increase the internal backoff send interval, normally batched events will generally be attempted
186
- * the next nearest even number of times. This means that the total number of actual send attempts will almost always be even
187
- * (setting to 5 will cause 6 requests), unless using manual synchronous flushing (calling flush(false)) which is not subject to
188
- * request level retry attempts.
189
- * Defaults to 6 times.
190
- */
191
- maxEventRetryAttempts?: number;
192
- /**
193
- * [Optional] Identifies the number of times any single event will be retried if it receives a failed (retriable) response as part
194
- * of processing / flushing events once a page unload state has been detected, this causes the event to be internally "requeued"
195
- * and resent in the next batch, which during page unload. Unlike the normal batching process, send requests are never retried,
196
- * so the value listed here is always the maximum number of attempts for any single event.
197
- * Defaults to 2 times.
198
- * Notes:
199
- * The SDK by default will use the sendBeacon() API if it exists which is treated as a fire and forget successful response, so for
200
- * environments that support or supply this API the events won't be retried (because they will be deeded to be successfully sent).
201
- * When an environment (IE) doesn't support sendBeacon(), this will cause multiple synchronous (by default) XMLHttpRequests to be sent,
202
- * which will block the UI until a response is received. You can disable ALL synchronous XHR requests by setting the 'disableXhrSync'
203
- * configuration setting and/or changing this value to 0 or 1.
204
- */
205
- maxUnloadEventRetryAttempts?: number;
206
- /**
207
- * [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string
208
- * value to indicate that the server should return a 204 for successful requests. Defaults to true
209
- */
210
- addNoResponse?: boolean;
211
- }
212
- /**
213
- * SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
214
- * @param payload - The payload object that should be sent, contains the url, bytes/string and headers for the request
215
- * @param oncomplete - The function to call once the request has completed whether a success, failure or timeout
216
- * @param sync - A boolean flag indicating whether the request should be sent as a synchronous request.
217
- */
218
- export type SendPOSTFunction = (payload: IPayloadData, oncomplete: (status: number, headers: {
219
- [headerName: string]: string;
220
- }, response?: string) => void, sync?: boolean) => void;
221
- /**
222
- * The IXHROverride interface overrides the way HTTP requests are sent.
223
- */
224
- export interface IXHROverride {
225
- /**
226
- * This method sends data to the specified URI using a POST request. If sync is true,
227
- * then the request is sent synchronously. The <i>oncomplete</i> function should always be called after the request is
228
- * completed (either successfully or timed out or failed due to errors).
229
- */
230
- sendPOST: SendPOSTFunction;
231
- }
232
- /**
233
- * An interface which extends the telemetry event to track send attempts.
234
- */
235
- export interface IPostTransmissionTelemetryItem extends IExtendedTelemetryItem {
236
- /**
237
- * The number of times the telemtry item has been attempted to be sent.
238
- */
239
- sendAttempt?: number;
240
- }
241
- /**
242
- * Real Time profile (default profile). RealTime Latency events are sent every 1 sec and
243
- * Normal Latency events are sent every 2 sec.
244
- */
245
- export declare const RT_PROFILE = "REAL_TIME";
246
- /**
247
- * Near Real Time profile. RealTime Latency events are sent every 3 sec and
248
- * Normal Latency events are sent every 6 sec.
249
- */
250
- export declare const NRT_PROFILE = "NEAR_REAL_TIME";
251
- /**
252
- * Best Effort. RealTime Latency events are sent every 9 sec and
253
- * Normal Latency events are sent every 18 sec.
254
- */
255
- export declare const BE_PROFILE = "BEST_EFFORT";
256
- /**
257
- * An interface representing Collector Web responses.
258
- */
259
- export interface ICollectorResult {
260
- /**
261
- * Number of events accepted.
262
- */
263
- acc?: number;
264
- /**
265
- * Number of events rejected.
266
- */
267
- rej?: number;
268
- /**
269
- * Web Result.
270
- */
271
- webResult?: ICollectorWebResult;
272
- }
273
- /**
274
- * An interface representing Collector Web responses.
275
- */
276
- export interface ICollectorWebResult {
277
- /**
278
- * MSFPC cookie.
279
- */
280
- msfpc?: string;
281
- /**
282
- * Authentication error.
283
- */
284
- authError?: string;
285
- /**
286
- * Auth Login URL.
287
- */
288
- authLoginUrl?: string;
289
- }
290
- /**
291
- * Post channel interface
292
- */
293
- export interface IPostChannel extends ITelemetryPlugin {
294
- /**
295
- * Diagnostic logger
296
- */
297
- diagLog: (itemCtx?: IProcessTelemetryContext) => IDiagnosticLogger;
298
- /**
299
- * Notification manager
300
- */
301
- _notificationManager: NotificationManager | undefined;
302
- /**
303
- * Override for setTimeout
304
- */
305
- _setTimeoutOverride?: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => any;
306
- /**
307
- * Backs off transmission. This exponentially increases all the timers.
308
- */
309
- _backOffTransmission(): void;
310
- /**
311
- * Clears back off for transmission.
312
- */
313
- _clearBackOff(): void;
314
- /**
315
- * Add handler to be executed with request response text.
316
- */
317
- addResponseHandler(responseHandler: (responseText: string) => void): void;
318
- }
319
- /**
320
- * This is an internal notification reason used by the HttpManager to report the reason for notification events
321
- * it contains general events as well as specific sections which encompass other enum values such as
322
- * SendRequestReason, EventsDiscardedReason and general HttpStatus values.
323
- */
324
- export declare const enum EventBatchNotificationReason {
325
- /**
326
- * Unable to send the batch as the outbound connection channel is paused
327
- */
328
- Paused = 1,
329
- /**
330
- * The events failed to send or retry, so requeue them
331
- */
332
- RequeueEvents = 100,
333
- /**
334
- * The Batch was successfully sent and a response received, equivalent to the HttpStatusCode of 200
335
- */
336
- Complete = 200,
337
- /**
338
- * No specific reason was specified or normal event schedule / timer
339
- */
340
- SendingUndefined = 1000,
341
- /**
342
- * Events are being sent based on the normal event schedule / timer.
343
- */
344
- SendingNormalSchedule = 1001,
345
- /**
346
- * A manual flush request was received
347
- */
348
- SendingManualFlush = 1001,
349
- /**
350
- * Unload event is being processed
351
- */
352
- SendingUnload = 1002,
353
- /**
354
- * The event(s) being sent are sync events
355
- */
356
- SendingSyncEvent = 1003,
357
- /**
358
- * The Channel was resumed
359
- */
360
- SendingResumed = 1004,
361
- /**
362
- * The event(s) being sent as a retry
363
- */
364
- SendingRetry = 1005,
365
- /**
366
- * Maximum batch size would be exceeded
367
- */
368
- SendingMaxBatchSize = 1010,
369
- /**
370
- * The Maximum number of events have already been queued
371
- */
372
- SendingMaxQueuedEvents = 1020,
373
- /**
374
- * The final value for a Sending notification
375
- */
376
- SendingEventMax = 1999,
377
- EventsDropped = 8000,
378
- NonRetryableStatus = 8001,
379
- InvalidEvent = 8002,
380
- SizeLimitExceeded = 8003,
381
- KillSwitch = 8004,
382
- QueueFull = 8005,
383
- EventsDroppedMax = 8999,
384
- /**
385
- * Represents the range Http Status codes 000-999 as 9000-9999
386
- */
387
- ResponseFailure = 9000,
388
- /**
389
- * Represents the range Http Status codes 200-299
390
- */
391
- PartialSuccess = 9200,
392
- /**
393
- * Represents the range Http Status codes 300-399
394
- */
395
- ClientConfigFailure = 9300,
396
- /**
397
- * Represents the range Http Status codes 400-499
398
- */
399
- ClientFailure = 9400,
400
- /**
401
- * Represents the range Http Status codes 500-599
402
- */
403
- ServerFailure = 9500,
404
- ResponseFailureMax = 9999
405
- }
@@ -1,47 +0,0 @@
1
- import { IPostTransmissionTelemetryItem } from "./DataModels";
2
- /**
3
- * This class defines a "batch" events related to a specific iKey, it is used by the PostChannel and HttpManager
4
- * to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous
5
- * array duplication and shared ownership issues that occurred due to race conditions caused by the async nature
6
- * of sending requests.
7
- */
8
- export declare class EventBatch {
9
- /**
10
- * Creates a new Event Batch object
11
- * @param iKey The iKey associated with this batch of events
12
- */
13
- static create(iKey: string, theEvents?: IPostTransmissionTelemetryItem[]): EventBatch;
14
- /**
15
- * Returns the iKey associated with this batch of events
16
- */
17
- iKey: () => string;
18
- /**
19
- * Returns the first msfpc value from the batch
20
- */
21
- Msfpc: () => string;
22
- /**
23
- * Returns the number of events contained in the batch
24
- */
25
- count: () => number;
26
- events: () => IPostTransmissionTelemetryItem[];
27
- /**
28
- * Add all of the events to the current batch, if the max number of events would be exceeded then no
29
- * events are added.
30
- * @param theEvents - The events that needs to be batched.
31
- * @returns The number of events added.
32
- */
33
- addEvent: (theEvents: IPostTransmissionTelemetryItem) => boolean;
34
- /**
35
- * Split this batch into 2 with any events > fromEvent returned in the new batch and all other
36
- * events are kept in the current batch.
37
- * @param fromEvent The first event to remove from the current batch.
38
- * @param numEvents The number of events to be removed from the current batch and returned in the new one. Defaults to all trailing events
39
- */
40
- split: (fromEvent: number, numEvents?: number) => EventBatch;
41
- /**
42
- * Private constructor so that caller is forced to use the static create method.
43
- * @param iKey - The iKey to associate with the events (not validated)
44
- * @param addEvents - The optional collection of events to assign to this batch - defaults to an empty array.
45
- */
46
- private constructor();
47
- }
@@ -1,88 +0,0 @@
1
- import { EventSendType, IExtendedAppInsightsCore, SendRequestReason } from "@microsoft/1ds-core-js";
2
- import { BatchNotificationActions } from "./BatchNotificationActions";
3
- import { IPostChannel, IXHROverride, PayloadListenerFunction, PayloadPreprocessorFunction } from "./DataModels";
4
- import { EventBatch } from "./EventBatch";
5
- import { IChannelConfiguration } from "./Index";
6
- import { ITimeoutOverrideWrapper } from "./TimeoutOverrideWrapper";
7
- /**
8
- * Class managing the sending of requests.
9
- */
10
- export declare class HttpManager {
11
- sendHook: PayloadPreprocessorFunction | undefined;
12
- sendListener: PayloadListenerFunction | undefined;
13
- _responseHandlers: Array<(responseText: string) => void>;
14
- /**
15
- * @constructor
16
- * @param requestQueue - The queue that contains the requests to be sent.
17
- */
18
- constructor(maxEventsPerBatch: number, maxConnections: number, maxRequestRetriesBeforeBackoff: number, actions: BatchNotificationActions, timeoutOverride: ITimeoutOverrideWrapper);
19
- /**
20
- * @constructor
21
- * @param requestQueue - The queue that contains the requests to be sent.
22
- * @param endpointUrl - The collector url to which the requests must be sent.
23
- * @param postManager - The post manager that we should add requests back to if needed.
24
- * @param httpInterface - The http interface that should be used to send HTTP requests.
25
- * @param channelConfig - The IChannelConfiguration the should be used to get additional configuration
26
- */
27
- initialize(endpointUrl: string, core: IExtendedAppInsightsCore, postChannel: IPostChannel, httpInterface: IXHROverride, channelConfig?: IChannelConfiguration): void;
28
- /**
29
- * Add query string parameter to url
30
- * @param name - Query string name.
31
- * @param value - Query string value.
32
- */
33
- addQueryStringParameter(name: string, value: string): void;
34
- /**
35
- * Add header to request
36
- * @param name - Header name.
37
- * @param value - Header value.
38
- */
39
- addHeader(name: string, value: string): void;
40
- /**
41
- * Add the batch of events to the queue for sending
42
- * @param batch The batch with the events to send
43
- * @returns True if the http manager has accepted the batch (including if the batch is empty) otherwise false
44
- */
45
- addBatch(batch: EventBatch): boolean;
46
- /**
47
- * Check if there is an idle connection and we can send a request.
48
- * @returns True if there is an idle connection, false otherwise.
49
- */
50
- canSendRequest(): boolean;
51
- /**
52
- * Send requests in the request queue up if there is an idle connection, sending is
53
- * not pause and clock skew manager allows sending request.
54
- * @param sendType - Identifies how the batched events should be send, defaults to Batched
55
- * @param sendReason - The reason the batch is being sent
56
- */
57
- sendQueuedRequests(sendType?: EventSendType, sendReason?: SendRequestReason): void;
58
- /**
59
- * Check if there are no active requests being sent.
60
- * @returns True if idle, false otherwise.
61
- */
62
- isCompletelyIdle(): boolean;
63
- /**
64
- * Inform the HttpManager that a page unload event was received
65
- */
66
- setUnloading(value: boolean): void;
67
- /**
68
- * Queue all the remaining requests to be sent. The requests will be
69
- * sent using HTML5 Beacons if they are available.
70
- */
71
- teardown(): void;
72
- /**
73
- * Pause the sending of requests. No new requests will be sent.
74
- */
75
- pause(): void;
76
- /**
77
- * Resume the sending of requests.
78
- */
79
- resume(): void;
80
- /**
81
- * Sends the batches synchronously to the collector. This api is used to send a batches immediate event.
82
- *
83
- * @param batch - The batch of events to be sent.
84
- * @param sendReason - The reason the batch is being sent
85
- * @param sendType - Identifies the sending type to use when sending the batch
86
- */
87
- sendSynchronousBatch(batch: EventBatch, sendType?: EventSendType, sendReason?: SendRequestReason): void;
88
- }