@microsoft/1ds-core-js 3.2.3 → 3.2.6

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 (77) hide show
  1. package/CODE_OF_CONDUCT.md +9 -0
  2. package/CONTRIBUTING.md +14 -0
  3. package/LICENSE.TXT +3 -3
  4. package/NOTICE +17 -0
  5. package/PRIVACY +3 -0
  6. package/README.md +15 -1
  7. package/SECURITY.md +41 -0
  8. package/SUPPORT.md +14 -0
  9. package/bundle/{ms.core-3.2.3.gbl.js → ms.core-3.2.6.gbl.js} +826 -725
  10. package/bundle/ms.core-3.2.6.gbl.js.map +1 -0
  11. package/bundle/ms.core-3.2.6.gbl.min.js +7 -0
  12. package/bundle/ms.core-3.2.6.gbl.min.js.map +1 -0
  13. package/bundle/ms.core-3.2.6.integrity.json +46 -0
  14. package/bundle/{ms.core-3.2.3.js → ms.core-3.2.6.js} +826 -725
  15. package/bundle/ms.core-3.2.6.js.map +1 -0
  16. package/bundle/ms.core-3.2.6.min.js +7 -0
  17. package/bundle/ms.core-3.2.6.min.js.map +1 -0
  18. package/bundle/ms.core.gbl.js +825 -724
  19. package/bundle/ms.core.gbl.js.map +1 -1
  20. package/bundle/ms.core.gbl.min.js +2 -2
  21. package/bundle/ms.core.gbl.min.js.map +1 -1
  22. package/bundle/ms.core.integrity.json +17 -17
  23. package/bundle/ms.core.js +825 -724
  24. package/bundle/ms.core.js.map +1 -1
  25. package/bundle/ms.core.min.js +2 -2
  26. package/bundle/ms.core.min.js.map +1 -1
  27. package/dist/ms.core.js +36 -35
  28. package/dist/ms.core.js.map +1 -1
  29. package/dist/ms.core.min.js +2 -2
  30. package/dist/ms.core.min.js.map +1 -1
  31. package/dist-esm/src/AppInsightsCore.d.ts +2 -7
  32. package/dist-esm/src/AppInsightsCore.js +25 -27
  33. package/dist-esm/src/AppInsightsCore.js.map +1 -1
  34. package/dist-esm/src/BaseCore.d.ts +2 -2
  35. package/dist-esm/src/BaseCore.js +17 -11
  36. package/dist-esm/src/BaseCore.js.map +1 -1
  37. package/dist-esm/src/DataModels.d.ts +5 -0
  38. package/dist-esm/src/DataModels.js +1 -1
  39. package/dist-esm/src/ESPromise.d.ts +5 -5
  40. package/dist-esm/src/ESPromise.js +7 -7
  41. package/dist-esm/src/ESPromise.js.map +1 -1
  42. package/dist-esm/src/ESPromiseScheduler.d.ts +4 -4
  43. package/dist-esm/src/ESPromiseScheduler.js +8 -8
  44. package/dist-esm/src/ESPromiseScheduler.js.map +1 -1
  45. package/dist-esm/src/Enums.d.ts +5 -5
  46. package/dist-esm/src/Enums.js +6 -6
  47. package/dist-esm/src/Enums.js.map +1 -1
  48. package/dist-esm/src/Index.d.ts +1 -2
  49. package/dist-esm/src/Index.js +2 -2
  50. package/dist-esm/src/Index.js.map +1 -1
  51. package/dist-esm/src/InternalConstants.d.ts +6 -0
  52. package/dist-esm/src/InternalConstants.js +19 -0
  53. package/dist-esm/src/InternalConstants.js.map +1 -0
  54. package/dist-esm/src/Utils.d.ts +9 -3
  55. package/dist-esm/src/Utils.js +19 -18
  56. package/dist-esm/src/Utils.js.map +1 -1
  57. package/dist-esm/src/ValueSanitizer.d.ts +1 -1
  58. package/dist-esm/src/ValueSanitizer.js +5 -4
  59. package/dist-esm/src/ValueSanitizer.js.map +1 -1
  60. package/package.json +4 -2
  61. package/src/AppInsightsCore.ts +29 -31
  62. package/src/BaseCore.ts +14 -11
  63. package/src/DataModels.ts +6 -0
  64. package/src/ESPromise.ts +6 -6
  65. package/src/ESPromiseScheduler.ts +8 -8
  66. package/src/Enums.ts +5 -5
  67. package/src/Index.ts +1 -1
  68. package/src/InternalConstants.ts +16 -0
  69. package/src/Utils.ts +24 -24
  70. package/src/ValueSanitizer.ts +5 -4
  71. package/bundle/ms.core-3.2.3.gbl.js.map +0 -1
  72. package/bundle/ms.core-3.2.3.gbl.min.js +0 -7
  73. package/bundle/ms.core-3.2.3.gbl.min.js.map +0 -1
  74. package/bundle/ms.core-3.2.3.integrity.json +0 -46
  75. package/bundle/ms.core-3.2.3.js.map +0 -1
  76. package/bundle/ms.core-3.2.3.min.js +0 -7
  77. package/bundle/ms.core-3.2.3.min.js.map +0 -1
package/src/BaseCore.ts CHANGED
@@ -1,15 +1,18 @@
1
1
  /**
2
- * BaseCore.ts
3
- * Base Core is a subset of 1DS Web SDK Core. The purpose of Base Core is to generate a smaller bundle size while providing essential features of Core. Features that are not included in Base Core are:
4
- * 1. Internal logging
5
- * 2. Sending notifications on telemetry sent/discarded
6
- * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
7
- * @copyright Microsoft 2018
8
- */
2
+ * BaseCore.ts
3
+ * Base Core is a subset of 1DS Web SDK Core. The purpose of Base Core is to generate a smaller bundle size while providing essential features of Core. Features that are not included in Base Core are:
4
+ * 1. Internal logging
5
+ * 2. Sending notifications on telemetry sent/discarded
6
+ * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
7
+ * @copyright Microsoft 2018
8
+ */
9
9
  import dynamicProto from "@microsoft/dynamicproto-js";
10
- import { BaseCore as InternalCore, IPlugin, eLoggingSeverity, ITelemetryItem, IDiagnosticLogger, INotificationManager, dumpObj, _throwInternal } from "@microsoft/applicationinsights-core-js";
11
- import { IExtendedConfiguration, IExtendedTelemetryItem, IExtendedAppInsightsCore } from "./DataModels";
10
+ import {
11
+ BaseCore as InternalCore, IDiagnosticLogger, INotificationManager, IPlugin, ITelemetryItem, _throwInternal, dumpObj, eLoggingSeverity
12
+ } from "@microsoft/applicationinsights-core-js";
13
+ import { IExtendedAppInsightsCore, IExtendedConfiguration, IExtendedTelemetryItem } from "./DataModels";
12
14
  import { _eExtendedInternalMessageId } from "./Enums";
15
+ import { STR_DEFAULT_ENDPOINT_URL } from "./InternalConstants";
13
16
  import { FullVersionString, isDocumentObjectAvailable } from "./Utils";
14
17
 
15
18
  export default class BaseCore extends InternalCore implements IExtendedAppInsightsCore {
@@ -24,11 +27,11 @@ export default class BaseCore extends InternalCore implements IExtendedAppInsigh
24
27
 
25
28
  _self.initialize = (config: IExtendedConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager) => {
26
29
  if (config && !config.endpointUrl) {
27
- config.endpointUrl = "https://browser.events.data.microsoft.com/OneCollector/1.0/";
30
+ config.endpointUrl = STR_DEFAULT_ENDPOINT_URL;
28
31
  }
29
32
 
30
33
  _self.getWParam = () => {
31
- return isDocumentObjectAvailable ? 0 : -1;
34
+ return (isDocumentObjectAvailable || !!config.enableWParam) ? 0 : -1;
32
35
  };
33
36
 
34
37
  try {
package/src/DataModels.ts CHANGED
@@ -122,6 +122,12 @@ export interface IExtendedConfiguration extends IConfiguration {
122
122
  * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
123
123
  */
124
124
  disablePageShowEvents?: string[];
125
+
126
+ /**
127
+ * Add "&w=0" parameter to support UA Parsing when web-workers don't have access to Document.
128
+ * Default is false
129
+ */
130
+ enableWParam?: boolean;
125
131
 
126
132
  // End of Internal note: remove these after consuming the ApplicationInsights Core version that defines these on IConfiguration
127
133
  }
package/src/ESPromise.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
- * ESPromise.ts
3
- * @author Nev Wylie (newylie))
4
- * @copyright Microsoft 2019
5
- * Simplified wrapper to provide ES6 style Promise callback handling for older browsers
6
- */
2
+ * ESPromise.ts
3
+ * @author Nev Wylie (newylie))
4
+ * @copyright Microsoft 2019
5
+ * Simplified wrapper to provide ES6 style Promise callback handling for older browsers
6
+ */
7
7
 
8
- import { isFunction } from "@microsoft/applicationinsights-core-js";
9
8
  import dynamicProto from "@microsoft/dynamicproto-js";
9
+ import { isFunction } from "@microsoft/applicationinsights-core-js";
10
10
 
11
11
  /**
12
12
  * @ignore -- Don't include in the generated documentation
@@ -1,13 +1,13 @@
1
1
  /**
2
- * ESPromiseScheduler.ts
3
- * @author Nev Wylie (newylie)
4
- * @copyright Microsoft 2019
5
- */
2
+ * ESPromiseScheduler.ts
3
+ * @author Nev Wylie (newylie)
4
+ * @copyright Microsoft 2019
5
+ */
6
6
 
7
- import ESPromise from "./ESPromise";
8
- import { ResolverResolveFunc, ResolverRejectFunc } from "./ESPromise";
9
- import { IDiagnosticLogger, getGlobal } from "@microsoft/applicationinsights-core-js";
10
7
  import dynamicProto from "@microsoft/dynamicproto-js";
8
+ import ESPromise from "./ESPromise";
9
+ import { IDiagnosticLogger, _warnToConsole, getGlobal } from "@microsoft/applicationinsights-core-js";
10
+ import { ResolverRejectFunc, ResolverResolveFunc } from "./ESPromise";
11
11
 
12
12
  /** This is a default timeout that will cause outstanding running promises to be removed/rejected to avoid filling up memory with blocked events */
13
13
  const LazyRejectPeriod = 600000; // 10 Minutes
@@ -309,7 +309,7 @@ export default class ESPromiseScheduler {
309
309
  }
310
310
 
311
311
  function _warnLog(message: string) {
312
- diagLog && diagLog.warnToConsole("ESPromiseScheduler[" + _scheduledName + "] " + message);
312
+ _warnToConsole(diagLog, "ESPromiseScheduler[" + _scheduledName + "] " + message);
313
313
  }
314
314
  }
315
315
 
package/src/Enums.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Enums.ts
3
- * @author Abhilash Panwar (abpanwar)
4
- * @copyright Microsoft 2018
5
- * File containing the enums as constants.
6
- */
2
+ * Enums.ts
3
+ * @author Abhilash Panwar (abpanwar)
4
+ * @copyright Microsoft 2018
5
+ * File containing the enums as constants.
6
+ */
7
7
 
8
8
  import { _InternalMessageId, _eInternalMessageId, createEnumStyle, objFreeze } from "@microsoft/applicationinsights-core-js";
9
9
 
package/src/Index.ts CHANGED
@@ -37,7 +37,7 @@ export {
37
37
  MinChannelPriorty, EventsDiscardedReason, ICoreUtils, IDiagnosticLogger, DiagnosticLogger, LoggingSeverity, SendRequestReason,
38
38
  IPerfEvent, IPerfManager, IPerfManagerProvider, PerfEvent, PerfManager, doPerf, ICustomProperties, Tags,
39
39
  EventHelper, AppInsightsCore as InternalAppInsightsCore, BaseCore as InternalBaseCore, _InternalLogMessage, _InternalMessageId,
40
- createEnumStyle, eLoggingSeverity, _eInternalMessageId, _throwInternal,// _warnToConsole, _logInternalMessage
40
+ createEnumStyle, eLoggingSeverity, _eInternalMessageId, _throwInternal, _warnToConsole, _logInternalMessage,
41
41
  // The HelperFuncs functions
42
42
  isTypeof, isUndefined, isNullOrUndefined, hasOwnProperty, isObject, isFunction, attachEvent, detachEvent, normalizeJsName,
43
43
  objForEachKey, strStartsWith, strEndsWith, strContains, strTrim, isDate, isArray, isError, isString, isNumber, isBoolean,
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
+ // Licensed under the MIT License.
3
+
4
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5
+ // Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!
6
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7
+
8
+ // Generally you should only put values that are used more than 2 times and then only if not already exposed as a constant (such as SdkCoreNames)
9
+ // as when using "short" named values from here they will be will be minified smaller than the SdkCoreNames[eSdkCoreNames.xxxx] value.
10
+
11
+ export const STR_EMPTY = "";
12
+ export const STR_DEFAULT_ENDPOINT_URL = "https://browser.events.data.microsoft.com/OneCollector/1.0/";
13
+ export const STR_PLUGIN_VERSION_STRING = "pluginVersionString";
14
+ export const STR_PLUGIN_VERSION_STRING_ARR = STR_PLUGIN_VERSION_STRING + "Arr" as "pluginVersionStringArr";
15
+ export const STR_VERSION = "version";
16
+ export const STR_PROPERTIES = "properties";
package/src/Utils.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  /**
2
- * Utils.ts
3
- * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
4
- * @copyright Microsoft 2018
5
- * File containing utility functions.
6
- */
7
- import { objCreateFn, strShimObject } from "@microsoft/applicationinsights-shims";
8
- import { IEventProperty, IExtendedTelemetryItem } from "./DataModels";
9
- import { eEventPropertyType, _ExtendedInternalMessageId, GuidStyle, eValueKind, FieldValueSanitizerType, EventLatency, EventLatencyValue } from "./Enums";
2
+ * Utils.ts
3
+ * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
4
+ * @copyright Microsoft 2018
5
+ * File containing utility functions.
6
+ */
10
7
  import {
11
- ITelemetryItem, getDocument, getNavigator, getWindow, getGlobalInst,
12
- objForEachKey, isUndefined, isNullOrUndefined, isNumber, isReactNative, isString, isBoolean, isArray,
13
- newGuid, isObject, perfNow, hasOwnProperty, addEventHandler, uaDisallowsSameSiteNone, strPrototype, objDefineAccessors,
14
- toISOString, strTrim, isFunction, objKeys, arrReduce, arrMap, arrIndexOf, arrForEach, strUndefined, strObject,
15
- areCookiesSupported, ICookieMgr, safeGetCookieMgr, generateW3CId,
16
- mwcRandom32, mwcRandomSeed, random32, randomValue, newId, isIE, dateNow, isError, isDate, isTypeof, ICoreUtils, strEndsWith, useXDomainRequest, isBeaconsSupported, addPageUnloadEventListener,
8
+ ICookieMgr, ICoreUtils, ITelemetryItem, addEventHandler, addPageUnloadEventListener, areCookiesSupported, arrForEach, arrIndexOf, arrMap,
9
+ arrReduce, dateNow, generateW3CId, getDocument, getGlobalInst, getNavigator, getWindow, hasOwnProperty, isArray, isBeaconsSupported,
10
+ isBoolean, isDate, isError, isFunction, isIE, isNullOrUndefined, isNumber, isObject, isReactNative, isString, isTypeof, isUndefined,
11
+ mwcRandom32, mwcRandomSeed, newGuid, newId, objDefineAccessors, objForEachKey, objKeys, perfNow, random32, randomValue, safeGetCookieMgr,
12
+ strEndsWith, strObject, strTrim, strUndefined, toISOString, uaDisallowsSameSiteNone, useXDomainRequest
17
13
  } from "@microsoft/applicationinsights-core-js";
14
+ import { ObjHasOwnProperty, objCreateFn, strShimObject, strShimPrototype } from "@microsoft/applicationinsights-shims";
15
+ import { IEventProperty, IExtendedTelemetryItem } from "./DataModels";
16
+ import { EventLatency, EventLatencyValue, FieldValueSanitizerType, GuidStyle, eEventPropertyType, eValueKind } from "./Enums";
17
+ import { STR_EMPTY } from "./InternalConstants";
18
18
 
19
19
  export const Version = "#version#";
20
20
  export const FullVersionString = "1DS-Web-JS-" + Version;
@@ -62,7 +62,7 @@ export function isValueAssigned(value: any) {
62
62
  /// <summary> takes a value and checks for undefined, null and empty string </summary>
63
63
  /// <param type="any"> value to be tested </param>
64
64
  /// <returns> true if value is null undefined or emptyString </returns>
65
- return !(value === "" || isNullOrUndefined(value));
65
+ return !(value === STR_EMPTY || isNullOrUndefined(value));
66
66
  }
67
67
 
68
68
  /**
@@ -77,7 +77,7 @@ export function getTenantId(apiKey: string | undefined): string {
77
77
  return apiKey.substring(0, indexTenantId);
78
78
  }
79
79
  }
80
- return "";
80
+ return STR_EMPTY;
81
81
  }
82
82
 
83
83
  /**
@@ -126,10 +126,10 @@ export function sanitizeProperty(name: string,
126
126
  // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.
127
127
  if (propType === "string" || propType === "number" || propType === "boolean" || isArray(property)) {
128
128
  property = ({ value: property } as IEventProperty);
129
- } else if (propType === "object" && !property.hasOwnProperty("value")) {
129
+ } else if (propType === "object" && !ObjHasOwnProperty.call(property, "value")) {
130
130
  property = ({ value: stringifyObjects ? JSON.stringify(property) : property } as IEventProperty);
131
131
  } else if (isNullOrUndefined((property as IEventProperty).value)
132
- || (property as IEventProperty).value === "" || (!isString((property as IEventProperty).value)
132
+ || (property as IEventProperty).value === STR_EMPTY || (!isString((property as IEventProperty).value)
133
133
  && !isNumber((property as IEventProperty).value) && !isBoolean((property as IEventProperty).value)
134
134
  && !isArray((property as IEventProperty).value))) {
135
135
  // Since property is IEventProperty, we need to validate its value
@@ -238,7 +238,7 @@ export function getCookie(name: string): string {
238
238
  return getCookieValue(safeGetCookieMgr(null), name);
239
239
  }
240
240
 
241
- return "";
241
+ return STR_EMPTY;
242
242
  }
243
243
 
244
244
  /**
@@ -258,7 +258,7 @@ export function getCookieValue(cookieMgr: ICookieMgr, name: string, decode: bool
258
258
  }
259
259
  }
260
260
 
261
- return cookieValue || "";
261
+ return cookieValue || STR_EMPTY;
262
262
  }
263
263
 
264
264
  /**
@@ -277,7 +277,7 @@ export function createGuid(style: GuidStyle = GuidStyle.Digits): string {
277
277
  } else if (style === GuidStyle.Parentheses) {
278
278
  theGuid = "(" + theGuid + ")";
279
279
  } else if (style === GuidStyle.Numeric) {
280
- theGuid = theGuid.replace(/-/g, "");
280
+ theGuid = theGuid.replace(/-/g, STR_EMPTY);
281
281
  }
282
282
 
283
283
  return theGuid;
@@ -298,7 +298,7 @@ export function extend(obj?: any, obj2?: any, obj3?: any, obj4?: any, obj5?: any
298
298
  var deep = false;
299
299
  var i = 0;
300
300
  var length = arguments.length;
301
- var objProto = Object[strPrototype];
301
+ var objProto = Object[strShimPrototype];
302
302
  var theArgs = arguments;
303
303
 
304
304
  // Check if a deep merge
@@ -400,7 +400,7 @@ export function getFieldValueType(value: any): FieldValueSanitizerType {
400
400
  // Empty arrays are not supported and are considered to be the same as null
401
401
  theType |= getFieldValueType(value[0]);
402
402
  }
403
- } else if (hasOwnProperty(value, "value")) {
403
+ } else if (ObjHasOwnProperty.call(value, "value")) {
404
404
  // Looks like an IEventProperty
405
405
  theType = FieldValueSanitizerType.EventProperty | getFieldValueType(value.value);
406
406
  }
@@ -562,4 +562,4 @@ export function openXhr(method: string, urlString: string, withCredentials?: boo
562
562
  }
563
563
 
564
564
  return xhr;
565
- }
565
+ }
@@ -1,9 +1,10 @@
1
- import { isNullOrUndefined, objForEachKey, isString } from "@microsoft/applicationinsights-core-js";
2
- import { isValueKind, isValueAssigned, getFieldValueType } from "./Utils";
1
+ import { isNullOrUndefined, isString, objForEachKey } from "@microsoft/applicationinsights-core-js";
3
2
  import {
4
- IEventProperty, IValueSanitizer, FieldValueSanitizerFunc, FieldValueSanitizerTypes, IFieldSanitizerDetails, IFieldValueSanitizerProvider,
3
+ FieldValueSanitizerFunc, FieldValueSanitizerTypes, IEventProperty, IFieldSanitizerDetails, IFieldValueSanitizerProvider, IValueSanitizer
5
4
  } from "./DataModels";
6
5
  import { FieldValueSanitizerType } from "./Enums";
6
+ import { STR_EMPTY } from "./InternalConstants";
7
+ import { getFieldValueType, isValueAssigned, isValueKind } from "./Utils";
7
8
 
8
9
  interface ISanitizerMapValue {
9
10
  canHandle: boolean;
@@ -154,7 +155,7 @@ export class ValueSanitizer implements IValueSanitizer {
154
155
  }
155
156
 
156
157
  // Check that property is valid
157
- if (!isString(name) || isNullOrUndefined(value) || (value as any) === "") {
158
+ if (!isString(name) || isNullOrUndefined(value) || (value as any) === STR_EMPTY) {
158
159
  return null;
159
160
  }
160
161