@microsoft/1ds-core-js 3.2.10 → 4.0.0

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 (95) hide show
  1. package/README.md +1 -1
  2. package/bundle/es5/ms.core-4.0.0.gbl.js +6221 -0
  3. package/bundle/es5/ms.core-4.0.0.gbl.js.map +1 -0
  4. package/bundle/es5/ms.core-4.0.0.gbl.min.js +7 -0
  5. package/bundle/es5/ms.core-4.0.0.gbl.min.js.map +1 -0
  6. package/bundle/es5/ms.core-4.0.0.integrity.json +46 -0
  7. package/bundle/es5/ms.core-4.0.0.js +6225 -0
  8. package/bundle/es5/ms.core-4.0.0.js.map +1 -0
  9. package/bundle/es5/ms.core-4.0.0.min.js +7 -0
  10. package/bundle/es5/ms.core-4.0.0.min.js.map +1 -0
  11. package/bundle/es5/ms.core.gbl.js +6221 -0
  12. package/bundle/es5/ms.core.gbl.js.map +1 -0
  13. package/bundle/es5/ms.core.gbl.min.js +7 -0
  14. package/bundle/es5/ms.core.gbl.min.js.map +1 -0
  15. package/bundle/es5/ms.core.integrity.json +46 -0
  16. package/bundle/es5/ms.core.js +6225 -0
  17. package/bundle/es5/ms.core.js.map +1 -0
  18. package/bundle/es5/ms.core.min.js +7 -0
  19. package/bundle/es5/ms.core.min.js.map +1 -0
  20. package/{bundle → dist/es5}/ms.core.js +3798 -2954
  21. package/dist/es5/ms.core.js.map +1 -0
  22. package/dist/es5/ms.core.min.js +7 -0
  23. package/dist/es5/ms.core.min.js.map +1 -0
  24. package/dist-es5/AppInsightsCore.js +91 -0
  25. package/dist-es5/AppInsightsCore.js.map +1 -0
  26. package/{dist-esm/src → dist-es5}/BaseCore.js +18 -11
  27. package/dist-es5/BaseCore.js.map +1 -0
  28. package/{dist-esm/src → dist-es5}/DataModels.js +1 -1
  29. package/{dist-esm/src → dist-es5}/Enums.js +3 -26
  30. package/dist-es5/Enums.js.map +1 -0
  31. package/{dist-esm/src → dist-es5}/Index.js +9 -14
  32. package/dist-es5/Index.js.map +1 -0
  33. package/{dist-esm/src → dist-es5}/InternalConstants.js +1 -3
  34. package/{dist-esm/src → dist-es5}/InternalConstants.js.map +1 -1
  35. package/{dist-esm/src → dist-es5}/Utils.js +19 -144
  36. package/dist-es5/Utils.js.map +1 -0
  37. package/{dist-esm/src → dist-es5}/ValueSanitizer.js +39 -3
  38. package/dist-es5/ValueSanitizer.js.map +1 -0
  39. package/package.json +18 -10
  40. package/tsconfig.json +5 -3
  41. package/types/1ds-core-js.d.ts +1106 -0
  42. package/types/1ds-core-js.namespaced.d.ts +1102 -0
  43. package/bundle/ms.core-3.2.10.gbl.js +0 -5357
  44. package/bundle/ms.core-3.2.10.gbl.js.map +0 -1
  45. package/bundle/ms.core-3.2.10.gbl.min.js +0 -7
  46. package/bundle/ms.core-3.2.10.gbl.min.js.map +0 -1
  47. package/bundle/ms.core-3.2.10.integrity.json +0 -46
  48. package/bundle/ms.core-3.2.10.js +0 -5360
  49. package/bundle/ms.core-3.2.10.js.map +0 -1
  50. package/bundle/ms.core-3.2.10.min.js +0 -7
  51. package/bundle/ms.core-3.2.10.min.js.map +0 -1
  52. package/bundle/ms.core.gbl.js +0 -5357
  53. package/bundle/ms.core.gbl.js.map +0 -1
  54. package/bundle/ms.core.gbl.min.js +0 -7
  55. package/bundle/ms.core.gbl.min.js.map +0 -1
  56. package/bundle/ms.core.integrity.json +0 -46
  57. package/bundle/ms.core.js.map +0 -1
  58. package/bundle/ms.core.min.js +0 -7
  59. package/bundle/ms.core.min.js.map +0 -1
  60. package/dist/ms.core.js +0 -1305
  61. package/dist/ms.core.js.map +0 -1
  62. package/dist/ms.core.min.js +0 -7
  63. package/dist/ms.core.min.js.map +0 -1
  64. package/dist-esm/src/AppInsightsCore.d.ts +0 -15
  65. package/dist-esm/src/AppInsightsCore.js +0 -114
  66. package/dist-esm/src/AppInsightsCore.js.map +0 -1
  67. package/dist-esm/src/BaseCore.d.ts +0 -13
  68. package/dist-esm/src/BaseCore.js.map +0 -1
  69. package/dist-esm/src/DataModels.d.ts +0 -273
  70. package/dist-esm/src/ESPromise.d.ts +0 -110
  71. package/dist-esm/src/ESPromise.js +0 -286
  72. package/dist-esm/src/ESPromise.js.map +0 -1
  73. package/dist-esm/src/ESPromiseScheduler.d.ts +0 -36
  74. package/dist-esm/src/ESPromiseScheduler.js +0 -274
  75. package/dist-esm/src/ESPromiseScheduler.js.map +0 -1
  76. package/dist-esm/src/Enums.d.ts +0 -356
  77. package/dist-esm/src/Enums.js.map +0 -1
  78. package/dist-esm/src/Index.d.ts +0 -19
  79. package/dist-esm/src/Index.js.map +0 -1
  80. package/dist-esm/src/InternalConstants.d.ts +0 -6
  81. package/dist-esm/src/Utils.d.ts +0 -190
  82. package/dist-esm/src/Utils.js.map +0 -1
  83. package/dist-esm/src/ValueSanitizer.d.ts +0 -40
  84. package/dist-esm/src/ValueSanitizer.js.map +0 -1
  85. package/src/AppInsightsCore.ts +0 -135
  86. package/src/BaseCore.ts +0 -72
  87. package/src/DataModels.ts +0 -297
  88. package/src/ESPromise.ts +0 -365
  89. package/src/ESPromiseScheduler.ts +0 -328
  90. package/src/Enums.ts +0 -386
  91. package/src/Index.ts +0 -81
  92. package/src/InternalConstants.ts +0 -16
  93. package/src/Utils.ts +0 -565
  94. package/src/ValueSanitizer.ts +0 -285
  95. /package/{dist-esm/src → dist-es5}/DataModels.js.map +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"Utils.js.map","sources":["Utils.js"],"sourcesContent":["var _a;\r\n/**\r\n* Utils.ts\r\n* @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)\r\n* @copyright Microsoft 2018\r\n* File containing utility functions.\r\n*/\r\nimport { addEventHandler, addPageUnloadEventListener, areCookiesSupported, arrForEach, arrIndexOf, arrMap, arrReduce, dateNow, generateW3CId, getDocument, getGlobalInst, getNavigator, getWindow, hasOwnProperty, isArray, isBeaconsSupported, isBoolean, isDate, isError, isFunction, isIE, isNullOrUndefined, isNumber, isObject, isReactNative, isString, isTypeof, isUndefined, mwcRandom32, mwcRandomSeed, newGuid, newId, objDefineAccessors, objForEachKey, objKeys, perfNow, random32, randomValue, safeGetCookieMgr, strEndsWith, strObject, strTrim, strUndefined, toISOString, uaDisallowsSameSiteNone, useXDomainRequest } from \"@microsoft/applicationinsights-core-js\";\r\nimport { ObjHasOwnProperty, objCreateFn, strShimObject, strShimPrototype } from \"@microsoft/applicationinsights-shims\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\nexport var Version = '3.2.10';\r\nexport var FullVersionString = \"1DS-Web-JS-\" + Version;\r\n// Defining here so we don't need to take (import) the ApplicationInsights Common module\r\nvar strDisabledPropertyName = \"Microsoft_ApplicationInsights_BypassAjaxInstrumentation\";\r\nvar strWithCredentials = \"withCredentials\";\r\nvar strTimeout = \"timeout\";\r\n// If value is array just get the type for the first element\r\nvar _fieldTypeEventPropMap = (_a = {},\r\n _a[0 /* FieldValueSanitizerType.NotSet */] = 0 /* eEventPropertyType.Unspecified */,\r\n _a[2 /* FieldValueSanitizerType.Number */] = 6 /* eEventPropertyType.Double */,\r\n _a[1 /* FieldValueSanitizerType.String */] = 1 /* eEventPropertyType.String */,\r\n _a[3 /* FieldValueSanitizerType.Boolean */] = 7 /* eEventPropertyType.Bool */,\r\n _a[4096 /* FieldValueSanitizerType.Array */ | 2 /* FieldValueSanitizerType.Number */] = 6 /* eEventPropertyType.Double */,\r\n _a[4096 /* FieldValueSanitizerType.Array */ | 1 /* FieldValueSanitizerType.String */] = 1 /* eEventPropertyType.String */,\r\n _a[4096 /* FieldValueSanitizerType.Array */ | 3 /* FieldValueSanitizerType.Boolean */] = 7 /* eEventPropertyType.Bool */,\r\n _a);\r\n/**\r\n * @ignore\r\n */\r\n// let _uaDisallowsSameSiteNone = null;\r\nvar uInt8ArraySupported = null;\r\n// var _areCookiesAvailable: boolean | undefined;\r\n/**\r\n * Checks if document object is available\r\n */\r\nexport var isDocumentObjectAvailable = Boolean(getDocument());\r\n/**\r\n * Checks if window object is available\r\n */\r\nexport var isWindowObjectAvailable = Boolean(getWindow());\r\n/**\r\n * Checks if value is assigned to the given param.\r\n * @param value - The token from which the tenant id is to be extracted.\r\n * @returns True/false denoting if value is assigned to the param.\r\n */\r\nexport function isValueAssigned(value) {\r\n /// <summary> takes a value and checks for undefined, null and empty string </summary>\r\n /// <param type=\"any\"> value to be tested </param>\r\n /// <returns> true if value is null undefined or emptyString </returns>\r\n return !(value === STR_EMPTY || isNullOrUndefined(value));\r\n}\r\n/**\r\n * Gets the tenant id from the tenant token.\r\n * @param apiKey - The token from which the tenant id is to be extracted.\r\n * @returns The tenant id.\r\n */\r\nexport function getTenantId(apiKey) {\r\n if (apiKey) {\r\n var indexTenantId = apiKey.indexOf(\"-\");\r\n if (indexTenantId > -1) {\r\n return apiKey.substring(0, indexTenantId);\r\n }\r\n }\r\n return STR_EMPTY;\r\n}\r\n/**\r\n * Checks if Uint8Array are available in the current environment. Safari and Firefox along with\r\n * ReactNative are known to not support Uint8Array properly.\r\n * @returns True if available, false otherwise.\r\n */\r\nexport function isUint8ArrayAvailable() {\r\n if (uInt8ArraySupported === null) {\r\n uInt8ArraySupported = !isUndefined(Uint8Array) && !isSafariOrFirefox() && !isReactNative();\r\n }\r\n return uInt8ArraySupported;\r\n}\r\n/**\r\n * Checks if the value is a valid EventLatency.\r\n * @param value - The value that needs to be checked.\r\n * @returns True if the value is in AWTEventLatency, false otherwise.\r\n */\r\nexport function isLatency(value) {\r\n if (value && isNumber(value) && value >= 1 /* EventLatencyValue.Normal */ && value <= 4 /* EventLatencyValue.Immediate */) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n/**\r\n * Sanitizes the Property. It checks the that the property name and value are valid. It also\r\n * checks/populates the correct type and pii of the property value.\r\n * @param name - property name - The property name.\r\n * @param property - The property value or an IEventProperty containing value,\r\n * type ,pii and customer content.\r\n * @returns IEventProperty containing valid name, value, pii and type or null if invalid.\r\n */\r\nexport function sanitizeProperty(name, property, stringifyObjects) {\r\n // Check that property is valid\r\n if ((!property && !isValueAssigned(property)) || typeof name !== \"string\") {\r\n return null;\r\n }\r\n // Perf optimization -- only need to get the type once not multiple times\r\n var propType = typeof property;\r\n // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.\r\n if (propType === \"string\" || propType === \"number\" || propType === \"boolean\" || isArray(property)) {\r\n property = { value: property };\r\n }\r\n else if (propType === \"object\" && !ObjHasOwnProperty.call(property, \"value\")) {\r\n property = { value: stringifyObjects ? JSON.stringify(property) : property };\r\n }\r\n else if (isNullOrUndefined(property.value)\r\n || property.value === STR_EMPTY || (!isString(property.value)\r\n && !isNumber(property.value) && !isBoolean(property.value)\r\n && !isArray(property.value))) {\r\n // Since property is IEventProperty, we need to validate its value\r\n return null;\r\n }\r\n // We need to check that if the property value is an array, it is valid\r\n if (isArray(property.value) &&\r\n !isArrayValid(property.value)) {\r\n return null;\r\n }\r\n // If either pii or cc is set convert value to string (since only string pii/cc is allowed).\r\n // If the value is a complex type like an array that can't be converted to string we will drop\r\n // the property.\r\n if (!isNullOrUndefined(property.kind)) {\r\n if (isArray(property.value) || !isValueKind(property.kind)) {\r\n return null;\r\n }\r\n property.value = property.value.toString();\r\n }\r\n return property;\r\n}\r\nexport function getCommonSchemaMetaData(value, kind, type) {\r\n var encodedTypeValue = -1;\r\n if (!isUndefined(value)) {\r\n if (kind > 0) {\r\n if (kind === 32) {\r\n // encode customer content. Value can only be string. bit 13-16 are for cc\r\n encodedTypeValue = (1 << 13);\r\n }\r\n else if (kind <= 13) {\r\n // encode PII. Value can only be string. bits 5-12 are for Pii\r\n encodedTypeValue = (kind << 5);\r\n }\r\n }\r\n // isDataType checks that the \"type\" is a number so we don't need to check for undefined\r\n if (isDataType(type)) {\r\n // Data Type is provided and valid, so use that\r\n if (encodedTypeValue === -1) {\r\n // Don't return -1\r\n encodedTypeValue = 0;\r\n }\r\n encodedTypeValue |= type;\r\n }\r\n else {\r\n var propType = _fieldTypeEventPropMap[getFieldValueType(value)] || -1;\r\n if (encodedTypeValue !== -1 && propType !== -1) {\r\n // pii exists so we must return correct type\r\n encodedTypeValue |= propType;\r\n }\r\n else if (propType === 6 /* eEventPropertyType.Double */) {\r\n encodedTypeValue = propType;\r\n }\r\n }\r\n }\r\n return encodedTypeValue;\r\n}\r\n/**\r\n * @deprecated - Use the core.getCookieMgr().disable()\r\n * Force the SDK not to store and read any data from cookies.\r\n * Overriding the applicationinsights-core version for tree-shaking\r\n */\r\nexport function disableCookies() {\r\n safeGetCookieMgr(null).setEnabled(false);\r\n}\r\n/**\r\n * @deprecated - Use the oneDs.getCookieMgr().set()\r\n * Sets the value of a cookie.\r\n * @param name - Cookie name.\r\n * @param value - Cookie value.\r\n * @param days - Expiration days.\r\n */\r\nexport function setCookie(name, value, days) {\r\n if (areCookiesSupported(null)) {\r\n safeGetCookieMgr(null).set(name, value, days * 86400, null, \"/\");\r\n }\r\n}\r\n/**\r\n * @deprecated - Use the oneDs.getCookieMgr().del()\r\n * Deletes a cookie, by setting its expiration to -1.\r\n * @param name - Cookie name to delete.\r\n */\r\nexport function deleteCookie(name) {\r\n if (areCookiesSupported(null)) {\r\n safeGetCookieMgr(null).del(name);\r\n }\r\n}\r\n/**\r\n * @deprecated - Use the oneDs.getCookieMgr().get()\r\n * Gets the cookie value for the specified cookie.\r\n * if value is k1=v1&k2==v2 then will return 'v1' for key 'k1'\r\n * @param cookieName - Cookie name.\r\n */\r\nexport function getCookie(name) {\r\n if (areCookiesSupported(null)) {\r\n return getCookieValue(safeGetCookieMgr(null), name);\r\n }\r\n return STR_EMPTY;\r\n}\r\n/**\r\n * Helper to get and decode the cookie value using decodeURIComponent, this is for historical\r\n * backward compatibility where the document.cookie value was decoded before parsing.\r\n * @param cookieMgr - The cookie manager to use\r\n * @param name - The name of the cookie to get\r\n * @param decode - A flag to indicate whether the cookie value should be decoded\r\n * @returns The decoded cookie value (if available) otherwise an empty string.\r\n */\r\nexport function getCookieValue(cookieMgr, name, decode) {\r\n if (decode === void 0) { decode = true; }\r\n var cookieValue;\r\n if (cookieMgr) {\r\n cookieValue = cookieMgr.get(name);\r\n if (decode && cookieValue && decodeURIComponent) {\r\n cookieValue = decodeURIComponent(cookieValue);\r\n }\r\n }\r\n return cookieValue || STR_EMPTY;\r\n}\r\n/**\r\n * Create a new guid.\r\n * @param style - The style of guid to generated, defaults to Digits\r\n * Digits (Default) : 32 digits separated by hyphens: 00000000-0000-0000-0000-000000000000\r\n * Braces - 32 digits separated by hyphens, enclosed in braces: {00000000-0000-0000-0000-000000000000}\r\n * Parentheses - 32 digits separated by hyphens, enclosed in parentheses: (00000000-0000-0000-0000-000000000000)\r\n * Numeric - 32 digits: 00000000000000000000000000000000\r\n * @returns The formatted guid.\r\n */\r\nexport function createGuid(style) {\r\n if (style === void 0) { style = \"D\" /* GuidStyle.Digits */; }\r\n var theGuid = newGuid();\r\n if (style === \"B\" /* GuidStyle.Braces */) {\r\n theGuid = \"{\" + theGuid + \"}\";\r\n }\r\n else if (style === \"P\" /* GuidStyle.Parentheses */) {\r\n theGuid = \"(\" + theGuid + \")\";\r\n }\r\n else if (style === \"N\" /* GuidStyle.Numeric */) {\r\n theGuid = theGuid.replace(/-/g, STR_EMPTY);\r\n }\r\n return theGuid;\r\n}\r\n/**\r\n * Pass in the objects to merge as arguments.\r\n * @param obj1 - object to merge. Set this argument to 'true' for a deep extend.\r\n * @param obj2 - object to merge.\r\n * @param obj3 - object to merge.\r\n * @param obj4 - object to merge.\r\n * @param obj5 - object to merge.\r\n * @returns The extended object.\r\n */\r\nexport function extend(obj, obj2, obj3, obj4, obj5) {\r\n // Variables\r\n var extended = {};\r\n var deep = false;\r\n var i = 0;\r\n var length = arguments.length;\r\n var objProto = Object[strShimPrototype];\r\n var theArgs = arguments;\r\n // Check if a deep merge\r\n if (objProto.toString.call(theArgs[0]) === \"[object Boolean]\") {\r\n deep = theArgs[0];\r\n i++;\r\n }\r\n // Loop through each object and conduct a merge\r\n for (; i < length; i++) {\r\n var obj = theArgs[i];\r\n objForEachKey(obj, function (prop, value) {\r\n // If deep merge and property is an object, merge properties\r\n if (deep && value && isObject(value)) {\r\n if (isArray(value)) {\r\n extended[prop] = extended[prop] || [];\r\n arrForEach(value, function (arrayValue, arrayIndex) {\r\n if (arrayValue && isObject(arrayValue)) {\r\n extended[prop][arrayIndex] = extend(true, extended[prop][arrayIndex], arrayValue);\r\n }\r\n else {\r\n extended[prop][arrayIndex] = arrayValue;\r\n }\r\n });\r\n }\r\n else {\r\n extended[prop] = extend(true, extended[prop], value);\r\n }\r\n }\r\n else {\r\n extended[prop] = value;\r\n }\r\n });\r\n }\r\n return extended;\r\n}\r\nexport var getTime = perfNow;\r\nexport function isValueKind(value) {\r\n // Always assume that it's a number (no type checking) for performance as this is used during the JSON serialization\r\n if (value === 0 /* eValueKind.NotSet */ || ((value > 0 /* eValueKind.NotSet */ && value <= 13 /* eValueKind.Pii_IPV4AddressLegacy */) || value === 32 /* eValueKind.CustomerContent_GenericContent */)) {\r\n return true;\r\n }\r\n return false;\r\n}\r\nfunction isDataType(value) {\r\n // Remark: 0 returns false, but it doesn't affect encoding anyways\r\n // Always assume that it's a number (no type checking) for performance as this is used during the JSON serialization\r\n if (value >= 0 && value <= 9) {\r\n return true;\r\n }\r\n return false;\r\n}\r\nfunction isSafariOrFirefox() {\r\n var nav = getNavigator();\r\n // If non-browser navigator will be undefined\r\n if (!isUndefined(nav) && nav.userAgent) {\r\n var ua = nav.userAgent.toLowerCase();\r\n if ((ua.indexOf(\"safari\") >= 0 || ua.indexOf(\"firefox\") >= 0) && ua.indexOf(\"chrome\") < 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n}\r\nexport function isArrayValid(value) {\r\n return value.length > 0;\r\n}\r\nexport function setProcessTelemetryTimings(event, identifier) {\r\n var evt = event;\r\n evt.timings = evt.timings || {};\r\n evt.timings.processTelemetryStart = evt.timings.processTelemetryStart || {};\r\n evt.timings.processTelemetryStart[identifier] = getTime();\r\n}\r\n/**\r\n * Returns a bitwise value for the FieldValueSanitizerType enum representing the decoded type of the passed value\r\n * @param value The value to determine the type\r\n */\r\nexport function getFieldValueType(value) {\r\n var theType = 0 /* FieldValueSanitizerType.NotSet */;\r\n if (value !== null && value !== undefined) {\r\n var objType = typeof value;\r\n if (objType === \"string\") {\r\n theType = 1 /* FieldValueSanitizerType.String */;\r\n }\r\n else if (objType === \"number\") {\r\n theType = 2 /* FieldValueSanitizerType.Number */;\r\n }\r\n else if (objType === \"boolean\") {\r\n theType = 3 /* FieldValueSanitizerType.Boolean */;\r\n }\r\n else if (objType === strShimObject) {\r\n theType = 4 /* FieldValueSanitizerType.Object */;\r\n if (isArray(value)) {\r\n theType = 4096 /* FieldValueSanitizerType.Array */;\r\n if (value.length > 0) {\r\n // Empty arrays are not supported and are considered to be the same as null\r\n theType |= getFieldValueType(value[0]);\r\n }\r\n }\r\n else if (ObjHasOwnProperty.call(value, \"value\")) {\r\n // Looks like an IEventProperty\r\n theType = 8192 /* FieldValueSanitizerType.EventProperty */ | getFieldValueType(value.value);\r\n }\r\n }\r\n }\r\n return theType;\r\n}\r\nexport var Utils = {\r\n Version: Version,\r\n FullVersionString: FullVersionString,\r\n strUndefined: strUndefined,\r\n strObject: strObject,\r\n Undefined: strUndefined,\r\n arrForEach: arrForEach,\r\n arrIndexOf: arrIndexOf,\r\n arrMap: arrMap,\r\n arrReduce: arrReduce,\r\n objKeys: objKeys,\r\n toISOString: toISOString,\r\n isReactNative: isReactNative,\r\n isString: isString,\r\n isNumber: isNumber,\r\n isBoolean: isBoolean,\r\n isFunction: isFunction,\r\n isArray: isArray,\r\n isObject: isObject,\r\n strTrim: strTrim,\r\n isDocumentObjectAvailable: isDocumentObjectAvailable,\r\n isWindowObjectAvailable: isWindowObjectAvailable,\r\n isValueAssigned: isValueAssigned,\r\n getTenantId: getTenantId,\r\n isBeaconsSupported: isBeaconsSupported,\r\n isUint8ArrayAvailable: isUint8ArrayAvailable,\r\n isLatency: isLatency,\r\n sanitizeProperty: sanitizeProperty,\r\n getISOString: toISOString,\r\n useXDomainRequest: useXDomainRequest,\r\n getCommonSchemaMetaData: getCommonSchemaMetaData,\r\n cookieAvailable: areCookiesSupported,\r\n disallowsSameSiteNone: uaDisallowsSameSiteNone,\r\n setCookie: setCookie,\r\n deleteCookie: deleteCookie,\r\n getCookie: getCookie,\r\n createGuid: createGuid,\r\n extend: extend,\r\n getTime: getTime,\r\n isValueKind: isValueKind,\r\n isArrayValid: isArrayValid,\r\n objDefineAccessors: objDefineAccessors,\r\n addPageUnloadEventListener: addPageUnloadEventListener,\r\n setProcessTelemetryTimings: setProcessTelemetryTimings,\r\n addEventHandler: addEventHandler,\r\n getFieldValueType: getFieldValueType,\r\n strEndsWith: strEndsWith,\r\n objForEachKey: objForEachKey\r\n};\r\n/**\r\n * Provides a collection of utility functions, included for backward compatibility with previous releases.\r\n * @deprecated Marking this instance as deprecated in favor of direct usage of the helper functions\r\n * as direct usage provides better tree-shaking and minification by avoiding the inclusion of the unused items\r\n * in your resulting code.\r\n * Overriding the applicationinsights-core version for tree-shaking\r\n */\r\nexport var CoreUtils = {\r\n _canUseCookies: undefined,\r\n isTypeof: isTypeof,\r\n isUndefined: isUndefined,\r\n isNullOrUndefined: isNullOrUndefined,\r\n hasOwnProperty: hasOwnProperty,\r\n isFunction: isFunction,\r\n isObject: isObject,\r\n isDate: isDate,\r\n isArray: isArray,\r\n isError: isError,\r\n isString: isString,\r\n isNumber: isNumber,\r\n isBoolean: isBoolean,\r\n toISOString: toISOString,\r\n arrForEach: arrForEach,\r\n arrIndexOf: arrIndexOf,\r\n arrMap: arrMap,\r\n arrReduce: arrReduce,\r\n strTrim: strTrim,\r\n objCreate: objCreateFn,\r\n objKeys: objKeys,\r\n objDefineAccessors: objDefineAccessors,\r\n addEventHandler: addEventHandler,\r\n dateNow: dateNow,\r\n isIE: isIE,\r\n disableCookies: disableCookies,\r\n newGuid: newGuid,\r\n perfNow: perfNow,\r\n newId: newId,\r\n randomValue: randomValue,\r\n random32: random32,\r\n mwcRandomSeed: mwcRandomSeed,\r\n mwcRandom32: mwcRandom32,\r\n generateW3CId: generateW3CId\r\n};\r\n/**\r\n * Helper to identify whether we are running in a chromium based browser environment\r\n */\r\nexport function isChromium() {\r\n return !!getGlobalInst(\"chrome\");\r\n}\r\n/**\r\n * Create and open an XMLHttpRequest object\r\n * @param method - The request method\r\n * @param urlString - The url\r\n * @param withCredentials - Option flag indicating that credentials should be sent\r\n * @param disabled - Optional flag indicating that the XHR object should be marked as disabled and not tracked (default is false)\r\n * @param isSync - Optional flag indicating if the instance should be a synchronous request (defaults to false)\r\n * @param timeout - Optional value identifying the timeout value that should be assigned to the XHR request\r\n * @returns A new opened XHR request\r\n */\r\nexport function openXhr(method, urlString, withCredentials, disabled, isSync, timeout) {\r\n if (disabled === void 0) { disabled = false; }\r\n if (isSync === void 0) { isSync = false; }\r\n function _wrapSetXhrProp(xhr, prop, value) {\r\n try {\r\n xhr[prop] = value;\r\n }\r\n catch (e) {\r\n // - Wrapping as depending on the environment setting the property may fail (non-terminally)\r\n }\r\n }\r\n var xhr = new XMLHttpRequest();\r\n if (disabled) {\r\n // Tag the instance so it's not tracked (trackDependency)\r\n // If the environment has locked down the XMLHttpRequest (preventExtensions and/or freeze), this would\r\n // cause the request to fail and we no telemetry would be sent\r\n _wrapSetXhrProp(xhr, strDisabledPropertyName, disabled);\r\n }\r\n if (withCredentials) {\r\n // Some libraries require that the withCredentials flag is set \"before\" open and\r\n // - Wrapping as IE 10 has started throwing when setting before open\r\n _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);\r\n }\r\n xhr.open(method, urlString, !isSync);\r\n if (withCredentials) {\r\n // withCredentials should be set AFTER open (https://xhr.spec.whatwg.org/#the-withcredentials-attribute)\r\n // And older firefox instances from 11+ will throw for sync events (current versions don't) which happens during unload processing\r\n _wrapSetXhrProp(xhr, strWithCredentials, withCredentials);\r\n }\r\n // Only set the timeout for asynchronous requests as\r\n // \"Timeout shouldn't be used for synchronous XMLHttpRequests requests used in a document environment or it will throw an InvalidAccessError exception.\"\"\r\n // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout\r\n if (!isSync && timeout) {\r\n _wrapSetXhrProp(xhr, strTimeout, timeout);\r\n }\r\n return xhr;\r\n}\r\n//# sourceMappingURL=Utils.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,40 +0,0 @@
1
- import { FieldValueSanitizerTypes, IEventProperty, IFieldValueSanitizerProvider, IValueSanitizer } from "./DataModels";
2
- import { getFieldValueType } from "./Utils";
3
- export declare class ValueSanitizer implements IValueSanitizer {
4
- static getFieldType: typeof getFieldValueType;
5
- /**
6
- * Add a value sanitizer as a fallback sanitizer if this sanitizer can't handle the path/name.
7
- */
8
- addSanitizer: (sanitizer: IValueSanitizer) => void;
9
- /**
10
- * Adds a field sanitizer to the evaluation list
11
- */
12
- addFieldSanitizer: (fieldSanitizer: IFieldValueSanitizerProvider) => void;
13
- /**
14
- * Does this field value sanitizer handle this path / field combination
15
- * @param path - The field path
16
- * @param name - The name of the field
17
- */
18
- handleField: (path: string, name: string) => boolean;
19
- /**
20
- * Sanitizes the value. It checks the that the property name and value are valid. It also
21
- * checks/populates the correct type and pii of the property value.
22
- * @param path - The root path of the property
23
- * @param name - The property name.
24
- * @param value - The property value or an IEventProperty containing value, type ,pii and customer content.
25
- * @param stringifyObjects - If supplied tells the sanitizer that it should JSON stringify() objects
26
- * @returns IEventProperty containing valid name, value, pii and type or null if invalid.
27
- */
28
- value: (path: string, name: string, value: FieldValueSanitizerTypes, stringifyObjects?: boolean) => IEventProperty | null;
29
- /**
30
- * Sanitizes the Property. It checks the that the property name and value are valid. It also
31
- * checks/populates the correct type and pii of the property value.
32
- * @param path - The root path of the property
33
- * @param name - The property name.
34
- * @param property - The property value or an IEventProperty containing value, type ,pii and customer content.
35
- * @param stringifyObjects - If supplied tells the sanitizer that it should JSON stringify() objects
36
- * @returns IEventProperty containing valid name, value, pii and type or null if invalid.
37
- */
38
- property: (path: string, name: string, property: IEventProperty, stringifyObjects?: boolean) => IEventProperty | null;
39
- constructor(fieldSanitizerProvider?: IFieldValueSanitizerProvider);
40
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"ValueSanitizer.js.map","sources":["ValueSanitizer.js"],"sourcesContent":["import { isNullOrUndefined, isString, objForEachKey } from \"@microsoft/applicationinsights-core-js\";\r\nimport { STR_EMPTY } from \"./InternalConstants\";\r\nimport { getFieldValueType, isValueAssigned, isValueKind } from \"./Utils\";\r\nvar ValueSanitizer = /** @class */ (function () {\r\n function ValueSanitizer(fieldSanitizerProvider) {\r\n var _self = this;\r\n // To aid with performance this is a lookup map to check if the field value sanitizer supports this field\r\n var _sanitizerMap = {};\r\n var _sanitizers = [];\r\n var _fieldSanitizers = [];\r\n if (fieldSanitizerProvider) {\r\n _fieldSanitizers.push(fieldSanitizerProvider);\r\n }\r\n function _getFieldSanitizer(path, name) {\r\n var result;\r\n var fieldLookup = _sanitizerMap[path];\r\n if (fieldLookup) {\r\n result = fieldLookup[name];\r\n }\r\n if (!result && result !== null) {\r\n // Null is a valid result indicating that the value sanitizer does not support this field\r\n if (isString(path) && isString(name)) {\r\n if (_fieldSanitizers.length > 0) {\r\n for (var lp = 0; lp < _fieldSanitizers.length; lp++) {\r\n if (_fieldSanitizers[lp].handleField(path, name)) {\r\n result = {\r\n canHandle: true,\r\n fieldHandler: _fieldSanitizers[lp]\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n else if (_sanitizers.length === 0) {\r\n // Special use-case where there is no sanitizer to pass on to, so just resolving the field\r\n // and returning the resulting value (same as sanitizeProperty())\r\n result = {\r\n canHandle: true\r\n };\r\n }\r\n }\r\n // We still don't have a handler so lets lookup the providers\r\n if (!result && result !== null) {\r\n // Setting the result to null -- which means we and any contained sanitizers can't handle this field\r\n result = null;\r\n for (var lp = 0; lp < _sanitizers.length; lp++) {\r\n if (_sanitizers[lp].handleField(path, name)) {\r\n result = {\r\n canHandle: true,\r\n handler: _sanitizers[lp],\r\n fieldHandler: null\r\n };\r\n break;\r\n }\r\n }\r\n }\r\n if (!fieldLookup) {\r\n fieldLookup = _sanitizerMap[path] = {};\r\n }\r\n fieldLookup[name] = result;\r\n }\r\n return result;\r\n }\r\n _self.addSanitizer = function (newSanitizer) {\r\n if (newSanitizer) {\r\n _sanitizers.push(newSanitizer);\r\n // Invalidate any previously mapped fields\r\n _sanitizerMap = {};\r\n }\r\n };\r\n _self.addFieldSanitizer = function (fieldSanitizer) {\r\n if (fieldSanitizer) {\r\n _fieldSanitizers.push(fieldSanitizer);\r\n // Invalidate any previously mapped fields\r\n _sanitizerMap = {};\r\n }\r\n };\r\n _self.handleField = function (path, name) {\r\n var mapValue = _getFieldSanitizer(path, name);\r\n return mapValue ? mapValue.canHandle : false;\r\n };\r\n _self.value = function (path, name, value, stringifyObjects) {\r\n var mapValue = _getFieldSanitizer(path, name);\r\n if (mapValue && mapValue.canHandle) {\r\n if (!mapValue || !mapValue.canHandle) {\r\n return null;\r\n }\r\n if (mapValue.handler) {\r\n // This value sanitizer can't handle this field so pass it only the next one\r\n return mapValue.handler.value(path, name, value, stringifyObjects);\r\n }\r\n // Check that property is valid\r\n if (!isString(name) || isNullOrUndefined(value) || value === STR_EMPTY) {\r\n return null;\r\n }\r\n var property = null;\r\n var fieldType = getFieldValueType(value);\r\n if ((fieldType & 8192 /* FieldValueSanitizerType.EventProperty */) === 8192 /* FieldValueSanitizerType.EventProperty */) {\r\n var subType = fieldType & ~8192 /* FieldValueSanitizerType.EventProperty */;\r\n property = value;\r\n if (!isValueAssigned(property.value) ||\r\n (subType !== 1 /* FieldValueSanitizerType.String */ &&\r\n subType !== 2 /* FieldValueSanitizerType.Number */ &&\r\n subType !== 3 /* FieldValueSanitizerType.Boolean */ &&\r\n (subType & 4096 /* FieldValueSanitizerType.Array */) !== 4096 /* FieldValueSanitizerType.Array */)) {\r\n // Not a supported IEventProperty type to be able to sanitize\r\n return null;\r\n }\r\n }\r\n else if (fieldType === 1 /* FieldValueSanitizerType.String */ ||\r\n fieldType === 2 /* FieldValueSanitizerType.Number */ ||\r\n fieldType === 3 /* FieldValueSanitizerType.Boolean */ ||\r\n (fieldType & 4096 /* FieldValueSanitizerType.Array */) === 4096 /* FieldValueSanitizerType.Array */) {\r\n // If the property isn't IEventProperty (and is either string, number, boolean or array), convert it into one.\r\n property = _convertToProperty(path, name, value);\r\n }\r\n else if (fieldType === 4 /* FieldValueSanitizerType.Object */) {\r\n property = _convertToProperty(path, name, !!stringifyObjects ? JSON.stringify(value) : value);\r\n }\r\n if (property) {\r\n return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);\r\n }\r\n }\r\n return null;\r\n };\r\n _self.property = function (path, name, property, stringifyObjects) {\r\n var mapValue = _getFieldSanitizer(path, name);\r\n if (!mapValue || !mapValue.canHandle) {\r\n return null;\r\n }\r\n // Check that property is valid\r\n if (!isString(name) || isNullOrUndefined(property) || !isValueAssigned(property.value)) {\r\n return null;\r\n }\r\n var fieldType = getFieldValueType(property.value);\r\n if (fieldType === 0 /* FieldValueSanitizerType.NotSet */) {\r\n // Not a supported field that we can sanitize or serialize\r\n return null;\r\n }\r\n return _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects);\r\n };\r\n function _handleProperty(mapValue, path, name, fieldType, property, stringifyObjects) {\r\n if (mapValue.handler) {\r\n // This value sanitizer can't handle this field so pass it only the next one\r\n return mapValue.handler.property(path, name, property, stringifyObjects);\r\n }\r\n // If either pii or cc is set convert value to string (since only string pii/cc is allowed).\r\n // If the value is a complex type like an array that can't be converted to string we will drop\r\n // the property.\r\n if (!isNullOrUndefined(property.kind)) {\r\n if ((fieldType & 4096 /* FieldValueSanitizerType.Array */) === 4096 /* FieldValueSanitizerType.Array */ || !isValueKind(property.kind)) {\r\n return null;\r\n }\r\n // Convert the value to a string and assign back to the original value\r\n property.value = property.value.toString();\r\n }\r\n return _callFieldSanitizer(mapValue.fieldHandler, path, name, fieldType, property);\r\n }\r\n function _convertToProperty(path, name, value) {\r\n if (isValueAssigned(value)) {\r\n return { value: value };\r\n }\r\n return null;\r\n }\r\n function _callFieldSanitizer(fieldProvider, path, name, theType, property) {\r\n if (property && fieldProvider) {\r\n var sanitizer = fieldProvider.getSanitizer(path, name, theType, property.kind, property.propertyType);\r\n if (sanitizer) {\r\n // This is where we the field will call the handler to \"scrub\" the value. This the primary hook for the ClientHashing Plugin to\r\n // be able to apply the hashFunc() / Sha256 conversion of the properties value\r\n if (theType === 4 /* FieldValueSanitizerType.Object */) {\r\n // Special case of an embedded object (ext.metadata, data.properties)\r\n var newValue_1 = {};\r\n var propValue = property.value;\r\n objForEachKey(propValue, function (propKey, theValue) {\r\n var newPath = path + \".\" + name;\r\n if (isValueAssigned(theValue)) {\r\n var newProp = _convertToProperty(newPath, propKey, theValue);\r\n newProp = _callFieldSanitizer(fieldProvider, newPath, propKey, getFieldValueType(theValue), newProp);\r\n if (newProp) {\r\n newValue_1[propKey] = newProp.value;\r\n }\r\n }\r\n });\r\n property.value = newValue_1;\r\n }\r\n else {\r\n var details = {\r\n path: path,\r\n name: name,\r\n type: theType,\r\n prop: property,\r\n sanitizer: _self\r\n };\r\n property = sanitizer.call(_self, details);\r\n }\r\n }\r\n }\r\n return property;\r\n }\r\n }\r\n ValueSanitizer.getFieldType = getFieldValueType;\r\n return ValueSanitizer;\r\n}());\r\nexport { ValueSanitizer };\r\n//# sourceMappingURL=ValueSanitizer.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -1,135 +0,0 @@
1
- /**
2
- * AppInsightsCore.ts
3
- * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
4
- * @copyright Microsoft 2018
5
- */
6
- import dynamicProto from "@microsoft/dynamicproto-js";
7
- import {
8
- AppInsightsCore as InternalCore, DiagnosticLogger, IDiagnosticLogger, INotificationManager, IPlugin, ITelemetryItem, _throwInternal,
9
- arrForEach, doPerf, dumpObj, eLoggingSeverity, throwError
10
- } from "@microsoft/applicationinsights-core-js";
11
- import { IExtendedAppInsightsCore, IExtendedConfiguration, IExtendedTelemetryItem } from "./DataModels";
12
- import { EventLatencyValue, _eExtendedInternalMessageId } from "./Enums";
13
- import { STR_DEFAULT_ENDPOINT_URL, STR_EMPTY, STR_PROPERTIES, STR_VERSION } from "./InternalConstants";
14
- import { FullVersionString, getTime, isLatency } from "./Utils";
15
-
16
- export default class AppInsightsCore extends InternalCore implements IExtendedAppInsightsCore {
17
-
18
- // Function to get w parameter used by OneCollector
19
- public getWParam: () => number;
20
- public pluginVersionStringArr: string[] = [];
21
- public pluginVersionString: string;
22
-
23
- constructor() {
24
- super();
25
-
26
- dynamicProto(AppInsightsCore, this, (_self, _base) => {
27
- if (!_self.logger || !_self.logger.queue) {
28
- // The AI Base can inject a No-Op logger so if not defined or the No-Op, change to use a default logger so initialization errors
29
- // are not dropped on the floor if one is not already defined
30
- _self.logger = new DiagnosticLogger({ loggingLevelConsole: eLoggingSeverity.CRITICAL });
31
- }
32
-
33
- _self.initialize = (config: IExtendedConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager) => {
34
- doPerf(_self, () => "AppInsightsCore.initialize", () => {
35
-
36
- let _pluginVersionStringArr = _self.pluginVersionStringArr;
37
-
38
- // Add default collector url
39
- if (config) {
40
- if (!config.endpointUrl) {
41
- config.endpointUrl = STR_DEFAULT_ENDPOINT_URL;
42
- }
43
- let propertyStorageOverride = config.propertyStorageOverride;
44
- // Validate property storage override
45
- if (propertyStorageOverride && (!propertyStorageOverride.getProperty || !propertyStorageOverride.setProperty)) {
46
- throwError("Invalid property storage override passed.");
47
- }
48
- if (config.channels) {
49
- arrForEach(config.channels, (channels) => {
50
- if (channels) {
51
- arrForEach(channels, (channel) => {
52
- if (channel.identifier && channel.version) {
53
- let ver = channel.identifier + "=" + channel.version;
54
- _pluginVersionStringArr.push(ver);
55
- }
56
- });
57
- }
58
- });
59
- }
60
- }
61
-
62
- _self.getWParam = () => {
63
- return (typeof document !== "undefined" || !!config.enableWParam) ? 0 : -1;
64
- };
65
-
66
- if (extensions) {
67
- arrForEach(extensions, (ext) => {
68
- if (ext && ext.identifier && ext.version) {
69
- let ver = ext.identifier + "=" + ext.version;
70
- _pluginVersionStringArr.push(ver);
71
- }
72
- });
73
- }
74
-
75
- _self.pluginVersionString = _pluginVersionStringArr.join(";");
76
- _self.pluginVersionStringArr = _pluginVersionStringArr;
77
-
78
- try {
79
- _base.initialize(config, extensions, logger, notificationManager);
80
-
81
- _self.pollInternalLogs("InternalLog");
82
- } catch (e) {
83
- let logger = _self.logger;
84
- let message = dumpObj(e);
85
- if (message.indexOf("channels") !== -1) {
86
- // Add some additional context to the underlying reported error
87
- message += "\n - Channels must be provided through config.channels only!";
88
- }
89
- _throwInternal(logger,
90
- eLoggingSeverity.CRITICAL,
91
- _eExtendedInternalMessageId.FailedToInitializeSDK, "SDK Initialization Failed - no telemetry will be sent: " + message
92
- );
93
- }
94
- }, () => ({ config, extensions, logger, notificationManager }));
95
- };
96
-
97
- _self.track = (item: IExtendedTelemetryItem|ITelemetryItem) => {
98
- doPerf(_self, () => "AppInsightsCore.track", () => {
99
- let telemetryItem: IExtendedTelemetryItem = item as IExtendedTelemetryItem;
100
- if (telemetryItem) {
101
- telemetryItem.timings = telemetryItem.timings || {};
102
- telemetryItem.timings.trackStart = getTime();
103
- if (!isLatency(telemetryItem.latency)) {
104
- telemetryItem.latency = EventLatencyValue.Normal;
105
- }
106
-
107
- let itemExt = telemetryItem.ext = telemetryItem.ext || {};
108
- itemExt.sdk = itemExt.sdk || {};
109
- itemExt.sdk.ver = FullVersionString;
110
- let baseData = telemetryItem.baseData = telemetryItem.baseData || {};
111
- baseData[STR_PROPERTIES] = baseData[STR_PROPERTIES] || {};
112
-
113
- let itemProperties = baseData[STR_PROPERTIES];
114
- itemProperties[STR_VERSION] = itemProperties[STR_VERSION] || _self.pluginVersionString || STR_EMPTY;
115
- }
116
-
117
- _base.track(telemetryItem);
118
- }, () => ({ item: item }), !((item as any).sync));
119
- };
120
- });
121
- }
122
-
123
- /**
124
- * Initialize the sdk.
125
- * @param config - The configuration to initialize the SDK.
126
- * @param extensions - An array of extensions that are to be used by the core.
127
- */
128
- public initialize(config: IExtendedConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager) {
129
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
130
- }
131
-
132
- public track(item: IExtendedTelemetryItem|ITelemetryItem) {
133
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
134
- }
135
- }
package/src/BaseCore.ts DELETED
@@ -1,72 +0,0 @@
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
- */
9
- import dynamicProto from "@microsoft/dynamicproto-js";
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";
14
- import { _eExtendedInternalMessageId } from "./Enums";
15
- import { STR_DEFAULT_ENDPOINT_URL } from "./InternalConstants";
16
- import { FullVersionString, isDocumentObjectAvailable } from "./Utils";
17
-
18
- export default class BaseCore extends InternalCore implements IExtendedAppInsightsCore {
19
-
20
- // Function to get w parameter used by OneCollector
21
- public getWParam: () => number;
22
-
23
- constructor() {
24
- super();
25
-
26
- dynamicProto(BaseCore, this, (_self, _base) => {
27
-
28
- _self.initialize = (config: IExtendedConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager) => {
29
- if (config && !config.endpointUrl) {
30
- config.endpointUrl = STR_DEFAULT_ENDPOINT_URL;
31
- }
32
-
33
- _self.getWParam = () => {
34
- return (isDocumentObjectAvailable || !!config.enableWParam) ? 0 : -1;
35
- };
36
-
37
- try {
38
- _base.initialize(config, extensions, logger, notificationManager);
39
- } catch (e) {
40
- _throwInternal(_self.logger,
41
- eLoggingSeverity.CRITICAL,
42
- _eExtendedInternalMessageId.FailedToInitializeSDK, "Initialization Failed: " + dumpObj(e) + "\n - Note: Channels must be provided through config.channels only"
43
- );
44
- }
45
- };
46
-
47
- _self.track = (item: IExtendedTelemetryItem|ITelemetryItem) => {
48
- let telemetryItem: IExtendedTelemetryItem = item as IExtendedTelemetryItem;
49
- if (telemetryItem) {
50
- let ext = telemetryItem.ext = telemetryItem.ext || {};
51
- ext.sdk = ext.sdk || {};
52
- ext.sdk.ver = FullVersionString;
53
- }
54
-
55
- _base.track(telemetryItem);
56
- };
57
- });
58
- }
59
-
60
- /**
61
- * Initialize the sdk.
62
- * @param config - The configuration to initialize the SDK.
63
- * @param extensions - An array of extensions that are to be used by the core.
64
- */
65
- public initialize(config: IExtendedConfiguration, extensions: IPlugin[], logger?: IDiagnosticLogger, notificationManager?: INotificationManager) {
66
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
67
- }
68
-
69
- public track(item: IExtendedTelemetryItem|ITelemetryItem) {
70
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
71
- }
72
- }
package/src/DataModels.ts DELETED
@@ -1,297 +0,0 @@
1
- /**
2
- * DataModels.ts
3
- * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
4
- * @copyright Microsoft 2018
5
- * File containing the interfaces for Web JS SDK.
6
- */
7
- import { ITelemetryItem, IConfiguration, IAppInsightsCore } from "@microsoft/applicationinsights-core-js";
8
- import { EventLatencyValue, EventPersistenceValue, EventSendType, FieldValueSanitizerType } from "./Enums";
9
-
10
- /**
11
- * An interface used to create an event property value along with tagging it as PII, or customer content.
12
- * <b>Caution:</b> Customer content and PII are mutually exclusive. You can use only one of them at a time.
13
- * If you use both, then the property will be considered invalid, and therefore won't be sent.
14
- */
15
- export interface IEventProperty {
16
- /**
17
- * The value for the property.
18
- */
19
- value: string | number | boolean | string[] | number[] | boolean[];
20
-
21
- /**
22
- * [Optional] The value kind associated with property value. The constant enum ValueKind should be used to specify the
23
- * different kinds.
24
- */
25
- kind?: number /*| ValueKind*/;
26
-
27
- /**
28
- * [Optional] The data type for the property. Valid values accepted by onecollector are
29
- * "string", "bool", "double", "int64", "datetime", "guid".
30
- * The EventPropertyType constant enum should be used to specify the different property type values.
31
- */
32
- propertyType?: number /*| EventPropertyType*/;
33
- }
34
-
35
- /**
36
- * An interface used to create an event, along with its name, properties, type, timestamp, and priority.
37
- */
38
- export interface IExtendedTelemetryItem extends ITelemetryItem {
39
- /**
40
- * Properties to be captured about the telemetry item.
41
- * Custom properties (alternatively referred to as Part C properties for a Common Schema event) can be
42
- * directly added under data.
43
- */
44
- data?: {
45
- [key: string]: string | number | boolean | string[] | number[] | boolean[] | IEventProperty | object;
46
- };
47
- /**
48
- * Telemetry properties pertaining to domain about which data is being captured. Example, duration, referrerUri for browser page.
49
- * These are alternatively referred to as Part B properties for a Common Schema event.
50
- */
51
- baseData?: {
52
- [key: string]: string | number | boolean | string[] | number[] | boolean[] | IEventProperty | object;
53
- };
54
- /**
55
- * An EventLatency value, that specifies the latency for the event.The EventLatency constant should be
56
- * used to specify the different latency values.
57
- */
58
- latency?: number | EventLatencyValue;
59
- /**
60
- * [Optional] An EventPersistence value, that specifies the persistence for the event. The EventPersistence constant
61
- * should be used to specify the different persistence values.
62
- */
63
- persistence?: number | EventPersistenceValue;
64
- /**
65
- * [Optional] A boolean that specifies whether the event should be sent as a sync request.
66
- */
67
- sync?: boolean | EventSendType;
68
- /**
69
- * [Optional] A timings object.
70
- */
71
- timings?: IEventTiming;
72
- }
73
-
74
- /**
75
- * The IExtendedConfiguration interface holds the configuration details passed to core during initialize.
76
- */
77
- export interface IExtendedConfiguration extends IConfiguration {
78
- /**
79
- * [Optional] The property storage override that should be used to store
80
- * internal SDK properties, otherwise stored as cookies. It is needed where cookies are not available.
81
- */
82
- propertyStorageOverride?: IPropertyStorageOverride;
83
-
84
- /**
85
- * [Optional] A boolean that indicated whether to disable the use of cookies by the 1DS Web SDK. The cookies added by the SDK are
86
- * MicrosoftApplicationsTelemetryDeviceId. If cookies are disabled, then session events are not sent unless propertyStorageOverride
87
- * is provided to store the values elsewhere.
88
- */
89
- disableCookiesUsage?: boolean;
90
-
91
- /**
92
- * [Optional] Name of the Anon cookie. The value will be set in the qsp header to collector requests. Collector will use this value to look for specific cookie to use for anid property.
93
- */
94
- anonCookieName?: string;
95
-
96
- /**
97
- * [Optional] Disables additional internal event timings that are added during processing of events, the timings are not sent as part telemetry items to the server
98
- */
99
- disableEventTimings?: boolean;
100
-
101
- /**
102
- * [Optional] Enables support for objects with compound keys which indirectly represent an object where the "key" of the object contains a "." as part of it's name.
103
- * @example
104
- * ```typescript
105
- * event: { "somedata.embeddedvalue": 123 }
106
- * ```
107
- */
108
- enableCompoundKey?: boolean;
109
-
110
- // Internal note: remove these after consuming the ApplicationInsights Core version that defines these on IConfiguration
111
-
112
- /**
113
- * [Optional] An array of the page unload events that you would like to be ignored, special note there must be at least one valid unload
114
- * event hooked, if you list all or the runtime environment only supports a listed "disabled" event it will still be hooked, if required by the SDK.
115
- * Unload events include "beforeunload", "unload", "visibilitychange" (with 'hidden' state) and "pagehide"
116
- */
117
- disablePageUnloadEvents?: string[];
118
-
119
- /**
120
- * [Optional] An array of page show events that you would like to be ignored, special note there must be at lease one valid show event
121
- * hooked, if you list all or the runtime environment only supports a listed (disabled) event it will STILL be hooked, if required by the SDK.
122
- * Page Show events include "pageshow" and "visibilitychange" (with 'visible' state)
123
- */
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;
131
-
132
- // End of Internal note: remove these after consuming the ApplicationInsights Core version that defines these on IConfiguration
133
- }
134
-
135
- /**
136
- * An interface used for telemetry event timings.
137
- */
138
- export interface IEventTiming {
139
- /**
140
- * Time when 1DS Core calls track
141
- */
142
- trackStart?: number;
143
- /**
144
- * Array of times when each plugin configured in 1DS calls processTelemetry method
145
- */
146
- processTelemetryStart?: { [key: string]: number; };
147
- /**
148
- * Array of times when a specific channel tried to send the telemetry to configured endpoint
149
- */
150
- sendEventStart?: { [key: string]: number; };
151
- /**
152
- * Array of times when a specific channel received a response from endpoint or request timed out
153
- */
154
- sendEventCompleted?: { [key: string]: number; };
155
- /**
156
- * Array of times when a specific channel started serialization of the telemetry event
157
- */
158
- serializationStart?: { [key: string]: number; };
159
- /**
160
- * Array of times when a specific channel completed serialization of the telemetry event
161
- */
162
- serializationCompleted?: { [key: string]: number; };
163
- }
164
-
165
- /**
166
- * The IPropertyStorageOverride interface provides a custom interface for storing internal SDK properties - otherwise they are
167
- * stored as cookies.
168
- * You need this interface when you intend to run auto collection for common properties, or when you log a session in
169
- * a non browser environment.
170
- */
171
- export interface IPropertyStorageOverride {
172
- /**
173
- * A function for passing key value pairs to be stored.
174
- * @param key - The key for the key value pair.
175
- * @param value - The value for the key value pair.
176
- */
177
- setProperty: (key: string, value: string) => void;
178
- /**
179
- * A function that gets a value for a given key.
180
- * @param key - The key for which the value must be fetched.
181
- */
182
- getProperty: (key: string) => string;
183
- }
184
-
185
- export interface IExtendedAppInsightsCore extends IAppInsightsCore {
186
- /**
187
- * [Optional] Get method to retrieve w parameter
188
- */
189
- getWParam?: () => number;
190
- }
191
-
192
- export type FieldValueSanitizerFunc = (details: IFieldSanitizerDetails) => IEventProperty | null;
193
-
194
- export type FieldValueSanitizerTypes = string | number | boolean | object | string[] | number[] | boolean[] | IEventProperty;
195
-
196
- /**
197
- * This interface defines the object that is passed to any provided FieldValueSanitizerFunc, it provides not only the value to be sanitized but also
198
- * some context about the value like it's location within the envelope (serialized object), the format is defined via the
199
- * [Common Schema 4.0](https://1dsdocs.azurewebsites.net/schema/README.html) specification.
200
- */
201
- export interface IFieldSanitizerDetails {
202
-
203
- /**
204
- * The path within the event where the value is stored
205
- */
206
- path: string;
207
-
208
- /**
209
- * The name of the field with the event path that will store the value
210
- */
211
- name: string;
212
-
213
- /**
214
- * Identifies the type of the property value
215
- */
216
- type: FieldValueSanitizerType;
217
-
218
- /**
219
- * The value for the property.
220
- */
221
- prop: IEventProperty;
222
-
223
- /**
224
- * A reference to the value sanitizer that created the details
225
- */
226
- sanitizer: IValueSanitizer;
227
- }
228
-
229
- /**
230
- * This interface is used during the serialization of individual fields when converting the events into envelope (serialized object) which is sent to the services,
231
- * the format is defined via the [Common Schema 4.0](https://1dsdocs.azurewebsites.net/schema/README.html) specification. The path and field names used are based
232
- * on how the data is serialized to the service (CS 4.0 location) and not specifically the location on the event object you pass into the track methods (unless they are the same).
233
- */
234
- export interface IFieldValueSanitizerProvider {
235
- /**
236
- * Does this field value sanitizer handle this path / field combination
237
- * @param path - The field path
238
- * @param name - The name of the field
239
- */
240
- handleField(path: string, name: string): boolean;
241
-
242
- /**
243
- * Get the field sanitizer for this type of field based on the field type, value kind and/or event property type
244
- * @param path - The field path
245
- * @param name - The name of the field
246
- * @param theType - The type of field
247
- * @param theKind - The value kind of the field
248
- * @param propType - The property type of the field
249
- */
250
- getSanitizer(path: string, name: string, theType: FieldValueSanitizerType, theKind?: number/* ValueKind*/, propType?: number/*EventPropertyType*/): FieldValueSanitizerFunc | null | undefined;
251
- }
252
-
253
- /**
254
- * This interface is used during the serialization of events into envelope (serialized object) which is sent to the services, the format is defined via the
255
- * [Common Schema 4.0](https://1dsdocs.azurewebsites.net/schema/README.html) specification. The path and field names used are based on how the data is serialized
256
- * to the service (CS 4.0 location) and not specifically the location on the event object you pass into the track methods (unless they are the same).
257
- */
258
- export interface IValueSanitizer {
259
- /**
260
- * Add a value sanitizer as a fallback sanitizer if this sanitizer can't handle the path/name.
261
- */
262
- addSanitizer: (sanitizer: IValueSanitizer) => void;
263
-
264
- /**
265
- * Adds a field sanitizer to the evaluation list
266
- */
267
- addFieldSanitizer: (fieldSanitizer: IFieldValueSanitizerProvider) => void;
268
-
269
- /**
270
- * Does this field value sanitizer handle this path / field combination
271
- * @param path - The field path
272
- * @param name - The name of the field
273
- */
274
- handleField: (path: string, name: string) => boolean;
275
-
276
- /**
277
- * Sanitizes the value. It checks the that the property name and value are valid. It also
278
- * checks/populates the correct type and pii of the property value.
279
- * @param path - The root path of the property
280
- * @param name - The property name.
281
- * @param value - The property value or an IEventProperty containing value, type ,pii and customer content.
282
- * @param stringifyObjects - If supplied tells the sanitizer that it should JSON stringify() objects
283
- * @returns IEventProperty containing valid name, value, pii and type or null if invalid.
284
- */
285
- value: (path: string, name: string, value: FieldValueSanitizerTypes, stringifyObjects?: boolean) => IEventProperty | null;
286
-
287
- /**
288
- * Sanitizes the Property. It checks the that the property name and value are valid. It also
289
- * checks/populates the correct type and pii of the property value.
290
- * @param path - The root path of the property
291
- * @param name - The property name.
292
- * @param property - The property value or an IEventProperty containing value, type ,pii and customer content.
293
- * @param stringifyObjects - If supplied tells the sanitizer that it should JSON stringify() objects
294
- * @returns IEventProperty containing valid name, value, pii and type or null if invalid.
295
- */
296
- property: (path: string, name: string, property: IEventProperty, stringifyObjects?: boolean) => IEventProperty | null;
297
- }