@microsoft/1ds-post-js 3.2.11 → 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 +15 -10
  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.11.gbl.js +0 -4524
  49. package/bundle/ms.post-3.2.11.gbl.js.map +0 -1
  50. package/bundle/ms.post-3.2.11.gbl.min.js +0 -7
  51. package/bundle/ms.post-3.2.11.gbl.min.js.map +0 -1
  52. package/bundle/ms.post-3.2.11.integrity.json +0 -46
  53. package/bundle/ms.post-3.2.11.js +0 -4527
  54. package/bundle/ms.post-3.2.11.js.map +0 -1
  55. package/bundle/ms.post-3.2.11.min.js +0 -7
  56. package/bundle/ms.post-3.2.11.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
@@ -0,0 +1,404 @@
1
+ /*
2
+ * 1DS JS SDK Post Channel, 4.0.0
3
+ * Copyright (c) Microsoft and contributors. All rights reserved.
4
+ *
5
+ * Javascript Telemetry SDKs <TelReachSDK@microsoft.com>
6
+ * https://1dsdocs.azurewebsites.net/sdk.html
7
+ */
8
+
9
+ declare namespace oneDS {
10
+ import { BaseTelemetryPlugin } from '@microsoft/1ds-core-js';
11
+ import { IAppInsightsCore } from '@microsoft/1ds-core-js';
12
+ import { IChannelControls } from '@microsoft/1ds-core-js';
13
+ import { IDiagnosticLogger } from '@microsoft/1ds-core-js';
14
+ import { IExtendedConfiguration } from '@microsoft/1ds-core-js';
15
+ import { IPlugin } from '@microsoft/1ds-core-js';
16
+ import { IProcessTelemetryContext } from '@microsoft/1ds-core-js';
17
+ import { IPromise } from '@nevware21/ts-async';
18
+ import { ITelemetryItem } from '@microsoft/1ds-core-js';
19
+ import { ITelemetryPlugin } from '@microsoft/1ds-core-js';
20
+ import { IUnloadHook } from '@microsoft/1ds-core-js';
21
+ import { IValueSanitizer } from '@microsoft/1ds-core-js';
22
+ import { SendRequestReason } from '@microsoft/1ds-core-js';
23
+
24
+ /**
25
+ * Best Effort. RealTime Latency events are sent every 9 sec and
26
+ * Normal Latency events are sent every 18 sec.
27
+ */
28
+ const BE_PROFILE = "BEST_EFFORT";
29
+
30
+ /**
31
+ * The IChannelConfiguration interface holds the configuration details passed to Post module.
32
+ */
33
+ interface IChannelConfiguration {
34
+ /**
35
+ * [Optional] The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
36
+ */
37
+ eventsLimitInMem?: number;
38
+ /**
39
+ * [Optional] Sets the maximum number of immediate latency events that will be cached in memory before the SDK starts to drop other
40
+ * immediate events only, does not drop normal and real time latency events as immediate events have their own internal queue. Under
41
+ * normal situations immediate events are scheduled to be sent in the next Javascript execution cycle, so the typically number of
42
+ * immediate events is small (~1), the only time more than one event may be present is when the channel is paused or immediate send
43
+ * is disabled (via manual transmit profile). By default max number of events is 500 and the default transmit time is 0ms.
44
+ */
45
+ immediateEventLimit?: number;
46
+ /**
47
+ * [Optional] If defined, when the number of queued events reaches or exceeded this limit this will cause the queue to be immediately
48
+ * flushed rather than waiting for the normal timers. Defaults to undefined.
49
+ */
50
+ autoFlushEventsLimit?: number;
51
+ /**
52
+ * [Optional] If defined allows you to disable the auto batch (iKey set of requests) flushing logic. This is in addition to the
53
+ * default transmission profile timers, autoFlushEventsLimit and eventsLimitInMem config values.
54
+ */
55
+ disableAutoBatchFlushLimit?: boolean;
56
+ /**
57
+ * [Optional] The HTTP override that should be used to send requests, as an IXHROverride object.
58
+ * 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),
59
+ * this override will NOT be called. You can now change this behavior by enabling the 'alwaysUseXhrOverride' configuration value.
60
+ * The payload data (first argument) now also includes any configured 'timeout' (defaults to undefined) and whether you should avoid
61
+ * creating any synchronous XHR requests 'disableXhrSync' (defaults to false/undefined)
62
+ */
63
+ httpXHROverride?: IXHROverride;
64
+ /**
65
+ * Override for Instrumentation key
66
+ */
67
+ overrideInstrumentationKey?: string;
68
+ /**
69
+ * Override for Endpoint where telemetry data is sent
70
+ */
71
+ overrideEndpointUrl?: string;
72
+ /**
73
+ * The master off switch. Do not send any data if set to TRUE
74
+ */
75
+ disableTelemetry?: boolean;
76
+ /**
77
+ * MC1 and MS0 cookies will not be returned from Collector endpoint.
78
+ */
79
+ ignoreMc1Ms0CookieProcessing?: boolean;
80
+ /**
81
+ * Override for setTimeout
82
+ */
83
+ setTimeoutOverride?: typeof setTimeout;
84
+ /**
85
+ * Override for clearTimeout
86
+ */
87
+ clearTimeoutOverride?: typeof clearTimeout;
88
+ /**
89
+ * [Optional] POST channel preprocessing function. Can be used to gzip the payload before transmission and to set the appropriate
90
+ * Content-Encoding header. The preprocessor is explicitly not called during teardown when using the sendBeacon() API.
91
+ */
92
+ payloadPreprocessor?: PayloadPreprocessorFunction;
93
+ /**
94
+ * [Optional] POST channel listener function, used for enabling logging or reporting (RemoteDDVChannel) of the payload that is being sent.
95
+ */
96
+ payloadListener?: PayloadListenerFunction;
97
+ /**
98
+ * [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
99
+ * to create serialized request. As not all implementations require this level of detail and it's now possible to get the same metrics via
100
+ * the IPerfManager and IPerfEvent we are enabling these details to be disabled. Default value is false to retain the previous behavior,
101
+ * if you are not using these metrics and performance is a concern then it is recommended to set this value to true.
102
+ */
103
+ disableEventTimings?: boolean;
104
+ /**
105
+ * [Optional] The value sanitizer to use while constructing the envelope.
106
+ */
107
+ valueSanitizer?: IValueSanitizer;
108
+ /**
109
+ * [Optional] During serialization, when an object is identified, should the object be serialized by JSON.stringify(theObject); (when true) otherwise by theObject.toString().
110
+ * Defaults to false
111
+ */
112
+ stringifyObjects?: boolean;
113
+ /**
114
+ * [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.
115
+ * @example
116
+ * ```typescript
117
+ * event: { "somedata.embeddedvalue": 123 }
118
+ * ```
119
+ */
120
+ enableCompoundKey?: boolean;
121
+ /**
122
+ * [Optional] Switch to disable the v8 optimizeObject() calls used to provide better serialization performance. Defaults to false.
123
+ */
124
+ disableOptimizeObj?: boolean;
125
+ /**
126
+ * [Optional] By default a "Cache-Control" header will be added to the outbound payloads with the value "no-cache, no-store", this is to
127
+ * avoid instances where Chrome can "Stall" requests which use the same outbound URL.
128
+ */
129
+ /**
130
+ * [Optional] Either an array or single value identifying the requested TransportType type that should be used.
131
+ * This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided.
132
+ */
133
+ transports?: number | number[];
134
+ /**
135
+ * [Optional] Either an array or single value identifying the requested TransportType type(s) that should be used during unload or events
136
+ * marked as sendBeacon. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride
137
+ * is provided and alwaysUseXhrOverride is true.
138
+ */
139
+ unloadTransports?: number | number[];
140
+ /**
141
+ * [Optional] A flag to enable or disable the usage of the sendBeacon() API (if available). If running on ReactNative this defaults
142
+ * to `false` for all other cases it defaults to `true`.
143
+ */
144
+ useSendBeacon?: boolean;
145
+ /**
146
+ * [Optional] A flag to disable the usage of the [fetch with keep-alive](https://javascript.info/fetch-api#keepalive) support.
147
+ */
148
+ disableFetchKeepAlive?: boolean;
149
+ /**
150
+ * [Optional] Avoid adding request headers to the outgoing request that would cause a pre-flight (OPTIONS) request to be sent for each request.
151
+ * This currently defaults to true but will be changed once the collector handles additional settings to allow the browser to better cache any
152
+ * previous OPTIONS response, at which point some of the current dynamic values sent on the query string will be moved to a header.
153
+ */
154
+ avoidOptions?: boolean;
155
+ /**
156
+ * [Optional] Specify a timeout (in ms) to apply to requests when sending requests using XHR, XDR or fetch requests. Defaults to undefined
157
+ * and therefore the runtime defaults (normally zero for browser environments)
158
+ */
159
+ xhrTimeout?: number;
160
+ /**
161
+ * [Optional] When using Xhr for sending requests disable sending as synchronous during unload or synchronous flush.
162
+ * You should enable this feature for IE (when there is no sendBeacon() or fetch (with keep-alive)) and you have clients
163
+ * that end up blocking the UI during page unloading. This will cause ALL XHR requests to be sent asynchronously which
164
+ * during page unload may result in the lose of telemetry.
165
+ */
166
+ disableXhrSync?: boolean;
167
+ /**
168
+ * [Optional] By default during unload (or when you specify to use sendBeacon() or sync fetch (with keep-alive) for an event) the SDK
169
+ * ignores any provided httpXhrOverride and attempts to use sendBeacon() or fetch(with keep-alive) when they are available.
170
+ * When this configuration option is true any provided httpXhrOverride will always be used, so any provided httpXhrOverride will
171
+ * also need to "handle" the synchronous unload scenario.
172
+ */
173
+ alwaysUseXhrOverride?: boolean;
174
+ /**
175
+ * [Optional] Identifies the number of times any single event will be retried if it receives a failed (retirable) response, this
176
+ * causes the event to be internally "requeued" and resent in the next batch. As each normal batched send request is retried at
177
+ * least once before starting to increase the internal backoff send interval, normally batched events will generally be attempted
178
+ * the next nearest even number of times. This means that the total number of actual send attempts will almost always be even
179
+ * (setting to 5 will cause 6 requests), unless using manual synchronous flushing (calling flush(false)) which is not subject to
180
+ * request level retry attempts.
181
+ * Defaults to 6 times.
182
+ */
183
+ maxEventRetryAttempts?: number;
184
+ /**
185
+ * [Optional] Identifies the number of times any single event will be retried if it receives a failed (retriable) response as part
186
+ * of processing / flushing events once a page unload state has been detected, this causes the event to be internally "requeued"
187
+ * and resent in the next batch, which during page unload. Unlike the normal batching process, send requests are never retried,
188
+ * so the value listed here is always the maximum number of attempts for any single event.
189
+ * Defaults to 2 times.
190
+ * Notes:
191
+ * The SDK by default will use the sendBeacon() API if it exists which is treated as a fire and forget successful response, so for
192
+ * environments that support or supply this API the events won't be retried (because they will be deeded to be successfully sent).
193
+ * When an environment (IE) doesn't support sendBeacon(), this will cause multiple synchronous (by default) XMLHttpRequests to be sent,
194
+ * which will block the UI until a response is received. You can disable ALL synchronous XHR requests by setting the 'disableXhrSync'
195
+ * configuration setting and/or changing this value to 0 or 1.
196
+ */
197
+ maxUnloadEventRetryAttempts?: number;
198
+ /**
199
+ * [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string
200
+ * value to indicate that the server should return a 204 for successful requests. Defaults to true
201
+ */
202
+ addNoResponse?: boolean;
203
+ }
204
+
205
+ /** IPayloadData describes interface of payload sent via POST channel */
206
+ interface IPayloadData {
207
+ urlString: string;
208
+ data: Uint8Array | string;
209
+ headers?: {
210
+ [name: string]: string;
211
+ };
212
+ timeout?: number;
213
+ disableXhrSync?: boolean;
214
+ disableFetchKeepAlive?: boolean;
215
+ }
216
+
217
+ /**
218
+ * Post channel interface
219
+ */
220
+ interface IPostChannel extends ITelemetryPlugin {
221
+ /**
222
+ * Diagnostic logger
223
+ */
224
+ diagLog: (itemCtx?: IProcessTelemetryContext) => IDiagnosticLogger;
225
+ /**
226
+ * Override for setTimeout
227
+ */
228
+ _setTimeoutOverride?: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => any;
229
+ /**
230
+ * Backs off transmission. This exponentially increases all the timers.
231
+ */
232
+ _backOffTransmission(): void;
233
+ /**
234
+ * Clears back off for transmission.
235
+ */
236
+ _clearBackOff(): void;
237
+ /**
238
+ * Add handler to be executed with request response text.
239
+ */
240
+ addResponseHandler(responseHandler: (responseText: string) => void): IUnloadHook;
241
+ }
242
+
243
+ /**
244
+ * The IXHROverride interface overrides the way HTTP requests are sent.
245
+ */
246
+ interface IXHROverride {
247
+ /**
248
+ * This method sends data to the specified URI using a POST request. If sync is true,
249
+ * then the request is sent synchronously. The <i>oncomplete</i> function should always be called after the request is
250
+ * completed (either successfully or timed out or failed due to errors).
251
+ */
252
+ sendPOST: SendPOSTFunction;
253
+ }
254
+
255
+ /**
256
+ * Near Real Time profile. RealTime Latency events are sent every 3 sec and
257
+ * Normal Latency events are sent every 6 sec.
258
+ */
259
+ const NRT_PROFILE = "NEAR_REAL_TIME";
260
+
261
+ /**
262
+ * Defines the function signature of a payload listener, which is called after the payload has been sent to the server. The listener is passed
263
+ * 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.
264
+ * Used by the Remove DDV extension to listen to server send events.
265
+ * @param orgPayload - The initially constructed payload object
266
+ * @param sendPayload - The alternative (possibly modified by a preprocessor) payload
267
+ * @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.
268
+ * @param isBeaconSend - A boolean flag indicating whether the payload was sent using the navigator.sendBeacon() API.
269
+ */
270
+ type PayloadListenerFunction = (orgPayload: IPayloadData, sendPayload?: IPayloadData, isSync?: boolean, isBeaconSend?: boolean) => void;
271
+
272
+ /**
273
+ * Defines the function signature for the Payload Preprocessor.
274
+ * @param payload - The Initial constructed payload that if not modified should be passed onto the callback function.
275
+ * @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.
276
+ * The modifiedBuffer argument can be either the original payload or may be modified by performing GZipping of the payload and adding the content header.
277
+ * @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.
278
+ * 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.
279
+ */
280
+ type PayloadPreprocessorFunction = (payload: IPayloadData, callback: (modifiedBuffer: IPayloadData) => void, isSync?: boolean) => void;
281
+
282
+ /**
283
+ * Class that manages adding events to inbound queues and batching of events
284
+ * into requests.
285
+ */
286
+ class PostChannel extends BaseTelemetryPlugin implements IChannelControls, IPostChannel {
287
+ identifier: string;
288
+ priority: number;
289
+ version: string;
290
+ constructor();
291
+ /**
292
+ * Start the queue manager to batch and send events via post.
293
+ * @param config - The core configuration.
294
+ */
295
+ initialize(coreConfig: IExtendedConfiguration, core: IAppInsightsCore, extensions: IPlugin[]): void;
296
+ /**
297
+ * Add an event to the appropriate inbound queue based on its latency.
298
+ * @param ev - The event to be added to the queue.
299
+ * @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
300
+ * can optionally use this to access the current core instance or define / pass additional information
301
+ * to later plugins (vs appending items to the telemetry item)
302
+ */
303
+ processTelemetry(ev: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
304
+ /**
305
+ * Sets the event queue limits at runtime (after initialization), if the number of queued events is greater than the
306
+ * eventLimit or autoFlushLimit then a flush() operation will be scheduled.
307
+ * @param eventLimit The number of events that can be kept in memory before the SDK starts to drop events. If the value passed is less than or
308
+ * equal to zero the value will be reset to the default (10,000).
309
+ * @param autoFlushLimit When defined, once this number of events has been queued the system perform a flush() to send the queued events
310
+ * without waiting for the normal schedule timers. Passing undefined, null or a value less than or equal to zero will disable the auto flush.
311
+ */
312
+ setEventQueueLimits(eventLimit: number, autoFlushLimit?: number): void;
313
+ /**
314
+ * Pause the transmission of any requests
315
+ */
316
+ pause(): void;
317
+ /**
318
+ * Resumes transmission of events.
319
+ */
320
+ resume(): void;
321
+ /**
322
+ * Add handler to be executed with request response text.
323
+ */
324
+ addResponseHandler(responseHanlder: (responseText: string) => void): IUnloadHook;
325
+ /**
326
+ * Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously (the default) and
327
+ * you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
328
+ * will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
329
+ * will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
330
+ * @param async - send data asynchronously when true
331
+ * @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
332
+ * If the caller doesn't return true the caller should assume that it may never be called.
333
+ * @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
334
+ * @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller
335
+ * should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
336
+ * [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
337
+ * the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
338
+ * and async is true.
339
+ */
340
+ flush(async?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void | IPromise<boolean>;
341
+ /**
342
+ * Set AuthMsaDeviceTicket header
343
+ * @param ticket - Ticket value.
344
+ */
345
+ setMsaAuthTicket(ticket: string): void;
346
+ /**
347
+ * Check if there are any events waiting to be scheduled for sending.
348
+ * @returns True if there are events, false otherwise.
349
+ */
350
+ hasEvents(): boolean;
351
+ /**
352
+ * Load custom transmission profiles. Each profile should have timers for real time, and normal and can
353
+ * optionally specify the immediate latency time in ms (defaults to 0 when not defined). Each profile should
354
+ * make sure that a each normal latency timer is a multiple of the real-time latency and the immediate
355
+ * is smaller than the real-time.
356
+ * Setting the timer value to -1 means that the events for that latency will not be scheduled to be sent.
357
+ * Note that once a latency has been set to not send, all latencies below it will also not be sent. The
358
+ * timers should be in the form of [normal, high, [immediate]].
359
+ * e.g Custom:
360
+ * [10,5] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms
361
+ * [10,5,1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 1ms
362
+ * [10,5,0] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms
363
+ * [10,5,-1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate events will not be
364
+ * scheduled on their own and but they will be included with real-time or normal events as the first events in a batch.
365
+ * This also removes any previously loaded custom profiles.
366
+ * @param profiles - A dictionary containing the transmit profiles.
367
+ */
368
+ _loadTransmitProfiles(profiles: {
369
+ [profileName: string]: number[];
370
+ }): void;
371
+ /**
372
+ * Set the transmit profile to be used. This will change the transmission timers
373
+ * based on the transmit profile.
374
+ * @param profileName - The name of the transmit profile to be used.
375
+ */
376
+ _setTransmitProfile(profileName: string): void;
377
+ /**
378
+ * Backs off transmission. This exponentially increases all the timers.
379
+ */
380
+ _backOffTransmission(): void;
381
+ /**
382
+ * Clears backoff for transmission.
383
+ */
384
+ _clearBackOff(): void;
385
+ }
386
+
387
+ /**
388
+ * Real Time profile (default profile). RealTime Latency events are sent every 1 sec and
389
+ * Normal Latency events are sent every 2 sec.
390
+ */
391
+ const RT_PROFILE = "REAL_TIME";
392
+
393
+ /**
394
+ * SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
395
+ * @param payload - The payload object that should be sent, contains the url, bytes/string and headers for the request
396
+ * @param oncomplete - The function to call once the request has completed whether a success, failure or timeout
397
+ * @param sync - A boolean flag indicating whether the request should be sent as a synchronous request.
398
+ */
399
+ type SendPOSTFunction = (payload: IPayloadData, oncomplete: (status: number, headers: {
400
+ [headerName: string]: string;
401
+ }, response?: string) => void, sync?: boolean) => void;
402
+
403
+
404
+ }