@microsoft/1ds-core-js 4.4.0-nightlybeta3.2602-27 → 4.4.1

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 (53) hide show
  1. package/README.md +56 -0
  2. package/bundle/es5/{ms.core-4.4.0-nightlybeta3.2602-27.gbl.js → ms.core-4.4.1.gbl.js} +498 -511
  3. package/bundle/es5/ms.core-4.4.1.gbl.js.map +1 -0
  4. package/bundle/es5/ms.core-4.4.1.gbl.min.js +7 -0
  5. package/bundle/es5/ms.core-4.4.1.gbl.min.js.map +1 -0
  6. package/bundle/es5/ms.core-4.4.1.integrity.json +46 -0
  7. package/bundle/es5/{ms.core-4.4.0-nightlybeta3.2602-27.js → ms.core-4.4.1.js} +498 -511
  8. package/bundle/es5/ms.core-4.4.1.js.map +1 -0
  9. package/bundle/es5/ms.core-4.4.1.min.js +7 -0
  10. package/bundle/es5/ms.core-4.4.1.min.js.map +1 -0
  11. package/bundle/es5/ms.core.gbl.js +497 -510
  12. package/bundle/es5/ms.core.gbl.js.map +1 -1
  13. package/bundle/es5/ms.core.gbl.min.js +2 -2
  14. package/bundle/es5/ms.core.gbl.min.js.map +1 -1
  15. package/bundle/es5/ms.core.integrity.json +17 -17
  16. package/bundle/es5/ms.core.js +497 -510
  17. package/bundle/es5/ms.core.js.map +1 -1
  18. package/bundle/es5/ms.core.min.js +2 -2
  19. package/bundle/es5/ms.core.min.js.map +1 -1
  20. package/dist/es5/ms.core.js +495 -508
  21. package/dist/es5/ms.core.js.map +1 -1
  22. package/dist/es5/ms.core.min.js +2 -2
  23. package/dist/es5/ms.core.min.js.map +1 -1
  24. package/dist-es5/Index.js +9 -22
  25. package/dist-es5/Index.js.map +1 -1
  26. package/package.json +69 -72
  27. package/types/1ds-core-js.d.ts +110 -691
  28. package/types/1ds-core-js.namespaced.d.ts +54 -5
  29. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.gbl.js.map +0 -1
  30. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.gbl.min.js +0 -7
  31. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.gbl.min.js.map +0 -1
  32. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.integrity.json +0 -46
  33. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.js.map +0 -1
  34. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.min.js +0 -7
  35. package/bundle/es5/ms.core-4.4.0-nightlybeta3.2602-27.min.js.map +0 -1
  36. package/dist-es5/AppInsightsCore.js +0 -96
  37. package/dist-es5/AppInsightsCore.js.map +0 -1
  38. package/dist-es5/BaseCore.js +0 -67
  39. package/dist-es5/BaseCore.js.map +0 -1
  40. package/dist-es5/DataModels.js +0 -7
  41. package/dist-es5/DataModels.js.map +0 -1
  42. package/dist-es5/Enums.js +0 -92
  43. package/dist-es5/Enums.js.map +0 -1
  44. package/dist-es5/InternalConstants.js +0 -19
  45. package/dist-es5/InternalConstants.js.map +0 -1
  46. package/dist-es5/Utils.js +0 -397
  47. package/dist-es5/Utils.js.map +0 -1
  48. package/dist-es5/ValueSanitizer.js +0 -262
  49. package/dist-es5/ValueSanitizer.js.map +0 -1
  50. package/dist-es5/__DynamicConstants.js +0 -28
  51. package/dist-es5/__DynamicConstants.js.map +0 -1
  52. package/dist-es5/extSpanUtils.js +0 -308
  53. package/dist-es5/extSpanUtils.js.map +0 -1
@@ -1,262 +0,0 @@
1
- /*
2
- * 1DS JS SDK Core, 4.4.0-nightlybeta3.2602-27
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- * (Microsoft Internal Only)
5
- */
6
- import { isNullOrUndefined, isString, objForEachKey } from "@microsoft/applicationinsights-core-js";
7
- import { arrForEach, arrIncludes, arrIndexOf, getLength } from "@nevware21/ts-utils";
8
- import { STR_EMPTY } from "./InternalConstants";
9
- import { getFieldValueType, isValueAssigned, isValueKind } from "./Utils";
10
- import { _DYN_CAN_HANDLE, _DYN_HANDLE_FIELD, _DYN_KIND, _DYN_LENGTH, _DYN_RM_FIELD_SANITIZER, _DYN_RM_SANITIZER, _DYN_VALUE } from "./__DynamicConstants";
11
- function _isSpecialName(name) {
12
- return (name == "__proto__" || name == "constructor" || name == "prototype");
13
- }
14
- var ValueSanitizer = /** @class */ (function () {
15
- function ValueSanitizer(fieldSanitizerProvider) {
16
- var _self = this;
17
- // To aid with performance this is a lookup map to check if the field value sanitizer supports this field
18
- var _sanitizerMap = {};
19
- var _sanitizers = [];
20
- var _fieldSanitizers = [];
21
- if (fieldSanitizerProvider) {
22
- _fieldSanitizers.push(fieldSanitizerProvider);
23
- }
24
- function _getFieldSanitizer(path, name) {
25
- var result;
26
- var fieldLookup = _sanitizerMap[path];
27
- if (fieldLookup) {
28
- result = fieldLookup[name];
29
- }
30
- if (!result && result !== null) {
31
- // Null is a valid result indicating that the value sanitizer does not support this field
32
- if (isString(path) && isString(name)) {
33
- if (_fieldSanitizers[_DYN_LENGTH /* @min:%2elength */] > 0) {
34
- for (var lp = 0; lp < _fieldSanitizers[_DYN_LENGTH /* @min:%2elength */]; lp++) {
35
- if (_fieldSanitizers[lp][_DYN_HANDLE_FIELD /* @min:%2ehandleField */](path, name)) {
36
- result = {
37
- canHandle: true,
38
- fieldHandler: _fieldSanitizers[lp]
39
- };
40
- break;
41
- }
42
- }
43
- }
44
- else if (_sanitizers[_DYN_LENGTH /* @min:%2elength */] === 0) {
45
- // Special use-case where there is no sanitizer to pass on to, so just resolving the field
46
- // and returning the resulting value (same as sanitizeProperty())
47
- result = {
48
- canHandle: true
49
- };
50
- }
51
- }
52
- // We still don't have a handler so lets lookup the providers
53
- if (!result && result !== null) {
54
- // Setting the result to null -- which means we and any contained sanitizers can't handle this field
55
- result = null;
56
- for (var lp = 0; lp < _sanitizers[_DYN_LENGTH /* @min:%2elength */]; lp++) {
57
- if (_sanitizers[lp][_DYN_HANDLE_FIELD /* @min:%2ehandleField */](path, name)) {
58
- result = {
59
- canHandle: true,
60
- handler: _sanitizers[lp],
61
- fieldHandler: null
62
- };
63
- break;
64
- }
65
- }
66
- }
67
- if (!fieldLookup) {
68
- // Handle edge case to avoid prototype pollution
69
- if (_isSpecialName(path)) {
70
- return null;
71
- }
72
- fieldLookup = _sanitizerMap[path] = {};
73
- }
74
- // Handle edge case to avoid prototype pollution
75
- if (_isSpecialName(name)) {
76
- return null;
77
- }
78
- fieldLookup[name] = result;
79
- }
80
- return result;
81
- }
82
- _self.clearCache = function () {
83
- _sanitizerMap = {};
84
- };
85
- _self.addSanitizer = function (newSanitizer) {
86
- if (newSanitizer) {
87
- if (!arrIncludes(_sanitizers, newSanitizer)) {
88
- _sanitizers.push(newSanitizer);
89
- }
90
- // Invalidate any previously mapped fields
91
- _sanitizerMap = {};
92
- }
93
- };
94
- _self.addFieldSanitizer = function (fieldSanitizer) {
95
- if (fieldSanitizer) {
96
- if (!arrIncludes(_fieldSanitizers, fieldSanitizer)) {
97
- _fieldSanitizers.push(fieldSanitizer);
98
- }
99
- // Invalidate any previously mapped fields
100
- _sanitizerMap = {};
101
- }
102
- };
103
- _self[_DYN_RM_SANITIZER /* @min:%2ermSanitizer */] = function (theSanitizer) {
104
- if (theSanitizer) {
105
- var idx = arrIndexOf(_sanitizers, theSanitizer);
106
- if (idx !== -1) {
107
- _sanitizers.splice(idx, 1);
108
- // Invalidate any previously mapped fields
109
- _sanitizerMap = {};
110
- }
111
- // Try and remove the sanitizer from any chained sanitizer as well
112
- arrForEach(_sanitizers, function (sanitizer) {
113
- sanitizer && sanitizer[_DYN_RM_SANITIZER /* @min:%2ermSanitizer */] && sanitizer[_DYN_RM_SANITIZER /* @min:%2ermSanitizer */](theSanitizer);
114
- });
115
- }
116
- };
117
- _self[_DYN_RM_FIELD_SANITIZER /* @min:%2ermFieldSanitizer */] = function (theFieldSanitizer) {
118
- if (theFieldSanitizer) {
119
- var idx = arrIndexOf(_fieldSanitizers, theFieldSanitizer);
120
- if (idx !== -1) {
121
- _fieldSanitizers.splice(idx, 1);
122
- // Invalidate any previously mapped fields
123
- _sanitizerMap = {};
124
- }
125
- // Try and remove the field sanitizer from any chained sanitizer as well
126
- arrForEach(_sanitizers, function (sanitizer) {
127
- sanitizer && sanitizer[_DYN_RM_FIELD_SANITIZER /* @min:%2ermFieldSanitizer */] && sanitizer[_DYN_RM_FIELD_SANITIZER /* @min:%2ermFieldSanitizer */](theFieldSanitizer);
128
- });
129
- }
130
- };
131
- _self.isEmpty = function () {
132
- return (getLength(_sanitizers) + getLength(_fieldSanitizers)) === 0;
133
- };
134
- _self[_DYN_HANDLE_FIELD /* @min:%2ehandleField */] = function (path, name) {
135
- var mapValue = _getFieldSanitizer(path, name);
136
- return mapValue ? mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */] : false;
137
- };
138
- _self[_DYN_VALUE /* @min:%2evalue */] = function (path, name, value, stringifyObjects) {
139
- var mapValue = _getFieldSanitizer(path, name);
140
- if (mapValue && mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */]) {
141
- if (!mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */]) {
142
- return null;
143
- }
144
- if (mapValue.handler) {
145
- // This value sanitizer can't handle this field so pass it only the next one
146
- return mapValue.handler[_DYN_VALUE /* @min:%2evalue */](path, name, value, stringifyObjects);
147
- }
148
- // Check that property is valid
149
- if (!isString(name) || isNullOrUndefined(value) || value === STR_EMPTY) {
150
- return null;
151
- }
152
- var property = null;
153
- var fieldType = getFieldValueType(value);
154
- if ((fieldType & 8192 /* FieldValueSanitizerType.EventProperty */) === 8192 /* FieldValueSanitizerType.EventProperty */) {
155
- var subType = fieldType & ~8192 /* FieldValueSanitizerType.EventProperty */;
156
- property = value;
157
- if (!isValueAssigned(property[_DYN_VALUE /* @min:%2evalue */]) ||
158
- (subType !== 1 /* FieldValueSanitizerType.String */ &&
159
- subType !== 2 /* FieldValueSanitizerType.Number */ &&
160
- subType !== 3 /* FieldValueSanitizerType.Boolean */ &&
161
- (subType & 4096 /* FieldValueSanitizerType.Array */) !== 4096 /* FieldValueSanitizerType.Array */)) {
162
- // Not a supported IEventProperty type to be able to sanitize
163
- return null;
164
- }
165
- }
166
- else if (fieldType === 1 /* FieldValueSanitizerType.String */ ||
167
- fieldType === 2 /* FieldValueSanitizerType.Number */ ||
168
- fieldType === 3 /* FieldValueSanitizerType.Boolean */ ||
169
- (fieldType & 4096 /* FieldValueSanitizerType.Array */) === 4096 /* FieldValueSanitizerType.Array */) {
170
- // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.
171
- property = _convertToProperty(path, name, value);
172
- }
173
- else if (fieldType === 4 /* FieldValueSanitizerType.Object */) {
174
- property = _convertToProperty(path, name, !!stringifyObjects ? JSON.stringify(value) : value);
175
- }
176
- if (property) {
177
- return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);
178
- }
179
- }
180
- return null;
181
- };
182
- _self.property = function (path, name, property, stringifyObjects) {
183
- var mapValue = _getFieldSanitizer(path, name);
184
- if (!mapValue || !mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */]) {
185
- return null;
186
- }
187
- // Check that property is valid
188
- if (!isString(name) || isNullOrUndefined(property) || !isValueAssigned(property[_DYN_VALUE /* @min:%2evalue */])) {
189
- return null;
190
- }
191
- var fieldType = getFieldValueType(property[_DYN_VALUE /* @min:%2evalue */]);
192
- if (fieldType === 0 /* FieldValueSanitizerType.NotSet */) {
193
- // Not a supported field that we can sanitize or serialize
194
- return null;
195
- }
196
- return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);
197
- };
198
- function _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects) {
199
- if (mapValue.handler) {
200
- // This value sanitizer can't handle this field so pass it only the next one
201
- return mapValue.handler.property(path, name, property, stringifyObjects);
202
- }
203
- // If either pii or cc is set convert value to string (since only string pii/cc is allowed).
204
- // If the value is a complex type like an array that can't be converted to string we will drop
205
- // the property.
206
- if (!isNullOrUndefined(property[_DYN_KIND /* @min:%2ekind */])) {
207
- if ((fieldType & 4096 /* FieldValueSanitizerType.Array */) === 4096 /* FieldValueSanitizerType.Array */ || !isValueKind(property[_DYN_KIND /* @min:%2ekind */])) {
208
- return null;
209
- }
210
- // Convert the value to a string and assign back to the original value
211
- property[_DYN_VALUE /* @min:%2evalue */] = property[_DYN_VALUE /* @min:%2evalue */].toString();
212
- }
213
- return _callFieldSanitizer(mapValue.fieldHandler, path, name, fieldType, property);
214
- }
215
- function _convertToProperty(path, name, value) {
216
- if (isValueAssigned(value)) {
217
- return { value: value };
218
- }
219
- return null;
220
- }
221
- function _callFieldSanitizer(fieldProvider, path, name, theType, property) {
222
- if (property && fieldProvider) {
223
- var sanitizer = fieldProvider.getSanitizer(path, name, theType, property[_DYN_KIND /* @min:%2ekind */], property.propertyType);
224
- if (sanitizer) {
225
- // This is where we the field will call the handler to "scrub" the value. This the primary hook for the ClientHashing Plugin to
226
- // be able to apply the hashFunc() / Sha256 conversion of the properties value
227
- if (theType === 4 /* FieldValueSanitizerType.Object */) {
228
- // Special case of an embedded object (ext.metadata, data.properties)
229
- var newValue_1 = {};
230
- var propValue = property[_DYN_VALUE /* @min:%2evalue */];
231
- objForEachKey(propValue, function (propKey, theValue) {
232
- var newPath = path + "." + name;
233
- if (isValueAssigned(theValue)) {
234
- var newProp = _convertToProperty(newPath, propKey, theValue);
235
- newProp = _callFieldSanitizer(fieldProvider, newPath, propKey, getFieldValueType(theValue), newProp);
236
- if (newProp) {
237
- newValue_1[propKey] = newProp[_DYN_VALUE /* @min:%2evalue */];
238
- }
239
- }
240
- });
241
- property[_DYN_VALUE /* @min:%2evalue */] = newValue_1;
242
- }
243
- else {
244
- var details = {
245
- path: path,
246
- name: name,
247
- type: theType,
248
- prop: property,
249
- sanitizer: _self
250
- };
251
- property = sanitizer.call(_self, details);
252
- }
253
- }
254
- }
255
- return property;
256
- }
257
- }
258
- ValueSanitizer.getFieldType = getFieldValueType;
259
- return ValueSanitizer;
260
- }());
261
- export { ValueSanitizer };
262
- //# sourceMappingURL=ValueSanitizer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ValueSanitizer.js.map","sources":["ValueSanitizer.js"],"sourcesContent":["import { isNullOrUndefined, isString, objForEachKey } from \"@microsoft/applicationinsights-core-js\";\r\nimport { arrForEach, arrIncludes, arrIndexOf, getLength } from \"@nevware21/ts-utils\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\nimport { getFieldValueType, isValueAssigned, isValueKind } from \"./Utils\";\r\nimport { _DYN_CAN_HANDLE, _DYN_HANDLE_FIELD, _DYN_KIND, _DYN_LENGTH, _DYN_RM_FIELD_SANITIZER, _DYN_RM_SANITIZER, _DYN_VALUE } from \"./__DynamicConstants\";\r\nfunction _isSpecialName(name) {\r\n return (name == \"__proto__\" || name == \"constructor\" || name == \"prototype\");\r\n}\r\nvar ValueSanitizer = /** @class */ (function () {\r\n function ValueSanitizer(fieldSanitizerProvider) {\r\n var _self = this;\r\n // To aid with performance this is a lookup map to check if the field value sanitizer supports this field\r\n var _sanitizerMap = {};\r\n var _sanitizers = [];\r\n var _fieldSanitizers = [];\r\n if (fieldSanitizerProvider) {\r\n _fieldSanitizers.push(fieldSanitizerProvider);\r\n }\r\n function _getFieldSanitizer(path, name) {\r\n var result;\r\n var fieldLookup = _sanitizerMap[path];\r\n if (fieldLookup) {\r\n result = fieldLookup[name];\r\n }\r\n if (!result && result !== null) {\r\n // Null is a valid result indicating that the value sanitizer does not support this field\r\n if (isString(path) && isString(name)) {\r\n if (_fieldSanitizers[_DYN_LENGTH /* @min:%2elength */] > 0) {\r\n for (var lp = 0; lp < _fieldSanitizers[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n if (_fieldSanitizers[lp][_DYN_HANDLE_FIELD /* @min:%2ehandleField */](path, name)) {\r\n result = {\r\n canHandle: true,\r\n fieldHandler: _fieldSanitizers[lp]\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n else if (_sanitizers[_DYN_LENGTH /* @min:%2elength */] === 0) {\r\n // Special use-case where there is no sanitizer to pass on to, so just resolving the field\r\n // and returning the resulting value (same as sanitizeProperty())\r\n result = {\r\n canHandle: true\r\n };\r\n }\r\n }\r\n // We still don't have a handler so lets lookup the providers\r\n if (!result && result !== null) {\r\n // Setting the result to null -- which means we and any contained sanitizers can't handle this field\r\n result = null;\r\n for (var lp = 0; lp < _sanitizers[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n if (_sanitizers[lp][_DYN_HANDLE_FIELD /* @min:%2ehandleField */](path, name)) {\r\n result = {\r\n canHandle: true,\r\n handler: _sanitizers[lp],\r\n fieldHandler: null\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n if (!fieldLookup) {\r\n // Handle edge case to avoid prototype pollution\r\n if (_isSpecialName(path)) {\r\n return null;\r\n }\r\n fieldLookup = _sanitizerMap[path] = {};\r\n }\r\n // Handle edge case to avoid prototype pollution\r\n if (_isSpecialName(name)) {\r\n return null;\r\n }\r\n fieldLookup[name] = result;\r\n }\r\n return result;\r\n }\r\n _self.clearCache = function () {\r\n _sanitizerMap = {};\r\n };\r\n _self.addSanitizer = function (newSanitizer) {\r\n if (newSanitizer) {\r\n if (!arrIncludes(_sanitizers, newSanitizer)) {\r\n _sanitizers.push(newSanitizer);\r\n }\r\n // Invalidate any previously mapped fields\r\n _sanitizerMap = {};\r\n }\r\n };\r\n _self.addFieldSanitizer = function (fieldSanitizer) {\r\n if (fieldSanitizer) {\r\n if (!arrIncludes(_fieldSanitizers, fieldSanitizer)) {\r\n _fieldSanitizers.push(fieldSanitizer);\r\n }\r\n // Invalidate any previously mapped fields\r\n _sanitizerMap = {};\r\n }\r\n };\r\n _self[_DYN_RM_SANITIZER /* @min:%2ermSanitizer */] = function (theSanitizer) {\r\n if (theSanitizer) {\r\n var idx = arrIndexOf(_sanitizers, theSanitizer);\r\n if (idx !== -1) {\r\n _sanitizers.splice(idx, 1);\r\n // Invalidate any previously mapped fields\r\n _sanitizerMap = {};\r\n }\r\n // Try and remove the sanitizer from any chained sanitizer as well\r\n arrForEach(_sanitizers, function (sanitizer) {\r\n sanitizer && sanitizer[_DYN_RM_SANITIZER /* @min:%2ermSanitizer */] && sanitizer[_DYN_RM_SANITIZER /* @min:%2ermSanitizer */](theSanitizer);\r\n });\r\n }\r\n };\r\n _self[_DYN_RM_FIELD_SANITIZER /* @min:%2ermFieldSanitizer */] = function (theFieldSanitizer) {\r\n if (theFieldSanitizer) {\r\n var idx = arrIndexOf(_fieldSanitizers, theFieldSanitizer);\r\n if (idx !== -1) {\r\n _fieldSanitizers.splice(idx, 1);\r\n // Invalidate any previously mapped fields\r\n _sanitizerMap = {};\r\n }\r\n // Try and remove the field sanitizer from any chained sanitizer as well\r\n arrForEach(_sanitizers, function (sanitizer) {\r\n sanitizer && sanitizer[_DYN_RM_FIELD_SANITIZER /* @min:%2ermFieldSanitizer */] && sanitizer[_DYN_RM_FIELD_SANITIZER /* @min:%2ermFieldSanitizer */](theFieldSanitizer);\r\n });\r\n }\r\n };\r\n _self.isEmpty = function () {\r\n return (getLength(_sanitizers) + getLength(_fieldSanitizers)) === 0;\r\n };\r\n _self[_DYN_HANDLE_FIELD /* @min:%2ehandleField */] = function (path, name) {\r\n var mapValue = _getFieldSanitizer(path, name);\r\n return mapValue ? mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */] : false;\r\n };\r\n _self[_DYN_VALUE /* @min:%2evalue */] = function (path, name, value, stringifyObjects) {\r\n var mapValue = _getFieldSanitizer(path, name);\r\n if (mapValue && mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */]) {\r\n if (!mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */]) {\r\n return null;\r\n }\r\n if (mapValue.handler) {\r\n // This value sanitizer can't handle this field so pass it only the next one\r\n return mapValue.handler[_DYN_VALUE /* @min:%2evalue */](path, name, value, stringifyObjects);\r\n }\r\n // Check that property is valid\r\n if (!isString(name) || isNullOrUndefined(value) || value === STR_EMPTY) {\r\n return null;\r\n }\r\n var property = null;\r\n var fieldType = getFieldValueType(value);\r\n if ((fieldType & 8192 /* FieldValueSanitizerType.EventProperty */) === 8192 /* FieldValueSanitizerType.EventProperty */) {\r\n var subType = fieldType & ~8192 /* FieldValueSanitizerType.EventProperty */;\r\n property = value;\r\n if (!isValueAssigned(property[_DYN_VALUE /* @min:%2evalue */]) ||\r\n (subType !== 1 /* FieldValueSanitizerType.String */ &&\r\n subType !== 2 /* FieldValueSanitizerType.Number */ &&\r\n subType !== 3 /* FieldValueSanitizerType.Boolean */ &&\r\n (subType & 4096 /* FieldValueSanitizerType.Array */) !== 4096 /* FieldValueSanitizerType.Array */)) {\r\n // Not a supported IEventProperty type to be able to sanitize\r\n return null;\r\n }\r\n }\r\n else if (fieldType === 1 /* FieldValueSanitizerType.String */ ||\r\n fieldType === 2 /* FieldValueSanitizerType.Number */ ||\r\n fieldType === 3 /* FieldValueSanitizerType.Boolean */ ||\r\n (fieldType & 4096 /* FieldValueSanitizerType.Array */) === 4096 /* FieldValueSanitizerType.Array */) {\r\n // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.\r\n property = _convertToProperty(path, name, value);\r\n }\r\n else if (fieldType === 4 /* FieldValueSanitizerType.Object */) {\r\n property = _convertToProperty(path, name, !!stringifyObjects ? JSON.stringify(value) : value);\r\n }\r\n if (property) {\r\n return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);\r\n }\r\n }\r\n return null;\r\n };\r\n _self.property = function (path, name, property, stringifyObjects) {\r\n var mapValue = _getFieldSanitizer(path, name);\r\n if (!mapValue || !mapValue[_DYN_CAN_HANDLE /* @min:%2ecanHandle */]) {\r\n return null;\r\n }\r\n // Check that property is valid\r\n if (!isString(name) || isNullOrUndefined(property) || !isValueAssigned(property[_DYN_VALUE /* @min:%2evalue */])) {\r\n return null;\r\n }\r\n var fieldType = getFieldValueType(property[_DYN_VALUE /* @min:%2evalue */]);\r\n if (fieldType === 0 /* FieldValueSanitizerType.NotSet */) {\r\n // Not a supported field that we can sanitize or serialize\r\n return null;\r\n }\r\n return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);\r\n };\r\n function _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects) {\r\n if (mapValue.handler) {\r\n // This value sanitizer can't handle this field so pass it only the next one\r\n return mapValue.handler.property(path, name, property, stringifyObjects);\r\n }\r\n // If either pii or cc is set convert value to string (since only string pii/cc is allowed).\r\n // If the value is a complex type like an array that can't be converted to string we will drop\r\n // the property.\r\n if (!isNullOrUndefined(property[_DYN_KIND /* @min:%2ekind */])) {\r\n if ((fieldType & 4096 /* FieldValueSanitizerType.Array */) === 4096 /* FieldValueSanitizerType.Array */ || !isValueKind(property[_DYN_KIND /* @min:%2ekind */])) {\r\n return null;\r\n }\r\n // Convert the value to a string and assign back to the original value\r\n property[_DYN_VALUE /* @min:%2evalue */] = property[_DYN_VALUE /* @min:%2evalue */].toString();\r\n }\r\n return _callFieldSanitizer(mapValue.fieldHandler, path, name, fieldType, property);\r\n }\r\n function _convertToProperty(path, name, value) {\r\n if (isValueAssigned(value)) {\r\n return { value: value };\r\n }\r\n return null;\r\n }\r\n function _callFieldSanitizer(fieldProvider, path, name, theType, property) {\r\n if (property && fieldProvider) {\r\n var sanitizer = fieldProvider.getSanitizer(path, name, theType, property[_DYN_KIND /* @min:%2ekind */], property.propertyType);\r\n if (sanitizer) {\r\n // This is where we the field will call the handler to \"scrub\" the value. This the primary hook for the ClientHashing Plugin to\r\n // be able to apply the hashFunc() / Sha256 conversion of the properties value\r\n if (theType === 4 /* FieldValueSanitizerType.Object */) {\r\n // Special case of an embedded object (ext.metadata, data.properties)\r\n var newValue_1 = {};\r\n var propValue = property[_DYN_VALUE /* @min:%2evalue */];\r\n objForEachKey(propValue, function (propKey, theValue) {\r\n var newPath = path + \".\" + name;\r\n if (isValueAssigned(theValue)) {\r\n var newProp = _convertToProperty(newPath, propKey, theValue);\r\n newProp = _callFieldSanitizer(fieldProvider, newPath, propKey, getFieldValueType(theValue), newProp);\r\n if (newProp) {\r\n newValue_1[propKey] = newProp[_DYN_VALUE /* @min:%2evalue */];\r\n }\r\n }\r\n });\r\n property[_DYN_VALUE /* @min:%2evalue */] = newValue_1;\r\n }\r\n else {\r\n var details = {\r\n path: path,\r\n name: name,\r\n type: theType,\r\n prop: property,\r\n sanitizer: _self\r\n };\r\n property = sanitizer.call(_self, details);\r\n }\r\n }\r\n }\r\n return property;\r\n }\r\n }\r\n ValueSanitizer.getFieldType = getFieldValueType;\r\n return ValueSanitizer;\r\n}());\r\nexport { ValueSanitizer };\r\n//# sourceMappingURL=ValueSanitizer.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;AACA;AACA"}
@@ -1,28 +0,0 @@
1
- /*
2
- * 1DS JS SDK Core, 4.4.0-nightlybeta3.2602-27
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- * (Microsoft Internal Only)
5
- */
6
-
7
- // Licensed under the MIT License.
8
- // @skip-file-minify
9
- // ##############################################################
10
- // AUTO GENERATED FILE: This file is Auto Generated during build.
11
- // ##############################################################
12
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13
- // Note: DON'T Export these const from the package as we are still targeting ES5 which can result in a mutable variables that someone could change!!!
14
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15
- export var _DYN_INITIALIZE = "initialize"; // Count: 4
16
- export var _DYN_INDEX_OF = "indexOf"; // Count: 4
17
- export var _DYN_TIMINGS = "timings"; // Count: 4
18
- export var _DYN_BASE_DATA = "baseData"; // Count: 4
19
- export var _DYN_POLL_INTERNAL_LOGS = "pollInternalLogs"; // Count: 4
20
- export var _DYN_KIND = "kind"; // Count: 6
21
- export var _DYN_VALUE = "value"; // Count: 20
22
- export var _DYN_LENGTH = "length"; // Count: 7
23
- export var _DYN_PROCESS_TELEMETRY_ST0 = "processTelemetryStart"; // Count: 3
24
- export var _DYN_HANDLE_FIELD = "handleField"; // Count: 3
25
- export var _DYN_RM_SANITIZER = "rmSanitizer"; // Count: 3
26
- export var _DYN_RM_FIELD_SANITIZER = "rmFieldSanitizer"; // Count: 3
27
- export var _DYN_CAN_HANDLE = "canHandle"; // Count: 4
28
- //# sourceMappingURL=__DynamicConstants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n// Note: DON'T Export these const from the package as we are still targeting ES5 which can result in a mutable variables that someone could change!!!\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\nexport var _DYN_INITIALIZE = \"initialize\"; // Count: 4\r\nexport var _DYN_INDEX_OF = \"indexOf\"; // Count: 4\r\nexport var _DYN_TIMINGS = \"timings\"; // Count: 4\r\nexport var _DYN_BASE_DATA = \"baseData\"; // Count: 4\r\nexport var _DYN_POLL_INTERNAL_LOGS = \"pollInternalLogs\"; // Count: 4\r\nexport var _DYN_KIND = \"kind\"; // Count: 6\r\nexport var _DYN_VALUE = \"value\"; // Count: 20\r\nexport var _DYN_LENGTH = \"length\"; // Count: 7\r\nexport var _DYN_PROCESS_TELEMETRY_ST0 = \"processTelemetryStart\"; // Count: 3\r\nexport var _DYN_HANDLE_FIELD = \"handleField\"; // Count: 3\r\nexport var _DYN_RM_SANITIZER = \"rmSanitizer\"; // Count: 3\r\nexport var _DYN_RM_FIELD_SANITIZER = \"rmFieldSanitizer\"; // Count: 3\r\nexport var _DYN_CAN_HANDLE = \"canHandle\"; // Count: 4\r\n//# sourceMappingURL=__DynamicConstants.js.map"],"names":[],"mappings":";;;;;AAA4D;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,308 +0,0 @@
1
- /*
2
- * 1DS JS SDK Core, 4.4.0-nightlybeta3.2602-27
3
- * Copyright (c) Microsoft and contributors. All rights reserved.
4
- * (Microsoft Internal Only)
5
- */
6
- // Copyright (c) Microsoft Corporation.
7
- // Licensed under the MIT License.
8
- import { ATTR_CLIENT_ADDRESS, ATTR_CLIENT_PORT, ATTR_ENDUSER_ID, ATTR_ENDUSER_PSEUDO_ID, ATTR_ERROR_TYPE, ATTR_EXCEPTION_MESSAGE, ATTR_EXCEPTION_STACKTRACE, ATTR_EXCEPTION_TYPE, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_NETWORK_LOCAL_ADDRESS, ATTR_NETWORK_LOCAL_PORT, ATTR_NETWORK_PEER_ADDRESS, ATTR_NETWORK_PEER_PORT, ATTR_NETWORK_PROTOCOL_NAME, ATTR_NETWORK_PROTOCOL_VERSION, ATTR_NETWORK_TRANSPORT, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, ATTR_URL_PATH, ATTR_URL_QUERY, ATTR_URL_SCHEME, ATTR_USER_AGENT_ORIGINAL, EXP_ATTR_ENDUSER_ID, EXP_ATTR_ENDUSER_PSEUDO_ID, EXP_ATTR_SYNTHETIC_TYPE, SEMATTRS_DB_NAME, SEMATTRS_DB_OPERATION, SEMATTRS_DB_STATEMENT, SEMATTRS_DB_SYSTEM, SEMATTRS_ENDUSER_ID, SEMATTRS_EXCEPTION_MESSAGE, SEMATTRS_EXCEPTION_STACKTRACE, SEMATTRS_EXCEPTION_TYPE, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_FLAVOR, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_TARGET, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_IP, SEMATTRS_NET_HOST_NAME, SEMATTRS_NET_HOST_PORT, SEMATTRS_NET_PEER_IP, SEMATTRS_NET_PEER_NAME, SEMATTRS_NET_PEER_PORT, SEMATTRS_NET_TRANSPORT, SEMATTRS_PEER_SERVICE, SEMATTRS_RPC_GRPC_STATUS_CODE, SEMATTRS_RPC_SYSTEM, createAttributeContainer, fieldRedaction, getHttpClientIp, getHttpHost, getHttpMethod, getHttpScheme, getHttpStatusCode, getHttpUrl, getSyntheticType, getUserAgent, hrTimeToMilliseconds, toISOString } from "@microsoft/applicationinsights-core-js";
9
- import { arrIncludes, asString, getLazy, getNavigator, isBoolean, isNullOrUndefined, isNumber, isString, strLower, strStartsWith, throwError } from "@nevware21/ts-utils";
10
- import { STR_NOT_SPECIFIED } from "./InternalConstants";
11
- import { _DYN_BASE_DATA, _DYN_KIND } from "./__DynamicConstants";
12
- /**
13
- * Azure SDK namespace.
14
- * @internal
15
- */
16
- var AzNamespace = "az.namespace";
17
- var AzResourceNamespace = "azure.resource_provider.namespace";
18
- var PORT_REGEX = ( /*#__PURE__*/getLazy(function () { return new RegExp(/(https?)(:\/\/.*)(:\d+)(\S*)/); }));
19
- var HTTP_DOT = "http.";
20
- var _MS_PROCESSED_BY_METRICS_EXTRACTORS = "_MS.ProcessedByMetricExtractors";
21
- /**
22
- * Legacy HTTP semantic convention values
23
- * @internal
24
- */
25
- var _ignoreSemanticValues = ( /* #__PURE__*/getLazy(_initIgnoreSemanticValues));
26
- /* #__NO_SIDE_EFFECTS__ */
27
- function _initIgnoreSemanticValues() {
28
- return [
29
- // Internal Microsoft attributes
30
- _MS_PROCESSED_BY_METRICS_EXTRACTORS,
31
- // Legacy HTTP semantic values
32
- SEMATTRS_NET_PEER_IP,
33
- SEMATTRS_NET_PEER_NAME,
34
- SEMATTRS_NET_HOST_IP,
35
- SEMATTRS_PEER_SERVICE,
36
- SEMATTRS_HTTP_USER_AGENT,
37
- SEMATTRS_HTTP_METHOD,
38
- SEMATTRS_HTTP_URL,
39
- SEMATTRS_HTTP_STATUS_CODE,
40
- SEMATTRS_HTTP_ROUTE,
41
- SEMATTRS_HTTP_HOST,
42
- SEMATTRS_DB_SYSTEM,
43
- SEMATTRS_DB_STATEMENT,
44
- SEMATTRS_DB_OPERATION,
45
- SEMATTRS_DB_NAME,
46
- SEMATTRS_RPC_SYSTEM,
47
- SEMATTRS_RPC_GRPC_STATUS_CODE,
48
- SEMATTRS_EXCEPTION_TYPE,
49
- SEMATTRS_EXCEPTION_MESSAGE,
50
- SEMATTRS_EXCEPTION_STACKTRACE,
51
- SEMATTRS_HTTP_SCHEME,
52
- SEMATTRS_HTTP_TARGET,
53
- SEMATTRS_HTTP_FLAVOR,
54
- SEMATTRS_NET_TRANSPORT,
55
- SEMATTRS_NET_HOST_NAME,
56
- SEMATTRS_NET_HOST_PORT,
57
- SEMATTRS_NET_PEER_PORT,
58
- SEMATTRS_HTTP_CLIENT_IP,
59
- SEMATTRS_ENDUSER_ID,
60
- HTTP_DOT + "status_text",
61
- // http Semabtic conventions
62
- ATTR_CLIENT_ADDRESS,
63
- ATTR_CLIENT_PORT,
64
- ATTR_SERVER_ADDRESS,
65
- ATTR_SERVER_PORT,
66
- ATTR_URL_FULL,
67
- ATTR_URL_PATH,
68
- ATTR_URL_QUERY,
69
- ATTR_URL_SCHEME,
70
- ATTR_ERROR_TYPE,
71
- ATTR_NETWORK_LOCAL_ADDRESS,
72
- ATTR_NETWORK_LOCAL_PORT,
73
- ATTR_NETWORK_PROTOCOL_NAME,
74
- ATTR_NETWORK_PEER_ADDRESS,
75
- ATTR_NETWORK_PEER_PORT,
76
- ATTR_NETWORK_PROTOCOL_VERSION,
77
- ATTR_NETWORK_TRANSPORT,
78
- ATTR_USER_AGENT_ORIGINAL,
79
- ATTR_HTTP_REQUEST_METHOD,
80
- ATTR_HTTP_RESPONSE_STATUS_CODE,
81
- ATTR_EXCEPTION_TYPE,
82
- ATTR_EXCEPTION_MESSAGE,
83
- ATTR_EXCEPTION_STACKTRACE,
84
- EXP_ATTR_ENDUSER_ID,
85
- EXP_ATTR_ENDUSER_PSEUDO_ID,
86
- EXP_ATTR_SYNTHETIC_TYPE,
87
- // Azure SDK attributes are not included as they are not part of the span attributes
88
- AzNamespace,
89
- AzResourceNamespace,
90
- "az.client_request_id",
91
- "azure.client.id",
92
- "az.service_request_id",
93
- "azure.service.request.id"
94
- ];
95
- }
96
- function _applyExtValue(ext, extName, name, value, overwriteExt) {
97
- if (isString(value) || isNumber(value) || isBoolean(value)) {
98
- var target = ext[extName] = ext[extName] || {};
99
- _applyValue(target, name, value, overwriteExt);
100
- }
101
- }
102
- function _applyValue(target, name, value, overwriteTarget) {
103
- if (target) {
104
- if (isString(value) || isNumber(value) || isBoolean(value)) {
105
- var targetValue = target[name];
106
- if (!overwriteTarget && (targetValue || isString(targetValue) || isNumber(targetValue) || isBoolean(targetValue))) {
107
- value = targetValue;
108
- }
109
- target[name] = value;
110
- }
111
- }
112
- return target;
113
- }
114
- function _populateExtensionsFromSpan(telemetryItem, span, container) {
115
- var ext = telemetryItem.ext = telemetryItem.ext || {};
116
- // Map OpenTelemetry enduser attributes to Application Insights user attributes
117
- var endUserId = container.get(ATTR_ENDUSER_ID);
118
- if (endUserId) {
119
- _applyExtValue(ext, "user", "authId", asString(endUserId), false);
120
- }
121
- var endUserPseudoId = container.get(ATTR_ENDUSER_PSEUDO_ID);
122
- if (endUserPseudoId) {
123
- _applyExtValue(ext, "user", "id", asString(endUserPseudoId), false);
124
- }
125
- }
126
- /**
127
- * Check to see if the key is in the list of known properties to ignore (exclude)
128
- * from part C properties population.
129
- * @param key - the property key to check
130
- * @param contextKeys - The current context keys
131
- * @returns true if the key should be ignored, false otherwise
132
- */
133
- function _isIgnorePartCKey(key) {
134
- var result = false;
135
- if (arrIncludes(_ignoreSemanticValues.v, key)) {
136
- // The key is in set of known keys to ignore
137
- result = true;
138
- }
139
- else if (strStartsWith(key, "microsoft.")) {
140
- // Ignoring all ALL keys starting with "microsoft."
141
- result = true;
142
- }
143
- return result;
144
- }
145
- function _populatePartC(item, container) {
146
- if (container) {
147
- var partC_1 = item.data = (item.data || {});
148
- _applyValue(partC_1, "httpHost", getHttpHost(container), false);
149
- _applyValue(partC_1, "httpScheme", getHttpScheme(container), false);
150
- _applyValue(partC_1, "httpClientIp", getHttpClientIp(container), false);
151
- _applyValue(partC_1, "httpUserAgent", getUserAgent(container), false);
152
- _applyValue(partC_1, "httpRoute", container.get(SEMATTRS_HTTP_ROUTE), false);
153
- _applyValue(partC_1, "netPeerName", container.get(SEMATTRS_NET_PEER_NAME), false);
154
- _applyValue(partC_1, "netPeerPort", container.get(SEMATTRS_NET_PEER_PORT), false);
155
- _applyValue(partC_1, "netPeerIp", container.get(SEMATTRS_NET_PEER_IP), false);
156
- _applyValue(partC_1, "peerService", container.get("service.name") || container.get(SEMATTRS_PEER_SERVICE), false);
157
- var syntheticSource = getSyntheticType(container);
158
- if (!!syntheticSource) {
159
- _applyValue(partC_1, "userAgentSyntheticType", syntheticSource, false);
160
- }
161
- var nav = getNavigator();
162
- if (nav && nav.userAgent) {
163
- _applyValue(partC_1, "userAgentOriginal", nav.userAgent, false);
164
- }
165
- // Azure SDK fields
166
- _applyValue(partC_1, "azureClientRequestId", container.get("azure.client.id") || container.get("az.client_request_id"), false);
167
- _applyValue(partC_1, "azureServiceRequestId", container.get("azure.service.request.id") || container.get("az.service_request_id"), false);
168
- var sampleRate = container.get("microsoft.sample_rate");
169
- if (!isNullOrUndefined(sampleRate)) {
170
- _applyValue(partC_1, "sampleRate", sampleRate, false);
171
- }
172
- container.forEach(function (key, value) {
173
- // Avoid duplication ignoring fields already mapped.
174
- if (!_isIgnorePartCKey(key)) {
175
- partC_1[key] = value;
176
- }
177
- });
178
- }
179
- }
180
- function _populateHttpProperties(otelSpanTelemetry, container, httpMethod, config) {
181
- if (httpMethod) {
182
- // Step the HTTP method
183
- _applyValue(otelSpanTelemetry, "httpMethod", httpMethod, false);
184
- // HTTP Dependency
185
- var httpUrl = getHttpUrl(container);
186
- if (httpUrl) {
187
- try {
188
- // Remove default port
189
- var res = PORT_REGEX.v.exec(asString(httpUrl));
190
- if (res !== null) {
191
- var protocol = res[1];
192
- var port = res[3];
193
- if ((protocol === "https" && port === ":443") ||
194
- (protocol === "http" && port === ":80")) {
195
- // Drop port
196
- httpUrl = res[1] + res[2] + res[4];
197
- }
198
- }
199
- }
200
- catch (_a) {
201
- /* no-op */
202
- }
203
- _applyValue(otelSpanTelemetry, "httpUrl", fieldRedaction(asString(httpUrl), config), false);
204
- }
205
- var httpStatusCode = getHttpStatusCode(container);
206
- if (httpStatusCode) {
207
- _applyValue(otelSpanTelemetry, "httpStatusCode", httpStatusCode, false);
208
- }
209
- }
210
- }
211
- function _populateDbProperties(otelSpanTelemetry, container, dbSystem) {
212
- if (dbSystem) {
213
- _applyValue(otelSpanTelemetry, "dbSystem", dbSystem, false);
214
- // Set the statement
215
- _applyValue(otelSpanTelemetry, "dbStatement", container.get(SEMATTRS_DB_STATEMENT) || container.get(SEMATTRS_DB_OPERATION), false);
216
- _applyValue(otelSpanTelemetry, "dbName", container.get(SEMATTRS_DB_NAME) || dbSystem || "<undefined>", false);
217
- }
218
- }
219
- function _populateRpcDependencyProperties(otelSpanTelemetry, container, rpcSystem) {
220
- if (rpcSystem) {
221
- _applyValue(otelSpanTelemetry, "rpcSystem", strLower(rpcSystem), false);
222
- _applyValue(otelSpanTelemetry, "rpcGrpcStatusCode", container.get(SEMATTRS_RPC_GRPC_STATUS_CODE), false);
223
- }
224
- }
225
- function _createOTelSpanTelemetryItem(core, span) {
226
- var container = span.attribContainer || createAttributeContainer(span.attributes);
227
- var spanCtx = span.spanContext();
228
- var statusCode = span.status ? span.status.code : 0 /* eOTelSpanStatusCode.UNSET */;
229
- var spanTelemetry = {
230
- name: span.name,
231
- kind: span[_DYN_KIND /* @min:%2ekind */],
232
- startTime: toISOString(new Date(hrTimeToMilliseconds(span.startTime))),
233
- success: statusCode !== 0 /* eOTelSpanStatusCode.UNSET */ ? statusCode !== 2 /* eOTelSpanStatusCode.ERROR */ : (Number(getHttpStatusCode(container)) || 0) < 400,
234
- duration: hrTimeToMilliseconds(span.duration)
235
- //azureResourceProvider: undefined, // Not currently supported
236
- //links: UNDEFINED_VALUE, // Not currently supported
237
- };
238
- // Set the parentId if available
239
- var parentCtx = span.parentSpanContext || (spanCtx ? spanCtx.parentCtx : null);
240
- _applyValue(spanTelemetry, "parentId", span.parentSpanId || (parentCtx ? parentCtx.spanId : null), false);
241
- if (spanCtx) {
242
- var traceState = spanCtx.traceState;
243
- if (traceState && !traceState.isEmpty) {
244
- _applyValue(spanTelemetry, "traceState", traceState.hdrs(1)[0], false);
245
- }
246
- }
247
- _populateHttpProperties(spanTelemetry, container, getHttpMethod(container), core.config);
248
- _populateDbProperties(spanTelemetry, container, container.get(SEMATTRS_DB_SYSTEM));
249
- _populateRpcDependencyProperties(spanTelemetry, container, container.get(SEMATTRS_RPC_SYSTEM));
250
- _applyValue(spanTelemetry, "azureResourceProvider", container.get(AzResourceNamespace) || container.get(AzNamespace), false);
251
- return _createTelemetryItem(spanTelemetry, span, "OTelSpan", "Ms.Web.Span");
252
- }
253
- function _createTelemetryItem(item, span, baseType, eventName) {
254
- eventName = eventName || STR_NOT_SPECIFIED;
255
- if (isNullOrUndefined(item) ||
256
- isNullOrUndefined(baseType) ||
257
- isNullOrUndefined(eventName)) {
258
- throwError("Input doesn't contain all required fields");
259
- }
260
- var iKey = "";
261
- if (item.iKey) {
262
- iKey = item.iKey;
263
- delete item.iKey;
264
- }
265
- var telemetryItem = {
266
- name: eventName,
267
- time: toISOString(span.endTime ? new Date(hrTimeToMilliseconds(span.endTime)) : new Date()),
268
- iKey: iKey,
269
- ext: {},
270
- baseType: baseType,
271
- baseData: item,
272
- data: {} // part C
273
- };
274
- return telemetryItem;
275
- }
276
- /**
277
- * Create an extended common schema telemetry item from the provided span
278
- * @param core - The app insights core instance
279
- * @param span - The span to create the telemetry item from
280
- * @returns A new extended telemetry item or null if the span kind is not supported
281
- */
282
- export function createExtendedTelemetryItemFromSpan(core, span) {
283
- var telemetryItem = _createOTelSpanTelemetryItem(core, span);
284
- var container = span.attribContainer || createAttributeContainer(span.attributes);
285
- if (telemetryItem) {
286
- // Set the Span common schema fields
287
- // Set start time for the telemetry item from the event, not the time it is being processed (the default)
288
- // The channel envelope creator uses this value when creating the envelope only when defined, otherwise it
289
- // uses the time when the item is being processed
290
- var partB = telemetryItem[_DYN_BASE_DATA /* @min:%2ebaseData */] = telemetryItem[_DYN_BASE_DATA /* @min:%2ebaseData */] || {};
291
- partB.startTime = new Date(hrTimeToMilliseconds(span.startTime));
292
- var spanContext = span.spanContext();
293
- if (spanContext) {
294
- // Add dt extension to the telemetry item
295
- var ext = telemetryItem.ext = telemetryItem.ext || {};
296
- var dt = ext["dt"] = ext["dt"] || {};
297
- // Don't overwrite any existing values
298
- _applyValue(dt, "spanId", spanContext.spanId, false);
299
- _applyValue(dt, "traceId", spanContext.traceId, false);
300
- _applyValue(dt, "traceFlags", spanContext.traceFlags, false);
301
- }
302
- _populateExtensionsFromSpan(telemetryItem, span, container);
303
- _populatePartC(telemetryItem, container);
304
- // Azure SDK
305
- }
306
- return telemetryItem;
307
- }
308
- //# sourceMappingURL=extSpanUtils.js.map