@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
@@ -1,46 +0,0 @@
1
- /**
2
- * RetryPolicy.ts
3
- * @author Abhilash Panwar (abpanwar)
4
- * @copyright Microsoft 2018
5
- */
6
- const RandomizationLowerThreshold = 0.8;
7
- const RandomizationUpperThreshold = 1.2;
8
- const BaseBackoff = 3000;
9
- const MaxBackoff = 600000;
10
-
11
- /**
12
- * Determine if the request should be retried for the given status code.
13
- * The below expression reads that we should only retry for:
14
- * - HttpStatusCodes that are smaller than 300.
15
- * - HttpStatusCodes greater or equal to 500 (except for 501-NotImplement
16
- * and 505-HttpVersionNotSupport).
17
- * - HttpStatusCode 408-RequestTimeout.
18
- * - HttpStatusCode 429.
19
- * This is based on Microsoft.WindowsAzure.Storage.RetryPolicies.ExponentialRetry class
20
- * @param httpStatusCode - The status code returned for the request.
21
- * @returns True if request should be retried, false otherwise.
22
- */
23
- export function retryPolicyShouldRetryForStatus(httpStatusCode: number): boolean {
24
- /* tslint:disable:triple-equals */
25
- // Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
26
- return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 408 && httpStatusCode != 429)
27
- || (httpStatusCode == 501)
28
- || (httpStatusCode == 505));
29
- /* tslint:enable:triple-equals */
30
- }
31
-
32
- /**
33
- * Gets the number of milliseconds to back off before retrying the request. The
34
- * back off duration is exponentially scaled based on the number of retries already
35
- * done for the request.
36
- * @param retriesSoFar - The number of times the request has already been retried.
37
- * @returns The back off duration for the request before it can be retried.
38
- */
39
- export function retryPolicyGetMillisToBackoffForRetry(retriesSoFar: number): number {
40
- let waitDuration = 0;
41
- let minBackoff = BaseBackoff * RandomizationLowerThreshold;
42
- let maxBackoff = BaseBackoff * RandomizationUpperThreshold;
43
- let randomBackoff = Math.floor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
44
- waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
45
- return Math.min(waitDuration, MaxBackoff);
46
- }
package/src/Serializer.ts DELETED
@@ -1,487 +0,0 @@
1
- /**
2
- * Serializer.ts
3
- * @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)
4
- * @copyright Microsoft 2018-2020
5
- */
6
- // @skip-file-minify
7
-
8
- import dynamicProto from "@microsoft/dynamicproto-js";
9
- import {
10
- EventSendType, FieldValueSanitizerFunc, FieldValueSanitizerType, IEventProperty, IPerfManagerProvider, IValueSanitizer,
11
- SendRequestReason, arrIndexOf, doPerf, getCommonSchemaMetaData, getTenantId, isArray, isValueAssigned, objForEachKey, sanitizeProperty,
12
- strStartsWith
13
- } from "@microsoft/1ds-core-js";
14
- import { IPostTransmissionTelemetryItem } from "./DataModels";
15
- import { EventBatch } from "./EventBatch";
16
- import { STR_EMPTY } from "./InternalConstants";
17
-
18
- /**
19
- * Note: This is an optimization for V8-based browsers. When V8 concatenates a string,
20
- * the strings are only joined logically using a "cons string" or "constructed/concatenated
21
- * string". These containers keep references to one another and can result in very large
22
- * memory usage. For example, if a 2MB string is constructed by concatenating 4 bytes
23
- * together at a time, the memory usage will be ~44MB; so ~22x increase. The strings are
24
- * only joined together when an operation requiring their joining takes place, such as
25
- * substr(). This function is called when adding data to this buffer to ensure these
26
- * types of strings are periodically joined to reduce the memory footprint.
27
- * Setting to every 20 events as the JSON.stringify() may have joined many strings
28
- * and calling this too much causes a minor delay while processing.
29
- */
30
- const _MAX_STRING_JOINS = 20;
31
-
32
- const RequestSizeLimitBytes = 3984588; // approx 3.8 Mb
33
- const BeaconRequestSizeLimitBytes = 65000; // approx 64kb (the current Edge, Firefox and Chrome max limit)
34
- const MaxRecordSize = 2000000; // approx 2 Mb
35
- const MaxBeaconRecordSize = Math.min(MaxRecordSize, BeaconRequestSizeLimitBytes);
36
- const metadata = "metadata";
37
- const f = "f";
38
- const rCheckDot = /\./;
39
-
40
- export interface ISerializedPayload {
41
- /**
42
- * The collection of iKeys included in this payload
43
- */
44
- apiKeys: string[];
45
-
46
- /**
47
- * Serialized payload blob that needs to be sent.
48
- */
49
- payloadBlob: string;
50
-
51
- /**
52
- * Extra events that would not fit into the serialized blob limit
53
- */
54
- overflow: EventBatch;
55
-
56
- /**
57
- * Events that where dropped because they exceeded the individual limit
58
- */
59
- sizeExceed: EventBatch[];
60
-
61
- /**
62
- * Events that where dropped because they could not be serialized
63
- */
64
- failedEvts: EventBatch[];
65
-
66
- /**
67
- * The batches included in this payload
68
- */
69
- batches: EventBatch[];
70
-
71
- /**
72
- * The number of events in the payload
73
- */
74
- numEvents: number;
75
-
76
- /**
77
- * The retry count for this payload
78
- */
79
- retryCnt: number;
80
-
81
- /**
82
- * Was this payload created during a teardown
83
- */
84
- isTeardown: boolean;
85
-
86
- /**
87
- * Is this payload a synchronous payload
88
- */
89
- isSync: boolean;
90
-
91
- /**
92
- * The payload has been constructed using a reduced payload size for usage with sendBeacon or fetch(with keepAlive) API's
93
- */
94
- isBeacon: boolean;
95
-
96
- /**
97
- * The request event sync type
98
- */
99
- sendType: EventSendType;
100
-
101
- /**
102
- * The reason the payload has is being sent
103
- */
104
- sendReason?: SendRequestReason;
105
- }
106
-
107
- /**
108
- * Class to handle serialization of event and request.
109
- * Currently uses Bond for serialization. Please note that this may be subject to change.
110
- */
111
- export class Serializer {
112
-
113
- constructor(perfManager?: IPerfManagerProvider, valueSanitizer?: IValueSanitizer, stringifyObjects?: boolean, enableCompoundKey?: boolean) {
114
- const strData = "data";
115
- const strBaseData = "baseData";
116
- const strExt = "ext";
117
-
118
- let _checkForCompoundkey = !!enableCompoundKey;
119
- let _processSubMetaData = true;
120
- let _theSanitizer: IValueSanitizer = valueSanitizer;
121
- let _isReservedCache = {};
122
-
123
- dynamicProto(Serializer, this, (_self) => {
124
-
125
- _self.createPayload = (retryCnt: number, isTeardown: boolean, isSync: boolean, isReducedPayload: boolean, sendReason: SendRequestReason, sendType: EventSendType): ISerializedPayload => {
126
- return {
127
- apiKeys: [],
128
- payloadBlob: STR_EMPTY,
129
- overflow: null,
130
- sizeExceed: [],
131
- failedEvts: [],
132
- batches: [],
133
- numEvents: 0,
134
- retryCnt: retryCnt,
135
- isTeardown: isTeardown,
136
- isSync: isSync,
137
- isBeacon: isReducedPayload,
138
- sendType: sendType,
139
- sendReason: sendReason
140
- };
141
- };
142
-
143
- _self.appendPayload = (payload: ISerializedPayload, theBatch: EventBatch, maxEventsPerBatch: number): boolean => {
144
- let canAddEvents = payload && theBatch && !payload.overflow;
145
- if (canAddEvents) {
146
- doPerf(perfManager, () => "Serializer:appendPayload", () => {
147
- let theEvents = theBatch.events();
148
- let payloadBlob = payload.payloadBlob;
149
- let payloadEvents = payload.numEvents;
150
- let eventsAdded = false;
151
- let sizeExceeded: IPostTransmissionTelemetryItem[] = [];
152
- let failedEvts: IPostTransmissionTelemetryItem[] = [];
153
- let isBeaconPayload = payload.isBeacon;
154
- let requestMaxSize = isBeaconPayload ? BeaconRequestSizeLimitBytes : RequestSizeLimitBytes;
155
- let recordMaxSize = isBeaconPayload ? MaxBeaconRecordSize : MaxRecordSize;
156
-
157
- let lp = 0;
158
- let joinCount = 0;
159
- while (lp < theEvents.length) {
160
- let theEvent = theEvents[lp];
161
- if (theEvent) {
162
- if (payloadEvents >= maxEventsPerBatch) {
163
- // Maximum events per payload reached, so don't add any more
164
- payload.overflow = theBatch.split(lp);
165
- break;
166
- }
167
-
168
- let eventBlob = _self.getEventBlob(theEvent);
169
- if (eventBlob && eventBlob.length <= recordMaxSize) {
170
- // This event will fit into the payload
171
- let blobLength = eventBlob.length;
172
- let currentSize = payloadBlob.length;
173
- if (currentSize + blobLength > requestMaxSize) {
174
- // Request or batch size exceeded, so don't add any more to the payload
175
- payload.overflow = theBatch.split(lp);
176
- break;
177
- }
178
-
179
- if (payloadBlob) {
180
- payloadBlob += "\n";
181
- }
182
-
183
- payloadBlob += eventBlob;
184
-
185
- joinCount ++;
186
- // v8 memory optimization only
187
- if (joinCount > _MAX_STRING_JOINS) {
188
- // this substr() should cause the constructed string to join
189
- payloadBlob.substr(0, 1);
190
- joinCount = 0;
191
- }
192
-
193
- eventsAdded = true;
194
- payloadEvents++;
195
- } else {
196
- if (eventBlob) {
197
- // Single event size exceeded so remove from the batch
198
- sizeExceeded.push(theEvent);
199
- } else {
200
- failedEvts.push(theEvent);
201
- }
202
-
203
- // We also need to remove this event from the existing array, otherwise a notification will be sent
204
- // indicating that it was successfully sent
205
- theEvents.splice(lp, 1);
206
- lp--;
207
- }
208
- }
209
-
210
- lp++;
211
- }
212
-
213
- if (sizeExceeded && sizeExceeded.length > 0) {
214
- payload.sizeExceed.push(EventBatch.create(theBatch.iKey(), sizeExceeded));
215
- // Remove the exceeded events from the batch
216
- }
217
-
218
- if (failedEvts && failedEvts.length > 0) {
219
- payload.failedEvts.push(EventBatch.create(theBatch.iKey(), failedEvts));
220
- // Remove the failed events from the batch
221
- }
222
-
223
- if (eventsAdded) {
224
- payload.batches.push(theBatch);
225
- payload.payloadBlob = payloadBlob;
226
- payload.numEvents = payloadEvents;
227
-
228
- let apiKey = theBatch.iKey();
229
- if (arrIndexOf(payload.apiKeys, apiKey) === -1) {
230
- payload.apiKeys.push(apiKey);
231
- }
232
- }
233
- }, () => ({ payload: payload, theBatch: { iKey: theBatch.iKey(), evts: theBatch.events() }, max: maxEventsPerBatch }));
234
- }
235
-
236
- return canAddEvents;
237
- };
238
-
239
- _self.getEventBlob = (eventData: IPostTransmissionTelemetryItem): string => {
240
- try {
241
- return doPerf(perfManager, () => "Serializer.getEventBlob", () => {
242
- let serializedEvent = { } as any;
243
- // Adding as dynamic keys for v8 performance
244
- serializedEvent.name = eventData.name;
245
- serializedEvent.time = eventData.time;
246
- serializedEvent.ver = eventData.ver;
247
- serializedEvent.iKey = "o:" + getTenantId(eventData.iKey);
248
-
249
- // Assigning local var so usage in part b/c don't throw if there is no ext
250
- let serializedExt = {};
251
-
252
- // Part A
253
- let eventExt = eventData[strExt];
254
- if (eventExt) {
255
- // Only assign ext if the event had one (There are tests covering this use case)
256
- serializedEvent[strExt] = serializedExt;
257
- objForEachKey(eventExt, (key, value) => {
258
- let data = serializedExt[key] = {};
259
-
260
- // Don't include a metadata callback as we don't currently set metadata Part A fields
261
- _processPathKeys(value, data, "ext." + key, true, null, null, true);
262
- });
263
- }
264
-
265
- let serializedData: any = serializedEvent[strData] = {};
266
- serializedData.baseType = eventData.baseType;
267
-
268
- let serializedBaseData = serializedData[strBaseData] = {};
269
-
270
- // Part B
271
- _processPathKeys(eventData.baseData, serializedBaseData, strBaseData, false, [strBaseData], (pathKeys, name, value) => {
272
- _addJSONPropertyMetaData(serializedExt, pathKeys, name, value);
273
- }, _processSubMetaData);
274
-
275
- // Part C
276
- _processPathKeys(eventData.data, serializedData, strData, false, [], (pathKeys, name, value) => {
277
- _addJSONPropertyMetaData(serializedExt, pathKeys, name, value);
278
- }, _processSubMetaData);
279
-
280
- return JSON.stringify(serializedEvent);
281
- }, () => ({ item: eventData }));
282
- } catch (e) {
283
- return null;
284
- }
285
- };
286
-
287
- function _isReservedField(path: string, name: string): boolean {
288
- let result = _isReservedCache[path];
289
-
290
- if (result === undefined) {
291
- if (path.length >= 7) {
292
- // Do not allow the changing of fields located in the ext.metadata or ext.web extension
293
- result = strStartsWith(path, "ext.metadata") || strStartsWith(path, "ext.web");
294
- }
295
-
296
- _isReservedCache[path] = result;
297
- }
298
-
299
- return result;
300
- }
301
-
302
- function _processPathKeys(
303
- srcObj: any,
304
- target: { [key: string]: {}},
305
- thePath: string,
306
- checkReserved: boolean,
307
- metadataPathKeys: string[],
308
- metadataCallback: (pathKeys: string[], key: string, value: IEventProperty) => void,
309
- processSubKeys: boolean) {
310
-
311
- objForEachKey(srcObj, (key, srcValue) => {
312
- let prop: IEventProperty = null;
313
- if (srcValue || isValueAssigned(srcValue)) {
314
- let path = thePath;
315
- let name = key;
316
-
317
- let theMetaPathKeys = metadataPathKeys;
318
- let destObj = target;
319
-
320
- // Handle keys with embedded '.', like "TestObject.testProperty"
321
- if (_checkForCompoundkey && !checkReserved && rCheckDot.test(key)) {
322
- let subKeys = key.split(".");
323
- let keyLen = subKeys.length;
324
- if (keyLen > 1) {
325
- if (theMetaPathKeys) {
326
- // Create a copy of the meta path keys so we can add the extra ones
327
- theMetaPathKeys = theMetaPathKeys.slice();
328
- }
329
-
330
- for (let lp = 0; lp < keyLen - 1; lp++) {
331
- let subKey = subKeys[lp];
332
- // Add/reuse the sub key object
333
- destObj = destObj[subKey] = destObj[subKey] || {};
334
- path += "." + subKey;
335
- if (theMetaPathKeys) {
336
- theMetaPathKeys.push(subKey);
337
- }
338
- }
339
-
340
- name = subKeys[keyLen - 1];
341
- }
342
- }
343
-
344
- let isReserved = checkReserved && _isReservedField(path, name);
345
- if (!isReserved && _theSanitizer && _theSanitizer.handleField(path, name)) {
346
- prop = _theSanitizer.value(path, name, srcValue, stringifyObjects);
347
- } else {
348
- prop = sanitizeProperty(name, srcValue, stringifyObjects);
349
- }
350
-
351
- if (prop) {
352
- // Set the value
353
- let newValue: any = prop.value;
354
- destObj[name] = newValue;
355
-
356
- if (metadataCallback) {
357
- metadataCallback(theMetaPathKeys, name, prop);
358
- }
359
-
360
- if (processSubKeys && typeof newValue === "object" && !isArray(newValue)) {
361
- let newPath = theMetaPathKeys;
362
- if (newPath) {
363
- newPath = newPath.slice();
364
- newPath.push(name);
365
- }
366
-
367
- // Make sure we process sub objects as well (for value sanitization and metadata)
368
- _processPathKeys(srcValue, newValue, path + "." + name, checkReserved, newPath, metadataCallback, processSubKeys);
369
- }
370
- }
371
- }
372
- });
373
- }
374
- });
375
- }
376
-
377
- /**
378
- * Create a serializer payload package
379
- * @param retryCnt The retry count for the events in this payload
380
- * @param isTeardown Is this payload being created as part of a teardown request
381
- * @param isSync Should this payload be sent as a synchronous request
382
- * @param isReducedPayload Is this payload going to be sent via sendBeacon() API
383
- * @param sendReason The reason the payload is being sent
384
- * @param sendType Identifies how this payload will be sent
385
- */
386
- public createPayload(retryCnt: number, isTeardown: boolean, isSync: boolean, isReducedPayload: boolean, sendReason: SendRequestReason, sendType: EventSendType): ISerializedPayload {
387
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
388
- return null;
389
- }
390
-
391
- /**
392
- * Append the batched events into the payload
393
- * @param payload The serialized payload detail object
394
- * @param theBatch The batched events to append to the payload
395
- * @param maxEventsPerBatch The maximum number of events to allow in the payload
396
- * @returns True if the events from the new batch where attempted to be added to the payload otherwise false
397
- */
398
- public appendPayload(payload: ISerializedPayload, theBatch: EventBatch, maxEventsPerBatch: number): boolean {
399
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
400
- return false;
401
- }
402
-
403
- /**
404
- * Bond serialize the event.
405
- * @param eventData - The event that needs to be serialized.
406
- * @returns The serialized json event.
407
- */
408
- public getEventBlob(eventData: IPostTransmissionTelemetryItem): string {
409
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
410
- return null;
411
- }
412
-
413
- /**
414
- * Does this field value sanitizer handle this path / field combination
415
- * @param path - The field path
416
- * @param name - The name of the field
417
- */
418
- public handleField(path: string, name: string): boolean {
419
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
420
- return false;
421
- }
422
-
423
- /**
424
- * Get the field sanitizer for this type of field based on the field type, value kind and/or event property type
425
- * @param path - The field path
426
- * @param name - The name of the field
427
- * @param theType - The type of field
428
- * @param theKind - The value kind of the field
429
- * @param propType - The property type of the field
430
- */
431
- public getSanitizer(path: string, name: string, theType: FieldValueSanitizerType, theKind?: number, propType?: number): FieldValueSanitizerFunc | null | undefined {
432
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
433
- return null;
434
- }
435
-
436
- }
437
-
438
- /**
439
- * @ignore
440
- */
441
- function _addJSONPropertyMetaData(json: { [name: string]: {} }, propKeys: string[], name: string, propertyValue: IEventProperty | null) {
442
- if (propertyValue && json) {
443
- let encodedTypeValue = getCommonSchemaMetaData(propertyValue.value, propertyValue.kind, propertyValue.propertyType);
444
- if (encodedTypeValue > -1) {
445
- // Add the root metadata
446
- let metaData = json[metadata];
447
- if (!metaData) {
448
- // Sets the root 'f'
449
- metaData = json[metadata] = { f: {} };
450
- }
451
-
452
- let metaTarget = metaData[f];
453
- if (!metaTarget) {
454
- // This can occur if someone has manually added an ext.metadata object
455
- // Such as ext.metadata.privLevel and ext.metadata.privTags
456
- metaTarget = metaData[f] = {};
457
- }
458
-
459
- // Traverse the metadata path and build each object (contains an 'f' key) -- if required
460
- if (propKeys) {
461
- for (let lp = 0; lp < propKeys.length; lp++) {
462
- let key = propKeys[lp];
463
- if (!metaTarget[key]) {
464
- metaTarget[key] = { f: {} };
465
- }
466
-
467
- let newTarget = metaTarget[key][f];
468
- if (!newTarget) {
469
- // Not expected, but can occur if the metadata context was pre-created as part of the event
470
- newTarget = metaTarget[key][f] = {};
471
- }
472
-
473
- metaTarget = newTarget;
474
- }
475
- }
476
-
477
- metaTarget = metaTarget[name] = { };
478
- if (isArray(propertyValue.value)) {
479
- metaTarget["a"] = {
480
- t: encodedTypeValue
481
- };
482
- } else {
483
- metaTarget["t"] = encodedTypeValue;
484
- }
485
- }
486
- }
487
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * TimeoutOverrideWrapper.ts
3
- * @author Nev Wylie (newylie)
4
- * @copyright Microsoft 2022
5
- * Simple internal timeout wrapper
6
- */
7
-
8
- export type TimeoutSetFunc<T = any> = (callback: (...args: any[]) => void, ms: number, ...args: any[]) => T;
9
- export type TimeoutClearFunc<T = any> = (timeoutId?: T) => void;
10
-
11
- export interface ITimeoutOverrideWrapper<T = any> {
12
- set: TimeoutSetFunc<T>;
13
- clear: TimeoutClearFunc<T>;
14
- }
15
-
16
- export function defaultSetTimeout<T = any>(callback: (...args: any[]) => void, ms: number, ...args: any[]): T {
17
- return setTimeout(callback, ms, args) as any;
18
- }
19
-
20
- export function defaultClearTimeout<T = any>(timeoutId?: T): void {
21
- clearTimeout(timeoutId as any);
22
- }
23
-
24
- export function createTimeoutWrapper<T = any>(argSetTimeout?: TimeoutSetFunc<T>, argClearTimeout?: TimeoutClearFunc<T>) {
25
- return {
26
- set: argSetTimeout || defaultSetTimeout,
27
- clear: argClearTimeout || defaultClearTimeout
28
- }
29
- }
@@ -1,23 +0,0 @@
1
- // This interface was removed from newer versions of typescript. Restore it for legacy support
2
- export interface XDomainRequest {
3
- timeout: number;
4
- onerror: (ev: Event) => any;
5
- onload: (ev: Event) => any;
6
- onprogress: (ev: any) => any;
7
- ontimeout: (ev: Event) => any;
8
- responseText: string;
9
- contentType: string;
10
- open(method: string, url: string): void;
11
- create(): XDomainRequest;
12
- abort(): void;
13
- send(data?: any): void;
14
- addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
15
- addEventListener(type: "load" | "timeout", listener: (ev: Event) => any, useCapture?: boolean): void;
16
- addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
17
- addEventListener(type: string, listener: EventListener, useCapture?: boolean): void;
18
- }
19
-
20
- // export declare var XDomainRequest: {
21
- // prototype: IXDomainRequest;
22
- // new (): IXDomainRequest;
23
- // };
File without changes
File without changes
File without changes