@microsoft/sp-diagnostics 1.23.2 → 1.24.0-beta.3

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 (223) hide show
  1. package/dist/78359e4b-07c2-43c6-8d0b-d060b4d577e8.manifest.json +6 -11
  2. package/dist/index-internal-beta.d.ts +22 -0
  3. package/dist/index-internal-public.d.ts +22 -0
  4. package/dist/index-internal.d.ts +22 -0
  5. package/dist/sp-diagnostics_none_ebdbca9bc199b51d4466.js +1 -0
  6. package/dist/tsdoc-metadata.json +1 -1
  7. package/lib-commonjs/Api/Engagement/EngagementLogger.js +91 -96
  8. package/lib-commonjs/Api/Engagement/IEngagementHandler.js +9 -3
  9. package/lib-commonjs/Api/ExecutionQueue.js +73 -86
  10. package/lib-commonjs/Api/ILogData.js +6 -3
  11. package/lib-commonjs/Api/ILogEntry.js +5 -2
  12. package/lib-commonjs/Api/ILogErrorData.js +6 -3
  13. package/lib-commonjs/Api/ILogSource.js +10 -3
  14. package/lib-commonjs/Api/ILogVerboseData.js +6 -3
  15. package/lib-commonjs/Api/Log/LogHandler.js +27 -26
  16. package/lib-commonjs/Api/LogEntry.js +40 -39
  17. package/lib-commonjs/Api/LogFeature.js +14 -10
  18. package/lib-commonjs/Api/LogLevel.js +22 -19
  19. package/lib-commonjs/Api/LogManager/CircularBuffer.js +56 -64
  20. package/lib-commonjs/Api/LogManager/LogManager.js +61 -78
  21. package/lib-commonjs/Api/LogSource.js +37 -35
  22. package/lib-commonjs/Api/LogType.js +20 -15
  23. package/lib-commonjs/Api/Qos/AutoAlertableQosMonitor.js +68 -82
  24. package/lib-commonjs/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.js +5 -2
  25. package/lib-commonjs/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.js +5 -2
  26. package/lib-commonjs/Api/Qos/IQos.js +5 -2
  27. package/lib-commonjs/Api/Qos/IQosEndEvent.js +5 -2
  28. package/lib-commonjs/Api/Qos/IQosExtraData.js +15 -3
  29. package/lib-commonjs/Api/Qos/IQosStartEvent.js +9 -3
  30. package/lib-commonjs/Api/Qos/QosLogger.js +54 -60
  31. package/lib-commonjs/Api/Qos/QosMonitor.js +163 -209
  32. package/lib-commonjs/Api/Qos/QosMonitorShareFailureWithCP.js +72 -92
  33. package/lib-commonjs/Api/Qos/QosResultType.js +14 -7
  34. package/lib-commonjs/Api/Trace/DefaultTraceHandler.js +20 -22
  35. package/lib-commonjs/Api/Trace/ITraceHandler.js +9 -3
  36. package/lib-commonjs/Api/Trace/ITraceLogger.js +5 -2
  37. package/lib-commonjs/Api/Trace/LogEvent.js +86 -125
  38. package/lib-commonjs/Api/Trace/TraceLogger.js +149 -161
  39. package/lib-commonjs/Diagnostics.js +68 -72
  40. package/lib-commonjs/DiagnosticsSettingsManager.js +48 -43
  41. package/lib-commonjs/IDiagnosticsSettings.js +5 -2
  42. package/lib-commonjs/common/Killswitches.js +13 -9
  43. package/lib-commonjs/extraData/DisplayApp.js +13 -5
  44. package/lib-commonjs/extraData/IDiagnosticContextInfo.js +5 -2
  45. package/lib-commonjs/extraData/IPageExtraData.js +5 -2
  46. package/lib-commonjs/extraData/PageType.js +15 -8
  47. package/lib-commonjs/extraData/PromotedState.js +18 -13
  48. package/lib-commonjs/extraData/WebTemplateId.js +13 -5
  49. package/lib-commonjs/extraData/setPageExtraData.js +37 -37
  50. package/lib-commonjs/index.js +102 -50
  51. package/{lib → lib-dts}/Api/Engagement/IEngagementHandler.d.ts +2 -0
  52. package/{lib → lib-dts}/Diagnostics.d.ts +11 -0
  53. package/{lib → lib-dts}/DiagnosticsSettingsManager.d.ts +4 -0
  54. package/lib-esm/Api/Engagement/EngagementLogger.js +137 -0
  55. package/lib-esm/Api/Engagement/IEngagementHandler.js +9 -0
  56. package/lib-esm/Api/ExecutionQueue.js +114 -0
  57. package/lib-esm/Api/ILogData.js +4 -0
  58. package/lib-esm/Api/ILogEntry.js +3 -0
  59. package/lib-esm/Api/ILogErrorData.js +4 -0
  60. package/lib-esm/Api/ILogSource.js +8 -0
  61. package/lib-esm/Api/ILogVerboseData.js +4 -0
  62. package/lib-esm/Api/Log/LogHandler.js +37 -0
  63. package/lib-esm/Api/LogEntry.js +44 -0
  64. package/lib-esm/Api/LogFeature.js +8 -0
  65. package/lib-esm/Api/LogLevel.js +20 -0
  66. package/lib-esm/Api/LogManager/CircularBuffer.js +83 -0
  67. package/lib-esm/Api/LogManager/LogManager.js +103 -0
  68. package/lib-esm/Api/LogSource.js +32 -0
  69. package/lib-esm/Api/LogType.js +20 -0
  70. package/lib-esm/Api/Qos/AutoAlertableQosMonitor.js +74 -0
  71. package/lib-esm/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.js +6 -0
  72. package/lib-esm/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.js +6 -0
  73. package/lib-esm/Api/Qos/IQos.js +6 -0
  74. package/lib-esm/Api/Qos/IQosEndEvent.js +6 -0
  75. package/lib-esm/Api/Qos/IQosExtraData.js +12 -0
  76. package/lib-esm/Api/Qos/IQosStartEvent.js +6 -0
  77. package/lib-esm/Api/Qos/QosLogger.js +64 -0
  78. package/lib-esm/Api/Qos/QosMonitor.js +258 -0
  79. package/lib-esm/Api/Qos/QosMonitorShareFailureWithCP.js +89 -0
  80. package/lib-esm/Api/Qos/QosResultType.js +11 -0
  81. package/lib-esm/Api/Trace/DefaultTraceHandler.js +23 -0
  82. package/lib-esm/Api/Trace/ITraceHandler.js +9 -0
  83. package/lib-esm/Api/Trace/ITraceLogger.js +3 -0
  84. package/lib-esm/Api/Trace/LogEvent.js +104 -0
  85. package/lib-esm/Api/Trace/TraceLogger.js +180 -0
  86. package/lib-esm/Diagnostics.js +78 -0
  87. package/lib-esm/DiagnosticsSettingsManager.js +65 -0
  88. package/lib-esm/IDiagnosticsSettings.js +3 -0
  89. package/{lib → lib-esm}/common/Killswitches.js +3 -4
  90. package/{lib → lib-esm}/extraData/DisplayApp.js +3 -2
  91. package/lib-esm/extraData/IDiagnosticContextInfo.js +7 -0
  92. package/lib-esm/extraData/IPageExtraData.js +3 -0
  93. package/{lib → lib-esm}/extraData/PageType.js +4 -4
  94. package/lib-esm/extraData/PromotedState.js +15 -0
  95. package/{lib → lib-esm}/extraData/WebTemplateId.js +3 -2
  96. package/{lib → lib-esm}/extraData/setPageExtraData.js +14 -20
  97. package/{lib → lib-esm}/index.js +3 -3
  98. package/package.json +33 -6
  99. package/dist/sp-diagnostics_none_414da724f4073ce8bb98.js +0 -1
  100. package/lib/Api/Engagement/EngagementLogger.d.ts.map +0 -1
  101. package/lib/Api/Engagement/EngagementLogger.js +0 -143
  102. package/lib/Api/Engagement/IEngagementHandler.d.ts.map +0 -1
  103. package/lib/Api/Engagement/IEngagementHandler.js +0 -2
  104. package/lib/Api/ExecutionQueue.d.ts.map +0 -1
  105. package/lib/Api/ExecutionQueue.js +0 -131
  106. package/lib/Api/ILogData.d.ts.map +0 -1
  107. package/lib/Api/ILogData.js +0 -3
  108. package/lib/Api/ILogEntry.d.ts.map +0 -1
  109. package/lib/Api/ILogEntry.js +0 -2
  110. package/lib/Api/ILogErrorData.d.ts.map +0 -1
  111. package/lib/Api/ILogErrorData.js +0 -3
  112. package/lib/Api/ILogSource.d.ts.map +0 -1
  113. package/lib/Api/ILogSource.js +0 -3
  114. package/lib/Api/ILogVerboseData.d.ts.map +0 -1
  115. package/lib/Api/ILogVerboseData.js +0 -3
  116. package/lib/Api/Log/LogHandler.d.ts.map +0 -1
  117. package/lib/Api/Log/LogHandler.js +0 -40
  118. package/lib/Api/LogEntry.d.ts.map +0 -1
  119. package/lib/Api/LogEntry.js +0 -51
  120. package/lib/Api/LogFeature.d.ts.map +0 -1
  121. package/lib/Api/LogFeature.js +0 -11
  122. package/lib/Api/LogLevel.d.ts.map +0 -1
  123. package/lib/Api/LogLevel.js +0 -24
  124. package/lib/Api/LogManager/CircularBuffer.d.ts.map +0 -1
  125. package/lib/Api/LogManager/CircularBuffer.js +0 -98
  126. package/lib/Api/LogManager/LogManager.d.ts.map +0 -1
  127. package/lib/Api/LogManager/LogManager.js +0 -121
  128. package/lib/Api/LogSource.d.ts.map +0 -1
  129. package/lib/Api/LogSource.js +0 -40
  130. package/lib/Api/LogType.d.ts.map +0 -1
  131. package/lib/Api/LogType.js +0 -23
  132. package/lib/Api/Qos/AutoAlertableQosMonitor.d.ts.map +0 -1
  133. package/lib/Api/Qos/AutoAlertableQosMonitor.js +0 -93
  134. package/lib/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.d.ts.map +0 -1
  135. package/lib/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.js +0 -2
  136. package/lib/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.d.ts.map +0 -1
  137. package/lib/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.js +0 -2
  138. package/lib/Api/Qos/IQos.d.ts.map +0 -1
  139. package/lib/Api/Qos/IQos.js +0 -2
  140. package/lib/Api/Qos/IQosEndEvent.d.ts.map +0 -1
  141. package/lib/Api/Qos/IQosEndEvent.js +0 -2
  142. package/lib/Api/Qos/IQosExtraData.d.ts.map +0 -1
  143. package/lib/Api/Qos/IQosExtraData.js +0 -2
  144. package/lib/Api/Qos/IQosStartEvent.d.ts.map +0 -1
  145. package/lib/Api/Qos/IQosStartEvent.js +0 -2
  146. package/lib/Api/Qos/QosLogger.d.ts.map +0 -1
  147. package/lib/Api/Qos/QosLogger.js +0 -74
  148. package/lib/Api/Qos/QosMonitor.d.ts.map +0 -1
  149. package/lib/Api/Qos/QosMonitor.js +0 -304
  150. package/lib/Api/Qos/QosMonitorShareFailureWithCP.d.ts.map +0 -1
  151. package/lib/Api/Qos/QosMonitorShareFailureWithCP.js +0 -114
  152. package/lib/Api/Qos/QosResultType.d.ts.map +0 -1
  153. package/lib/Api/Qos/QosResultType.js +0 -11
  154. package/lib/Api/Trace/DefaultTraceHandler.d.ts.map +0 -1
  155. package/lib/Api/Trace/DefaultTraceHandler.js +0 -30
  156. package/lib/Api/Trace/ITraceHandler.d.ts.map +0 -1
  157. package/lib/Api/Trace/ITraceHandler.js +0 -2
  158. package/lib/Api/Trace/ITraceLogger.d.ts.map +0 -1
  159. package/lib/Api/Trace/ITraceLogger.js +0 -2
  160. package/lib/Api/Trace/LogEvent.d.ts.map +0 -1
  161. package/lib/Api/Trace/LogEvent.js +0 -147
  162. package/lib/Api/Trace/TraceLogger.d.ts.map +0 -1
  163. package/lib/Api/Trace/TraceLogger.js +0 -196
  164. package/lib/Diagnostics.d.ts.map +0 -1
  165. package/lib/Diagnostics.js +0 -82
  166. package/lib/DiagnosticsSettingsManager.d.ts.map +0 -1
  167. package/lib/DiagnosticsSettingsManager.js +0 -62
  168. package/lib/IDiagnosticsSettings.d.ts.map +0 -1
  169. package/lib/IDiagnosticsSettings.js +0 -2
  170. package/lib/common/Killswitches.d.ts.map +0 -1
  171. package/lib/extraData/DisplayApp.d.ts.map +0 -1
  172. package/lib/extraData/IDiagnosticContextInfo.d.ts.map +0 -1
  173. package/lib/extraData/IDiagnosticContextInfo.js +0 -2
  174. package/lib/extraData/IPageExtraData.d.ts.map +0 -1
  175. package/lib/extraData/IPageExtraData.js +0 -2
  176. package/lib/extraData/PageType.d.ts.map +0 -1
  177. package/lib/extraData/PromotedState.d.ts.map +0 -1
  178. package/lib/extraData/PromotedState.js +0 -17
  179. package/lib/extraData/WebTemplateId.d.ts.map +0 -1
  180. package/lib/extraData/setPageExtraData.d.ts.map +0 -1
  181. package/lib/index.d.ts.map +0 -1
  182. /package/{lib → lib-dts}/Api/Engagement/EngagementLogger.d.ts +0 -0
  183. /package/{lib → lib-dts}/Api/ExecutionQueue.d.ts +0 -0
  184. /package/{lib → lib-dts}/Api/ILogData.d.ts +0 -0
  185. /package/{lib → lib-dts}/Api/ILogEntry.d.ts +0 -0
  186. /package/{lib → lib-dts}/Api/ILogErrorData.d.ts +0 -0
  187. /package/{lib → lib-dts}/Api/ILogSource.d.ts +0 -0
  188. /package/{lib → lib-dts}/Api/ILogVerboseData.d.ts +0 -0
  189. /package/{lib → lib-dts}/Api/Log/LogHandler.d.ts +0 -0
  190. /package/{lib → lib-dts}/Api/LogEntry.d.ts +0 -0
  191. /package/{lib → lib-dts}/Api/LogFeature.d.ts +0 -0
  192. /package/{lib → lib-dts}/Api/LogLevel.d.ts +0 -0
  193. /package/{lib → lib-dts}/Api/LogManager/CircularBuffer.d.ts +0 -0
  194. /package/{lib → lib-dts}/Api/LogManager/LogManager.d.ts +0 -0
  195. /package/{lib → lib-dts}/Api/LogSource.d.ts +0 -0
  196. /package/{lib → lib-dts}/Api/LogType.d.ts +0 -0
  197. /package/{lib → lib-dts}/Api/Qos/AutoAlertableQosMonitor.d.ts +0 -0
  198. /package/{lib → lib-dts}/Api/Qos/CustomerPromiseInterfaces/ICustomerPromiseErrorDetails.d.ts +0 -0
  199. /package/{lib → lib-dts}/Api/Qos/CustomerPromiseInterfaces/IExtraDataForCustomerPromise.d.ts +0 -0
  200. /package/{lib → lib-dts}/Api/Qos/IQos.d.ts +0 -0
  201. /package/{lib → lib-dts}/Api/Qos/IQosEndEvent.d.ts +0 -0
  202. /package/{lib → lib-dts}/Api/Qos/IQosExtraData.d.ts +0 -0
  203. /package/{lib → lib-dts}/Api/Qos/IQosStartEvent.d.ts +0 -0
  204. /package/{lib → lib-dts}/Api/Qos/QosLogger.d.ts +0 -0
  205. /package/{lib → lib-dts}/Api/Qos/QosMonitor.d.ts +0 -0
  206. /package/{lib → lib-dts}/Api/Qos/QosMonitorShareFailureWithCP.d.ts +0 -0
  207. /package/{lib → lib-dts}/Api/Qos/QosResultType.d.ts +0 -0
  208. /package/{lib → lib-dts}/Api/Trace/DefaultTraceHandler.d.ts +0 -0
  209. /package/{lib → lib-dts}/Api/Trace/ITraceHandler.d.ts +0 -0
  210. /package/{lib → lib-dts}/Api/Trace/ITraceLogger.d.ts +0 -0
  211. /package/{lib → lib-dts}/Api/Trace/LogEvent.d.ts +0 -0
  212. /package/{lib → lib-dts}/Api/Trace/TraceLogger.d.ts +0 -0
  213. /package/{lib → lib-dts}/IDiagnosticsSettings.d.ts +0 -0
  214. /package/{lib → lib-dts}/common/Killswitches.d.ts +0 -0
  215. /package/{lib → lib-dts}/extraData/DisplayApp.d.ts +0 -0
  216. /package/{lib → lib-dts}/extraData/IDiagnosticContextInfo.d.ts +0 -0
  217. /package/{lib → lib-dts}/extraData/IPageExtraData.d.ts +0 -0
  218. /package/{lib → lib-dts}/extraData/PageType.d.ts +0 -0
  219. /package/{lib → lib-dts}/extraData/PromotedState.d.ts +0 -0
  220. /package/{lib → lib-dts}/extraData/WebTemplateId.d.ts +0 -0
  221. /package/{lib → lib-dts}/extraData/setPageExtraData.d.ts +0 -0
  222. /package/{lib → lib-dts}/index.d.ts +0 -0
  223. /package/{lib → lib-esm}/sp-diagnostics.manifest.json +0 -0
@@ -0,0 +1,64 @@
1
+ import ExecutionQueue from '../ExecutionQueue';
2
+ class QosLogger {
3
+ static get instance() {
4
+ if (!this._instance) {
5
+ this._instance = new QosLogger();
6
+ }
7
+ return this._instance;
8
+ }
9
+ get shouldProcessInRealTime() {
10
+ return this._shouldProcessInRealTime;
11
+ }
12
+ set shouldProcessInRealTime(processInRealTime) {
13
+ this._shouldProcessInRealTime = processInRealTime;
14
+ this._deferExecutor.shouldExecuteInRealTime = processInRealTime;
15
+ }
16
+ setLogger(qosLogger) {
17
+ this._qosLogger = qosLogger;
18
+ }
19
+ getQosEvent(key) {
20
+ return this._qosEvents.get(key);
21
+ }
22
+ startQosMonitor(key, startData) {
23
+ if (!this._qosEvents.has(key)) {
24
+ this._deferExecutor.addExecutionEntry('start', key, startData);
25
+ }
26
+ }
27
+ writeQosEndResult(key, endData) {
28
+ this._deferExecutor.addExecutionEntry('end', key, endData);
29
+ }
30
+ _startMonitor(key, event) {
31
+ if (this._qosLogger) {
32
+ this._qosEvents.set(key, new this._qosLogger(event));
33
+ }
34
+ }
35
+ _endMonitor(key, event) {
36
+ const qosEvent = this._qosEvents.get(key);
37
+ if (qosEvent) {
38
+ qosEvent.end(event);
39
+ this._qosEvents.delete(key);
40
+ }
41
+ }
42
+ _initializeLogger() {
43
+ const startHandler = (key, e)=>{
44
+ this._startMonitor(key, e);
45
+ };
46
+ const endHandler = (key, e)=>{
47
+ this._endMonitor(key, e);
48
+ };
49
+ this._deferExecutor.addHandler('start', startHandler);
50
+ this._deferExecutor.addHandler('end', endHandler);
51
+ }
52
+ constructor(){
53
+ this._qosEvents = new Map();
54
+ this._deferExecutor = new ExecutionQueue();
55
+ this._shouldProcessInRealTime = false;
56
+ this._initializeLogger();
57
+ }
58
+ }
59
+ /**
60
+ * QosLogger allows multiple QosMonitors to be deferred processed.
61
+ * @internal
62
+ */ export { QosLogger as default };
63
+
64
+ //# sourceMappingURL=./QosLogger.js.map
@@ -0,0 +1,258 @@
1
+ import { _BrowserUtilities, _SPKillSwitch } from '@microsoft/sp-core-library';
2
+ // Copyright (c) Microsoft. All rights reserved.
3
+ import { Guid, Text, Validate } from '@microsoft/sp-core-library';
4
+ import { getErrorMessage, getQosEndSchemaFromError, CustomError } from '@msinternal/odsp-core-bundle';
5
+ import TraceLogger from '../Trace/TraceLogger';
6
+ import { QosResultType } from './QosResultType';
7
+ import QosLogger from './QosLogger';
8
+ import EngagementLogger from '../Engagement/EngagementLogger';
9
+ import Diagnostics from '../../Diagnostics';
10
+ import DiagnosticsSettingsManager from '../../DiagnosticsSettingsManager';
11
+ import { merge } from '@microsoft/sp-lodash-subset';
12
+ const LOG_SOURCE = {
13
+ id: 'QosMonitor'
14
+ };
15
+ const QOS_MONISTOR_HAS_ENDED_ERROR_STRING = "QoS monitor '{0}' has ended with '{1}' already. Ignoring '{2}' tag.";
16
+ const AUTHORING_SESSION_ID_KEY = 'AuthoringSessionId';
17
+ const AUTHORING_OP_SEQUENCE_ID_KEY = 'AuthoringOpSequenceId';
18
+ const AUTHORING_SESSION_CLIENT_COUNT = 'AuthoringSessionClientCount';
19
+ class QosMonitor {
20
+ static startRealTimeProcessing() {
21
+ if (!QosLogger.instance.shouldProcessInRealTime) {
22
+ this._shouldProcessInRealTime(true);
23
+ }
24
+ }
25
+ /**
26
+ * Only used in unit tests
27
+ * @internal
28
+ */ static _shouldProcessInRealTime(processInRealTime) {
29
+ QosLogger.instance.shouldProcessInRealTime = processInRealTime;
30
+ }
31
+ get name() {
32
+ return this._scenarioName;
33
+ }
34
+ get shortEventName() {
35
+ return 'Qos';
36
+ }
37
+ get resultCode() {
38
+ return this._endResultCode;
39
+ }
40
+ get resultType() {
41
+ return this._endResult;
42
+ }
43
+ get extraData() {
44
+ return this._endExtraData;
45
+ }
46
+ set extraData(value) {
47
+ this._endExtraData = value;
48
+ }
49
+ get hasEnded() {
50
+ return this._hasEnded;
51
+ }
52
+ /**
53
+ * QoS monitor ends with success
54
+ * You will see success tag: SPPages.ScenarioName.Success
55
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ writeSuccess(extraData) {
57
+ this._writeQosEnd(QosResultType.Success, undefined, undefined, extraData);
58
+ }
59
+ /**
60
+ * QoS monitor ends with failure
61
+ * You will see failure tag: SPPages.ScenarioName.<failuretag>.Failure.
62
+ * <failuretag> will be filled with param tagName
63
+ */ writeUnexpectedFailure(tagNameSuffix = 'DefaultUnexpected', ex, // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
+ extraData) {
65
+ this._writeQosEnd(QosResultType.Failure, tagNameSuffix, ex, extraData);
66
+ }
67
+ /*
68
+ * QoS monitor ends with expected failure
69
+ * You will see success tag: ModernPublish.RenderPublishPage.<failuretag>.ExpectedFailure.
70
+ * <failuretag> will be filled with param tagName
71
+ */ writeExpectedFailure(tagNameSuffix = 'DefaultExpected', ex, // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
+ extraData) {
73
+ this._writeQosEnd(QosResultType.ExpectedFailure, tagNameSuffix, ex, extraData);
74
+ }
75
+ _writeQosEnd(resultType, tagNameSuffix, ex, // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ extraData) {
77
+ if (this._shouldSkip(resultType)) {
78
+ return;
79
+ }
80
+ this._ensureCorrelationId(resultType, extraData);
81
+ this._endResultCode = tagNameSuffix;
82
+ this._endResult = resultType;
83
+ const errorString = !ex ? undefined : getErrorMessage(ex);
84
+ if (ex instanceof CustomError) {
85
+ const endSchema = getQosEndSchemaFromError(ex);
86
+ if (endSchema) {
87
+ endSchema.resultType = this._endResult;
88
+ // Make sure the extraData from `endSchema` takes priority so that
89
+ // extra data like correlation id from the error object is logged
90
+ // instead of the generic extra data from `_endExtraData`.
91
+ endSchema.extraData = merge({}, this._endExtraData, endSchema.extraData);
92
+ }
93
+ QosLogger.instance.writeQosEndResult(this._id, endSchema);
94
+ } else {
95
+ const endData = {
96
+ resultCode: this._endResultCode,
97
+ resultType: this._endResult,
98
+ error: errorString,
99
+ extraData: this._endExtraData
100
+ };
101
+ QosLogger.instance.writeQosEndResult(this._id, endData);
102
+ }
103
+ this._writeToEngagement();
104
+ }
105
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
+ _ensureCorrelationId(resultType, extraData) {
107
+ if (extraData) {
108
+ this._ensureEndExtraData();
109
+ // Instead of slower ...[spread], copy over the incoming values manually
110
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
111
+ Object.keys(extraData).forEach((k)=>this._endExtraData[k] = extraData[k]);
112
+ }
113
+ if (DiagnosticsSettingsManager.isInitialized && resultType !== QosResultType.Success) {
114
+ const capitalKey = 'CorrelationId';
115
+ const lowerKey = 'correlationId';
116
+ const correlationId = this._endExtraData && (this._endExtraData[capitalKey] || this._endExtraData[lowerKey]) || DiagnosticsSettingsManager.settings.correlationId;
117
+ if (correlationId) {
118
+ if (!this._endExtraData) {
119
+ this._endExtraData = {};
120
+ }
121
+ this._endExtraData[capitalKey] = correlationId;
122
+ }
123
+ }
124
+ this._logHostType();
125
+ this._ensureAuthoringSessionId();
126
+ }
127
+ _ensureEndExtraData() {
128
+ if (!this._endExtraData) {
129
+ this._endExtraData = {};
130
+ }
131
+ }
132
+ /**
133
+ * Logs the application hosted in Teams in combination with which Teams application it was hosted on.
134
+ * Viva1p-TeamsNative: Viva home app loaded through Teams Desktop application, not including mobile
135
+ * Viva1p-TeamsWeb: Viva home app loaded through Teams Web browser, not including mobile
136
+ * MEEBridge-TeamsNative: VivaConnections MEEBridge app loaded through Teams mobile client.
137
+ * ClassHome-TeamsNative: ClassHome app loaded through Teams Desktop application, not including mobile
138
+ * ClassHome-TeamsWeb: ClassHome app loaded through Teams Web browser, not including mobile
139
+ */ _logHostType() {
140
+ if (DiagnosticsSettingsManager.isInitialized) {
141
+ const appHostType = _BrowserUtilities.getTeamsAppType();
142
+ // Skip logging for default SPO path for now to limit quota impact
143
+ if (appHostType) {
144
+ this._ensureEndExtraData();
145
+ const hostKey = 'appHostType';
146
+ // Unlikely, but avoid overwriting matching key value
147
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
148
+ if (!this._endExtraData[hostKey]) {
149
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
150
+ this._endExtraData[hostKey] = appHostType;
151
+ }
152
+ }
153
+ }
154
+ }
155
+ _isDebugSession() {
156
+ try {
157
+ if (!_SPKillSwitch.isActivated('761ccb86-4fa0-4f56-a05b-477bcc09bd9f' /* '08/01/2024', 'finnnavin: Let QoSMonitor run in debug, uploading is blocked at SDK-level.' */ )) {
158
+ return false;
159
+ } else {
160
+ return !!_BrowserUtilities.safelyAccessSessionStorage('spfx-debug');
161
+ }
162
+ } catch {
163
+ // KillSwitches throw exceptions when not initialized.
164
+ // Currently this only happens when spfx-debug is present, so telemetry isn't being logged by the handler, and we can return false.
165
+ return false;
166
+ }
167
+ }
168
+ _shouldSkip(result) {
169
+ if (this._hasEnded && this._endResult !== undefined) {
170
+ const message = Text.format(QOS_MONISTOR_HAS_ENDED_ERROR_STRING, this.name, this._qosResultTypeValue[this._endResult], this._qosResultTypeValue[result]);
171
+ if (this._endResult !== result) {
172
+ TraceLogger.logError(LOG_SOURCE, new Error(message));
173
+ }
174
+ if (DEBUG) {
175
+ TraceLogger.logVerbose(LOG_SOURCE, message, 'skipEnd');
176
+ }
177
+ return true;
178
+ } else {
179
+ this._hasEnded = true;
180
+ return this._isDebugSession();
181
+ }
182
+ }
183
+ _writeToEngagement() {
184
+ if (this._copyToInterana) {
185
+ EngagementLogger.log({
186
+ name: this.name,
187
+ isIntentional: !!(this.extraData || {}).isIntentional,
188
+ extraData: this.extraData || {}
189
+ });
190
+ }
191
+ if (this._copyToCosmos) {
192
+ // Engagement name requires certain format. Cannot just use QOS name.
193
+ // Record Qos name in extra data 'qosName'
194
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
195
+ const engagementData = {
196
+ name: 'Spfx.Qos.ToEngagement',
197
+ extraData: this.extraData || {}
198
+ };
199
+ engagementData.extraData.qosName = this.name;
200
+ if (this.resultType) {
201
+ engagementData.extraData.qosResultType = this._qosResultTypeValue[this.resultType];
202
+ }
203
+ if (this.resultCode) {
204
+ engagementData.extraData.qosResultCode = this.resultCode;
205
+ }
206
+ EngagementLogger.log(engagementData);
207
+ }
208
+ }
209
+ /**
210
+ * Creates a QoS monitor (initializes it and logs the start event)
211
+ * @param scenarioName - Unique name of the QoS scenario
212
+ * You will see start tag: SPPages.ScenarioName.Start
213
+ * @param copyToCosmos - Indicate whether this data should be used as Engagement as well, and sent to COSMOS.
214
+ * @param copyToInterana - Indicate whether this data should be used as Engagement as well, and sent to Interana.
215
+ */ constructor(scenarioName, copyToCosmos = false, copyToInterana = false){
216
+ this._qosResultTypeValue = {
217
+ [QosResultType.Success]: 'Success',
218
+ [QosResultType.Failure]: 'Failure',
219
+ [QosResultType.ExpectedFailure]: 'ExpectedFailure'
220
+ };
221
+ this._ensureAuthoringSessionId = ()=>{
222
+ const authoringSessionId = DiagnosticsSettingsManager.settings?.extraDiagnosticInfo?.authoringSessionId;
223
+ if (authoringSessionId) {
224
+ this._ensureEndExtraData();
225
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
226
+ this._endExtraData[AUTHORING_SESSION_ID_KEY] = authoringSessionId;
227
+ const authoringOpSequenceId = DiagnosticsSettingsManager.settings?.extraDiagnosticInfo?.authoringOpSequenceId;
228
+ if (authoringOpSequenceId) {
229
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
230
+ this._endExtraData[AUTHORING_OP_SEQUENCE_ID_KEY] = authoringOpSequenceId;
231
+ }
232
+ const authoringSessionClientCount = Diagnostics.getAuthoringSessionClientCountInfo();
233
+ if (authoringSessionClientCount && this._endExtraData) {
234
+ this._endExtraData[AUTHORING_SESSION_CLIENT_COUNT] = authoringSessionClientCount;
235
+ }
236
+ }
237
+ };
238
+ Validate.isNonemptyString(scenarioName, 'scenarioName');
239
+ this._id = Guid.newGuid().toString();
240
+ if (!this._isDebugSession()) {
241
+ QosLogger.instance.startQosMonitor(this._id, {
242
+ name: scenarioName
243
+ });
244
+ }
245
+ this._scenarioName = scenarioName;
246
+ this._hasEnded = false;
247
+ this._copyToCosmos = copyToCosmos;
248
+ this._copyToInterana = copyToInterana;
249
+ }
250
+ }
251
+ /**
252
+ * Qos logger
253
+ * This class represents the Qos monitor APIs
254
+ *
255
+ * @internal
256
+ */ export { QosMonitor as default };
257
+
258
+ //# sourceMappingURL=./QosMonitor.js.map
@@ -0,0 +1,89 @@
1
+ import QosMonitor from './QosMonitor';
2
+ import { QosResultType } from './QosResultType';
3
+ import _Diagnostics from '../../Diagnostics';
4
+ import { isAppendSuffixIfBrowserIsOfflineAtLoggingTimeKsActive } from '../../common/Killswitches';
5
+ /**
6
+ * Monitor which handles failures for QosMonitor and also invokes Customer Promise Handlers to record failure
7
+ * @internal
8
+ */ export class QosMonitorShareFailureWithCP extends QosMonitor {
9
+ /**
10
+ * QoS monitor ends with failure and invokes the Customer Promise handlers
11
+ * to log a failure
12
+ * @internal
13
+ *
14
+ * You will see failure tag: SPPages.ScenarioName.<failuretag>.Failure.
15
+ * <failuretag> will be filled with param tagName
16
+ */ writeUnexpectedFailure(tagNameSuffix = 'DefaultUnexpected', ex, // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ extraData) {
18
+ super.writeUnexpectedFailure(tagNameSuffix, ex, extraData);
19
+ this._logCustomerPromiseFailure(ex?.message || 'DefaultErrorMessage', tagNameSuffix, QosResultType.Failure, extraData);
20
+ }
21
+ /**
22
+ * QoS monitor ends with expected failure and invokes the Customer Promise handlers
23
+ * to log an expected failure
24
+ * @internal
25
+ *
26
+ * You will see success tag: ModernPublish.RenderPublishPage.<failuretag>.ExpectedFailure.
27
+ * <failuretag> will be filled with param tagName
28
+ */ writeExpectedFailure(tagNameSuffix = 'DefaultExpected', ex, // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ extraData, skipLoggingCustomerPromiseFailure = false) {
30
+ super.writeExpectedFailure(tagNameSuffix, ex, extraData);
31
+ if (!skipLoggingCustomerPromiseFailure) {
32
+ this._logCustomerPromiseFailure(ex?.message || 'DefaultErrorMessage', tagNameSuffix, QosResultType.ExpectedFailure, extraData);
33
+ }
34
+ }
35
+ /**
36
+ * Invokes the registered Customer Promise Handlers by using the passed in serviceKey
37
+ * @param errorMessage - Information to indicate which scenario failed.
38
+ * @param errorScenario -Additional error details describing the failure from the module.
39
+ * @param resultType - ResultTypeEnum used to indicate expected or unexpected failure.
40
+ * @param extraData - Additional information to be logged, which might include pageType and/or errorStack
41
+ */ _logCustomerPromiseFailure(errorMessage, errorScenario, resultType = QosResultType.Failure, // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
+ extraData) {
43
+ if (this._extraDataForCustomerPromise) {
44
+ this._extraDataForCustomerPromise.forEach((extraHandlerInfo)=>{
45
+ const { logFailure, veto } = extraHandlerInfo;
46
+ const errorModuleName = extraHandlerInfo.errorModuleName + getAuthoringSuffix() + (!isAppendSuffixIfBrowserIsOfflineAtLoggingTimeKsActive() ? getOfflineSuffix() : '');
47
+ const errorDetailsForCP = {
48
+ errorCode: errorModuleName,
49
+ errorScenario,
50
+ errorMessage,
51
+ resultType,
52
+ pageType: extraData?.pageType,
53
+ errorStack: extraData?.errorStack,
54
+ veto
55
+ };
56
+ logFailure(errorDetailsForCP);
57
+ });
58
+ }
59
+ }
60
+ /**
61
+ * Creates a QoS monitor and also registers the Customer promise handlers to notify in case of failures
62
+ * @internal
63
+ *
64
+ * @param scenarioName - Unique name of the QoS scenario
65
+ * @param copyToEngagement - indicate whether this data should be used as Engagement as well.
66
+ * @param extraDataForCustomerPromise - Holds extra information about Customer Promise handlers to invoke
67
+ * and error information where failures are logged
68
+ */ constructor(scenarioName, copyToEngagement = false, extraDataForCustomerPromise, copyToCosmos = false){
69
+ super(scenarioName, /* copyToCosmos */ copyToCosmos, /* copyToInterana */ copyToEngagement);
70
+ this._extraDataForCustomerPromise = extraDataForCustomerPromise;
71
+ }
72
+ }
73
+ function getAuthoringSuffix() {
74
+ const extraDiagnosticInfo = _Diagnostics._getExtraDiagnosticInfo();
75
+ if (!extraDiagnosticInfo || !extraDiagnosticInfo.hasAuthoringStarted) {
76
+ return '';
77
+ } else if (!extraDiagnosticInfo.authoringSessionClientCount) {
78
+ return extraDiagnosticInfo.isAuthoringUsingDDS ? ` in Legacy Authoring (DDS)` : ' in Legacy Authoring (no DDS)';
79
+ } else if (extraDiagnosticInfo.authoringSessionClientCount > 1) {
80
+ return ' with Multiple Users';
81
+ } else {
82
+ return '';
83
+ }
84
+ }
85
+ function getOfflineSuffix() {
86
+ return window.navigator.onLine ? '' : ' (offline)';
87
+ }
88
+
89
+ //# sourceMappingURL=./QosMonitorShareFailureWithCP.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Qos Result Type const object.
3
+ * @internal
4
+ */ // eslint-disable-next-line @typescript-eslint/typedef
5
+ export const QosResultType = {
6
+ Success: 0,
7
+ Failure: 1,
8
+ ExpectedFailure: 2
9
+ };
10
+
11
+ //# sourceMappingURL=./QosResultType.js.map
@@ -0,0 +1,23 @@
1
+ class DefaultTraceHandler {
2
+ /**
3
+ * Default implementation for log function.
4
+ */ log(traceLogEvent) {
5
+ if (!DEPRECATED_UNIT_TEST) {
6
+ // eslint-disable-next-line no-console
7
+ console.log(`Error: ${traceLogEvent.data}, ` + `Event Name: ${traceLogEvent.eventName}, ` + `Result Code: ${traceLogEvent.resultCode}`);
8
+ }
9
+ }
10
+ /**
11
+ * Default implementation for verbose function.
12
+ */ verbose(verboseTraceEvent) {
13
+ if (!DEPRECATED_UNIT_TEST) {
14
+ // eslint-disable-next-line no-console
15
+ console.log(`Error: ${verboseTraceEvent.data}, Event Name: ${verboseTraceEvent.eventName}`);
16
+ }
17
+ }
18
+ }
19
+ /**
20
+ * Default implementation for the Trace logger class.
21
+ */ export { DefaultTraceHandler as default };
22
+
23
+ //# sourceMappingURL=./DefaultTraceHandler.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Trace logger log data interface
3
+ * @internal
4
+ */ /**
5
+ * ITraceLogEvent log data interface
6
+ * @internal
7
+ */ export { };
8
+
9
+ //# sourceMappingURL=./ITraceHandler.js.map
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=./ITraceLogger.js.map
@@ -0,0 +1,104 @@
1
+ import { logSourceServiceKey } from '../LogSource';
2
+ import LogManager from '../LogManager/LogManager';
3
+ class LogEvent {
4
+ /**
5
+ * Use this method to log an event.
6
+ *
7
+ * @param source - source of the log event, e.g. class name of the source file
8
+ * @param data - data of the log event
9
+ * @param level - level of the log event
10
+ * @param serviceScope - scope of the log event, e.g. component/web part
11
+ */ static log(source, data, level, serviceScope) {
12
+ const event = new LogEvent(source, data, level, serviceScope);
13
+ LogEvent.logManager.log(event);
14
+ return event;
15
+ }
16
+ toString() {
17
+ const timedPrefix = `[${this._timestamp}][${this._prefix}]`;
18
+ if (this._message) {
19
+ return `${timedPrefix} ${this._message}`;
20
+ } else if (this._error) {
21
+ return `${timedPrefix} ${this._error.toString()}`;
22
+ } else {
23
+ return timedPrefix;
24
+ }
25
+ }
26
+ get timestamp() {
27
+ return this._timestamp;
28
+ }
29
+ get level() {
30
+ return this._level;
31
+ }
32
+ get prefix() {
33
+ return this._prefix;
34
+ }
35
+ get scope() {
36
+ return this._scope;
37
+ }
38
+ get source() {
39
+ return this._source;
40
+ }
41
+ get message() {
42
+ return this._message;
43
+ }
44
+ get error() {
45
+ return this._error;
46
+ }
47
+ get _maxSourceLength() {
48
+ return 30;
49
+ }
50
+ get _maxMessageLength() {
51
+ return 150;
52
+ }
53
+ _validate(source, data) {
54
+ if (!source) {
55
+ throw new Error('source cannot be undefined or null for Logger');
56
+ }
57
+ if (!data) {
58
+ throw new Error('data cannot be undefined or null');
59
+ }
60
+ }
61
+ _setData(data) {
62
+ if (typeof data === 'string') {
63
+ this._message = data.substr(0, this._maxMessageLength);
64
+ } else if (data instanceof Error) {
65
+ this._error = data;
66
+ }
67
+ }
68
+ _getPrefix() {
69
+ let prefix = `${this._source}`;
70
+ if (this._scope && !this._scope.isEmpty()) {
71
+ prefix = `${this._scope.id.substr(0, this._maxSourceLength)}.${prefix}`;
72
+ }
73
+ return `${prefix}`;
74
+ }
75
+ _getScope(serviceScope) {
76
+ let parentSource;
77
+ if (serviceScope) {
78
+ serviceScope.whenFinished(()=>{
79
+ parentSource = serviceScope.consume(logSourceServiceKey);
80
+ });
81
+ }
82
+ return parentSource;
83
+ }
84
+ /**
85
+ * Do not call this constructor directly. Use LogEvent.log instead.
86
+ */ constructor(source, data, level, serviceScope){
87
+ this._validate(source, data);
88
+ this._timestamp = new Date().getTime();
89
+ this._scope = this._getScope(serviceScope);
90
+ this._source = source.substr(0, this._maxSourceLength);
91
+ this._setData(data);
92
+ this._level = level;
93
+ this._prefix = this._getPrefix();
94
+ }
95
+ }
96
+ /**
97
+ * Allows process log events.
98
+ */ LogEvent.logManager = new LogManager();
99
+ /**
100
+ * An object that represents one log event.
101
+ * @internal
102
+ */ export { LogEvent as default };
103
+
104
+ //# sourceMappingURL=./LogEvent.js.map