@microsoft/applicationinsights-core-js 3.0.0-beta.2208-03 → 3.0.0-beta.2208-16

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 (121) hide show
  1. package/README.md +7 -0
  2. package/browser/applicationinsights-core-js.integrity.json +9 -9
  3. package/browser/applicationinsights-core-js.js +2040 -2155
  4. package/browser/applicationinsights-core-js.js.map +1 -1
  5. package/browser/applicationinsights-core-js.min.js +2 -2
  6. package/browser/applicationinsights-core-js.min.js.map +1 -1
  7. package/dist/applicationinsights-core-js.api.json +6998 -10817
  8. package/dist/applicationinsights-core-js.api.md +88 -177
  9. package/dist/applicationinsights-core-js.d.ts +94 -494
  10. package/dist/applicationinsights-core-js.js +2040 -2155
  11. package/dist/applicationinsights-core-js.js.map +1 -1
  12. package/dist/applicationinsights-core-js.min.js +2 -2
  13. package/dist/applicationinsights-core-js.min.js.map +1 -1
  14. package/dist/applicationinsights-core-js.rollup.d.ts +94 -494
  15. package/dist-esm/JavaScriptSDK/AppInsightsCore.js +2 -2
  16. package/dist-esm/JavaScriptSDK/AppInsightsCore.js.map +1 -1
  17. package/dist-esm/JavaScriptSDK/BaseCore.js +11 -12
  18. package/dist-esm/JavaScriptSDK/BaseCore.js.map +1 -1
  19. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +3 -2
  20. package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js.map +1 -1
  21. package/dist-esm/JavaScriptSDK/ChannelController.js +2 -2
  22. package/dist-esm/JavaScriptSDK/ChannelController.js.map +1 -1
  23. package/dist-esm/JavaScriptSDK/CookieMgr.js +27 -26
  24. package/dist-esm/JavaScriptSDK/CookieMgr.js.map +1 -1
  25. package/dist-esm/JavaScriptSDK/CoreUtils.js +8 -140
  26. package/dist-esm/JavaScriptSDK/CoreUtils.js.map +1 -1
  27. package/dist-esm/JavaScriptSDK/DataCacheHelper.js +2 -2
  28. package/dist-esm/JavaScriptSDK/DataCacheHelper.js.map +1 -1
  29. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +3 -3
  30. package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js.map +1 -1
  31. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +4 -3
  32. package/dist-esm/JavaScriptSDK/DiagnosticLogger.js.map +1 -1
  33. package/dist-esm/JavaScriptSDK/EnvUtils.js +132 -136
  34. package/dist-esm/JavaScriptSDK/EnvUtils.js.map +1 -1
  35. package/dist-esm/JavaScriptSDK/EventHelpers.js +2 -3
  36. package/dist-esm/JavaScriptSDK/EventHelpers.js.map +1 -1
  37. package/dist-esm/JavaScriptSDK/HelperFuncs.js +23 -470
  38. package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
  39. package/dist-esm/JavaScriptSDK/InstrumentHooks.js +5 -5
  40. package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
  41. package/dist-esm/JavaScriptSDK/InternalConstants.js +4 -4
  42. package/dist-esm/JavaScriptSDK/InternalConstants.js.map +1 -1
  43. package/dist-esm/JavaScriptSDK/NotificationManager.js +2 -2
  44. package/dist-esm/JavaScriptSDK/NotificationManager.js.map +1 -1
  45. package/dist-esm/JavaScriptSDK/PerfManager.js +4 -8
  46. package/dist-esm/JavaScriptSDK/PerfManager.js.map +1 -1
  47. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +3 -3
  48. package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js.map +1 -1
  49. package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
  50. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +2 -2
  51. package/dist-esm/JavaScriptSDK/TelemetryHelpers.js.map +1 -1
  52. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js +3 -3
  53. package/dist-esm/JavaScriptSDK/TelemetryInitializerPlugin.js.map +1 -1
  54. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js +2 -3
  55. package/dist-esm/JavaScriptSDK/UnloadHandlerContainer.js.map +1 -1
  56. package/dist-esm/JavaScriptSDK/W3cTraceParent.js +2 -2
  57. package/dist-esm/JavaScriptSDK/W3cTraceParent.js.map +1 -1
  58. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js +5 -31
  59. package/dist-esm/JavaScriptSDK.Enums/EnumHelperFuncs.js.map +1 -1
  60. package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
  61. package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
  62. package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
  63. package/dist-esm/JavaScriptSDK.Enums/TelemetryUnloadReason.js +1 -1
  64. package/dist-esm/JavaScriptSDK.Enums/TelemetryUpdateReason.js +1 -1
  65. package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
  66. package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
  67. package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
  68. package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
  69. package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
  70. package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
  71. package/dist-esm/JavaScriptSDK.Interfaces/IDistributedTraceContext.js +1 -1
  72. package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
  73. package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
  74. package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
  75. package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
  76. package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
  77. package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
  78. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryInitializers.js +1 -1
  79. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
  80. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
  81. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
  82. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUnloadState.js +1 -1
  83. package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryUpdateState.js +1 -1
  84. package/dist-esm/JavaScriptSDK.Interfaces/ITraceParent.js +1 -1
  85. package/dist-esm/JavaScriptSDK.Interfaces/IUnloadableComponent.js +1 -1
  86. package/dist-esm/__DynamicConstants.js +11 -13
  87. package/dist-esm/__DynamicConstants.js.map +1 -1
  88. package/dist-esm/applicationinsights-core-js.js +6 -5
  89. package/dist-esm/applicationinsights-core-js.js.map +1 -1
  90. package/package.json +4 -3
  91. package/src/JavaScriptSDK/AppInsightsCore.ts +1 -1
  92. package/src/JavaScriptSDK/BaseCore.ts +2 -4
  93. package/src/JavaScriptSDK/BaseTelemetryPlugin.ts +2 -1
  94. package/src/JavaScriptSDK/ChannelController.ts +1 -1
  95. package/src/JavaScriptSDK/CookieMgr.ts +6 -5
  96. package/src/JavaScriptSDK/CoreUtils.ts +7 -423
  97. package/src/JavaScriptSDK/DbgExtensionUtils.ts +2 -2
  98. package/src/JavaScriptSDK/DiagnosticLogger.ts +3 -2
  99. package/src/JavaScriptSDK/EnvUtils.ts +145 -148
  100. package/src/JavaScriptSDK/EventHelpers.ts +1 -2
  101. package/src/JavaScriptSDK/HelperFuncs.ts +22 -536
  102. package/src/JavaScriptSDK/InstrumentHooks.ts +4 -4
  103. package/src/JavaScriptSDK/InternalConstants.ts +3 -3
  104. package/src/JavaScriptSDK/NotificationManager.ts +1 -1
  105. package/src/JavaScriptSDK/PerfManager.ts +3 -7
  106. package/src/JavaScriptSDK/ProcessTelemetryContext.ts +4 -4
  107. package/src/JavaScriptSDK/TelemetryHelpers.ts +1 -1
  108. package/src/JavaScriptSDK/TelemetryInitializerPlugin.ts +2 -2
  109. package/src/JavaScriptSDK/UnloadHandlerContainer.ts +1 -2
  110. package/src/JavaScriptSDK/W3cTraceParent.ts +1 -1
  111. package/src/JavaScriptSDK.Enums/EnumHelperFuncs.ts +5 -36
  112. package/src/JavaScriptSDK.Interfaces/ITelemetryPlugin.ts +7 -0
  113. package/tsconfig.json +1 -1
  114. package/types/JavaScriptSDK/CoreUtils.d.ts +0 -270
  115. package/types/JavaScriptSDK/EnvUtils.d.ts +0 -65
  116. package/types/JavaScriptSDK/HelperFuncs.d.ts +3 -154
  117. package/types/JavaScriptSDK.Enums/EnumHelperFuncs.d.ts +6 -18
  118. package/types/JavaScriptSDK.Interfaces/ITelemetryPlugin.d.ts +6 -0
  119. package/types/__DynamicConstants.d.ts +2 -4
  120. package/types/applicationinsights-core-js.d.ts +5 -4
  121. package/types/tsdoc-metadata.json +1 -1
@@ -1,12 +1,12 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
  import dynamicProto from "@microsoft/dynamicproto-js";
4
+ import { arrForEach, arrIndexOf } from "@nevware21/ts-utils";
4
5
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
5
6
  import { INotificationListener } from "../JavaScriptSDK.Interfaces/INotificationListener";
6
7
  import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
7
8
  import { IPerfEvent } from "../JavaScriptSDK.Interfaces/IPerfEvent";
8
9
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
9
- import { arrForEach, arrIndexOf } from "./HelperFuncs";
10
10
  import { STR_EVENTS_DISCARDED, STR_EVENTS_SEND_REQUEST, STR_EVENTS_SENT, STR_PERF_EVENT } from "./InternalConstants";
11
11
 
12
12
  function _runListeners(listeners: INotificationListener[], name: string, isAsync: boolean, callback: (listener: INotificationListener) => void) {
@@ -1,10 +1,11 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
  import dynamicProto from "@microsoft/dynamicproto-js";
4
+ import { isArray, isFunction, objDefineAccessors } from "@nevware21/ts-utils";
4
5
  import { INotificationManager } from "../JavaScriptSDK.Interfaces/INotificationManager";
5
6
  import { IPerfEvent } from "../JavaScriptSDK.Interfaces/IPerfEvent";
6
7
  import { IPerfManager, IPerfManagerProvider } from "../JavaScriptSDK.Interfaces/IPerfManager";
7
- import { dateNow, isArray, isFunction, objDefineAccessors } from "./HelperFuncs";
8
+ import { dateNow } from "./HelperFuncs";
8
9
  import { STR_GET_PERF_MGR } from "./InternalConstants";
9
10
 
10
11
  const strExecutionContextKey = "ctx";
@@ -63,7 +64,6 @@ export class PerfEvent implements IPerfEvent {
63
64
 
64
65
  constructor(name: string, payloadDetails: () => any, isAsync: boolean) {
65
66
  let _self = this;
66
- let accessorDefined = false;
67
67
  _self.start = dateNow();
68
68
  _self.name = name;
69
69
  _self.isAsync = isAsync;
@@ -72,7 +72,7 @@ export class PerfEvent implements IPerfEvent {
72
72
  if (isFunction(payloadDetails)) {
73
73
  // Create an accessor to minimize the potential performance impact of executing the payloadDetails callback
74
74
  let theDetails:any;
75
- accessorDefined = objDefineAccessors(_self, "payload", () => {
75
+ objDefineAccessors(_self, "payload", () => {
76
76
  // Delay the execution of the payloadDetails until needed
77
77
  if (!theDetails && isFunction(payloadDetails)) {
78
78
  theDetails = payloadDetails();
@@ -130,10 +130,6 @@ export class PerfEvent implements IPerfEvent {
130
130
  _self.time = dateNow() - _self.start;
131
131
  _self.exTime = _self.time - childTime;
132
132
  _self.complete = () => {};
133
- if (!accessorDefined && isFunction(payloadDetails)) {
134
- // If we couldn't define the property set during complete -- to minimize the perf impact until after the time
135
- _self.payload = payloadDetails();
136
- }
137
133
  };
138
134
  }
139
135
  }
@@ -2,6 +2,9 @@
2
2
  // Licensed under the MIT License.
3
3
  "use strict";
4
4
 
5
+ import {
6
+ arrForEach, dumpObj, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objForEachKey, objFreeze, objKeys
7
+ } from "@nevware21/ts-utils";
5
8
  import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
6
9
  import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
7
10
  import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
@@ -15,10 +18,7 @@ import { ITelemetryPluginChain } from "../JavaScriptSDK.Interfaces/ITelemetryPlu
15
18
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
16
19
  import { ITelemetryUpdateState } from "../JavaScriptSDK.Interfaces/ITelemetryUpdateState";
17
20
  import { _throwInternal, safeGetLogger } from "./DiagnosticLogger";
18
- import { dumpObj } from "./EnvUtils";
19
- import {
20
- arrForEach, isArray, isFunction, isNullOrUndefined, isObject, isUndefined, objExtend, objForEachKey, objFreeze, objKeys, proxyFunctions
21
- } from "./HelperFuncs";
21
+ import { objExtend, proxyFunctions } from "./HelperFuncs";
22
22
  import { STR_CORE, STR_DISABLED, STR_EMPTY } from "./InternalConstants";
23
23
  import { doPerf } from "./PerfManager";
24
24
  import { _getPluginState } from "./TelemetryHelpers";
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  "use strict";
4
4
 
5
+ import { arrForEach, isFunction } from "@nevware21/ts-utils";
5
6
  import { IAppInsightsCore } from "../JavaScriptSDK.Interfaces/IAppInsightsCore";
6
7
  import { IDistributedTraceContext } from "../JavaScriptSDK.Interfaces/IDistributedTraceContext";
7
8
  import { IProcessTelemetryContext, IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
@@ -11,7 +12,6 @@ import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnl
11
12
  import { ITraceParent } from "../JavaScriptSDK.Interfaces/ITraceParent";
12
13
  import { IUnloadableComponent } from "../JavaScriptSDK.Interfaces/IUnloadableComponent";
13
14
  import { createElmNodeData } from "./DataCacheHelper";
14
- import { arrForEach, isFunction } from "./HelperFuncs";
15
15
  import { STR_CORE, STR_PRIORITY, STR_PROCESS_TELEMETRY } from "./InternalConstants";
16
16
  import { isValidSpanId, isValidTraceId } from "./W3cTraceParent";
17
17
 
@@ -2,6 +2,7 @@
2
2
  // // Licensed under the MIT License.
3
3
 
4
4
  import dynamicProto from "@microsoft/dynamicproto-js";
5
+ import { arrForEach, dumpObj } from "@nevware21/ts-utils";
5
6
  import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
6
7
  import { IProcessTelemetryContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
7
8
  import {
@@ -10,8 +11,7 @@ import {
10
11
  import { ITelemetryItem } from "../JavaScriptSDK.Interfaces/ITelemetryItem";
11
12
  import { BaseTelemetryPlugin } from "./BaseTelemetryPlugin";
12
13
  import { _throwInternal } from "./DiagnosticLogger";
13
- import { dumpObj } from "./EnvUtils";
14
- import { arrForEach, getExceptionName } from "./HelperFuncs";
14
+ import { getExceptionName } from "./HelperFuncs";
15
15
 
16
16
  interface _IInternalTelemetryInitializerHandler {
17
17
  id: number;
@@ -1,12 +1,11 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
+ import { arrForEach, dumpObj } from "@nevware21/ts-utils";
4
5
  import { _eInternalMessageId, eLoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
5
6
  import { IProcessTelemetryUnloadContext } from "../JavaScriptSDK.Interfaces/IProcessTelemetryContext";
6
7
  import { ITelemetryUnloadState } from "../JavaScriptSDK.Interfaces/ITelemetryUnloadState";
7
8
  import { _throwInternal } from "./DiagnosticLogger";
8
- import { dumpObj } from "./EnvUtils";
9
- import { arrForEach } from "./HelperFuncs";
10
9
 
11
10
  export type UnloadHandler = (itemCtx: IProcessTelemetryUnloadContext, unloadState: ITelemetryUnloadState) => void;
12
11
 
@@ -1,7 +1,7 @@
1
+ import { isArray, isString, strTrim } from "@nevware21/ts-utils";
1
2
  import { ITraceParent } from "../JavaScriptSDK.Interfaces/ITraceParent";
2
3
  import { generateW3CId } from "./CoreUtils";
3
4
  import { findMetaTag, findNamedServerTiming } from "./EnvUtils";
4
- import { isArray, isString, strTrim } from "./HelperFuncs";
5
5
 
6
6
  // using {0,16} for leading and trailing whitespace just to constrain the possible runtime of a random string
7
7
  const TRACE_PARENT_REGEX = /^([\da-f]{2})-([\da-f]{32})-([\da-f]{16})-([\da-f]{2})(-[^\s]*)?$/;
@@ -1,40 +1,17 @@
1
1
  // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
  // Licensed under the MIT License.
3
3
 
4
- import { objForEachKey, deepFreeze } from "../JavaScriptSDK/HelperFuncs";
4
+ import { EnumCls, createEnum, createTypeMap } from "@nevware21/ts-utils";
5
5
 
6
- export declare type EnumValue<E = any> = { readonly [key in keyof E]: E[key] };
7
- export declare type EnumMap<E = any, I = E> = { readonly [key in keyof E extends string ? keyof E : never]: key extends string ? key : keyof E } & I;
6
+ export declare type EnumValue<E = any> = EnumCls<E>;
7
+ // export declare type EnumMap<E = any, I = E> = EnumNameMap<E, I>;
8
8
 
9
9
  /**
10
10
  * Create an enum style object which has both the key => value and value => key mappings
11
11
  * @param values - The values to populate on the new object
12
12
  * @returns
13
13
  */
14
- export function createEnumStyle<E>(values: { [key in keyof E]: E[keyof E] }): EnumValue<E> {
15
- let enumClass: any = {};
16
- objForEachKey(values, (field, value) => {
17
- enumClass[field] = value;
18
- enumClass[value] = field;
19
- });
20
-
21
- return deepFreeze(enumClass);
22
- }
23
-
24
- /**
25
- * Create a 2 index map that maps an enum's key as both the key and value, X["key"] => "key" and X[0] => "keyof 0".
26
- * @param values - The values to populate on the new object
27
- * @returns
28
- */
29
- export function createEnumMap<E, I = keyof E>(values: { [key in keyof E]: E[keyof E] }): EnumMap<E, I> {
30
- let mapClass: any = {};
31
- objForEachKey(values, (field, value) => {
32
- mapClass[field] = field;
33
- mapClass[value] = field;
34
- });
35
-
36
- return deepFreeze(mapClass);
37
- }
14
+ export const createEnumStyle: <E>(values: { [key in keyof E]: E[keyof E] }) => EnumValue<E> = createEnum;
38
15
 
39
16
  /**
40
17
  * Create a 2 index map that maps an enum's key and value to the defined map value, X["key"] => mapValue and X[0] => mapValue.
@@ -45,12 +22,4 @@ export function createEnumMap<E, I = keyof E>(values: { [key in keyof E]: E[keyo
45
22
  * @param values - The values to populate on the new object
46
23
  * @returns
47
24
  */
48
- export function createValueMap<E, V = E>(values: { [key in keyof E]: [ E[keyof E], V[keyof V] ] }): V {
49
- let mapClass: any = {};
50
- objForEachKey(values, (field, value) => {
51
- mapClass[field] = value[1];
52
- mapClass[value[0]] = value[1];
53
- });
54
-
55
- return deepFreeze(mapClass);
56
- }
25
+ export const createValueMap: <E, V = E>(values: { [key in keyof E]: [ E[keyof E], V[keyof V] ] }) => V = createTypeMap;
@@ -84,4 +84,11 @@ export interface IPlugin {
84
84
  * Plugin version (available in data.properties.version in common schema)
85
85
  */
86
86
  readonly version?: string;
87
+
88
+ /**
89
+ * The App Insights core to use for backward compatibility.
90
+ * Therefore the interface will be able to access the core without needing to cast to "any".
91
+ * [optional] any 3rd party plugins which are already implementing this interface don't fail to compile.
92
+ */
93
+ core?: IAppInsightsCore
87
94
  }
package/tsconfig.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "noImplicitAny": true,
6
6
  "module": "es6",
7
7
  "moduleResolution": "node",
8
- "target": "es3",
8
+ "target": "es5",
9
9
  "forceConsistentCasingInFileNames": true,
10
10
  "importHelpers": true,
11
11
  "noEmitHelpers": true,
@@ -1,6 +1,3 @@
1
- import { IConfiguration } from "../JavaScriptSDK.Interfaces/IConfiguration";
2
- import { ICookieMgr } from "../JavaScriptSDK.Interfaces/ICookieMgr";
3
- import { IDiagnosticLogger } from "../JavaScriptSDK.Interfaces/IDiagnosticLogger";
4
1
  export declare const Undefined = "undefined";
5
2
  export declare function newGuid(): string;
6
3
  /**
@@ -19,270 +16,3 @@ export declare function strEndsWith(value: string, search: string): boolean;
19
16
  * generate W3C trace id
20
17
  */
21
18
  export declare function generateW3CId(): string;
22
- /**
23
- * Provides a collection of utility functions, included for backward compatibility with previous releases.
24
- * @deprecated Marking this interface and instance as deprecated in favor of direct usage of the helper functions
25
- * as direct usage provides better tree-shaking and minification by avoiding the inclusion of the unused items
26
- * in your resulting code.
27
- */
28
- export interface ICoreUtils {
29
- /**
30
- * Internal - Do not use directly.
31
- * @deprecated Direct usage of this property is not recommend
32
- */
33
- _canUseCookies: boolean;
34
- isTypeof: (value: any, theType: string) => boolean;
35
- isUndefined: (value: any) => boolean;
36
- isNullOrUndefined: (value: any) => boolean;
37
- hasOwnProperty: (obj: any, prop: string) => boolean;
38
- /**
39
- * Checks if the passed of value is a function.
40
- * @param {any} value - Value to be checked.
41
- * @return {boolean} True if the value is a boolean, false otherwise.
42
- */
43
- isFunction: (value: any) => value is Function;
44
- /**
45
- * Checks if the passed of value is a function.
46
- * @param {any} value - Value to be checked.
47
- * @return {boolean} True if the value is a boolean, false otherwise.
48
- */
49
- isObject: (value: any) => boolean;
50
- /**
51
- * Check if an object is of type Date
52
- */
53
- isDate: (obj: any) => obj is Date;
54
- /**
55
- * Check if an object is of type Array
56
- */
57
- isArray: (obj: any) => boolean;
58
- /**
59
- * Check if an object is of type Error
60
- */
61
- isError: (obj: any) => obj is Error;
62
- /**
63
- * Checks if the type of value is a string.
64
- * @param {any} value - Value to be checked.
65
- * @return {boolean} True if the value is a string, false otherwise.
66
- */
67
- isString: (value: any) => value is string;
68
- /**
69
- * Checks if the type of value is a number.
70
- * @param {any} value - Value to be checked.
71
- * @return {boolean} True if the value is a number, false otherwise.
72
- */
73
- isNumber: (value: any) => value is number;
74
- /**
75
- * Checks if the type of value is a boolean.
76
- * @param {any} value - Value to be checked.
77
- * @return {boolean} True if the value is a boolean, false otherwise.
78
- */
79
- isBoolean: (value: any) => value is boolean;
80
- /**
81
- * Convert a date to I.S.O. format in IE8
82
- */
83
- toISOString: (date: Date) => string;
84
- /**
85
- * Performs the specified action for each element in an array. This helper exists to avoid adding a polyfil for older browsers
86
- * that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
87
- * implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
88
- * cause a testing requirement to test with and without the implementations
89
- * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. It can return -1 to break out of the loop
90
- * @param thisArg [Optional] An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
91
- */
92
- arrForEach: <T>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => void | number, thisArg?: any) => void;
93
- /**
94
- * Returns the index of the first occurrence of a value in an array. This helper exists to avoid adding a polyfil for older browsers
95
- * that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype
96
- * implementation. Note: For consistency this will not use the Array.prototype.xxxx implementation if it exists as this would
97
- * cause a testing requirement to test with and without the implementations
98
- * @param searchElement The value to locate in the array.
99
- * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
100
- */
101
- arrIndexOf: <T>(arr: T[], searchElement: T, fromIndex?: number) => number;
102
- /**
103
- * Calls a defined callback function on each element of an array, and returns an array that contains the results. This helper exists
104
- * to avoid adding a polyfil for older browsers that do not define Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page
105
- * checks for presence/absence of the prototype implementation. Note: For consistency this will not use the Array.prototype.xxxx
106
- * implementation if it exists as this would cause a testing requirement to test with and without the implementations
107
- * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
108
- * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
109
- */
110
- arrMap: <T, R>(arr: T[], callbackfn: (value: T, index?: number, array?: T[]) => R, thisArg?: any) => R[];
111
- /**
112
- * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is
113
- * provided as an argument in the next call to the callback function. This helper exists to avoid adding a polyfil for older browsers that do not define
114
- * Array.prototype.xxxx (eg. ES3 only, IE8) just in case any page checks for presence/absence of the prototype implementation. Note: For consistency
115
- * this will not use the Array.prototype.xxxx implementation if it exists as this would cause a testing requirement to test with and without the implementations
116
- * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
117
- * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
118
- */
119
- arrReduce: <T, R>(arr: T[], callbackfn: (previousValue: T | R, currentValue?: T, currentIndex?: number, array?: T[]) => R, initialValue?: R) => R;
120
- /**
121
- * helper method to trim strings (IE8 does not implement String.prototype.trim)
122
- */
123
- strTrim: (str: any) => string;
124
- /**
125
- * Creates an object that has the specified prototype, and that optionally contains specified properties. This helper exists to avoid adding a polyfil
126
- * for older browsers that do not define Object.create eg. ES3 only, IE8 just in case any page checks for presence/absence of the prototype implementation.
127
- * Note: For consistency this will not use the Object.create implementation if it exists as this would cause a testing requirement to test with and without the implementations
128
- * @param obj Object to use as a prototype. May be null
129
- */
130
- objCreate: (obj: object) => any;
131
- /**
132
- * Returns the names of the enumerable string properties and methods of an object. This helper exists to avoid adding a polyfil for older browsers
133
- * that do not define Object.keys eg. ES3 only, IE8 just in case any page checks for presence/absence of the prototype implementation.
134
- * Note: For consistency this will not use the Object.keys implementation if it exists as this would cause a testing requirement to test with and without the implementations
135
- * @param obj Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
136
- */
137
- objKeys: (obj: {}) => string[];
138
- /**
139
- * Try to define get/set object property accessors for the target object/prototype, this will provide compatibility with
140
- * existing API definition when run within an ES5+ container that supports accessors but still enable the code to be loaded
141
- * and executed in an ES3 container, providing basic IE8 compatibility.
142
- * @param target The object on which to define the property.
143
- * @param prop The name of the property to be defined or modified.
144
- * @param getProp The getter function to wire against the getter.
145
- * @param setProp The setter function to wire against the setter.
146
- * @returns True if it was able to create the accessors otherwise false
147
- */
148
- objDefineAccessors: <T>(target: any, prop: string, getProp?: () => T, setProp?: (v: T) => void) => boolean;
149
- /**
150
- * Trys to add an event handler for the specified event to the window, body and document
151
- * @param eventName {string} - The name of the event
152
- * @param callback {any} - The callback function that needs to be executed for the given event
153
- * @return {boolean} - true if the handler was successfully added
154
- */
155
- addEventHandler: (eventName: string, callback: any, evtNamespace?: string | string[]) => boolean;
156
- /**
157
- * Return the current time via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less)
158
- * https://caniuse.com/#search=Date.now
159
- */
160
- dateNow: () => number;
161
- /**
162
- * Identifies whether the current environment appears to be IE
163
- */
164
- isIE: () => boolean;
165
- /**
166
- * @deprecated - Use the core.getCookieMgr().disable()
167
- * Force the SDK not to store and read any data from cookies.
168
- */
169
- disableCookies: () => void;
170
- newGuid: () => string;
171
- /**
172
- * Return the current value of the Performance Api now() function (if available) and fallback to dateNow() if it is unavailable (IE9 or less)
173
- * https://caniuse.com/#search=performance.now
174
- */
175
- perfNow: () => number;
176
- /**
177
- * Generate random base64 id string.
178
- * The default length is 22 which is 132-bits so almost the same as a GUID but as base64 (the previous default was 5)
179
- * @param maxLength - Optional value to specify the length of the id to be generated, defaults to 22
180
- */
181
- newId: (maxLength?: number) => string;
182
- /**
183
- * Generate a random value between 0 and maxValue, max value should be limited to a 32-bit maximum.
184
- * So maxValue(16) will produce a number from 0..16 (range of 17)
185
- * @param maxValue
186
- */
187
- randomValue: (maxValue: number) => number;
188
- /**
189
- * generate a random 32-bit number (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), defaults un-unsigned.
190
- * @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)
191
- */
192
- random32: (signed?: boolean) => number;
193
- /**
194
- * Seed the MWC random number generator with the specified seed or a random value
195
- * @param value - optional the number to used as the seed, if undefined, null or zero a random value will be chosen
196
- */
197
- mwcRandomSeed: (value?: number) => void;
198
- /**
199
- * Generate a random 32-bit number between (0x000000..0xFFFFFFFF) or (-0x80000000..0x7FFFFFFF), using MWC (Multiply with carry)
200
- * instead of Math.random() defaults to un-signed.
201
- * Used as a replacement random generator for IE to avoid issues with older IE instances.
202
- * @param signed - True to return a signed 32-bit number (-0x80000000..0x7FFFFFFF) otherwise an unsigned one (0x000000..0xFFFFFFFF)
203
- */
204
- mwcRandom32: (signed?: boolean) => number;
205
- /**
206
- * generate W3C trace id
207
- */
208
- generateW3CId: () => string;
209
- }
210
- /**
211
- * Provides a collection of utility functions, included for backward compatibility with previous releases.
212
- * @deprecated Marking this instance as deprecated in favor of direct usage of the helper functions
213
- * as direct usage provides better tree-shaking and minification by avoiding the inclusion of the unused items
214
- * in your resulting code.
215
- */
216
- export declare const CoreUtils: ICoreUtils;
217
- export interface IEventHelper {
218
- /**
219
- * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
220
- * @param obj Object to add the event too.
221
- * @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix
222
- * @param handlerRef Pointer that specifies the function to call when event fires
223
- * @returns True if the function was bound successfully to the event, otherwise false
224
- */
225
- Attach: (obj: any, eventNameWithoutOn: string, handlerRef: any) => boolean;
226
- /**
227
- * Binds the specified function to an event, so that the function gets called whenever the event fires on the object
228
- * @deprecated Use {@link EventHelper#Attach} as we are already in a class call EventHelper the extra "Event" just causes a larger result
229
- * @param obj Object to add the event too.
230
- * @param eventNameWithoutOn String that specifies any of the standard DHTML Events without "on" prefix
231
- * @param handlerRef Pointer that specifies the function to call when event fires
232
- * @returns True if the function was bound successfully to the event, otherwise false
233
- */
234
- AttachEvent: (obj: any, eventNameWithoutOn: string, handlerRef: any) => boolean;
235
- /**
236
- * Removes an event handler for the specified event
237
- * @param eventName {string} - The name of the event
238
- * @param callback {any} - The callback function that needs to be executed for the given event
239
- * @return {boolean} - true if the handler was successfully added
240
- */
241
- Detach: (obj: any, eventNameWithoutOn: string, handlerRef: any) => void;
242
- /**
243
- * Removes an event handler for the specified event
244
- * @deprecated Use {@link EventHelper#Detach} as we are already in a class call EventHelper the extra "Event" just causes a larger result
245
- * @param eventName {string} - The name of the event
246
- * @param callback {any} - The callback function that needs to be executed for the given event
247
- * @return {boolean} - true if the handler was successfully added
248
- */
249
- DetachEvent: (obj: any, eventNameWithoutOn: string, handlerRef: any) => void;
250
- }
251
- export declare const EventHelper: IEventHelper;
252
- /**
253
- * Helper to support backward compatibility for users that use the legacy cookie handling functions and the use the internal
254
- * CoreUtils._canUseCookies global flag to enable/disable cookies usage.
255
- * Note: This has the following deliberate side-effects
256
- * - Creates the global (legacy) cookie manager if it does not already exist
257
- * - Attempts to add "listeners" to the CoreUtils._canUseCookies property to support the legacy usage
258
- * @param config
259
- * @param logger
260
- * @returns
261
- */
262
- export declare function _legacyCookieMgr(config?: IConfiguration, logger?: IDiagnosticLogger): ICookieMgr;
263
- /**
264
- * @deprecated - Use the core.getCookieMgr().disable()
265
- * Force the SDK not to store and read any data from cookies.
266
- */
267
- export declare function disableCookies(): void;
268
- /**
269
- * @deprecated - Use the core.getCookieMgr().isEnabled()
270
- * Helper method to tell if document.cookie object is available and whether it can be used.
271
- */
272
- export declare function canUseCookies(logger: IDiagnosticLogger): any;
273
- /**
274
- * @deprecated - Use the core.getCookieMgr().get()
275
- * helper method to access userId and sessionId cookie
276
- */
277
- export declare function getCookie(logger: IDiagnosticLogger, name: string): string;
278
- /**
279
- * @deprecated - Use the core.getCookieMgr().set()
280
- * helper method to set userId and sessionId cookie
281
- */
282
- export declare function setCookie(logger: IDiagnosticLogger, name: string, value: string, domain?: string): void;
283
- /**
284
- * @deprecated - Use the core.getCookieMgr().del()
285
- * Deletes a cookie by setting it's expiration time in the past.
286
- * @param name - The name of the cookie to delete.
287
- */
288
- export declare function deleteCookie(logger: IDiagnosticLogger, name: string): boolean;
@@ -3,67 +3,6 @@
3
3
  * @param enabled
4
4
  */
5
5
  export declare function setEnableEnvMocks(enabled: boolean): void;
6
- /**
7
- * Return the named global object if available, will return null if the object is not available.
8
- * @param name The globally named object
9
- */
10
- export declare function getGlobalInst<T>(name: string): T;
11
- /**
12
- * Checks if window object is available, this is required as we support the API running without a
13
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a window
14
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: window is not defined"
15
- * exception will be thrown.
16
- * Defined as a function to support lazy / late binding environments.
17
- */
18
- export declare function hasWindow(): boolean;
19
- /**
20
- * Returns the global window object if it is present otherwise null.
21
- * This helper is used to access the window object without causing an exception
22
- * "Uncaught ReferenceError: window is not defined"
23
- */
24
- export declare function getWindow(): Window | null;
25
- /**
26
- * Checks if document object is available, this is required as we support the API running without a
27
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a document
28
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: document is not defined"
29
- * exception will be thrown.
30
- * Defined as a function to support lazy / late binding environments.
31
- */
32
- export declare function hasDocument(): boolean;
33
- /**
34
- * Returns the global document object if it is present otherwise null.
35
- * This helper is used to access the document object without causing an exception
36
- * "Uncaught ReferenceError: document is not defined"
37
- */
38
- export declare function getDocument(): Document | null;
39
- /**
40
- * Checks if navigator object is available, this is required as we support the API running without a
41
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a navigator
42
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: navigator is not defined"
43
- * exception will be thrown.
44
- * Defined as a function to support lazy / late binding environments.
45
- */
46
- export declare function hasNavigator(): boolean;
47
- /**
48
- * Returns the global navigator object if it is present otherwise null.
49
- * This helper is used to access the navigator object without causing an exception
50
- * "Uncaught ReferenceError: navigator is not defined"
51
- */
52
- export declare function getNavigator(): Navigator | null;
53
- /**
54
- * Checks if history object is available, this is required as we support the API running without a
55
- * window /document (eg. Node server, electron webworkers) and if we attempt to assign a history
56
- * object to a local variable or pass as an argument an "Uncaught ReferenceError: history is not defined"
57
- * exception will be thrown.
58
- * Defined as a function to support lazy / late binding environments.
59
- */
60
- export declare function hasHistory(): boolean;
61
- /**
62
- * Returns the global history object if it is present otherwise null.
63
- * This helper is used to access the history object without causing an exception
64
- * "Uncaught ReferenceError: history is not defined"
65
- */
66
- export declare function getHistory(): History | null;
67
6
  /**
68
7
  * Returns the global location object if it is present otherwise null.
69
8
  * This helper is used to access the location object without causing an exception
@@ -118,10 +57,6 @@ export declare function isIE(): boolean;
118
57
  * Gets IE version returning the document emulation mode if we are running on IE, or null otherwise
119
58
  */
120
59
  export declare function getIEVersion(userAgentStr?: string): number;
121
- /**
122
- * Returns string representation of an object suitable for diagnostics logging.
123
- */
124
- export declare function dumpObj(object: any): string;
125
60
  export declare function isSafari(userAgentStr?: string): boolean;
126
61
  /**
127
62
  * Checks if HTML5 Beacons are supported in the current environment.