@microsoft/applicationinsights-common 3.3.5-nightly3.2501-07 → 3.3.5-nightly3.2501-08

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 (101) hide show
  1. package/browser/es5/applicationinsights-common.cjs.js +247 -136
  2. package/browser/es5/applicationinsights-common.cjs.js.map +1 -1
  3. package/browser/es5/applicationinsights-common.cjs.min.js +2 -2
  4. package/browser/es5/applicationinsights-common.cjs.min.js.map +1 -1
  5. package/browser/es5/applicationinsights-common.gbl.js +249 -138
  6. package/browser/es5/applicationinsights-common.gbl.js.map +1 -1
  7. package/browser/es5/applicationinsights-common.gbl.min.js +2 -2
  8. package/browser/es5/applicationinsights-common.gbl.min.js.map +1 -1
  9. package/browser/es5/applicationinsights-common.integrity.json +25 -25
  10. package/browser/es5/applicationinsights-common.js +249 -138
  11. package/browser/es5/applicationinsights-common.js.map +1 -1
  12. package/browser/es5/applicationinsights-common.min.js +2 -2
  13. package/browser/es5/applicationinsights-common.min.js.map +1 -1
  14. package/dist/es5/applicationinsights-common.js +247 -136
  15. package/dist/es5/applicationinsights-common.js.map +1 -1
  16. package/dist/es5/applicationinsights-common.min.js +2 -2
  17. package/dist/es5/applicationinsights-common.min.js.map +1 -1
  18. package/dist-es5/ConnectionStringParser.js +1 -1
  19. package/dist-es5/Constants.js +1 -1
  20. package/dist-es5/DomHelperFuncs.js +1 -1
  21. package/dist-es5/Enums.js +1 -1
  22. package/dist-es5/HelperFuncs.js +1 -1
  23. package/dist-es5/Interfaces/ConnectionString.js +1 -1
  24. package/dist-es5/Interfaces/Context/IApplication.js +1 -1
  25. package/dist-es5/Interfaces/Context/IDevice.js +1 -1
  26. package/dist-es5/Interfaces/Context/IInternal.js +1 -1
  27. package/dist-es5/Interfaces/Context/ILocation.js +1 -1
  28. package/dist-es5/Interfaces/Context/IOperatingSystem.js +1 -1
  29. package/dist-es5/Interfaces/Context/ISample.js +1 -1
  30. package/dist-es5/Interfaces/Context/ISession.js +1 -1
  31. package/dist-es5/Interfaces/Context/ISessionManager.js +1 -1
  32. package/dist-es5/Interfaces/Context/ITelemetryTrace.js +1 -1
  33. package/dist-es5/Interfaces/Context/IUser.js +1 -1
  34. package/dist-es5/Interfaces/Context/IWeb.js +1 -1
  35. package/dist-es5/Interfaces/Contracts/AvailabilityData.js +1 -1
  36. package/dist-es5/Interfaces/Contracts/ContextTagKeys.js +1 -1
  37. package/dist-es5/Interfaces/Contracts/DataPointType.js +1 -1
  38. package/dist-es5/Interfaces/Contracts/DependencyKind.js +1 -1
  39. package/dist-es5/Interfaces/Contracts/DependencySourceType.js +1 -1
  40. package/dist-es5/Interfaces/Contracts/IBase.js +1 -1
  41. package/dist-es5/Interfaces/Contracts/IData.js +1 -1
  42. package/dist-es5/Interfaces/Contracts/IDataPoint.js +1 -1
  43. package/dist-es5/Interfaces/Contracts/IDomain.js +1 -1
  44. package/dist-es5/Interfaces/Contracts/IEnvelope.js +1 -1
  45. package/dist-es5/Interfaces/Contracts/IEventData.js +1 -1
  46. package/dist-es5/Interfaces/Contracts/IExceptionData.js +1 -1
  47. package/dist-es5/Interfaces/Contracts/IExceptionDetails.js +1 -1
  48. package/dist-es5/Interfaces/Contracts/IMessageData.js +1 -1
  49. package/dist-es5/Interfaces/Contracts/IMetricData.js +1 -1
  50. package/dist-es5/Interfaces/Contracts/IPageViewData.js +1 -1
  51. package/dist-es5/Interfaces/Contracts/IPageViewPerfData.js +1 -1
  52. package/dist-es5/Interfaces/Contracts/IRemoteDependencyData.js +1 -1
  53. package/dist-es5/Interfaces/Contracts/IStackFrame.js +1 -1
  54. package/dist-es5/Interfaces/Contracts/RequestData.js +1 -1
  55. package/dist-es5/Interfaces/Contracts/SeverityLevel.js +1 -1
  56. package/dist-es5/Interfaces/IAppInsights.js +1 -1
  57. package/dist-es5/Interfaces/IConfig.js +1 -1
  58. package/dist-es5/Interfaces/ICorrelationConfig.js +1 -1
  59. package/dist-es5/Interfaces/IDependencyTelemetry.js +1 -1
  60. package/dist-es5/Interfaces/IEventTelemetry.js +1 -1
  61. package/dist-es5/Interfaces/IExceptionTelemetry.js +1 -1
  62. package/dist-es5/Interfaces/IMetricTelemetry.js +1 -1
  63. package/dist-es5/Interfaces/IPageViewPerformanceTelemetry.js +1 -1
  64. package/dist-es5/Interfaces/IPageViewTelemetry.js +1 -1
  65. package/dist-es5/Interfaces/IPartC.js +1 -1
  66. package/dist-es5/Interfaces/IPropertiesPlugin.js +1 -1
  67. package/dist-es5/Interfaces/IRequestContext.js +1 -1
  68. package/dist-es5/Interfaces/IStorageBuffer.js +1 -1
  69. package/dist-es5/Interfaces/ITelemetryContext.js +1 -1
  70. package/dist-es5/Interfaces/IThrottleMgr.js +1 -1
  71. package/dist-es5/Interfaces/ITraceTelemetry.js +1 -1
  72. package/dist-es5/Interfaces/PartAExtensions.js +1 -1
  73. package/dist-es5/Interfaces/Telemetry/IEnvelope.js +1 -1
  74. package/dist-es5/Interfaces/Telemetry/ISerializable.js +1 -1
  75. package/dist-es5/Offline.js +1 -1
  76. package/dist-es5/RequestResponseHeaders.js +1 -1
  77. package/dist-es5/StorageHelperFuncs.js +1 -1
  78. package/dist-es5/Telemetry/Common/Data.js +1 -1
  79. package/dist-es5/Telemetry/Common/DataPoint.js +1 -1
  80. package/dist-es5/Telemetry/Common/DataSanitizer.js +1 -1
  81. package/dist-es5/Telemetry/Common/Envelope.js +3 -3
  82. package/dist-es5/Telemetry/Common/Envelope.js.map +1 -1
  83. package/dist-es5/Telemetry/Event.js +1 -1
  84. package/dist-es5/Telemetry/Exception.js +371 -137
  85. package/dist-es5/Telemetry/Exception.js.map +1 -1
  86. package/dist-es5/Telemetry/Metric.js +1 -1
  87. package/dist-es5/Telemetry/PageView.js +1 -1
  88. package/dist-es5/Telemetry/PageViewPerformance.js +1 -1
  89. package/dist-es5/Telemetry/RemoteDependencyData.js +1 -1
  90. package/dist-es5/Telemetry/Trace.js +1 -1
  91. package/dist-es5/TelemetryItemCreator.js +1 -1
  92. package/dist-es5/ThrottleMgr.js +1 -1
  93. package/dist-es5/UrlHelperFuncs.js +4 -4
  94. package/dist-es5/UrlHelperFuncs.js.map +1 -1
  95. package/dist-es5/Util.js +1 -1
  96. package/dist-es5/__DynamicConstants.js +13 -12
  97. package/dist-es5/__DynamicConstants.js.map +1 -1
  98. package/dist-es5/applicationinsights-common.js +1 -1
  99. package/package.json +3 -3
  100. package/types/applicationinsights-common.d.ts +1 -1
  101. package/types/applicationinsights-common.namespaced.d.ts +6 -6
@@ -1,15 +1,150 @@
1
1
  /*
2
- * Application Insights JavaScript SDK - Common, 3.3.5-nightly3.2501-07
2
+ * Application Insights JavaScript SDK - Common, 3.3.5-nightly3.2501-08
3
3
  * Copyright (c) Microsoft and contributors. All rights reserved.
4
4
  */
5
5
 
6
6
 
7
7
  import { __assignFn as __assign } from "@microsoft/applicationinsights-shims";
8
8
  import { arrForEach, arrMap, isArray, isError, isFunction, isNullOrUndefined, isObject, isString, strTrim } from "@microsoft/applicationinsights-core-js";
9
- import { getWindow, strIndexOf } from "@nevware21/ts-utils";
9
+ import { asString, getWindow, objFreeze, strIndexOf } from "@nevware21/ts-utils";
10
10
  import { strNotSpecified } from "../Constants";
11
- import { _DYN_ASSEMBLY, _DYN_EXCEPTIONS, _DYN_FILE_NAME, _DYN_HAS_FULL_STACK, _DYN_IS_MANUAL, _DYN_LENGTH, _DYN_LEVEL, _DYN_LINE, _DYN_MEASUREMENTS, _DYN_MESSAGE, _DYN_METHOD, _DYN_NAME, _DYN_PARSED_STACK, _DYN_PROBLEM_GROUP, _DYN_PROPERTIES, _DYN_PUSH, _DYN_SEVERITY_LEVEL, _DYN_SIZE_IN_BYTES, _DYN_SPLIT, _DYN_STRINGIFY, _DYN_TO_STRING, _DYN_TYPE_NAME, _DYN__CREATE_FROM_INTERFA1 } from "../__DynamicConstants";
11
+ import { _DYN_AI_DATA_CONTRACT, _DYN_ASSEMBLY, _DYN_EXCEPTIONS, _DYN_FILE_NAME, _DYN_HAS_FULL_STACK, _DYN_IS_MANUAL, _DYN_LENGTH, _DYN_LEVEL, _DYN_LINE, _DYN_MATCH, _DYN_MEASUREMENTS, _DYN_MESSAGE, _DYN_METHOD, _DYN_NAME, _DYN_PARSED_STACK, _DYN_PROBLEM_GROUP, _DYN_PROPERTIES, _DYN_PUSH, _DYN_SEVERITY_LEVEL, _DYN_SIZE_IN_BYTES, _DYN_SPLIT, _DYN_STRINGIFY, _DYN_TO_STRING, _DYN_TYPE_NAME } from "../__DynamicConstants";
12
12
  import { dataSanitizeException, dataSanitizeMeasurements, dataSanitizeMessage, dataSanitizeProperties, dataSanitizeString } from "./Common/DataSanitizer";
13
+ // These Regex covers the following patterns
14
+ // 1. Chrome/Firefox/IE/Edge:
15
+ // at functionName (filename:lineNumber:columnNumber)
16
+ // at functionName (filename:lineNumber)
17
+ // at filename:lineNumber:columnNumber
18
+ // at filename:lineNumber
19
+ // at functionName@filename:lineNumber:columnNumber
20
+ // 2. Safari / Opera:
21
+ // functionName@filename:lineNumber:columnNumber
22
+ // functionName@filename:lineNumber
23
+ // filename:lineNumber:columnNumber
24
+ // filename:lineNumber
25
+ // Line ## of scriptname script filename:lineNumber:columnNumber
26
+ // Line ## of scriptname script filename
27
+ // 3. IE/Edge (Additional formats)
28
+ // at functionName@filename:lineNumber
29
+ var STACKFRAME_BASE_SIZE = 58; // '{"method":"","level":,"assembly":"","fileName":"","line":}'.length
30
+ /**
31
+ * Check if the string conforms to what looks like a stack frame line and not just a general message
32
+ * comment or other non-stack related info.
33
+ *
34
+ * This should be used to filter out any leading "message" lines from a stack trace, before attempting to parse
35
+ * the individual stack frames. Once you have estabilsted the start of the stack frames you can then use the
36
+ * FULL_STACK_FRAME_1, FULL_STACK_FRAME_2, FULL_STACK_FRAME_3, and EXTRACT_FILENAME to parse the individual
37
+ * stack frames to extract the method, filename, line number, and column number.
38
+ * These may still provide invalid matches, so the sequence of execution is important to avoid providing
39
+ * an invalid parsed stack.
40
+ */
41
+ var IS_FRAME = /^\s{0,50}(from\s|at\s|Line\s{1,5}\d{1,10}\s{1,5}of|\w{1,50}@\w{1,80}|[^\(\s\n]+:[0-9\?]+(?::[0-9\?]+)?)/;
42
+ /**
43
+ * Parse a well formed stack frame with both the line and column numbers
44
+ * ----------------------------------
45
+ * **Primary focus of the matching**
46
+ * - at functionName (filename:lineNumber:columnNumber)
47
+ * - at filename:lineNumber:columnNumber
48
+ * - at functionName@filename:lineNumber:columnNumber
49
+ * - functionName (filename:lineNumber:columnNumber)
50
+ * - filename:lineNumber:columnNumber
51
+ * - functionName@filename:lineNumber:columnNumber
52
+ */
53
+ var FULL_STACK_FRAME_1 = /^(?:\s{0,50}at)?\s{0,50}([^\@\()\s]+)?\s{0,50}(?:\s|\@|\()\s{0,5}([^\(\s\n\]]+):([0-9\?]+):([0-9\?]+)\)?$/;
54
+ /**
55
+ * Parse a well formed stack frame with only a line number.
56
+ * ----------------------------------
57
+ * > Note: this WILL also match with line and column number, but the line number is included with the filename
58
+ * > you should attempt to match with FULL_STACK_FRAME_1 first.
59
+ *
60
+ * **Primary focus of the matching (run FULL_STACK_FRAME_1 first)**
61
+ * - at functionName (filename:lineNumber)
62
+ * - at filename:lineNumber
63
+ * - at functionName@filename:lineNumber
64
+ * - functionName (filename:lineNumber)
65
+ * - filename:lineNumber
66
+ * - functionName@filename:lineNumber
67
+ *
68
+ * **Secondary matches**
69
+ * - at functionName (filename:lineNumber:columnNumber)
70
+ * - at filename:lineNumber:columnNumber
71
+ * - at functionName@filename:lineNumber:columnNumber
72
+ * - functionName (filename:lineNumber:columnNumber)
73
+ * - filename:lineNumber:columnNumber
74
+ * - functionName@filename:lineNumber:columnNumber
75
+ */
76
+ var FULL_STACK_FRAME_2 = /^(?:\s{0,50}at)?\s{0,50}([^\@\()\s]+)?\s{0,50}(?:\s|\@|\()\s{0,5}([^\(\s\n\]]+):([0-9\?]+)\)?$/;
77
+ /**
78
+ * Attempt to Parse a frame that doesn't include a line or column number.
79
+ * ----------------------------------
80
+ * > Note: this WILL also match lines with a line or line and column number, you should attempt to match with
81
+ * both FULL_STACK_FRAME_1 and FULL_STACK_FRAME_2 first to avoid false positives.
82
+ *
83
+ * **Unexpected Invalid Matches** (Matches that should be avoided -- by using the FULL_STACK_FRAME_1 and FULL_STACK_FRAME_2 first)
84
+ * - at https://localhost:44365/static/node_bundles/@microsoft/blah/js/bundle.js:144112:27
85
+ * - at https://localhost:44365/static/node_bundles/@microsoft/blah/js/bundle.js:144112:27
86
+ *
87
+ * **Primary focus of the matching (run FULL_STACK_FRAME_1 first)**
88
+ * - at functionName@filename
89
+ * - at functionName (filename)
90
+ * - at functionName filename
91
+ * - at filename <- Will actuall match this as the "method" and not the filename (care should be taken to avoid this)
92
+ * - functionName@filename
93
+ * - functionName (filename)
94
+ * - functionName filename
95
+ * - functionName
96
+ *
97
+ * **Secondary matches** (The line and column numbers will be included with the matched filename)
98
+ * - at functionName (filename:lineNumber:columnNumber)
99
+ * - at functionName (filename:lineNumber)
100
+ * - at filename:lineNumber:columnNumber
101
+ * - at filename:lineNumber
102
+ * - at functionName@filename:lineNumber:columnNumber
103
+ * - at functionName@filename:lineNumber
104
+ * - functionName (filename:lineNumber:columnNumber)
105
+ * - functionName (filename:lineNumber)
106
+ * - filename:lineNumber:columnNumber
107
+ * - filename:lineNumber
108
+ * - functionName@filename:lineNumber:columnNumber
109
+ * - functionName@filename:lineNumber
110
+ */
111
+ var FULL_STACK_FRAME_3 = /^(?:\s{0,50}at)?\s{0,50}([^\@\()\s]+)?\s{0,50}(?:\s|\@|\()\s{0,5}([^\(\s\n\)\]]+)\)?$/;
112
+ /**
113
+ * Attempt to extract the filename (with or without line and column numbers) from a string.
114
+ * ----------------------------------
115
+ * > Note: this will only match the filename (with any line or column numbers) and will
116
+ * > return what looks like the filename, however, it will also match random strings that
117
+ * > look like a filename, so care should be taken to ensure that the filename is actually
118
+ * > a filename before using it.
119
+ * >
120
+ * > It is recommended to use this in conjunction with the FULL_STACK_FRAME_1, FULL_STACK_FRAME_2, and FULL_STACK_FRAME_3
121
+ * > to ensure first to reduce false matches, if all of these fail then you can use this to extract the filename from a random
122
+ * > strings to identify any potential filename from a known stack frame line.
123
+ *
124
+ * **Known Invalid matching**
125
+ *
126
+ * This regex will basically match any "final" string of a line or one that is trailed by a comma, so this should not
127
+ * be used as the "only" matching regex, but rather as a final fallback to extract the filename from a string.
128
+ * If you are certain that the string line is a stack frame and not part of the exception message (lines before the stack)
129
+ * or trailing comments, then you can use this to extract the filename and then further parse with PARSE_FILENAME_LINE_COL
130
+ * and PARSE_FILENAME_LINE_ONLY to extract any potential the line and column numbers.
131
+ *
132
+ * **Primary focus of the matching**
133
+ * - at (anonymous) @ VM60:1
134
+ * - Line 21 of linked script file://localhost/C:/Temp/stacktrace.js
135
+ * - Line 11 of inline#1 script in http://localhost:3000/static/js/main.206f4846.js:2:296748
136
+ * - Line 68 of inline#2 script in file://localhost/teststack.html
137
+ * - at Global code (http://example.com/stacktrace.js:11:1)
138
+ */
139
+ var EXTRACT_FILENAME = /(?:^|\(|\s{0,10}[\w\)]+\@)?([^\(\n\s\]\)]+)(?:\:([0-9]+)(?:\:([0-9]+))?)?\)?(?:,|$)/;
140
+ /**
141
+ * Attempt to extract the filename, line number, and column number from a string.
142
+ */
143
+ var PARSE_FILENAME_LINE_COL = /([^\(\s\n]+):([0-9]+):([0-9]+)$/;
144
+ /**
145
+ * Attempt to extract the filename and line number from a string.
146
+ */
147
+ var PARSE_FILENAME_LINE_ONLY = /([^\(\s\n]+):([0-9]+)$/;
13
148
  var NoMethod = "<no_method>";
14
149
  var strError = "error";
15
150
  var strStack = "stack";
@@ -17,6 +152,18 @@ var strStackDetails = "stackDetails";
17
152
  var strErrorSrc = "errorSrc";
18
153
  var strMessage = "message";
19
154
  var strDescription = "description";
155
+ var _parseSequence = [
156
+ { re: FULL_STACK_FRAME_1, len: 5, m: 1, fn: 2, ln: 3, col: 4 },
157
+ { chk: _ignoreNative, pre: _scrubAnonymous, re: FULL_STACK_FRAME_2, len: 4, m: 1, fn: 2, ln: 3 },
158
+ { re: FULL_STACK_FRAME_3, len: 3, m: 1, fn: 2, hdl: _handleFilename },
159
+ { re: EXTRACT_FILENAME, len: 2, fn: 1, hdl: _handleFilename }
160
+ ];
161
+ function _scrubAnonymous(frame) {
162
+ return frame.replace(/(\(anonymous\))/, "<anonymous>");
163
+ }
164
+ function _ignoreNative(frame) {
165
+ return strIndexOf(frame, "[native") < 0;
166
+ }
20
167
  function _stringify(value, convertToString) {
21
168
  var result = value;
22
169
  if (result && !isString(result)) {
@@ -178,9 +325,7 @@ function _formatStackTrace(stackDetails) {
178
325
  var stack = "";
179
326
  if (stackDetails) {
180
327
  if (stackDetails.obj) {
181
- arrForEach(stackDetails.obj, function (entry) {
182
- stack += entry + "\n";
183
- });
328
+ stack = stackDetails.obj.join("\n");
184
329
  }
185
330
  else {
186
331
  stack = stackDetails.src || "";
@@ -194,13 +339,19 @@ function _parseStack(stack) {
194
339
  if (frames && frames[_DYN_LENGTH /* @min:%2elength */] > 0) {
195
340
  parsedStack = [];
196
341
  var level_1 = 0;
342
+ var foundStackStart_1 = false;
197
343
  var totalSizeInBytes_1 = 0;
198
344
  arrForEach(frames, function (frame) {
199
- var theFrame = frame[_DYN_TO_STRING /* @min:%2etoString */]();
200
- if (_StackFrame.regex.test(theFrame)) {
201
- var parsedFrame = new _StackFrame(theFrame, level_1++);
202
- totalSizeInBytes_1 += parsedFrame[_DYN_SIZE_IN_BYTES /* @min:%2esizeInBytes */];
203
- parsedStack[_DYN_PUSH /* @min:%2epush */](parsedFrame);
345
+ if (foundStackStart_1 || _isStackFrame(frame)) {
346
+ var theFrame = asString(frame);
347
+ // Once we have found the first stack frame we treat the rest of the lines as part of the stack
348
+ foundStackStart_1 = true;
349
+ var parsedFrame = _extractStackFrame(theFrame, level_1);
350
+ if (parsedFrame) {
351
+ totalSizeInBytes_1 += parsedFrame[_DYN_SIZE_IN_BYTES /* @min:%2esizeInBytes */];
352
+ parsedStack[_DYN_PUSH /* @min:%2epush */](parsedFrame);
353
+ level_1++;
354
+ }
204
355
  }
205
356
  });
206
357
  // DP Constraint - exception parsed stack must be < 32KB
@@ -303,7 +454,7 @@ var Exception = /** @class */ (function () {
303
454
  if (id) {
304
455
  properties.id = id;
305
456
  }
306
- _self[_DYN_EXCEPTIONS /* @min:%2eexceptions */] = [new _ExceptionDetails(logger, exception, properties)];
457
+ _self[_DYN_EXCEPTIONS /* @min:%2eexceptions */] = [_createExceptionDetails(logger, exception, properties)];
307
458
  _self[_DYN_PROPERTIES /* @min:%2eproperties */] = dataSanitizeProperties(logger, properties);
308
459
  _self[_DYN_MEASUREMENTS /* @min:%2emeasurements */] = dataSanitizeMeasurements(logger, measurements);
309
460
  if (severityLevel) {
@@ -350,7 +501,7 @@ var Exception = /** @class */ (function () {
350
501
  };
351
502
  Exception.CreateFromInterface = function (logger, exception, properties, measurements) {
352
503
  var exceptions = exception[_DYN_EXCEPTIONS /* @min:%2eexceptions */]
353
- && arrMap(exception[_DYN_EXCEPTIONS /* @min:%2eexceptions */], function (ex) { return _ExceptionDetails[_DYN__CREATE_FROM_INTERFA1 /* @min:%2eCreateFromInterface */](logger, ex); });
504
+ && arrMap(exception[_DYN_EXCEPTIONS /* @min:%2eexceptions */], function (ex) { return _createExDetailsFromInterface(logger, ex); });
354
505
  var exceptionData = new Exception(logger, __assign(__assign({}, exception), { exceptions: exceptions }), properties, measurements);
355
506
  return exceptionData;
356
507
  };
@@ -394,137 +545,220 @@ var Exception = /** @class */ (function () {
394
545
  return Exception;
395
546
  }());
396
547
  export { Exception };
397
- var _ExceptionDetails = /** @class */ (function () {
398
- function _ExceptionDetails(logger, exception, properties) {
399
- this.aiDataContract = {
400
- id: 0 /* FieldType.Default */,
401
- outerId: 0 /* FieldType.Default */,
402
- typeName: 1 /* FieldType.Required */,
403
- message: 1 /* FieldType.Required */,
404
- hasFullStack: 0 /* FieldType.Default */,
405
- stack: 0 /* FieldType.Default */,
406
- parsedStack: 2 /* FieldType.Array */
407
- };
408
- var _self = this;
409
- if (!_isExceptionDetailsInternal(exception)) {
410
- var error = exception;
411
- var evt = error && error.evt;
412
- if (!isError(error)) {
413
- error = error[strError] || evt || error;
414
- }
415
- _self[_DYN_TYPE_NAME /* @min:%2etypeName */] = dataSanitizeString(logger, _getErrorType(error)) || strNotSpecified;
416
- _self[_DYN_MESSAGE /* @min:%2emessage */] = dataSanitizeMessage(logger, _formatMessage(exception || error, _self[_DYN_TYPE_NAME /* @min:%2etypeName */])) || strNotSpecified;
417
- var stack = exception[strStackDetails] || _getStackFromErrorObj(exception);
418
- _self[_DYN_PARSED_STACK /* @min:%2eparsedStack */] = _parseStack(stack);
419
- // after parsedStack is inited, iterate over each frame object, sanitize its assembly field
420
- if (isArray(_self[_DYN_PARSED_STACK /* @min:%2eparsedStack */])) {
421
- arrMap(_self[_DYN_PARSED_STACK /* @min:%2eparsedStack */], function (frame) {
422
- frame[_DYN_ASSEMBLY /* @min:%2eassembly */] = dataSanitizeString(logger, frame[_DYN_ASSEMBLY /* @min:%2eassembly */]);
423
- frame[_DYN_FILE_NAME /* @min:%2efileName */] = dataSanitizeString(logger, frame[_DYN_FILE_NAME /* @min:%2efileName */]);
424
- });
425
- }
426
- _self[strStack] = dataSanitizeException(logger, _formatStackTrace(stack));
427
- _self.hasFullStack = isArray(_self.parsedStack) && _self.parsedStack[_DYN_LENGTH /* @min:%2elength */] > 0;
428
- if (properties) {
429
- properties[_DYN_TYPE_NAME /* @min:%2etypeName */] = properties[_DYN_TYPE_NAME /* @min:%2etypeName */] || _self[_DYN_TYPE_NAME /* @min:%2etypeName */];
430
- }
548
+ var exDetailsAiDataContract = objFreeze({
549
+ id: 0 /* FieldType.Default */,
550
+ outerId: 0 /* FieldType.Default */,
551
+ typeName: 1 /* FieldType.Required */,
552
+ message: 1 /* FieldType.Required */,
553
+ hasFullStack: 0 /* FieldType.Default */,
554
+ stack: 0 /* FieldType.Default */,
555
+ parsedStack: 2 /* FieldType.Array */
556
+ });
557
+ function _toInterface() {
558
+ var _a;
559
+ var _self = this;
560
+ var parsedStack = isArray(_self[_DYN_PARSED_STACK /* @min:%2eparsedStack */])
561
+ && arrMap(_self[_DYN_PARSED_STACK /* @min:%2eparsedStack */], function (frame) { return _parsedFrameToInterface(frame); });
562
+ var exceptionDetailsInterface = (_a = {
563
+ id: _self.id,
564
+ outerId: _self.outerId,
565
+ typeName: _self[_DYN_TYPE_NAME /* @min:%2etypeName */],
566
+ message: _self[_DYN_MESSAGE /* @min:%2emessage */],
567
+ hasFullStack: _self[_DYN_HAS_FULL_STACK /* @min:%2ehasFullStack */],
568
+ stack: _self[strStack]
569
+ },
570
+ _a[_DYN_PARSED_STACK /* @min:parsedStack */] = parsedStack || undefined,
571
+ _a);
572
+ return exceptionDetailsInterface;
573
+ }
574
+ export function _createExceptionDetails(logger, exception, properties) {
575
+ var _a;
576
+ var id;
577
+ var outerId;
578
+ var typeName;
579
+ var message;
580
+ var hasFullStack;
581
+ var theStack;
582
+ var parsedStack;
583
+ if (!_isExceptionDetailsInternal(exception)) {
584
+ var error = exception;
585
+ var evt = error && error.evt;
586
+ if (!isError(error)) {
587
+ error = error[strError] || evt || error;
588
+ }
589
+ typeName = dataSanitizeString(logger, _getErrorType(error)) || strNotSpecified;
590
+ message = dataSanitizeMessage(logger, _formatMessage(exception || error, typeName)) || strNotSpecified;
591
+ var stack = exception[strStackDetails] || _getStackFromErrorObj(exception);
592
+ parsedStack = _parseStack(stack);
593
+ // after parsedStack is inited, iterate over each frame object, sanitize its assembly field
594
+ if (isArray(parsedStack)) {
595
+ arrMap(parsedStack, function (frame) {
596
+ frame[_DYN_ASSEMBLY /* @min:%2eassembly */] = dataSanitizeString(logger, frame[_DYN_ASSEMBLY /* @min:%2eassembly */]);
597
+ frame[_DYN_FILE_NAME /* @min:%2efileName */] = dataSanitizeString(logger, frame[_DYN_FILE_NAME /* @min:%2efileName */]);
598
+ });
599
+ }
600
+ theStack = dataSanitizeException(logger, _formatStackTrace(stack));
601
+ hasFullStack = isArray(parsedStack) && parsedStack[_DYN_LENGTH /* @min:%2elength */] > 0;
602
+ if (properties) {
603
+ properties[_DYN_TYPE_NAME /* @min:%2etypeName */] = properties[_DYN_TYPE_NAME /* @min:%2etypeName */] || typeName;
604
+ }
605
+ }
606
+ else {
607
+ typeName = exception[_DYN_TYPE_NAME /* @min:%2etypeName */];
608
+ message = exception[_DYN_MESSAGE /* @min:%2emessage */];
609
+ theStack = exception[strStack];
610
+ parsedStack = exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */] || [];
611
+ hasFullStack = exception[_DYN_HAS_FULL_STACK /* @min:%2ehasFullStack */];
612
+ }
613
+ return _a = {},
614
+ _a[_DYN_AI_DATA_CONTRACT /* @min:aiDataContract */] = exDetailsAiDataContract,
615
+ _a.id = id,
616
+ _a.outerId = outerId,
617
+ _a[_DYN_TYPE_NAME /* @min:typeName */] = typeName,
618
+ _a[_DYN_MESSAGE /* @min:message */] = message,
619
+ _a[_DYN_HAS_FULL_STACK /* @min:hasFullStack */] = hasFullStack,
620
+ _a.stack = theStack,
621
+ _a[_DYN_PARSED_STACK /* @min:parsedStack */] = parsedStack,
622
+ _a.toInterface = _toInterface,
623
+ _a;
624
+ }
625
+ export function _createExDetailsFromInterface(logger, exception) {
626
+ var parsedStack = (isArray(exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */])
627
+ && arrMap(exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */], function (frame) { return _stackFrameFromInterface(frame); }))
628
+ || exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */];
629
+ var exceptionDetails = _createExceptionDetails(logger, __assign(__assign({}, exception), { parsedStack: parsedStack }));
630
+ return exceptionDetails;
631
+ }
632
+ function _parseFilename(theFrame, fileName) {
633
+ var lineCol = fileName[_DYN_MATCH /* @min:%2ematch */](PARSE_FILENAME_LINE_COL);
634
+ if (lineCol && lineCol[_DYN_LENGTH /* @min:%2elength */] >= 4) {
635
+ theFrame[_DYN_FILE_NAME /* @min:%2efileName */] = lineCol[1];
636
+ theFrame[_DYN_LINE /* @min:%2eline */] = parseInt(lineCol[2]);
637
+ }
638
+ else {
639
+ var lineNo = fileName[_DYN_MATCH /* @min:%2ematch */](PARSE_FILENAME_LINE_ONLY);
640
+ if (lineNo && lineNo[_DYN_LENGTH /* @min:%2elength */] >= 3) {
641
+ theFrame[_DYN_FILE_NAME /* @min:%2efileName */] = lineNo[1];
642
+ theFrame[_DYN_LINE /* @min:%2eline */] = parseInt(lineNo[2]);
431
643
  }
432
644
  else {
433
- _self[_DYN_TYPE_NAME /* @min:%2etypeName */] = exception[_DYN_TYPE_NAME /* @min:%2etypeName */];
434
- _self[_DYN_MESSAGE /* @min:%2emessage */] = exception[_DYN_MESSAGE /* @min:%2emessage */];
435
- _self[strStack] = exception[strStack];
436
- _self[_DYN_PARSED_STACK /* @min:%2eparsedStack */] = exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */] || [];
437
- _self[_DYN_HAS_FULL_STACK /* @min:%2ehasFullStack */] = exception[_DYN_HAS_FULL_STACK /* @min:%2ehasFullStack */];
645
+ theFrame[_DYN_FILE_NAME /* @min:%2efileName */] = fileName;
438
646
  }
439
647
  }
440
- _ExceptionDetails.prototype.toInterface = function () {
441
- var _a;
442
- var _self = this;
443
- var parsedStack = _self[_DYN_PARSED_STACK /* @min:%2eparsedStack */] instanceof Array
444
- && arrMap(_self[_DYN_PARSED_STACK /* @min:%2eparsedStack */], function (frame) { return frame.toInterface(); });
445
- var exceptionDetailsInterface = (_a = {
446
- id: _self.id,
447
- outerId: _self.outerId,
448
- typeName: _self[_DYN_TYPE_NAME /* @min:%2etypeName */],
449
- message: _self[_DYN_MESSAGE /* @min:%2emessage */],
450
- hasFullStack: _self[_DYN_HAS_FULL_STACK /* @min:%2ehasFullStack */],
451
- stack: _self[strStack]
452
- },
453
- _a[_DYN_PARSED_STACK /* @min:parsedStack */] = parsedStack || undefined,
454
- _a);
455
- return exceptionDetailsInterface;
456
- };
457
- _ExceptionDetails.CreateFromInterface = function (logger, exception) {
458
- var parsedStack = (exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */] instanceof Array
459
- && arrMap(exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */], function (frame) { return _StackFrame[_DYN__CREATE_FROM_INTERFA1 /* @min:%2eCreateFromInterface */](frame); }))
460
- || exception[_DYN_PARSED_STACK /* @min:%2eparsedStack */];
461
- var exceptionDetails = new _ExceptionDetails(logger, __assign(__assign({}, exception), { parsedStack: parsedStack }));
462
- return exceptionDetails;
463
- };
464
- return _ExceptionDetails;
465
- }());
466
- export { _ExceptionDetails };
467
- var _StackFrame = /** @class */ (function () {
468
- function _StackFrame(sourceFrame, level) {
469
- this.aiDataContract = {
470
- level: 1 /* FieldType.Required */,
471
- method: 1 /* FieldType.Required */,
472
- assembly: 0 /* FieldType.Default */,
473
- fileName: 0 /* FieldType.Default */,
474
- line: 0 /* FieldType.Default */
475
- };
476
- var _self = this;
477
- _self[_DYN_SIZE_IN_BYTES /* @min:%2esizeInBytes */] = 0;
478
- // Not converting this to isString() as typescript uses this logic to "understand" the different
479
- // types for the 2 different code paths
480
- if (typeof sourceFrame === "string") {
481
- var frame = sourceFrame;
482
- _self[_DYN_LEVEL /* @min:%2elevel */] = level;
483
- _self[_DYN_METHOD /* @min:%2emethod */] = NoMethod;
484
- _self[_DYN_ASSEMBLY /* @min:%2eassembly */] = strTrim(frame);
485
- _self[_DYN_FILE_NAME /* @min:%2efileName */] = "";
486
- _self[_DYN_LINE /* @min:%2eline */] = 0;
487
- var matches = frame.match(_StackFrame.regex);
488
- if (matches && matches[_DYN_LENGTH /* @min:%2elength */] >= 5) {
489
- _self[_DYN_METHOD /* @min:%2emethod */] = strTrim(matches[2]) || _self[_DYN_METHOD /* @min:%2emethod */];
490
- _self[_DYN_FILE_NAME /* @min:%2efileName */] = strTrim(matches[4]);
491
- _self[_DYN_LINE /* @min:%2eline */] = parseInt(matches[5]) || 0;
492
- }
648
+ }
649
+ function _handleFilename(theFrame, sequence, matches) {
650
+ var filename = theFrame[_DYN_FILE_NAME /* @min:%2efileName */];
651
+ if (sequence.fn && matches && matches[_DYN_LENGTH /* @min:%2elength */] > sequence.fn) {
652
+ if (sequence.ln && matches[_DYN_LENGTH /* @min:%2elength */] > sequence.ln) {
653
+ filename = strTrim(matches[sequence.fn] || "");
654
+ theFrame[_DYN_LINE /* @min:%2eline */] = parseInt(strTrim(matches[sequence.ln] || "")) || 0;
493
655
  }
494
656
  else {
495
- _self[_DYN_LEVEL /* @min:%2elevel */] = sourceFrame[_DYN_LEVEL /* @min:%2elevel */];
496
- _self[_DYN_METHOD /* @min:%2emethod */] = sourceFrame[_DYN_METHOD /* @min:%2emethod */];
497
- _self[_DYN_ASSEMBLY /* @min:%2eassembly */] = sourceFrame[_DYN_ASSEMBLY /* @min:%2eassembly */];
498
- _self[_DYN_FILE_NAME /* @min:%2efileName */] = sourceFrame[_DYN_FILE_NAME /* @min:%2efileName */];
499
- _self[_DYN_LINE /* @min:%2eline */] = sourceFrame[_DYN_LINE /* @min:%2eline */];
500
- _self[_DYN_SIZE_IN_BYTES /* @min:%2esizeInBytes */] = 0;
657
+ filename = strTrim(matches[sequence.fn] || "");
501
658
  }
502
- _self.sizeInBytes += _self.method[_DYN_LENGTH /* @min:%2elength */];
503
- _self.sizeInBytes += _self.fileName[_DYN_LENGTH /* @min:%2elength */];
504
- _self.sizeInBytes += _self.assembly[_DYN_LENGTH /* @min:%2elength */];
505
- // todo: these might need to be removed depending on how the back-end settles on their size calculation
506
- _self[_DYN_SIZE_IN_BYTES /* @min:%2esizeInBytes */] += _StackFrame.baseSize;
507
- _self.sizeInBytes += _self.level.toString()[_DYN_LENGTH /* @min:%2elength */];
508
- _self.sizeInBytes += _self.line.toString()[_DYN_LENGTH /* @min:%2elength */];
509
659
  }
510
- _StackFrame.CreateFromInterface = function (frame) {
511
- return new _StackFrame(frame, null /* level is available in frame interface */);
512
- };
513
- _StackFrame.prototype.toInterface = function () {
514
- var _self = this;
515
- return {
516
- level: _self[_DYN_LEVEL /* @min:%2elevel */],
517
- method: _self[_DYN_METHOD /* @min:%2emethod */],
518
- assembly: _self[_DYN_ASSEMBLY /* @min:%2eassembly */],
519
- fileName: _self[_DYN_FILE_NAME /* @min:%2efileName */],
520
- line: _self[_DYN_LINE /* @min:%2eline */]
521
- };
660
+ if (filename) {
661
+ _parseFilename(theFrame, filename);
662
+ }
663
+ }
664
+ function _isStackFrame(frame) {
665
+ var result = false;
666
+ if (frame && isString(frame)) {
667
+ var trimmedFrame = strTrim(frame);
668
+ if (trimmedFrame) {
669
+ result = IS_FRAME.test(trimmedFrame);
670
+ }
671
+ }
672
+ return result;
673
+ }
674
+ var stackFrameAiDataContract = objFreeze({
675
+ level: 1 /* FieldType.Required */,
676
+ method: 1 /* FieldType.Required */,
677
+ assembly: 0 /* FieldType.Default */,
678
+ fileName: 0 /* FieldType.Default */,
679
+ line: 0 /* FieldType.Default */
680
+ });
681
+ export function _extractStackFrame(frame, level) {
682
+ var _a;
683
+ var theFrame;
684
+ if (frame && isString(frame) && strTrim(frame)) {
685
+ theFrame = (_a = {},
686
+ _a[_DYN_AI_DATA_CONTRACT /* @min:aiDataContract */] = stackFrameAiDataContract,
687
+ _a[_DYN_LEVEL /* @min:level */] = level,
688
+ _a[_DYN_ASSEMBLY /* @min:assembly */] = strTrim(frame),
689
+ _a[_DYN_METHOD /* @min:method */] = NoMethod,
690
+ _a.fileName = "",
691
+ _a.line = 0,
692
+ _a[_DYN_SIZE_IN_BYTES /* @min:sizeInBytes */] = 0,
693
+ _a);
694
+ var idx = 0;
695
+ while (idx < _parseSequence[_DYN_LENGTH /* @min:%2elength */]) {
696
+ var sequence = _parseSequence[idx];
697
+ if (sequence.chk && !sequence.chk(frame)) {
698
+ break;
699
+ }
700
+ if (sequence.pre) {
701
+ frame = sequence.pre(frame);
702
+ }
703
+ // Attempt to "parse" the stack frame
704
+ var matches = frame[_DYN_MATCH /* @min:%2ematch */](sequence.re);
705
+ if (matches && matches[_DYN_LENGTH /* @min:%2elength */] >= sequence.len) {
706
+ if (sequence.m) {
707
+ theFrame[_DYN_METHOD /* @min:%2emethod */] = strTrim(matches[sequence.m] || NoMethod);
708
+ }
709
+ if (sequence.hdl) {
710
+ // Run any custom handler
711
+ sequence.hdl(theFrame, sequence, matches);
712
+ }
713
+ else if (sequence.fn) {
714
+ if (sequence.ln) {
715
+ theFrame[_DYN_FILE_NAME /* @min:%2efileName */] = strTrim(matches[sequence.fn] || "");
716
+ theFrame[_DYN_LINE /* @min:%2eline */] = parseInt(strTrim(matches[sequence.ln] || "")) || 0;
717
+ }
718
+ else {
719
+ _parseFilename(theFrame, matches[sequence.fn] || "");
720
+ }
721
+ }
722
+ // We found a match so stop looking
723
+ break;
724
+ }
725
+ idx++;
726
+ }
727
+ }
728
+ return _populateFrameSizeInBytes(theFrame);
729
+ }
730
+ function _stackFrameFromInterface(frame) {
731
+ var _a;
732
+ var parsedFrame = (_a = {},
733
+ _a[_DYN_AI_DATA_CONTRACT /* @min:aiDataContract */] = stackFrameAiDataContract,
734
+ _a.level = frame[_DYN_LEVEL /* @min:%2elevel */],
735
+ _a.method = frame[_DYN_METHOD /* @min:%2emethod */],
736
+ _a.assembly = frame[_DYN_ASSEMBLY /* @min:%2eassembly */],
737
+ _a.fileName = frame[_DYN_FILE_NAME /* @min:%2efileName */],
738
+ _a.line = frame[_DYN_LINE /* @min:%2eline */],
739
+ _a[_DYN_SIZE_IN_BYTES /* @min:sizeInBytes */] = 0,
740
+ _a);
741
+ return _populateFrameSizeInBytes(parsedFrame);
742
+ }
743
+ function _populateFrameSizeInBytes(frame) {
744
+ var sizeInBytes = STACKFRAME_BASE_SIZE;
745
+ if (frame) {
746
+ sizeInBytes += frame.method[_DYN_LENGTH /* @min:%2elength */];
747
+ sizeInBytes += frame.assembly[_DYN_LENGTH /* @min:%2elength */];
748
+ sizeInBytes += frame.fileName[_DYN_LENGTH /* @min:%2elength */];
749
+ sizeInBytes += frame.level.toString()[_DYN_LENGTH /* @min:%2elength */];
750
+ sizeInBytes += frame.line.toString()[_DYN_LENGTH /* @min:%2elength */];
751
+ frame[_DYN_SIZE_IN_BYTES /* @min:%2esizeInBytes */] = sizeInBytes;
752
+ }
753
+ return frame;
754
+ }
755
+ export function _parsedFrameToInterface(frame) {
756
+ return {
757
+ level: frame[_DYN_LEVEL /* @min:%2elevel */],
758
+ method: frame[_DYN_METHOD /* @min:%2emethod */],
759
+ assembly: frame[_DYN_ASSEMBLY /* @min:%2eassembly */],
760
+ fileName: frame[_DYN_FILE_NAME /* @min:%2efileName */],
761
+ line: frame[_DYN_LINE /* @min:%2eline */]
522
762
  };
523
- // regex to match stack frames from ie/chrome/ff
524
- // methodName=$2, fileName=$4, lineNo=$5, column=$6
525
- _StackFrame.regex = /^([\s]+at)?[\s]{0,50}([^\@\()]+?)[\s]{0,50}(\@|\()([^\(\n]+):([0-9]+):([0-9]+)(\)?)$/;
526
- _StackFrame.baseSize = 58; // '{"method":"","level":,"assembly":"","fileName":"","line":}'.length
527
- return _StackFrame;
528
- }());
529
- export { _StackFrame };
763
+ }
530
764
  //# sourceMappingURL=Exception.js.map