@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,108 +0,0 @@
1
- /**
2
- * Serializer.ts
3
- * @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)
4
- * @copyright Microsoft 2018-2020
5
- */
6
- import { EventSendType, FieldValueSanitizerFunc, FieldValueSanitizerType, IPerfManagerProvider, IValueSanitizer, SendRequestReason } from "@microsoft/1ds-core-js";
7
- import { IPostTransmissionTelemetryItem } from "./DataModels";
8
- import { EventBatch } from "./EventBatch";
9
- export interface ISerializedPayload {
10
- /**
11
- * The collection of iKeys included in this payload
12
- */
13
- apiKeys: string[];
14
- /**
15
- * Serialized payload blob that needs to be sent.
16
- */
17
- payloadBlob: string;
18
- /**
19
- * Extra events that would not fit into the serialized blob limit
20
- */
21
- overflow: EventBatch;
22
- /**
23
- * Events that where dropped because they exceeded the individual limit
24
- */
25
- sizeExceed: EventBatch[];
26
- /**
27
- * Events that where dropped because they could not be serialized
28
- */
29
- failedEvts: EventBatch[];
30
- /**
31
- * The batches included in this payload
32
- */
33
- batches: EventBatch[];
34
- /**
35
- * The number of events in the payload
36
- */
37
- numEvents: number;
38
- /**
39
- * The retry count for this payload
40
- */
41
- retryCnt: number;
42
- /**
43
- * Was this payload created during a teardown
44
- */
45
- isTeardown: boolean;
46
- /**
47
- * Is this payload a synchronous payload
48
- */
49
- isSync: boolean;
50
- /**
51
- * The payload has been constructed using a reduced payload size for usage with sendBeacon or fetch(with keepAlive) API's
52
- */
53
- isBeacon: boolean;
54
- /**
55
- * The request event sync type
56
- */
57
- sendType: EventSendType;
58
- /**
59
- * The reason the payload has is being sent
60
- */
61
- sendReason?: SendRequestReason;
62
- }
63
- /**
64
- * Class to handle serialization of event and request.
65
- * Currently uses Bond for serialization. Please note that this may be subject to change.
66
- */
67
- export declare class Serializer {
68
- constructor(perfManager?: IPerfManagerProvider, valueSanitizer?: IValueSanitizer, stringifyObjects?: boolean, enableCompoundKey?: boolean);
69
- /**
70
- * Create a serializer payload package
71
- * @param retryCnt The retry count for the events in this payload
72
- * @param isTeardown Is this payload being created as part of a teardown request
73
- * @param isSync Should this payload be sent as a synchronous request
74
- * @param isReducedPayload Is this payload going to be sent via sendBeacon() API
75
- * @param sendReason The reason the payload is being sent
76
- * @param sendType Identifies how this payload will be sent
77
- */
78
- createPayload(retryCnt: number, isTeardown: boolean, isSync: boolean, isReducedPayload: boolean, sendReason: SendRequestReason, sendType: EventSendType): ISerializedPayload;
79
- /**
80
- * Append the batched events into the payload
81
- * @param payload The serialized payload detail object
82
- * @param theBatch The batched events to append to the payload
83
- * @param maxEventsPerBatch The maximum number of events to allow in the payload
84
- * @returns True if the events from the new batch where attempted to be added to the payload otherwise false
85
- */
86
- appendPayload(payload: ISerializedPayload, theBatch: EventBatch, maxEventsPerBatch: number): boolean;
87
- /**
88
- * Bond serialize the event.
89
- * @param eventData - The event that needs to be serialized.
90
- * @returns The serialized json event.
91
- */
92
- getEventBlob(eventData: IPostTransmissionTelemetryItem): string;
93
- /**
94
- * Does this field value sanitizer handle this path / field combination
95
- * @param path - The field path
96
- * @param name - The name of the field
97
- */
98
- handleField(path: string, name: string): boolean;
99
- /**
100
- * Get the field sanitizer for this type of field based on the field type, value kind and/or event property type
101
- * @param path - The field path
102
- * @param name - The name of the field
103
- * @param theType - The type of field
104
- * @param theKind - The value kind of the field
105
- * @param propType - The property type of the field
106
- */
107
- getSanitizer(path: string, name: string, theType: FieldValueSanitizerType, theKind?: number, propType?: number): FieldValueSanitizerFunc | null | undefined;
108
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Serializer.js.map","sources":["Serializer.js"],"sourcesContent":["/**\r\n* Serializer.ts\r\n* @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)\r\n* @copyright Microsoft 2018-2020\r\n*/\r\n// @skip-file-minify\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { arrIndexOf, doPerf, getCommonSchemaMetaData, getTenantId, isArray, isValueAssigned, objForEachKey, sanitizeProperty, strStartsWith } from \"@microsoft/1ds-core-js\";\r\nimport { EventBatch } from \"./EventBatch\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\n/**\r\n * Note: This is an optimization for V8-based browsers. When V8 concatenates a string,\r\n * the strings are only joined logically using a \"cons string\" or \"constructed/concatenated\r\n * string\". These containers keep references to one another and can result in very large\r\n * memory usage. For example, if a 2MB string is constructed by concatenating 4 bytes\r\n * together at a time, the memory usage will be ~44MB; so ~22x increase. The strings are\r\n * only joined together when an operation requiring their joining takes place, such as\r\n * substr(). This function is called when adding data to this buffer to ensure these\r\n * types of strings are periodically joined to reduce the memory footprint.\r\n * Setting to every 20 events as the JSON.stringify() may have joined many strings\r\n * and calling this too much causes a minor delay while processing.\r\n */\r\nvar _MAX_STRING_JOINS = 20;\r\nvar RequestSizeLimitBytes = 3984588; // approx 3.8 Mb\r\nvar BeaconRequestSizeLimitBytes = 65000; // approx 64kb (the current Edge, Firefox and Chrome max limit)\r\nvar MaxRecordSize = 2000000; // approx 2 Mb\r\nvar MaxBeaconRecordSize = Math.min(MaxRecordSize, BeaconRequestSizeLimitBytes);\r\nvar metadata = \"metadata\";\r\nvar f = \"f\";\r\nvar rCheckDot = /\\./;\r\n/**\r\n* Class to handle serialization of event and request.\r\n* Currently uses Bond for serialization. Please note that this may be subject to change.\r\n*/\r\nvar Serializer = /** @class */ (function () {\r\n function Serializer(perfManager, valueSanitizer, stringifyObjects, enableCompoundKey) {\r\n var strData = \"data\";\r\n var strBaseData = \"baseData\";\r\n var strExt = \"ext\";\r\n var _checkForCompoundkey = !!enableCompoundKey;\r\n var _processSubMetaData = true;\r\n var _theSanitizer = valueSanitizer;\r\n var _isReservedCache = {};\r\n dynamicProto(Serializer, this, function (_self) {\r\n _self.createPayload = function (retryCnt, isTeardown, isSync, isReducedPayload, sendReason, sendType) {\r\n return {\r\n apiKeys: [],\r\n payloadBlob: STR_EMPTY,\r\n overflow: null,\r\n sizeExceed: [],\r\n failedEvts: [],\r\n batches: [],\r\n numEvents: 0,\r\n retryCnt: retryCnt,\r\n isTeardown: isTeardown,\r\n isSync: isSync,\r\n isBeacon: isReducedPayload,\r\n sendType: sendType,\r\n sendReason: sendReason\r\n };\r\n };\r\n _self.appendPayload = function (payload, theBatch, maxEventsPerBatch) {\r\n var canAddEvents = payload && theBatch && !payload.overflow;\r\n if (canAddEvents) {\r\n doPerf(perfManager, function () { return \"Serializer:appendPayload\"; }, function () {\r\n var theEvents = theBatch.events();\r\n var payloadBlob = payload.payloadBlob;\r\n var payloadEvents = payload.numEvents;\r\n var eventsAdded = false;\r\n var sizeExceeded = [];\r\n var failedEvts = [];\r\n var isBeaconPayload = payload.isBeacon;\r\n var requestMaxSize = isBeaconPayload ? BeaconRequestSizeLimitBytes : RequestSizeLimitBytes;\r\n var recordMaxSize = isBeaconPayload ? MaxBeaconRecordSize : MaxRecordSize;\r\n var lp = 0;\r\n var joinCount = 0;\r\n while (lp < theEvents.length) {\r\n var theEvent = theEvents[lp];\r\n if (theEvent) {\r\n if (payloadEvents >= maxEventsPerBatch) {\r\n // Maximum events per payload reached, so don't add any more\r\n payload.overflow = theBatch.split(lp);\r\n break;\r\n }\r\n var eventBlob = _self.getEventBlob(theEvent);\r\n if (eventBlob && eventBlob.length <= recordMaxSize) {\r\n // This event will fit into the payload\r\n var blobLength = eventBlob.length;\r\n var currentSize = payloadBlob.length;\r\n if (currentSize + blobLength > requestMaxSize) {\r\n // Request or batch size exceeded, so don't add any more to the payload\r\n payload.overflow = theBatch.split(lp);\r\n break;\r\n }\r\n if (payloadBlob) {\r\n payloadBlob += \"\\n\";\r\n }\r\n payloadBlob += eventBlob;\r\n joinCount++;\r\n // v8 memory optimization only\r\n if (joinCount > _MAX_STRING_JOINS) {\r\n // this substr() should cause the constructed string to join\r\n payloadBlob.substr(0, 1);\r\n joinCount = 0;\r\n }\r\n eventsAdded = true;\r\n payloadEvents++;\r\n }\r\n else {\r\n if (eventBlob) {\r\n // Single event size exceeded so remove from the batch\r\n sizeExceeded.push(theEvent);\r\n }\r\n else {\r\n failedEvts.push(theEvent);\r\n }\r\n // We also need to remove this event from the existing array, otherwise a notification will be sent\r\n // indicating that it was successfully sent\r\n theEvents.splice(lp, 1);\r\n lp--;\r\n }\r\n }\r\n lp++;\r\n }\r\n if (sizeExceeded && sizeExceeded.length > 0) {\r\n payload.sizeExceed.push(EventBatch.create(theBatch.iKey(), sizeExceeded));\r\n // Remove the exceeded events from the batch\r\n }\r\n if (failedEvts && failedEvts.length > 0) {\r\n payload.failedEvts.push(EventBatch.create(theBatch.iKey(), failedEvts));\r\n // Remove the failed events from the batch\r\n }\r\n if (eventsAdded) {\r\n payload.batches.push(theBatch);\r\n payload.payloadBlob = payloadBlob;\r\n payload.numEvents = payloadEvents;\r\n var apiKey = theBatch.iKey();\r\n if (arrIndexOf(payload.apiKeys, apiKey) === -1) {\r\n payload.apiKeys.push(apiKey);\r\n }\r\n }\r\n }, function () { return ({ payload: payload, theBatch: { iKey: theBatch.iKey(), evts: theBatch.events() }, max: maxEventsPerBatch }); });\r\n }\r\n return canAddEvents;\r\n };\r\n _self.getEventBlob = function (eventData) {\r\n try {\r\n return doPerf(perfManager, function () { return \"Serializer.getEventBlob\"; }, function () {\r\n var serializedEvent = {};\r\n // Adding as dynamic keys for v8 performance\r\n serializedEvent.name = eventData.name;\r\n serializedEvent.time = eventData.time;\r\n serializedEvent.ver = eventData.ver;\r\n serializedEvent.iKey = \"o:\" + getTenantId(eventData.iKey);\r\n // Assigning local var so usage in part b/c don't throw if there is no ext\r\n var serializedExt = {};\r\n // Part A\r\n var eventExt = eventData[strExt];\r\n if (eventExt) {\r\n // Only assign ext if the event had one (There are tests covering this use case)\r\n serializedEvent[strExt] = serializedExt;\r\n objForEachKey(eventExt, function (key, value) {\r\n var data = serializedExt[key] = {};\r\n // Don't include a metadata callback as we don't currently set metadata Part A fields\r\n _processPathKeys(value, data, \"ext.\" + key, true, null, null, true);\r\n });\r\n }\r\n var serializedData = serializedEvent[strData] = {};\r\n serializedData.baseType = eventData.baseType;\r\n var serializedBaseData = serializedData[strBaseData] = {};\r\n // Part B\r\n _processPathKeys(eventData.baseData, serializedBaseData, strBaseData, false, [strBaseData], function (pathKeys, name, value) {\r\n _addJSONPropertyMetaData(serializedExt, pathKeys, name, value);\r\n }, _processSubMetaData);\r\n // Part C\r\n _processPathKeys(eventData.data, serializedData, strData, false, [], function (pathKeys, name, value) {\r\n _addJSONPropertyMetaData(serializedExt, pathKeys, name, value);\r\n }, _processSubMetaData);\r\n return JSON.stringify(serializedEvent);\r\n }, function () { return ({ item: eventData }); });\r\n }\r\n catch (e) {\r\n return null;\r\n }\r\n };\r\n function _isReservedField(path, name) {\r\n var result = _isReservedCache[path];\r\n if (result === undefined) {\r\n if (path.length >= 7) {\r\n // Do not allow the changing of fields located in the ext.metadata or ext.web extension\r\n result = strStartsWith(path, \"ext.metadata\") || strStartsWith(path, \"ext.web\");\r\n }\r\n _isReservedCache[path] = result;\r\n }\r\n return result;\r\n }\r\n function _processPathKeys(srcObj, target, thePath, checkReserved, metadataPathKeys, metadataCallback, processSubKeys) {\r\n objForEachKey(srcObj, function (key, srcValue) {\r\n var prop = null;\r\n if (srcValue || isValueAssigned(srcValue)) {\r\n var path = thePath;\r\n var name_1 = key;\r\n var theMetaPathKeys = metadataPathKeys;\r\n var destObj = target;\r\n // Handle keys with embedded '.', like \"TestObject.testProperty\"\r\n if (_checkForCompoundkey && !checkReserved && rCheckDot.test(key)) {\r\n var subKeys = key.split(\".\");\r\n var keyLen = subKeys.length;\r\n if (keyLen > 1) {\r\n if (theMetaPathKeys) {\r\n // Create a copy of the meta path keys so we can add the extra ones\r\n theMetaPathKeys = theMetaPathKeys.slice();\r\n }\r\n for (var lp = 0; lp < keyLen - 1; lp++) {\r\n var subKey = subKeys[lp];\r\n // Add/reuse the sub key object\r\n destObj = destObj[subKey] = destObj[subKey] || {};\r\n path += \".\" + subKey;\r\n if (theMetaPathKeys) {\r\n theMetaPathKeys.push(subKey);\r\n }\r\n }\r\n name_1 = subKeys[keyLen - 1];\r\n }\r\n }\r\n var isReserved = checkReserved && _isReservedField(path, name_1);\r\n if (!isReserved && _theSanitizer && _theSanitizer.handleField(path, name_1)) {\r\n prop = _theSanitizer.value(path, name_1, srcValue, stringifyObjects);\r\n }\r\n else {\r\n prop = sanitizeProperty(name_1, srcValue, stringifyObjects);\r\n }\r\n if (prop) {\r\n // Set the value\r\n var newValue = prop.value;\r\n destObj[name_1] = newValue;\r\n if (metadataCallback) {\r\n metadataCallback(theMetaPathKeys, name_1, prop);\r\n }\r\n if (processSubKeys && typeof newValue === \"object\" && !isArray(newValue)) {\r\n var newPath = theMetaPathKeys;\r\n if (newPath) {\r\n newPath = newPath.slice();\r\n newPath.push(name_1);\r\n }\r\n // Make sure we process sub objects as well (for value sanitization and metadata)\r\n _processPathKeys(srcValue, newValue, path + \".\" + name_1, checkReserved, newPath, metadataCallback, processSubKeys);\r\n }\r\n }\r\n }\r\n });\r\n }\r\n });\r\n }\r\n /**\r\n * Create a serializer payload package\r\n * @param retryCnt The retry count for the events in this payload\r\n * @param isTeardown Is this payload being created as part of a teardown request\r\n * @param isSync Should this payload be sent as a synchronous request\r\n * @param isReducedPayload Is this payload going to be sent via sendBeacon() API\r\n * @param sendReason The reason the payload is being sent\r\n * @param sendType Identifies how this payload will be sent\r\n */\r\n Serializer.prototype.createPayload = function (retryCnt, isTeardown, isSync, isReducedPayload, sendReason, sendType) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Append the batched events into the payload\r\n * @param payload The serialized payload detail object\r\n * @param theBatch The batched events to append to the payload\r\n * @param maxEventsPerBatch The maximum number of events to allow in the payload\r\n * @returns True if the events from the new batch where attempted to be added to the payload otherwise false\r\n */\r\n Serializer.prototype.appendPayload = function (payload, theBatch, maxEventsPerBatch) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Bond serialize the event.\r\n * @param eventData - The event that needs to be serialized.\r\n * @returns The serialized json event.\r\n */\r\n Serializer.prototype.getEventBlob = function (eventData) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Does this field value sanitizer handle this path / field combination\r\n * @param path - The field path\r\n * @param name - The name of the field\r\n */\r\n Serializer.prototype.handleField = function (path, name) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n /**\r\n * Get the field sanitizer for this type of field based on the field type, value kind and/or event property type\r\n * @param path - The field path\r\n * @param name - The name of the field\r\n * @param theType - The type of field\r\n * @param theKind - The value kind of the field\r\n * @param propType - The property type of the field\r\n */\r\n Serializer.prototype.getSanitizer = function (path, name, theType, theKind, propType) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n return Serializer;\r\n}());\r\nexport { Serializer };\r\n/**\r\n * @ignore\r\n */\r\nfunction _addJSONPropertyMetaData(json, propKeys, name, propertyValue) {\r\n if (propertyValue && json) {\r\n var encodedTypeValue = getCommonSchemaMetaData(propertyValue.value, propertyValue.kind, propertyValue.propertyType);\r\n if (encodedTypeValue > -1) {\r\n // Add the root metadata\r\n var metaData = json[metadata];\r\n if (!metaData) {\r\n // Sets the root 'f'\r\n metaData = json[metadata] = { f: {} };\r\n }\r\n var metaTarget = metaData[f];\r\n if (!metaTarget) {\r\n // This can occur if someone has manually added an ext.metadata object\r\n // Such as ext.metadata.privLevel and ext.metadata.privTags\r\n metaTarget = metaData[f] = {};\r\n }\r\n // Traverse the metadata path and build each object (contains an 'f' key) -- if required\r\n if (propKeys) {\r\n for (var lp = 0; lp < propKeys.length; lp++) {\r\n var key = propKeys[lp];\r\n if (!metaTarget[key]) {\r\n metaTarget[key] = { f: {} };\r\n }\r\n var newTarget = metaTarget[key][f];\r\n if (!newTarget) {\r\n // Not expected, but can occur if the metadata context was pre-created as part of the event\r\n newTarget = metaTarget[key][f] = {};\r\n }\r\n metaTarget = newTarget;\r\n }\r\n }\r\n metaTarget = metaTarget[name] = {};\r\n if (isArray(propertyValue.value)) {\r\n metaTarget[\"a\"] = {\r\n t: encodedTypeValue\r\n };\r\n }\r\n else {\r\n metaTarget[\"t\"] = encodedTypeValue;\r\n }\r\n }\r\n }\r\n}\r\n//# sourceMappingURL=Serializer.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;sDAqDM,CAAC;;;;;;sBACe;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,18 +0,0 @@
1
- /**
2
- * TimeoutOverrideWrapper.ts
3
- * @author Nev Wylie (newylie)
4
- * @copyright Microsoft 2022
5
- * Simple internal timeout wrapper
6
- */
7
- export type TimeoutSetFunc<T = any> = (callback: (...args: any[]) => void, ms: number, ...args: any[]) => T;
8
- export type TimeoutClearFunc<T = any> = (timeoutId?: T) => void;
9
- export interface ITimeoutOverrideWrapper<T = any> {
10
- set: TimeoutSetFunc<T>;
11
- clear: TimeoutClearFunc<T>;
12
- }
13
- export declare function defaultSetTimeout<T = any>(callback: (...args: any[]) => void, ms: number, ...args: any[]): T;
14
- export declare function defaultClearTimeout<T = any>(timeoutId?: T): void;
15
- export declare function createTimeoutWrapper<T = any>(argSetTimeout?: TimeoutSetFunc<T>, argClearTimeout?: TimeoutClearFunc<T>): {
16
- set: TimeoutSetFunc<T>;
17
- clear: TimeoutClearFunc<T>;
18
- };
@@ -1,28 +0,0 @@
1
- /*
2
- * 1DS JS SDK POST plugin, 3.2.11
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- * (Microsoft Internal Only)
5
- */
6
- /**
7
- * TimeoutOverrideWrapper.ts
8
- * @author Nev Wylie (newylie)
9
- * @copyright Microsoft 2022
10
- * Simple internal timeout wrapper
11
- */
12
- export function defaultSetTimeout(callback, ms) {
13
- var args = [];
14
- for (var _i = 2; _i < arguments.length; _i++) {
15
- args[_i - 2] = arguments[_i];
16
- }
17
- return setTimeout(callback, ms, args);
18
- }
19
- export function defaultClearTimeout(timeoutId) {
20
- clearTimeout(timeoutId);
21
- }
22
- export function createTimeoutWrapper(argSetTimeout, argClearTimeout) {
23
- return {
24
- set: argSetTimeout || defaultSetTimeout,
25
- clear: argClearTimeout || defaultClearTimeout
26
- };
27
- }
28
- //# sourceMappingURL=TimeoutOverrideWrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeoutOverrideWrapper.js.map","sources":["TimeoutOverrideWrapper.js"],"sourcesContent":["/**\r\n* TimeoutOverrideWrapper.ts\r\n* @author Nev Wylie (newylie)\r\n* @copyright Microsoft 2022\r\n* Simple internal timeout wrapper\r\n*/\r\nexport function defaultSetTimeout(callback, ms) {\r\n var args = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n args[_i - 2] = arguments[_i];\r\n }\r\n return setTimeout(callback, ms, args);\r\n}\r\nexport function defaultClearTimeout(timeoutId) {\r\n clearTimeout(timeoutId);\r\n}\r\nexport function createTimeoutWrapper(argSetTimeout, argClearTimeout) {\r\n return {\r\n set: argSetTimeout || defaultSetTimeout,\r\n clear: argClearTimeout || defaultClearTimeout\r\n };\r\n}\r\n//# sourceMappingURL=TimeoutOverrideWrapper.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,17 +0,0 @@
1
- export interface XDomainRequest {
2
- timeout: number;
3
- onerror: (ev: Event) => any;
4
- onload: (ev: Event) => any;
5
- onprogress: (ev: any) => any;
6
- ontimeout: (ev: Event) => any;
7
- responseText: string;
8
- contentType: string;
9
- open(method: string, url: string): void;
10
- create(): XDomainRequest;
11
- abort(): void;
12
- send(data?: any): void;
13
- addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
14
- addEventListener(type: "load" | "timeout", listener: (ev: Event) => any, useCapture?: boolean): void;
15
- addEventListener(type: "progress", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
16
- addEventListener(type: string, listener: EventListener, useCapture?: boolean): void;
17
- }
@@ -1,44 +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
-
10
- export type BatchNotificationAction = (batches: EventBatch[], reason?: EventBatchNotificationReason, isSyncRequest?: boolean, sendType?: EventSendType) => void;
11
-
12
- // tslint:disable-next-line:interface-name
13
- export interface BatchNotificationActions {
14
- /**
15
- * Attempts have been made to send the events but all failed.
16
- * Requeue the events (if possible) for resending.
17
- */
18
- requeue?: BatchNotificationAction;
19
-
20
- /**
21
- * The batch is about to be sent
22
- */
23
- send?: BatchNotificationAction;
24
-
25
- /**
26
- * The batch has been sent acknowledged by the server
27
- */
28
- sent?: BatchNotificationAction;
29
-
30
- /**
31
- * The events of the batch have been dropped
32
- */
33
- drop?: BatchNotificationAction;
34
-
35
- /**
36
- * The events of the batch have been dropped after being sent but not acknowledged
37
- */
38
- rspFail?: BatchNotificationAction;
39
-
40
- /**
41
- * Default callback action to call when no specific action could be identified for the reason
42
- */
43
- oth?: BatchNotificationAction;
44
- }
@@ -1,127 +0,0 @@
1
- /**
2
- * ClockSkewManager.ts
3
- * @author Abhilash Panwar (abpanwar)
4
- * @copyright Microsoft 2018
5
- */
6
-
7
- import dynamicProto from "@microsoft/dynamicproto-js";
8
-
9
- /**
10
- * Class to manage clock skew correction.
11
- */
12
- export default class ClockSkewManager {
13
-
14
- constructor() {
15
- let _allowRequestSending = true;
16
- let _shouldAddClockSkewHeaders = true;
17
- let _isFirstRequest = true;
18
- let _clockSkewHeaderValue = "use-collector-delta";
19
- let _clockSkewSet = false;
20
-
21
- dynamicProto(ClockSkewManager, this, (_self) => {
22
- /**
23
- * Determine if requests can be sent.
24
- * @returns True if requests can be sent, false otherwise.
25
- */
26
- _self.allowRequestSending = (): boolean => {
27
- return _allowRequestSending;
28
- };
29
-
30
- /**
31
- * Tells the ClockSkewManager that it should assume that the first request has now been sent,
32
- * If this method had not yet been called AND the clock Skew had not been set this will set
33
- * allowRequestSending to false until setClockSet() is called.
34
- */
35
- _self.firstRequestSent = () => {
36
- if (_isFirstRequest) {
37
- _isFirstRequest = false;
38
- if (!_clockSkewSet) {
39
- // Block sending until we get the first clock Skew
40
- _allowRequestSending = false;
41
- }
42
- }
43
- };
44
-
45
- /**
46
- * Determine if clock skew headers should be added to the request.
47
- * @returns True if clock skew headers should be added, false otherwise.
48
- */
49
- _self.shouldAddClockSkewHeaders = (): boolean => {
50
- return _shouldAddClockSkewHeaders;
51
- };
52
-
53
- /**
54
- * Gets the clock skew header value.
55
- * @returns The clock skew header value.
56
- */
57
- _self.getClockSkewHeaderValue = (): string => {
58
- return _clockSkewHeaderValue;
59
- };
60
-
61
- /**
62
- * Sets the clock skew header value. Once clock skew is set this method
63
- * is no-op.
64
- * @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.
65
- */
66
- _self.setClockSkew = (timeDeltaInMillis?: string) => {
67
- if (!_clockSkewSet) {
68
- if (timeDeltaInMillis) {
69
- _clockSkewHeaderValue = timeDeltaInMillis;
70
- _shouldAddClockSkewHeaders = true;
71
- _clockSkewSet = true;
72
- } else {
73
- _shouldAddClockSkewHeaders = false;
74
- }
75
-
76
- // Unblock sending
77
- _allowRequestSending = true;
78
- }
79
- };
80
- });
81
- }
82
-
83
- /**
84
- * Determine if the request can be sent.
85
- * @returns True if requests can be sent, false otherwise.
86
- */
87
- public allowRequestSending(): boolean {
88
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
89
- return false;
90
- }
91
-
92
- /**
93
- * Tells the ClockSkewManager that it should assume that the first request has now been sent,
94
- * If this method had not yet been called AND the clock Skew had not been set this will set
95
- * allowRequestSending to false until setClockSet() is called.
96
- */
97
- public firstRequestSent(): void {
98
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
99
- }
100
-
101
- /**
102
- * Determine if clock skew headers should be added to the request.
103
- * @returns True if clock skew headers should be added, false otherwise.
104
- */
105
- public shouldAddClockSkewHeaders(): boolean {
106
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
107
- return false;
108
- }
109
-
110
- /**
111
- * Gets the clock skew header value.
112
- * @returns The clock skew header value.
113
- */
114
- public getClockSkewHeaderValue(): string {
115
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
116
- return null;
117
- }
118
-
119
- /**
120
- * Sets the clock skew header value. Once clock skew is set this method
121
- * is no-op.
122
- * @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.
123
- */
124
- public setClockSkew(timeDeltaInMillis?: string) {
125
- // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging
126
- }
127
- }
package/src/EventBatch.ts DELETED
@@ -1,137 +0,0 @@
1
- /**
2
- * EventBatch.ts
3
- * @author Nev Wylie (newylie)
4
- * @copyright Microsoft 2020
5
- */
6
- import { isNullOrUndefined, isValueAssigned } from "@microsoft/1ds-core-js";
7
- import { IPostTransmissionTelemetryItem } from "./DataModels";
8
- import { STR_EMPTY, STR_MSFPC } from "./InternalConstants";
9
-
10
- function _getEventMsfpc(theEvent: IPostTransmissionTelemetryItem): string {
11
- let intWeb = ((theEvent.ext || {})["intweb"]);
12
- if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {
13
- return intWeb[STR_MSFPC];
14
- }
15
-
16
- return null;
17
- }
18
-
19
- function _getMsfpc(theEvents: IPostTransmissionTelemetryItem[]): string {
20
- let msfpc: string = null;
21
-
22
- for (let lp = 0; msfpc === null && lp < theEvents.length; lp++) {
23
- msfpc = _getEventMsfpc(theEvents[lp]);
24
- }
25
-
26
- return msfpc;
27
- }
28
-
29
- /**
30
- * This class defines a "batch" events related to a specific iKey, it is used by the PostChannel and HttpManager
31
- * to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous
32
- * array duplication and shared ownership issues that occurred due to race conditions caused by the async nature
33
- * of sending requests.
34
- */
35
- export class EventBatch {
36
-
37
- /**
38
- * Creates a new Event Batch object
39
- * @param iKey The iKey associated with this batch of events
40
- */
41
- public static create(iKey: string, theEvents?: IPostTransmissionTelemetryItem[]): EventBatch {
42
- return new EventBatch(iKey, theEvents);
43
- }
44
-
45
- /**
46
- * Returns the iKey associated with this batch of events
47
- */
48
- public iKey: () => string;
49
-
50
- /**
51
- * Returns the first msfpc value from the batch
52
- */
53
- public Msfpc:() => string;
54
-
55
- /**
56
- * Returns the number of events contained in the batch
57
- */
58
- public count: () => number;
59
-
60
- public events: () => IPostTransmissionTelemetryItem[];
61
-
62
- /**
63
- * Add all of the events to the current batch, if the max number of events would be exceeded then no
64
- * events are added.
65
- * @param theEvents - The events that needs to be batched.
66
- * @returns The number of events added.
67
- */
68
- public addEvent: (theEvents: IPostTransmissionTelemetryItem) => boolean;
69
-
70
- /**
71
- * Split this batch into 2 with any events > fromEvent returned in the new batch and all other
72
- * events are kept in the current batch.
73
- * @param fromEvent The first event to remove from the current batch.
74
- * @param numEvents The number of events to be removed from the current batch and returned in the new one. Defaults to all trailing events
75
- */
76
- public split: (fromEvent: number, numEvents?: number) => EventBatch;
77
-
78
- /**
79
- * Private constructor so that caller is forced to use the static create method.
80
- * @param iKey - The iKey to associate with the events (not validated)
81
- * @param addEvents - The optional collection of events to assign to this batch - defaults to an empty array.
82
- */
83
- private constructor(iKey: string, addEvents?: IPostTransmissionTelemetryItem[]) {
84
- let events: IPostTransmissionTelemetryItem[] = addEvents ? [].concat(addEvents) : [];
85
- let _self = this;
86
- let _msfpc = _getMsfpc(events);
87
-
88
- _self.iKey = (): string => {
89
- return iKey;
90
- };
91
-
92
- _self.Msfpc = (): string => {
93
- // return the cached value unless it's undefined -- used to avoid cpu
94
- return _msfpc || STR_EMPTY;
95
- };
96
-
97
- _self.count = (): number => {
98
- return events.length;
99
- };
100
-
101
- _self.events = (): IPostTransmissionTelemetryItem[] => {
102
- return events;
103
- };
104
-
105
- _self.addEvent = (theEvent: IPostTransmissionTelemetryItem): boolean => {
106
- if (theEvent) {
107
- events.push(theEvent);
108
- if (!_msfpc) {
109
- // Not found so try and find one
110
- _msfpc = _getEventMsfpc(theEvent);
111
- }
112
-
113
- return true;
114
- }
115
-
116
- return false;
117
- };
118
-
119
- _self.split = (fromEvent: number, numEvents?: number) => {
120
- // Create a new batch with the same iKey
121
- let theEvents: IPostTransmissionTelemetryItem[];
122
- if (fromEvent < events.length) {
123
- let cnt = events.length - fromEvent;
124
- if (!isNullOrUndefined(numEvents)) {
125
- cnt = numEvents < cnt ? numEvents : cnt;
126
- }
127
-
128
- theEvents = events.splice(fromEvent, cnt);
129
-
130
- // reset the fetched msfpc value
131
- _msfpc = _getMsfpc(events);
132
- }
133
-
134
- return new EventBatch(iKey, theEvents);
135
- };
136
- }
137
- }