@microsoft/applicationinsights-core-js 3.0.0-beta.2210-01 → 3.0.0-beta.2210-03

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 (178) hide show
  1. package/browser/applicationinsights-core-js.integrity.json +9 -9
  2. package/browser/applicationinsights-core-js.js +1249 -675
  3. package/browser/applicationinsights-core-js.js.map +1 -1
  4. package/browser/applicationinsights-core-js.min.js +2 -2
  5. package/browser/applicationinsights-core-js.min.js.map +1 -1
  6. package/dist/applicationinsights-core-js.api.json +3680 -1694
  7. package/dist/applicationinsights-core-js.api.md +126 -46
  8. package/dist/applicationinsights-core-js.d.ts +327 -124
  9. package/dist/applicationinsights-core-js.js +1249 -675
  10. package/dist/applicationinsights-core-js.js.map +1 -1
  11. package/dist/applicationinsights-core-js.min.js +2 -2
  12. package/dist/applicationinsights-core-js.min.js.map +1 -1
  13. package/dist/applicationinsights-core-js.rollup.d.ts +327 -124
  14. package/dist-esm/Config/ConfigDefaults.js +114 -0
  15. package/dist-esm/Config/ConfigDefaults.js.map +1 -0
  16. package/dist-esm/Config/DynamicConfig.js +129 -0
  17. package/dist-esm/Config/DynamicConfig.js.map +1 -0
  18. package/dist-esm/Config/DynamicProperty.js +139 -0
  19. package/dist-esm/Config/DynamicProperty.js.map +1 -0
  20. package/dist-esm/Config/DynamicState.js +109 -0
  21. package/dist-esm/Config/DynamicState.js.map +1 -0
  22. package/dist-esm/Config/DynamicSupport.js +57 -0
  23. package/dist-esm/Config/DynamicSupport.js.map +1 -0
  24. package/dist-esm/Config/IConfigDefaults.js +8 -0
  25. package/dist-esm/Config/IConfigDefaults.js.map +1 -0
  26. package/dist-esm/Config/IDynamicConfigHandler.js +8 -0
  27. package/dist-esm/Config/IDynamicConfigHandler.js.map +1 -0
  28. package/dist-esm/Config/IDynamicPropertyHandler.js +8 -0
  29. package/dist-esm/Config/IDynamicPropertyHandler.js.map +1 -0
  30. package/dist-esm/Config/IDynamicWatcher.js +8 -0
  31. package/dist-esm/Config/IDynamicWatcher.js.map +1 -0
  32. package/dist-esm/Config/_IDynamicConfigHandlerState.js +6 -0
  33. package/dist-esm/Config/_IDynamicConfigHandlerState.js.map +1 -0
  34. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +808 -23
  35. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  36. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +22 -18
  37. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  38. package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
  39. package/dist-esm/JavaScriptSDK/CookieMgr.js +78 -38
  40. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/CoreUtils.js +6 -5
  42. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +10 -8
  44. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
  46. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +40 -23
  47. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  48. package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -115
  49. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  50. package/dist-esm/JavaScriptSDK/EventHelpers.js +30 -29
  51. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  52. package/dist-esm/JavaScriptSDK/HelperFuncs.js +19 -34
  53. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  54. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +1 -1
  55. package/dist-esm/JavaScriptSDK/InternalConstants.js +5 -1
  56. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  57. package/dist-esm/JavaScriptSDK/NotificationManager.js +18 -11
  58. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  59. package/dist-esm/JavaScriptSDK/PerfManager.js +2 -3
  60. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  61. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +62 -53
  62. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  63. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  64. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +8 -10
  65. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  66. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -4
  67. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  68. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +1 -1
  69. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +12 -10
  70. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  71. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +1 -2
  72. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js.map +1 -1
  73. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +2 -107
  75. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js.map +1 -1
  76. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  86. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  87. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  88. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  89. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  90. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  91. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  92. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  93. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  94. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  95. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  96. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  97. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  98. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  99. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js +8 -0
  100. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadHook.js.map +1 -0
  101. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +3 -1
  102. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js.map +1 -1
  103. package/dist-esm/__DynamicConstants.js +26 -23
  104. package/dist-esm/__DynamicConstants.js.map +1 -1
  105. package/dist-esm/applicationinsights-core-js.js +6 -4
  106. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  107. package/package.json +2 -2
  108. package/src/JavaScriptSDK/AppInsightsCore.ts +1156 -16
  109. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +25 -17
  110. package/src/JavaScriptSDK/CookieMgr.ts +88 -41
  111. package/src/JavaScriptSDK/CoreUtils.ts +4 -3
  112. package/src/JavaScriptSDK/DiagnosticLogger.ts +45 -23
  113. package/src/JavaScriptSDK/EnvUtils.ts +0 -133
  114. package/src/JavaScriptSDK/EventHelpers.ts +29 -28
  115. package/src/JavaScriptSDK/HelperFuncs.ts +22 -39
  116. package/src/JavaScriptSDK/InternalConstants.ts +5 -0
  117. package/src/JavaScriptSDK/NotificationManager.ts +25 -14
  118. package/src/JavaScriptSDK/PerfManager.ts +2 -2
  119. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +73 -56
  120. package/src/JavaScriptSDK/TelemetryHelpers.ts +8 -9
  121. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +2 -2
  122. package/src/JavaScriptSDK/W3cTraceParent.ts +7 -6
  123. package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +0 -1
  124. package/src/JavaScriptSDK.Enums/LoggingEnums.ts +9 -108
  125. package/src/JavaScriptSDK.Enums/TelemetryUpdateReason.ts +1 -1
  126. package/src/JavaScriptSDK.Interfaces/IAppInsightsCore.ts +28 -3
  127. package/src/JavaScriptSDK.Interfaces/ICookieMgr.ts +8 -0
  128. package/src/JavaScriptSDK.Interfaces/IDiagnosticLogger.ts +14 -7
  129. package/src/JavaScriptSDK.Interfaces/IInstrumentHooks.ts +3 -1
  130. package/src/JavaScriptSDK.Interfaces/INotificationListener.ts +5 -5
  131. package/src/JavaScriptSDK.Interfaces/INotificationManager.ts +8 -8
  132. package/src/JavaScriptSDK.Interfaces/IPerfManager.ts +3 -3
  133. package/src/JavaScriptSDK.Interfaces/IProcessTelemetryContext.ts +10 -9
  134. package/src/JavaScriptSDK.Interfaces/ITelemetryInitializers.ts +2 -1
  135. package/src/JavaScriptSDK.Interfaces/ITelemetryUpdateState.ts +15 -5
  136. package/src/JavaScriptSDK.Interfaces/IUnloadHook.ts +22 -0
  137. package/src/JavaScriptSDK.Interfaces/IUnloadableComponent.ts +3 -3
  138. package/tsconfig.json +3 -2
  139. package/types/Config/ConfigDefaults.d.ts +10 -0
  140. package/types/Config/DynamicConfig.d.ts +23 -0
  141. package/types/Config/DynamicProperty.d.ts +3 -0
  142. package/types/Config/DynamicState.d.ts +3 -0
  143. package/types/Config/DynamicSupport.d.ts +15 -0
  144. package/types/Config/IConfigDefaults.d.ts +42 -0
  145. package/types/Config/IDynamicConfigHandler.d.ts +46 -0
  146. package/types/Config/IDynamicPropertyHandler.d.ts +11 -0
  147. package/types/Config/IDynamicWatcher.d.ts +28 -0
  148. package/types/Config/_IDynamicConfigHandlerState.d.ts +35 -0
  149. package/types/JavaScriptSDK/AppInsightsCore.d.ts +136 -4
  150. package/types/JavaScriptSDK/BaseTelemetryPlugin.d.ts +2 -2
  151. package/types/JavaScriptSDK/CookieMgr.d.ts +0 -10
  152. package/types/JavaScriptSDK/DiagnosticLogger.d.ts +13 -11
  153. package/types/JavaScriptSDK/EventHelpers.d.ts +24 -24
  154. package/types/JavaScriptSDK/HelperFuncs.d.ts +13 -11
  155. package/types/JavaScriptSDK/InternalConstants.d.ts +4 -0
  156. package/types/JavaScriptSDK/NotificationManager.d.ts +7 -7
  157. package/types/JavaScriptSDK/PerfManager.d.ts +2 -2
  158. package/types/JavaScriptSDK/ProcessTelemetryContext.d.ts +3 -2
  159. package/types/JavaScriptSDK/TelemetryHelpers.d.ts +3 -3
  160. package/types/JavaScriptSDK.Enums/LoggingEnums.d.ts +7 -5
  161. package/types/JavaScriptSDK.Enums/TelemetryUpdateReason.d.ts +1 -0
  162. package/types/JavaScriptSDK.Interfaces/IAppInsightsCore.d.ts +25 -3
  163. package/types/JavaScriptSDK.Interfaces/ICookieMgr.d.ts +6 -0
  164. package/types/JavaScriptSDK.Interfaces/IDiagnosticLogger.d.ts +13 -7
  165. package/types/JavaScriptSDK.Interfaces/IInstrumentHooks.d.ts +2 -1
  166. package/types/JavaScriptSDK.Interfaces/INotificationListener.d.ts +5 -5
  167. package/types/JavaScriptSDK.Interfaces/INotificationManager.d.ts +8 -8
  168. package/types/JavaScriptSDK.Interfaces/IPerfManager.d.ts +3 -3
  169. package/types/JavaScriptSDK.Interfaces/IProcessTelemetryContext.d.ts +5 -9
  170. package/types/JavaScriptSDK.Interfaces/ITelemetryInitializers.d.ts +2 -1
  171. package/types/JavaScriptSDK.Interfaces/ITelemetryUpdateState.d.ts +13 -2
  172. package/types/JavaScriptSDK.Interfaces/IUnloadHook.d.ts +18 -0
  173. package/types/__DynamicConstants.d.ts +18 -15
  174. package/types/applicationinsights-core-js.d.ts +11 -4
  175. package/dist-esm/JavaScriptSDK/BaseCore.js +0 -654
  176. package/dist-esm/JavaScriptSDK/BaseCore.js.map +0 -1
  177. package/src/JavaScriptSDK/BaseCore.ts +0 -948
  178. package/types/JavaScriptSDK/BaseCore.d.ts +0 -124
@@ -35,7 +35,6 @@ let _enableMocks = false;
35
35
  let _useXDomainRequest: boolean | null = null;
36
36
  let _beaconsSupported: boolean | null = null;
37
37
 
38
-
39
38
  function _hasProperty(theClass: any, property: string) {
40
39
  let supported = false;
41
40
  if (theClass) {
@@ -72,123 +71,6 @@ export function setEnableEnvMocks(enabled: boolean) {
72
71
  _enableMocks = enabled;
73
72
  }
74
73
 
75
- // /**
76
- // * Return the named global object if available, will return null if the object is not available.
77
- // * @param name The globally named object
78
- // */
79
- // export function getinst<T>(name:string): T {
80
- // let gbl = getGlobal();
81
- // if (gbl && gbl[name]) {
82
- // return gbl[name] as T;
83
- // }
84
-
85
- // // Test workaround, for environments where <global>.window (when global == window) doesn't return the base window
86
- // if (name === strWindow && hasWindow()) {
87
- // // tslint:disable-next-line: no-angle-bracket-type-assertion
88
- // return <any>window as T;
89
- // }
90
-
91
- // return null;
92
- // }
93
-
94
- // /**
95
- // * Checks if window object is available, this is required as we support the API running without a
96
- // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a window
97
- // * object to a local variable or pass as an argument an "Uncaught ReferenceError: window is not defined"
98
- // * exception will be thrown.
99
- // * Defined as a function to support lazy / late binding environments.
100
- // */
101
- // export const hasWindow = () => boolean = hasWindow;
102
- // return Boolean(typeof window === strShimObject && window);
103
- // }
104
-
105
- // /**
106
- // * Returns the global window object if it is present otherwise null.
107
- // * This helper is used to access the window object without causing an exception
108
- // * "Uncaught ReferenceError: window is not defined"
109
- // */
110
- // export function getWindow(): Window | null {
111
- // if (hasWindow()) {
112
- // return window;
113
- // }
114
-
115
- // // Return the global instance or null
116
- // return getInst(strWindow);
117
- // }
118
-
119
- // /**
120
- // * Checks if document object is available, this is required as we support the API running without a
121
- // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a document
122
- // * object to a local variable or pass as an argument an "Uncaught ReferenceError: document is not defined"
123
- // * exception will be thrown.
124
- // * Defined as a function to support lazy / late binding environments.
125
- // */
126
- // export function hasDocument(): boolean {
127
- // return Boolean(typeof document === strShimObject && document);
128
- // }
129
-
130
- // /**
131
- // * Returns the global document object if it is present otherwise null.
132
- // * This helper is used to access the document object without causing an exception
133
- // * "Uncaught ReferenceError: document is not defined"
134
- // */
135
- // export function getDocument(): Document | null {
136
- // if (hasDocument()) {
137
- // return document;
138
- // }
139
-
140
- // return getInst(strDocument);
141
- // }
142
-
143
-
144
- // /**
145
- // * Checks if navigator object is available, this is required as we support the API running without a
146
- // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator
147
- // * object to a local variable or pass as an argument an "Uncaught ReferenceError: navigator is not defined"
148
- // * exception will be thrown.
149
- // * Defined as a function to support lazy / late binding environments.
150
- // */
151
- // export function hasNavigator(): boolean {
152
- // return Boolean(typeof navigator === strShimObject && navigator);
153
- // }
154
-
155
- // /**
156
- // * Returns the global navigator object if it is present otherwise null.
157
- // * This helper is used to access the navigator object without causing an exception
158
- // * "Uncaught ReferenceError: navigator is not defined"
159
- // */
160
- // export function getNavigator(): Navigator | null {
161
- // if (hasNavigator()) {
162
- // return navigator;
163
- // }
164
-
165
- // return getInst(strNavigator);
166
- // }
167
-
168
- // /**
169
- // * Checks if history object is available, this is required as we support the API running without a
170
- // * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
171
- // * object to a local variable or pass as an argument an "Uncaught ReferenceError: history is not defined"
172
- // * exception will be thrown.
173
- // * Defined as a function to support lazy / late binding environments.
174
- // */
175
- // export function hasHistory(): boolean {
176
- // return Boolean(typeof history === strShimObject && history);
177
- // }
178
-
179
- // /**
180
- // * Returns the global history object if it is present otherwise null.
181
- // * This helper is used to access the history object without causing an exception
182
- // * "Uncaught ReferenceError: history is not defined"
183
- // */
184
- // export function getHistory(): History | null {
185
- // if (hasHistory()) {
186
- // return history;
187
- // }
188
-
189
- // return getInst(strHistory);
190
- // }
191
-
192
74
  /**
193
75
  * Returns the global location object if it is present otherwise null.
194
76
  * This helper is used to access the location object without causing an exception
@@ -323,21 +205,6 @@ export function getIEVersion(userAgentStr: string = null): number {
323
205
  return null;
324
206
  }
325
207
 
326
- // /**
327
- // * Returns string representation of an object suitable for diagnostics logging.
328
- // */
329
- // export function dumpObj(object: any): string {
330
- // const objectTypeDump: string = Object[strShimPrototype].toString.call(object);
331
- // let propertyValueDump: string = STR_EMPTY;
332
- // if (objectTypeDump === "[object Error]") {
333
- // propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
334
- // } else if (hasJSON()) {
335
- // propertyValueDump = getJSON().stringify(object);
336
- // }
337
-
338
- // return objectTypeDump + propertyValueDump;
339
- // }
340
-
341
208
  export function isSafari(userAgentStr ?: string) {
342
209
  if (!userAgentStr || !isString(userAgentStr)) {
343
210
  let navigator = getNavigator() || ({} as Navigator);
@@ -1,7 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
- import { arrForEach, arrIndexOf, getDocument, getWindow, isArray, objForEachKey, objKeys } from "@nevware21/ts-utils";
3
+ import { arrForEach, arrIndexOf, getDocument, getWindow, isArray, objKeys } from "@nevware21/ts-utils";
4
4
  import { createElmNodeData, createUniqueNamespace } from "./DataCacheHelper";
5
+ import { objForEachKey } from "./HelperFuncs";
5
6
  import { STR_EMPTY } from "./InternalConstants";
6
7
 
7
8
  // Added to help with minfication
@@ -46,7 +47,7 @@ const eventNamespace = /^([^.]*)(?:\.(.+)|)/
46
47
 
47
48
  function _normalizeNamespace(name: string) {
48
49
  if (name && name.replace) {
49
- return name.replace(/^\s*\.*|\.*\s*$/g, STR_EMPTY);
50
+ return name.replace(/^[\s\.]+|(?=[\s\.])[\.\s]+$/g, STR_EMPTY);
50
51
  }
51
52
 
52
53
  return name;
@@ -216,13 +217,13 @@ export function mergeEvtNamespace(theNamespace: string, namespaces?: string | st
216
217
 
217
218
  /**
218
219
  * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
219
- * @param obj Object to add the event too.
220
- * @param eventName String that specifies any of the standard DHTML Events without "on" prefix, if may also include an optional (dot "." prefixed)
220
+ * @param obj - Object to add the event too.
221
+ * @param eventName - String that specifies any of the standard DHTML Events without "on" prefix, if may also include an optional (dot "." prefixed)
221
222
  * namespaces "click" "click.mynamespace" in addition to specific namespaces.
222
- * @param handlerRef Pointer that specifies the function to call when event fires
223
+ * @param handlerRef - Pointer that specifies the function to call when event fires
223
224
  * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
224
225
  * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
225
- * @param useCapture [Optional] Defaults to false
226
+ * @param useCapture - [Optional] Defaults to false
226
227
  * @returns True if the function was bound successfully to the event, otherwise false
227
228
  */
228
229
  export function eventOn<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[] | null, useCapture: boolean = false) {
@@ -253,15 +254,15 @@ export function eventOn<T>(target: T, eventName: string, handlerRef: any, evtNam
253
254
 
254
255
  /**
255
256
  * Removes an event handler for the specified event
256
- * @param Object to remove the event from
257
- * @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
257
+ * @param Object - to remove the event from
258
+ * @param eventName - {string} - The name of the event, with optional namespaces or just the namespaces,
258
259
  * such as "click", "click.mynamespace" or ".mynamespace"
259
- * @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
260
+ * @param handlerRef - {any} - The callback function that needs to be removed from the given event, when using a
260
261
  * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
261
262
  * otherwise this will only remove events with this specific handler.
262
263
  * @param evtNamespace - [Optional] Additional namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace,
263
264
  * if the eventName also includes a namespace the namespace(s) are merged into a single namespace
264
- * @param useCapture [Optional] Defaults to false
265
+ * @param useCapture - [Optional] Defaults to false
265
266
  */
266
267
  export function eventOff<T>(target: T, eventName: string, handlerRef: any, evtNamespace?: string | string[] | null, useCapture: boolean = false) {
267
268
  if (target) {
@@ -290,10 +291,10 @@ export function eventOff<T>(target: T, eventName: string, handlerRef: any, evtNa
290
291
 
291
292
  /**
292
293
  * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
293
- * @param obj Object to add the event too.
294
- * @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix and optional (dot "." prefixed) namespaces "click" "click.mynamespace".
295
- * @param handlerRef Pointer that specifies the function to call when event fires
296
- * @param useCapture [Optional] Defaults to false
294
+ * @param obj - Object to add the event too.
295
+ * @param eventNameWithoutOn - String that specifies any of the standard DHTML Events without "on" prefix and optional (dot "." prefixed) namespaces "click" "click.mynamespace".
296
+ * @param handlerRef - Pointer that specifies the function to call when event fires
297
+ * @param useCapture - [Optional] Defaults to false
297
298
  * @returns True if the function was bound successfully to the event, otherwise false
298
299
  */
299
300
  export function attachEvent(obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture: boolean = false) {
@@ -302,13 +303,13 @@ export function attachEvent(obj: any, eventNameWithoutOn: string, handlerRef: an
302
303
 
303
304
  /**
304
305
  * Removes an event handler for the specified event
305
- * @param Object to remove the event from
306
- * @param eventNameWithoutOn {string} - The name of the event, with optional namespaces or just the namespaces,
306
+ * @param Object - to remove the event from
307
+ * @param eventNameWithoutOn - {string} - The name of the event, with optional namespaces or just the namespaces,
307
308
  * such as "click", "click.mynamespace" or ".mynamespace"
308
- * @param handlerRef {any} - The callback function that needs to be removed from the given event, when using a
309
+ * @param handlerRef - {any} - The callback function that needs to be removed from the given event, when using a
309
310
  * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
310
311
  * otherwise this will only remove events with this specific handler.
311
- * @param useCapture [Optional] Defaults to false
312
+ * @param useCapture - [Optional] Defaults to false
312
313
  */
313
314
  export function detachEvent(obj: any, eventNameWithoutOn: string, handlerRef: any, useCapture: boolean = false) {
314
315
  eventOff(obj, eventNameWithoutOn, handlerRef, null, useCapture);
@@ -316,8 +317,8 @@ export function detachEvent(obj: any, eventNameWithoutOn: string, handlerRef: an
316
317
 
317
318
  /**
318
319
  * Trys to add an event handler for the specified event to the window, body and document
319
- * @param eventName {string} - The name of the event
320
- * @param callback {any} - The callback function that needs to be executed for the given event
320
+ * @param eventName - {string} - The name of the event
321
+ * @param callback - {any} - The callback function that needs to be executed for the given event
321
322
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
322
323
  * @return {boolean} - true if the handler was successfully added
323
324
  */
@@ -339,9 +340,9 @@ export function addEventHandler(eventName: string, callback: any, evtNamespace?:
339
340
 
340
341
  /**
341
342
  * Trys to remove event handler(s) for the specified event/namespace to the window, body and document
342
- * @param eventName {string} - The name of the event, with optional namespaces or just the namespaces,
343
+ * @param eventName - {string} - The name of the event, with optional namespaces or just the namespaces,
343
344
  * such as "click", "click.mynamespace" or ".mynamespace"
344
- * @param callback {any} - - The callback function that needs to be removed from the given event, when using a
345
+ * @param callback - {any} - - The callback function that needs to be removed from the given event, when using a
345
346
  * namespace (with or without a qualifying event) this may be null to remove all previously attached event handlers
346
347
  * otherwise this will only remove events with this specific handler.
347
348
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
@@ -361,8 +362,8 @@ export function removeEventHandler(eventName: string, callback: any, evtNamespac
361
362
 
362
363
  /**
363
364
  * Bind the listener to the array of events
364
- * @param events An string array of event names to bind the listener to
365
- * @param listener The event callback to call when the event is triggered
365
+ * @param events - An string array of event names to bind the listener to
366
+ * @param listener - The event callback to call when the event is triggered
366
367
  * @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
367
368
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
368
369
  * @returns true - when at least one of the events was registered otherwise false
@@ -385,8 +386,8 @@ function _addEventListeners(events: string[], listener: any, excludeEvents?: str
385
386
 
386
387
  /**
387
388
  * Bind the listener to the array of events
388
- * @param events An string array of event names to bind the listener to
389
- * @param listener The event callback to call when the event is triggered
389
+ * @param events - An string array of event names to bind the listener to
390
+ * @param listener - The event callback to call when the event is triggered
390
391
  * @param excludeEvents - [Optional] An array of events that should not be hooked (if possible), unless no other events can be.
391
392
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
392
393
  * @returns true - when at least one of the events was registered otherwise false
@@ -408,8 +409,8 @@ export function addEventListeners(events: string[], listener: any, excludeEvents
408
409
 
409
410
  /**
410
411
  * Remove the listener from the array of events
411
- * @param events An string array of event names to bind the listener to
412
- * @param listener The event callback to call when the event is triggered
412
+ * @param events - An string array of event names to bind the listener to
413
+ * @param listener - The event callback to call when the event is triggered
413
414
  * @param evtNamespace - [Optional] Namespace(s) to append to the event listeners so they can be uniquely identified and removed based on this namespace.
414
415
  */
415
416
  export function removeEventListeners(events: string[], listener: any, evtNamespace?: string | string[]) {
@@ -1,19 +1,15 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
- import { ObjAssign, ObjClass, ObjHasOwnProperty, ObjProto, strShimFunction, strShimPrototype } from "@microsoft/applicationinsights-shims";
3
+ import { ObjAssign, ObjClass, strShimFunction } from "@microsoft/applicationinsights-shims";
4
4
  import {
5
- arrForEach, isArray, isBoolean, isError, isFunction, isNullOrUndefined, isObject, isString, isUndefined, objDeepFreeze,
6
- objDefineAccessors, objForEachKey, objHasOwnProperty, strIndexOf, throwUnsupported
5
+ arrForEach, asString as asString21, isArray, isBoolean, isError, isFunction, isNullOrUndefined, isObject, isString, isUndefined,
6
+ objDeepFreeze, objDefineAccessors, objForEachKey as objForEachKey21, objHasOwn, objHasOwnProperty, strIndexOf
7
7
  } from "@nevware21/ts-utils";
8
8
  import { STR_EMPTY } from "./InternalConstants";
9
9
 
10
10
  // RESTRICT and AVOID circular dependencies you should not import other contained modules or export the contents of this file directly
11
11
 
12
12
  // Added to help with minification
13
- const cString = "String";
14
- const cObject = "Object";
15
- const strToISOString = "toISOString";
16
- const strMap = "map";
17
13
  const strToString = "toString";
18
14
  const strGetPrototypeOf = "getPrototypeOf";
19
15
 
@@ -23,11 +19,7 @@ const strGetPrototypeOf = "getPrototypeOf";
23
19
  */
24
20
  const strConstructor = "constructor";
25
21
 
26
- const DateProto = Date[strShimPrototype];
27
- const _dateToISOString = DateProto[strToISOString] || _polyfillRequired("Date", strToISOString);
28
- const _objToString = ObjProto[strToString] || _polyfillRequired(cObject, strToString);
29
-
30
- const _fnToString = ObjHasOwnProperty[strToString] || _polyfillRequired(cString, strToString);
22
+ const _fnToString = ObjClass[strToString];
31
23
  // Cache what this browser reports as the object function constructor (as a string)
32
24
  const _objFunctionString = _fnToString.call(ObjClass);
33
25
 
@@ -35,17 +27,7 @@ const rCamelCase = /-([a-z])/g;
35
27
  const rNormalizeInvalid = /([^\w\d_$])/g;
36
28
  const rLeadingNumeric = /^(\d+[\w\d_$])/;
37
29
 
38
- function _polyfillRequired(object:string, name: string): any {
39
- return function() {
40
- throwUnsupported("Polyfill required for [" + name + "]");
41
- }
42
- }
43
-
44
- export let _getObjProto = Object[strGetPrototypeOf] || _polyfillRequired(cObject, strGetPrototypeOf);
45
-
46
- export function objToString(obj: any) {
47
- return _objToString.call(obj);
48
- }
30
+ export let _getObjProto = Object[strGetPrototypeOf];
49
31
 
50
32
  export function isNotUndefined<T>(value: T): value is T {
51
33
  return !isUndefined(value);
@@ -60,7 +42,7 @@ export function isNotNullOrUndefined<T>(value: T): value is T {
60
42
  * normalizes the name so that it would. This method does not identify or change any keywords
61
43
  * meaning that if you pass in a known keyword the same value will be returned.
62
44
  * This is a simplified version
63
- * @param name The name to validate
45
+ * @param name - The name to validate
64
46
  */
65
47
  export function normalizeJsName(name: string): string {
66
48
  let value = name;
@@ -80,6 +62,14 @@ export function normalizeJsName(name: string): string {
80
62
  return value;
81
63
  }
82
64
 
65
+ /**
66
+ * This is a helper function for the equivalent of arForEach(objKeys(target), callbackFn), this is a
67
+ * performance optimization to avoid the creation of a new array for large objects
68
+ * @param target - The target object to find and process the keys
69
+ * @param callbackfn - The function to call with the details
70
+ */
71
+ export const objForEachKey = objForEachKey21;
72
+
83
73
  /**
84
74
  * A simple wrapper (for minification support) to check if the value contains the search string.
85
75
  * @param value - The string value to check for the existence of the search value
@@ -108,7 +98,7 @@ export function isPlainObject(value: any): boolean {
108
98
  result = true;
109
99
  } else {
110
100
  // Objects that have a prototype are plain only if they were created using the Object global (native) function
111
- if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
101
+ if (proto[strConstructor] && objHasOwnProperty(proto, strConstructor)) {
112
102
  proto = proto[strConstructor];
113
103
  }
114
104
 
@@ -123,7 +113,7 @@ export function isPlainObject(value: any): boolean {
123
113
  * Convert a date to I.S.O. format in IE8
124
114
  */
125
115
  export function toISOString(date: Date) {
126
- return _dateToISOString.call(date);
116
+ return date && date.toISOString() || "";
127
117
  }
128
118
 
129
119
  export const deepFreeze: <T>(obj: T) => T = objDeepFreeze;
@@ -195,15 +185,6 @@ export function getSetValue<T, K extends keyof T>(target: T, field: K, defValue?
195
185
  return theValue;
196
186
  }
197
187
 
198
- /**
199
- * Get the mapped config value, if null or undefined any supplied defaultValue will be returned.
200
- * @param field - The name of the field as the named enum value (number) or the string name.
201
- * @param defaultValue - The default value to return if the config field is not present, null or undefined.
202
- */
203
- export function getCfgValue<V>(theValue: V, defaultValue?: V): V {
204
- return !isNullOrUndefined(theValue) ? theValue : defaultValue;
205
- }
206
-
207
188
  function _createProxyFunction<S>(source: S | (() => S), funcName: (keyof S)) {
208
189
  let srcFunc: () => S = null;
209
190
  let src: S = null;
@@ -253,7 +234,7 @@ export function proxyAssign<T, S>(target: T, source: S, chkSet?: (name: string,
253
234
  target[field as string] = _createProxyFunction(source, field);
254
235
  }
255
236
  } else if (!chkSet || chkSet(field, false, source, target)) {
256
- if (objHasOwnProperty(target, field)) {
237
+ if (objHasOwn(target, field)) {
257
238
  // Remove any previous instance property
258
239
  delete (target as any)[field];
259
240
  }
@@ -316,7 +297,7 @@ export function proxyFunctions<T, S>(target: T, source: S | (() => S), functions
316
297
  /**
317
298
  * Simpler helper to create a dynamic class that implements the interface and populates the values with the defaults.
318
299
  * Only instance properties (hasOwnProperty) values are copied from the defaults to the new instance
319
- * @param defaults Simple helper
300
+ * @param defaults - Simple helper
320
301
  */
321
302
  export function createClassFromInterface<T>(defaults?: T) {
322
303
  return class {
@@ -385,7 +366,7 @@ export function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1 | any, obj2?: T2, ob
385
366
  let isArgArray = isArray(arg);
386
367
  let isArgObj = isObject(arg);
387
368
  for (let prop in arg) {
388
- let propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
369
+ let propOk = (isArgArray && (prop in arg)) || (isArgObj && objHasOwn(arg, prop));
389
370
  if (!propOk) {
390
371
  continue;
391
372
  }
@@ -420,4 +401,6 @@ export function objExtend<T1, T2, T3, T4, T5, T6>(obj1?: T1 | any, obj2?: T2, ob
420
401
  }
421
402
 
422
403
  return extended;
423
- }
404
+ }
405
+
406
+ export const asString = asString21;
@@ -5,6 +5,7 @@
5
5
  // Note: DON'T Export these const from the package as we are still targeting IE/ES5 this will export a mutable variables that someone could change ###
6
6
  // ###################################################################################################################################################
7
7
 
8
+ export const UNDEFINED_VALUE: any = undefined;
8
9
  export const STR_EMPTY = "";
9
10
  export const STR_CHANNELS = "channels";
10
11
  export const STR_CORE = "core";
@@ -24,3 +25,7 @@ export const STR_ERROR_TO_CONSOLE = "errorToConsole";
24
25
  export const STR_WARN_TO_CONSOLE = "warnToConsole";
25
26
 
26
27
  export const STR_GET_PERF_MGR = "getPerfMgr";
28
+ export const STR_DOMAIN = "domain";
29
+ export const STR_PATH = "path";
30
+
31
+ export const STR_NOT_DYNAMIC_ERROR = "Not dynamic - ";
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  import dynamicProto from "@microsoft/dynamicproto-js";
4
4
  import { arrForEach, arrIndexOf } from "@nevware21/ts-utils";
5
+ import { createDynamicConfig } from "../Config/DynamicConfig";
5
6
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
6
7
  import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
7
8
  import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
@@ -9,6 +10,10 @@ import { IPerfEvent } from "../JavaScriptSDK.Interfaces/IPerfEvent";
9
10
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
10
11
  import { STR_EVENTS_DISCARDED, STR_EVENTS_SEND_REQUEST, STR_EVENTS_SENT, STR_PERF_EVENT } from "./InternalConstants";
11
12
 
13
+ const defaultValues = {
14
+ perfEvtsSendAll: false
15
+ };
16
+
12
17
  function _runListeners(listeners: INotificationListener[], name: string, isAsync: boolean, callback: (listener: INotificationListener) => void) {
13
18
  arrForEach(listeners, (listener) => {
14
19
  if (listener && listener[name]) {
@@ -32,7 +37,13 @@ export class NotificationManager implements INotificationManager {
32
37
  listeners: INotificationListener[] = [];
33
38
 
34
39
  constructor(config?: IConfiguration) {
35
- let perfEvtsSendAll = !!(config ||{}).perfEvtsSendAll;
40
+ let perfEvtsSendAll: boolean;
41
+
42
+ let cfgHandler = createDynamicConfig(config, defaultValues);
43
+
44
+ cfgHandler.watch((details) => {
45
+ perfEvtsSendAll = !!details.cfg.perfEvtsSendAll;
46
+ });
36
47
 
37
48
  dynamicProto(NotificationManager, this, (_self) => {
38
49
  _self.addNotificationListener = (listener: INotificationListener): void => {
@@ -41,7 +52,7 @@ export class NotificationManager implements INotificationManager {
41
52
 
42
53
  /**
43
54
  * Removes all instances of the listener.
44
- * @param {INotificationListener} listener - AWTNotificationListener to remove.
55
+ * @param listener - AWTNotificationListener to remove.
45
56
  */
46
57
  _self.removeNotificationListener = (listener: INotificationListener): void => {
47
58
  let index: number = arrIndexOf(_self.listeners, listener);
@@ -53,7 +64,7 @@ export class NotificationManager implements INotificationManager {
53
64
 
54
65
  /**
55
66
  * Notification for events sent.
56
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
67
+ * @param events - The array of events that have been sent.
57
68
  */
58
69
  _self.eventsSent = (events: ITelemetryItem[]): void => {
59
70
  _runListeners(_self.listeners, STR_EVENTS_SENT, true, (listener) => {
@@ -63,8 +74,8 @@ export class NotificationManager implements INotificationManager {
63
74
 
64
75
  /**
65
76
  * Notification for events being discarded.
66
- * @param {ITelemetryItem[]} events - The array of events that have been discarded by the SDK.
67
- * @param {number} reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
77
+ * @param events - The array of events that have been discarded by the SDK.
78
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
68
79
  * constant should be used to check the different values.
69
80
  */
70
81
  _self.eventsDiscarded = (events: ITelemetryItem[], reason: number): void => {
@@ -75,8 +86,8 @@ export class NotificationManager implements INotificationManager {
75
86
 
76
87
  /**
77
88
  * [Optional] A function called when the events have been requested to be sent to the sever.
78
- * @param {number} sendReason - The reason why the event batch is being sent.
79
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
89
+ * @param sendReason - The reason why the event batch is being sent.
90
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
80
91
  */
81
92
  _self.eventsSendRequest = (sendReason: number, isAsync: boolean): void => {
82
93
  _runListeners(_self.listeners, STR_EVENTS_SEND_REQUEST, isAsync, (listener) => {
@@ -104,7 +115,7 @@ export class NotificationManager implements INotificationManager {
104
115
 
105
116
  /**
106
117
  * Adds a notification listener.
107
- * @param {INotificationListener} listener - The notification listener to be added.
118
+ * @param listener - The notification listener to be added.
108
119
  */
109
120
  addNotificationListener(listener: INotificationListener): void {
110
121
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
@@ -112,7 +123,7 @@ export class NotificationManager implements INotificationManager {
112
123
 
113
124
  /**
114
125
  * Removes all instances of the listener.
115
- * @param {INotificationListener} listener - AWTNotificationListener to remove.
126
+ * @param listener - AWTNotificationListener to remove.
116
127
  */
117
128
  removeNotificationListener(listener: INotificationListener): void {
118
129
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
@@ -120,7 +131,7 @@ export class NotificationManager implements INotificationManager {
120
131
 
121
132
  /**
122
133
  * Notification for events sent.
123
- * @param {ITelemetryItem[]} events - The array of events that have been sent.
134
+ * @param events - The array of events that have been sent.
124
135
  */
125
136
  eventsSent(events: ITelemetryItem[]): void {
126
137
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
@@ -128,8 +139,8 @@ export class NotificationManager implements INotificationManager {
128
139
 
129
140
  /**
130
141
  * Notification for events being discarded.
131
- * @param {ITelemetryItem[]} events - The array of events that have been discarded by the SDK.
132
- * @param {number} reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
142
+ * @param events - The array of events that have been discarded by the SDK.
143
+ * @param reason - The reason for which the SDK discarded the events. The EventsDiscardedReason
133
144
  * constant should be used to check the different values.
134
145
  */
135
146
  eventsDiscarded(events: ITelemetryItem[], reason: number): void {
@@ -138,8 +149,8 @@ export class NotificationManager implements INotificationManager {
138
149
 
139
150
  /**
140
151
  * [Optional] A function called when the events have been requested to be sent to the sever.
141
- * @param {number} sendReason - The reason why the event batch is being sent.
142
- * @param {boolean} isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
152
+ * @param sendReason - The reason why the event batch is being sent.
153
+ * @param isAsync - A flag which identifies whether the requests are being sent in an async or sync manner.
143
154
  */
144
155
  eventsSendRequest?(sendReason: number, isAsync: boolean): void {
145
156
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
@@ -177,7 +177,7 @@ export class PerfManager implements IPerfManager {
177
177
  /**
178
178
  * Create a new event and start timing, the manager may return null/undefined to indicate that it does not
179
179
  * want to monitor this source event.
180
- * @param src The source name of the event
180
+ * @param src - The source name of the event
181
181
  * @param payloadDetails - An optional callback function to fetch the payload details for the event.
182
182
  * @param isAsync - Is the event occurring from a async event
183
183
  */
@@ -188,7 +188,7 @@ export class PerfManager implements IPerfManager {
188
188
 
189
189
  /**
190
190
  * Complete the perfEvent and fire any notifications.
191
- * @param perfEvent Fire the event which will also complete the passed event
191
+ * @param perfEvent - Fire the event which will also complete the passed event
192
192
  */
193
193
  public fire(perfEvent: IPerfEvent): void {
194
194
  // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging